Utils ported

This commit is contained in:
Sebastian Hartte
2020-06-28 03:41:44 +02:00
parent 7c28a71e10
commit fee5b7fdfc
204 changed files with 1371 additions and 1737 deletions
@@ -23,7 +23,7 @@
package appeng.api.implementations.guiobjects; package appeng.api.implementations.guiobjects;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
@@ -33,5 +33,5 @@ import appeng.api.networking.IGridHost;
public interface INetworkTool extends IGuiItemObject { public interface INetworkTool extends IGuiItemObject {
IGridHost getGridHost(); // null for most purposes. IGridHost getGridHost(); // null for most purposes.
ItemTransferable getInventory(); FixedItemInv getInventory();
} }
@@ -23,7 +23,7 @@
package appeng.api.implementations.tiles; package appeng.api.implementations.tiles;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public interface ISegmentedInventory { public interface ISegmentedInventory {
@@ -36,5 +36,5 @@ public interface ISegmentedInventory {
* *
* @return inventory with inventory name * @return inventory with inventory name
*/ */
ItemTransferable getInventoryByName(String name); FixedItemInv getInventoryByName(String name);
} }
@@ -23,7 +23,7 @@
package appeng.api.implementations.tiles; package appeng.api.implementations.tiles;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public interface IViewCellStorage { public interface IViewCellStorage {
@@ -32,5 +32,5 @@ public interface IViewCellStorage {
* *
* @return inventory with at least 5 slot * @return inventory with at least 5 slot
*/ */
ItemTransferable getViewCellStorage(); FixedItemInv getViewCellStorage();
} }
@@ -23,7 +23,7 @@
package appeng.api.storage.cells; package appeng.api.storage.cells;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
@@ -50,12 +50,12 @@ public interface ICellInventory<T extends IAEStack<T>> extends IMEInventory<T> {
/** /**
* @return access configured list * @return access configured list
*/ */
ItemTransferable getConfigInventory(); FixedItemInv getConfigInventory();
/** /**
* @return access installed upgrades. * @return access installed upgrades.
*/ */
ItemTransferable getUpgradesInventory(); FixedItemInv getUpgradesInventory();
/** /**
* @return How many bytes are used for each type? * @return How many bytes are used for each type?
@@ -23,7 +23,7 @@
package appeng.api.storage.cells; package appeng.api.storage.cells;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
@@ -47,7 +47,7 @@ public interface ICellWorkbenchItem {
* *
* onInventoryChange will be called when saving is needed. * onInventoryChange will be called when saving is needed.
*/ */
ItemTransferable getUpgradesInventory(ItemStack is); FixedItemInv getUpgradesInventory(ItemStack is);
/** /**
* Used to extract, or mirror the contents of the work bench onto the cell. * Used to extract, or mirror the contents of the work bench onto the cell.
@@ -56,7 +56,7 @@ public interface ICellWorkbenchItem {
* *
* onInventoryChange will be called when saving is needed. * onInventoryChange will be called when saving is needed.
*/ */
ItemTransferable getConfigInventory(ItemStack is); FixedItemInv getConfigInventory(ItemStack is);
/** /**
* @return the current fuzzy status. * @return the current fuzzy status.
@@ -18,7 +18,7 @@
package appeng.tile; package appeng.tile;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.util.ICommonTile; import appeng.api.util.ICommonTile;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
@@ -296,7 +296,7 @@ public class AEBaseBlockEntity extends BlockEntity implements IOrientable, IComm
} }
if (this instanceof ISegmentedInventory) { if (this instanceof ISegmentedInventory) {
final ItemTransferable inv = ((ISegmentedInventory) this).getInventoryByName("config"); final FixedItemInv inv = ((ISegmentedInventory) this).getInventoryByName("config");
if (inv instanceof AppEngInternalAEInventory) { if (inv instanceof AppEngInternalAEInventory) {
final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv; final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory(null, target.getSlots()); final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory(null, target.getSlots());
@@ -354,7 +354,7 @@ public class AEBaseBlockEntity extends BlockEntity implements IOrientable, IComm
} }
if (this instanceof ISegmentedInventory) { if (this instanceof ISegmentedInventory) {
final ItemTransferable inv = ((ISegmentedInventory) this).getInventoryByName("config"); final FixedItemInv inv = ((ISegmentedInventory) this).getInventoryByName("config");
if (inv instanceof AppEngInternalAEInventory) { if (inv instanceof AppEngInternalAEInventory) {
((AppEngInternalAEInventory) inv).writeToNBT(output, "config"); ((AppEngInternalAEInventory) inv).writeToNBT(output, "config");
} }
@@ -23,7 +23,7 @@ import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.FixedItemInv; import alexiil.mc.lib.attributes.item.FixedItemInv;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv; import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
@@ -49,12 +49,12 @@ public abstract class AEBaseInvBlockEntity extends AEBaseBlockEntity implements
@Override @Override
public void fromTag(BlockState state, final CompoundTag data) { public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data); super.fromTag(state, data);
final ItemTransferable inv = this.getInternalInventory(); final FixedItemInv inv = this.getInternalInventory();
if (inv != EmptyFixedItemInv.INSTANCE) { if (inv != EmptyFixedItemInv.INSTANCE) {
final CompoundTag opt = data.getCompound("inv"); final CompoundTag opt = data.getCompound("inv");
for (int x = 0; x < inv.getSlots(); x++) { for (int x = 0; x < inv.getSlotCount(); x++) {
final CompoundTag item = opt.getCompound("item" + x); final CompoundTag item = opt.getCompound("item" + x);
ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.read(item)); ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.fromTag(item));
} }
} }
} }
@@ -83,10 +83,10 @@ public abstract class AEBaseInvBlockEntity extends AEBaseBlockEntity implements
@Override @Override
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) { public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
final ItemTransferable inv = this.getInternalInventory(); final FixedItemInv inv = this.getInternalInventory();
for (int l = 0; l < inv.getSlots(); l++) { for (int l = 0; l < inv.getSlotCount(); l++) {
final ItemStack is = inv.getStackInSlot(l); final ItemStack is = inv.getInvStack(l);
if (!is.isEmpty()) { if (!is.isEmpty()) {
drops.add(is); drops.add(is);
} }
@@ -94,11 +94,11 @@ public abstract class AEBaseInvBlockEntity extends AEBaseBlockEntity implements
} }
@Override @Override
public abstract void onChangeInventory(ItemTransferable inv, int slot, InvOperation mc, ItemStack removed, public abstract void onChangeInventory(FixedItemInv inv, int slot, InvOperation mc, ItemStack removed,
ItemStack added); ItemStack added);
protected @Nonnull protected @Nonnull
ItemTransferable getItemHandlerForSide(@Nonnull Direction side) { FixedItemInv getItemHandlerForSide(@Nonnull Direction side) {
return this.getInternalInventory(); return this.getInternalInventory();
} }
@@ -33,12 +33,12 @@ public class CraftingStorageItem extends AEBaseBlockItem {
} }
@Override @Override
public ItemStack getContainerItem(final ItemStack itemStack) { public ItemStack getRecipeRemainder(final ItemStack itemStack) {
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY); return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
} }
@Override @Override
public boolean hasContainerItem(final ItemStack stack) { public boolean hasRecipeRemainder(final ItemStack stack) {
return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING); return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
} }
} }
@@ -104,7 +104,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
final ChargerBlockEntity tile = this.getBlockEntity(w, pos); final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) { if (tile != null) {
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged() if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
.isSameAs(tile.getInternalInventory().getStackInSlot(0))) { .isSameAs(tile.getInternalInventory().getInvStack(0))) {
final double xOff = 0.0; final double xOff = 0.0;
final double yOff = 0.0; final double yOff = 0.0;
final double zOff = 0.0; final double zOff = 0.0;
@@ -185,7 +185,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerBlockEntity tile) { private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerBlockEntity tile) {
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null); TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform); return new ImmutablePair<>(tile.getInternalInventory().getInvStack(0), transform);
} }
} }
@@ -85,9 +85,9 @@ public class TinyTNTBlock extends AEBaseBlock {
if (!w.isClient) { if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F, final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter); pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
w.addEntity(primedTinyTNTEntity); w.spawnEntity(primedTinyTNTEntity);
w.playSound(null, primedTinyTNTEntity.getPosX(), primedTinyTNTEntity.getPosY(), w.playSound(null, primedTinyTNTEntity.getX(), primedTinyTNTEntity.getY(),
primedTinyTNTEntity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1); primedTinyTNTEntity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1);
} }
} }
@@ -145,7 +145,7 @@ public class TinyTNTBlock extends AEBaseBlock {
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy()); pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy());
primedTinyTNTEntity primedTinyTNTEntity
.setFuse(w.rand.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8); .setFuse(w.rand.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8);
w.addEntity(primedTinyTNTEntity); w.spawnEntity(primedTinyTNTEntity);
} }
} }
@@ -168,7 +168,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
@Override @Override
public ItemStack getPickBlock(BlockState state, HitResult target, BlockView world, BlockPos pos, public ItemStack getPickBlock(BlockState state, HitResult target, BlockView world, BlockPos pos,
PlayerEntity player) { PlayerEntity player) {
final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ()); final Vec3d v3 = target.getPos().subtract(pos.getX(), pos.getY(), pos.getZ());
final SelectedPart sp = this.cb(world, pos).selectPart(v3); final SelectedPart sp = this.cb(world, pos).selectPart(v3);
if (sp.part != null) { if (sp.part != null) {
@@ -194,7 +194,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
if (target.getType() != Type.BLOCK) { if (target.getType() != Type.BLOCK) {
return false; return false;
} }
BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z); BlockPos blockPos = new BlockPos(target.getPos().x, target.getPos().y, target.getPos().z);
ICableBusContainer cb = this.cb(world, blockPos); ICableBusContainer cb = this.cb(world, blockPos);
@@ -214,9 +214,9 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
// Spawn a particle for one of the particle textures // Spawn a particle for one of the particle textures
Sprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState)); Sprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
if (texture != null) { if (texture != null) {
double x = target.getHitVec().x; double x = target.getPos().x;
double y = target.getHitVec().y; double y = target.getPos().y;
double z = target.getHitVec().z; double z = target.getPos().z;
// FIXME: Check how this looks, probably like shit, maybe provide parts the // FIXME: Check how this looks, probably like shit, maybe provide parts the
// ability to supply particle textures??? // ability to supply particle textures???
effectRenderer effectRenderer
@@ -310,7 +310,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
if (rtr instanceof BlockHitResult) { if (rtr instanceof BlockHitResult) {
BlockHitResult brtr = (BlockHitResult) rtr; BlockHitResult brtr = (BlockHitResult) rtr;
if (brtr.getPos().equals(pos)) { if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos)); final Vec3d hitVec = rtr.getPos().subtract(new Vec3d(pos));
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) { if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
NetworkHandler.instance().sendToServer(new ClickPacket(pos, brtr.getSide(), (float) hitVec.x, NetworkHandler.instance().sendToServer(new ClickPacket(pos, brtr.getSide(), (float) hitVec.x,
@@ -329,7 +329,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockHitResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
// Transform from world into block space // Transform from world into block space
Vec3d hitVec = hit.getHitVec(); Vec3d hitVec = hit.getPos();
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ()); Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResult.SUCCESS : ActionResult.PASS; return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResult.SUCCESS : ActionResult.PASS;
} }
@@ -29,6 +29,7 @@ import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -82,7 +83,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
if (hit.getSide() == tg.getUp()) { if (hit.getSide() == tg.getUp()) {
if (!tg.openGui(p)) { if (!tg.openGui(p)) {
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get()); p.sendSystemMessage(PlayerMessages.ChestCannotReadStorageCell.get(), Util.NIL_UUID);
} }
} else { } else {
ContainerOpener.openContainer(ChestContainer.TYPE, p, ContainerOpener.openContainer(ChestContainer.TYPE, p,
+4 -13
View File
@@ -64,15 +64,6 @@ public class ClientHelper extends ServerHelper {
} }
} }
@Override
public World getWorld() {
if (Platform.isClient()) {
return MinecraftClient.getInstance().world;
} else {
return super.getWorld();
}
}
@Override @Override
public void bindTileEntitySpecialRenderer(final Class<? extends BlockEntity> tile, final AEBaseBlock blk) { public void bindTileEntitySpecialRenderer(final Class<? extends BlockEntity> tile, final AEBaseBlock blk) {
@@ -113,7 +104,7 @@ public class ClientHelper extends ServerHelper {
@Override @Override
public boolean shouldAddParticles(final Random r) { public boolean shouldAddParticles(final Random r) {
switch (MinecraftClient.getInstance().gameSettings.particles) { switch (MinecraftClient.getInstance().options.particles) {
default: default:
case ALL: case ALL:
return true; return true;
@@ -154,9 +145,9 @@ public class ClientHelper extends ServerHelper {
final PlayerEntity player = mc.player; final PlayerEntity player = mc.player;
final int x = (int) player.getPosX(); final int x = (int) player.getX();
final int y = (int) player.getPosY(); final int y = (int) player.getY();
final int z = (int) player.getPosZ(); final int z = (int) player.getZ();
final int range = 16 * 16; final int range = 16 * 16;
@@ -26,7 +26,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.Formatting;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME; import appeng.client.me.SlotME;
@@ -63,7 +63,7 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
.format(myStack.getStackSize()); .format(myStack.getStackSize());
final String format = String.format(local, formattedAmount); final String format = String.format(local, formattedAmount);
currentToolTip.add(TextFormatting.GRAY + format); currentToolTip.add(Formatting.GRAY + format);
} }
if (myStack.getCountRequestable() > 0) { if (myStack.getCountRequestable() > 0) {
@@ -82,7 +82,7 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount()); final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
final String format = String.format(local, formattedAmount); final String format = String.format(local, formattedAmount);
currentToolTip.add(TextFormatting.GRAY + format); currentToolTip.add(Formatting.GRAY + format);
this.renderTooltip(currentToolTip, x, y, this.font); this.renderTooltip(currentToolTip, x, y, this.font);
@@ -32,6 +32,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Formatting;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -53,7 +54,6 @@ import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -198,11 +198,11 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
lines = Lists.newArrayList(lines); // Make a copy lines = Lists.newArrayList(lines); // Make a copy
// Make the first line white // Make the first line white
lines.set(0, TextFormatting.WHITE + lines.get(0)); lines.set(0, Formatting.WHITE + lines.get(0));
// All lines after the first are colored gray // All lines after the first are colored gray
for (int i = 1; i < lines.size(); i++) { for (int i = 1; i < lines.size(); i++) {
lines.set(i, TextFormatting.GRAY + lines.get(i)); lines.set(i, Formatting.GRAY + lines.get(i));
} }
this.renderTooltip(lines, x, y, this.font); this.renderTooltip(lines, x, y, this.font);
@@ -504,7 +504,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (getPlayer().inventory.getItemStack().isEmpty() && theSlot != null) { if (getPlayer().inventory.getItemStack().isEmpty() && theSlot != null) {
for (int j = 0; j < 9; ++j) { for (int j = 0; j < 9; ++j) {
if (getMinecraft().gameSettings.keyBindsHotbar[j].isActiveAndMatches(input)) { if (getMinecraft().options.keyBindsHotbar[j].isActiveAndMatches(input)) {
final List<Slot> slots = this.getInventorySlots(); final List<Slot> slots = this.getInventorySlots();
for (final Slot s : slots) { for (final Slot s : slots) {
if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) { if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) {
@@ -22,7 +22,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.fml.client.gui.GuiUtils;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.ActionItems; import appeng.api.config.ActionItems;
import appeng.api.config.CopyMode; import appeng.api.config.CopyMode;
@@ -118,9 +118,9 @@ public class CellWorkbenchScreen extends UpgradeableScreen<CellWorkbenchContaine
this.copyMode.setState(this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE); this.copyMode.setState(this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE);
boolean hasFuzzy = false; boolean hasFuzzy = false;
final ItemTransferable inv = this.container.getCellUpgradeInventory(); final FixedItemInv inv = this.container.getCellUpgradeInventory();
for (int x = 0; x < inv.getSlots(); x++) { for (int x = 0; x < inv.getSlotCount(); x++) {
final ItemStack is = inv.getStackInSlot(x); final ItemStack is = inv.getInvStack(x);
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) { if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
if (((IUpgradeModule) is.getItem()).getType(is) == Upgrades.FUZZY) { if (((IUpgradeModule) is.getItem()).getType(is) == Upgrades.FUZZY) {
hasFuzzy = true; hasFuzzy = true;
@@ -223,7 +223,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
for (int x = 0; x < current.getInventory().getSlots(); x++) { for (int x = 0; x < current.getInventory().getSlots(); x++) {
final String which = Integer.toString(x); final String which = Integer.toString(x);
if (invData.contains(which)) { if (invData.contains(which)) {
current.getInventory().setStackInSlot(x, ItemStack.read(invData.getCompound(which))); current.getInventory().setStackInSlot(x, ItemStack.fromTag(invData.getCompound(which)));
} }
} }
} catch (final NumberFormatException ignored) { } catch (final NumberFormatException ignored) {
@@ -319,7 +319,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
for (int i = 0; i < outTag.size(); i++) { for (int i = 0; i < outTag.size(); i++) {
final ItemStack parsedItemStack = ItemStack.read(outTag.getCompound(i)); final ItemStack parsedItemStack = ItemStack.fromTag(outTag.getCompound(i));
if (!parsedItemStack.isEmpty()) { if (!parsedItemStack.isEmpty()) {
final String displayName = Platform.getItemDisplayName(AEApi.instance().storage() final String displayName = Platform.getItemDisplayName(AEApi.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString() .getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
@@ -18,6 +18,7 @@
package appeng.client.me; package appeng.client.me;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -55,7 +56,7 @@ public class SlotDisconnected extends AppEngSlot {
final ItemStack is = super.getStack(); final ItemStack is = super.getStack();
if (!is.isEmpty() && is.getItem() instanceof EncodedPatternItem) { if (!is.isEmpty() && is.getItem() instanceof EncodedPatternItem) {
final EncodedPatternItem iep = (EncodedPatternItem) is.getItem(); final EncodedPatternItem iep = (EncodedPatternItem) is.getItem();
final ItemStack out = iep.getOutput(is); final ItemStack out = iep.getOutput(MinecraftClient.getInstance().world, is);
if (!out.isEmpty()) { if (!out.isEmpty()) {
return out; return out;
} }
@@ -115,9 +115,9 @@ public class EncodedPatternBakedModel extends DelegateBakedModel {
public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, @Nullable World world, public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, @Nullable World world,
@Nullable LivingEntity entity) { @Nullable LivingEntity entity) {
boolean shiftHeld = Screen.hasShiftDown(); boolean shiftHeld = Screen.hasShiftDown();
if (shiftHeld) { if (shiftHeld && world != null) {
EncodedPatternItem iep = (EncodedPatternItem) stack.getItem(); EncodedPatternItem iep = (EncodedPatternItem) stack.getItem();
ItemStack output = iep.getOutput(stack); ItemStack output = iep.getOutput(world, stack);
if (!output.isEmpty()) { if (!output.isEmpty()) {
BakedModel realModel = MinecraftClient.getInstance().getItemRenderer().getItemModelMesher() BakedModel realModel = MinecraftClient.getInstance().getItemRenderer().getItemModelMesher()
.getItemModel(output); .getItemModel(output);
@@ -62,9 +62,9 @@ public class EnergyFx extends SpriteTexturedParticle {
@Override @Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
float x = (float) (this.prevPosX + (this.posX - this.prevPosX) * partialTicks); float x = (float) (this.prevX + (this.posX - this.prevX) * partialTicks);
float y = (float) (this.prevPosY + (this.posY - this.prevPosY) * partialTicks); float y = (float) (this.prevY + (this.posY - this.prevY) * partialTicks);
float z = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks); float z = (float) (this.prevZ + (this.posZ - this.prevZ) * partialTicks);
final int blkX = MathHelper.floor(x); final int blkX = MathHelper.floor(x);
final int blkY = MathHelper.floor(y); final int blkY = MathHelper.floor(y);
@@ -91,9 +91,9 @@ public class LightningFX extends SpriteTexturedParticle {
@Override @Override
public void tick() { public void tick() {
this.prevPosX = this.posX; this.prevX = this.posX;
this.prevPosY = this.posY; this.prevY = this.posY;
this.prevPosZ = this.posZ; this.prevZ = this.posZ;
if (this.age++ >= this.maxAge) { if (this.age++ >= this.maxAge) {
this.setExpired(); this.setExpired();
@@ -109,9 +109,9 @@ public class LightningFX extends SpriteTexturedParticle {
@Override @Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
Vec3d vec3d = renderInfo.getProjectedView(); Vec3d vec3d = renderInfo.getProjectedView();
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - vec3d.getX()); float centerX = (float) (MathHelper.lerp(partialTicks, this.prevX, this.posX) - vec3d.getX());
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - vec3d.getY()); float centerY = (float) (MathHelper.lerp(partialTicks, this.prevY, this.posY) - vec3d.getY());
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - vec3d.getZ()); float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevZ, this.posZ) - vec3d.getZ());
final float j = 1.0f; final float j = 1.0f;
float red = this.particleRed * j * 0.9f; float red = this.particleRed * j * 0.9f;
@@ -54,9 +54,9 @@ public class MatterCannonFX extends SpriteTexturedParticle {
@Override @Override
public void tick() { public void tick() {
this.prevPosX = this.posX; this.prevX = this.posX;
this.prevPosY = this.posY; this.prevY = this.posY;
this.prevPosZ = this.posZ; this.prevZ = this.posZ;
if (this.age++ >= this.maxAge) { if (this.age++ >= this.maxAge) {
this.setExpired(); this.setExpired();
@@ -44,9 +44,9 @@ public class VibrantFX extends SpriteTexturedParticle {
this.motionX = 0.0D; this.motionX = 0.0D;
this.motionY = 0.0D; this.motionY = 0.0D;
this.motionZ = 0.0D; this.motionZ = 0.0D;
this.prevPosX = this.posX; this.prevX = this.posX;
this.prevPosY = this.posY; this.prevY = this.posY;
this.prevPosZ = this.posZ; this.prevZ = this.posZ;
this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D)); this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
} }
@@ -67,9 +67,9 @@ public class VibrantFX extends SpriteTexturedParticle {
*/ */
@Override @Override
public void tick() { public void tick() {
this.prevPosX = this.posX; this.prevX = this.posX;
this.prevPosY = this.posY; this.prevY = this.posY;
this.prevPosZ = this.posZ; this.prevZ = this.posZ;
// this.moveEntity(this.motionX, this.motionY, this.motionZ); // this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.particleScale *= 0.95; this.particleScale *= 0.95;
@@ -156,7 +156,7 @@ public class SkyCompassBakedModel implements IDynamicBakedModel {
if (world != null && entity instanceof ClientPlayerEntity) { if (world != null && entity instanceof ClientPlayerEntity) {
PlayerEntity player = (PlayerEntity) entity; PlayerEntity player = (PlayerEntity) entity;
float offRads = (float) (player.rotationYaw / 180.0f * (float) Math.PI + Math.PI); float offRads = (float) (player.yaw / 180.0f * (float) Math.PI + Math.PI);
SkyCompassBakedModel.this.fallbackRotation = offRads SkyCompassBakedModel.this.fallbackRotation = offRads
+ getAnimatedRotation(player.getPosition(), true); + getAnimatedRotation(player.getPosition(), true);
@@ -1,7 +1,7 @@
package appeng.client.render.tesr; package appeng.client.render.tesr;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.render.model.json.ModelTransformation;
@@ -126,16 +126,16 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
// render items. // render items.
ItemTransferable tileInv = tile.getInternalInventory(); FixedItemInv tileInv = tile.getInternalInventory();
int items = 0; int items = 0;
if (!tileInv.getStackInSlot(0).isEmpty()) { if (!tileInv.getInvStack(0).isEmpty()) {
items++; items++;
} }
if (!tileInv.getStackInSlot(1).isEmpty()) { if (!tileInv.getInvStack(1).isEmpty()) {
items++; items++;
} }
if (!tileInv.getStackInSlot(2).isEmpty()) { if (!tileInv.getInvStack(2).isEmpty()) {
items++; items++;
} }
@@ -145,7 +145,7 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
// consumed, see below) // consumed, see below)
renderPresses = false; renderPresses = false;
ItemStack is = tileInv.getStackInSlot(3); ItemStack is = tileInv.getInvStack(3);
if (is.isEmpty()) { if (is.isEmpty()) {
final InscriberRecipe ir = tile.getTask(); final InscriberRecipe ir = tile.getTask();
@@ -160,12 +160,12 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
this.renderItem(ms, is, 0.0f, buffers, combinedLight, combinedOverlay); this.renderItem(ms, is, 0.0f, buffers, combinedLight, combinedOverlay);
} else { } else {
renderPresses = true; renderPresses = true;
this.renderItem(ms, tileInv.getStackInSlot(2), 0.0f, buffers, combinedLight, combinedOverlay); this.renderItem(ms, tileInv.getInvStack(2), 0.0f, buffers, combinedLight, combinedOverlay);
} }
if (renderPresses) { if (renderPresses) {
this.renderItem(ms, tileInv.getStackInSlot(0), press, buffers, combinedLight, combinedOverlay); this.renderItem(ms, tileInv.getInvStack(0), press, buffers, combinedLight, combinedOverlay);
this.renderItem(ms, tileInv.getStackInSlot(1), -press, buffers, combinedLight, combinedOverlay); this.renderItem(ms, tileInv.getInvStack(1), -press, buffers, combinedLight, combinedOverlay);
} }
ms.pop(); ms.pop();
@@ -24,12 +24,12 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
@@ -73,7 +73,7 @@ import appeng.helpers.InventoryAction;
import appeng.me.helpers.PlayerSource; import appeng.me.helpers.PlayerSource;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
@@ -262,7 +262,7 @@ public abstract class AEBaseContainer extends Container {
} }
protected void bindPlayerInventory(final PlayerInventory PlayerInventory, final int offsetX, final int offsetY) { protected void bindPlayerInventory(final PlayerInventory PlayerInventory, final int offsetX, final int offsetY) {
ItemTransferable ih = new PlayerInvWrapper(PlayerInventory); FixedItemInv ih = new PlayerInvWrapper(PlayerInventory);
// bind player inventory // bind player inventory
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@@ -523,8 +523,8 @@ public abstract class AEBaseContainer extends Container {
@Override @Override
public boolean canInteractWith(final PlayerEntity PlayerEntity) { public boolean canInteractWith(final PlayerEntity PlayerEntity) {
if (this.isValidContainer()) { if (this.isValidContainer()) {
if (this.tileEntity instanceof IInventory) { if (this.tileEntity instanceof Inventory) {
return ((IInventory) this.tileEntity).isUsableByPlayer(PlayerEntity); return ((Inventory) this.tileEntity).isUsableByPlayer(PlayerEntity);
} }
return true; return true;
} }
@@ -666,7 +666,7 @@ public abstract class AEBaseContainer extends Container {
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource()); this.getActionSource());
if (ais == null) { if (ais == null) {
final InventoryAdaptor ia = new AdaptorItemHandler( final InventoryAdaptor ia = new AdaptorFixedInv(
new WrapperCursorItemHandler(player.inventory)); new WrapperCursorItemHandler(player.inventory));
final ItemStack fail = ia.removeItems(1, extracted.getDefinition(), null); final ItemStack fail = ia.removeItems(1, extracted.getDefinition(), null);
@@ -705,7 +705,7 @@ public abstract class AEBaseContainer extends Container {
ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource()); this.getActionSource());
if (ais != null) { if (ais != null) {
final InventoryAdaptor ia = new AdaptorItemHandler( final InventoryAdaptor ia = new AdaptorFixedInv(
new WrapperCursorItemHandler(player.inventory)); new WrapperCursorItemHandler(player.inventory));
final ItemStack fail = ia.addItems(ais.createItemStack()); final ItemStack fail = ia.addItems(ais.createItemStack());
@@ -117,9 +117,9 @@ public final class ContainerLocator {
if (is.isEmpty()) { if (is.isEmpty()) {
throw new IllegalArgumentException("Cannot open an item-inventory with empty hands"); throw new IllegalArgumentException("Cannot open an item-inventory with empty hands");
} }
int invSize = player.inventory.getSizeInventory(); int invSize = player.inventory.size();
for (int i = 0; i < invSize; i++) { for (int i = 0; i < invSize; i++) {
if (player.inventory.getStackInSlot(i) == is) { if (player.inventory.getStack(i) == is) {
return i; return i;
} }
} }
@@ -20,7 +20,7 @@ package appeng.container.implementations;
import java.util.Iterator; import java.util.Iterator;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@@ -83,7 +83,7 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
public void setFuzzy(final FuzzyMode valueOf) { public void setFuzzy(final FuzzyMode valueOf) {
final ICellWorkbenchItem cwi = this.workBench.getCell(); final ICellWorkbenchItem cwi = this.workBench.getCell();
if (cwi != null) { if (cwi != null) {
cwi.setFuzzyMode(this.workBench.getInventoryByName("cell").getStackInSlot(0), valueOf); cwi.setFuzzyMode(this.workBench.getInventoryByName("cell").getInvStack(0), valueOf);
} }
} }
@@ -102,14 +102,13 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
@Override @Override
protected void setupConfig() { protected void setupConfig() {
final ItemTransferable cell = this.getUpgradeable().getInventoryByName("cell"); final FixedItemInv cell = this.getUpgradeable().getInventoryByName("cell");
this.addSlot(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.addSlot(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8,
this.getPlayerInv())); this.getPlayerInv()));
final ItemTransferable inv = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv inv = this.getUpgradeable().getInventoryByName("config");
final WrapperSupplierItemHandler upgradeInventory = new WrapperSupplierItemHandler( final WrapperSupplierItemHandler upgradeInventory = new WrapperSupplierItemHandler(
this::getCellUpgradeInventory); this::getCellUpgradeInventory);
// null, 3 * 8 );
int offset = 0; int offset = 0;
final int y = 29; final int y = 29;
@@ -141,17 +140,17 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
@Override @Override
public int availableUpgrades() { public int availableUpgrades() {
final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0); final ItemStack is = this.workBench.getInventoryByName("cell").getInvStack(0);
if (this.prevStack != is) { if (this.prevStack != is) {
this.prevStack = is; this.prevStack = is;
this.lastUpgrades = this.getCellUpgradeInventory().getSlots(); this.lastUpgrades = this.getCellUpgradeInventory().getSlotCount();
} }
return this.lastUpgrades; return this.lastUpgrades;
} }
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0); final ItemStack is = this.workBench.getInventoryByName("cell").getInvStack(0);
if (Platform.isServer()) { if (Platform.isServer()) {
for (final IContainerListener listener : this.listeners) { for (final IContainerListener listener : this.listeners) {
if (this.prevStack != is) { if (this.prevStack != is) {
@@ -182,8 +181,8 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
return idx < this.availableUpgrades(); return idx < this.availableUpgrades();
} }
public ItemTransferable getCellUpgradeInventory() { public FixedItemInv getCellUpgradeInventory() {
final ItemTransferable upgradeInventory = this.workBench.getCellUpgradeInventory(); final FixedItemInv upgradeInventory = this.workBench.getCellUpgradeInventory();
return upgradeInventory == null ? EmptyFixedItemInv.INSTANCE : upgradeInventory; return upgradeInventory == null ? EmptyFixedItemInv.INSTANCE : upgradeInventory;
} }
@@ -205,16 +204,16 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
private FuzzyMode getWorkBenchFuzzyMode() { private FuzzyMode getWorkBenchFuzzyMode() {
final ICellWorkbenchItem cwi = this.workBench.getCell(); final ICellWorkbenchItem cwi = this.workBench.getCell();
if (cwi != null) { if (cwi != null) {
return cwi.getFuzzyMode(this.workBench.getInventoryByName("cell").getStackInSlot(0)); return cwi.getFuzzyMode(this.workBench.getInventoryByName("cell").getInvStack(0));
} }
return FuzzyMode.IGNORE_ALL; return FuzzyMode.IGNORE_ALL;
} }
public void partition() { public void partition() {
final ItemTransferable inv = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv inv = this.getUpgradeable().getInventoryByName("config");
final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getStackInSlot(0); final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getInvStack(0);
final IStorageChannel channel = is.getItem() instanceof IStorageCell final IStorageChannel channel = is.getItem() instanceof IStorageCell
? ((IStorageCell) is.getItem()).getChannel() ? ((IStorageCell) is.getItem()).getChannel()
: AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); : AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
@@ -227,7 +226,7 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
i = list.iterator(); i = list.iterator();
} }
for (int x = 0; x < inv.getSlots(); x++) { for (int x = 0; x < inv.getSlotCount(); x++) {
if (i.hasNext()) { if (i.hasNext()) {
// TODO: check if ok // TODO: check if ok
final ItemStack g = i.next().asItemStackRepresentation(); final ItemStack g = i.next().asItemStackRepresentation();
@@ -22,7 +22,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.CondenserOutput; import appeng.api.config.CondenserOutput;
import appeng.api.config.Settings; import appeng.api.config.Settings;
@@ -54,7 +54,7 @@ public class CondenserContainer extends AEBaseContainer implements IProgressProv
super(TYPE, id, ip, condenser, null); super(TYPE, id, ip, condenser, null);
this.condenser = condenser; this.condenser = condenser;
ItemTransferable inv = condenser.getInternalInventory(); FixedItemInv inv = condenser.getInternalInventory();
this.addSlot(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.TRASH, inv, 0, 51, 52, ip)); this.addSlot(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.TRASH, inv, 0, 51, 52, ip));
this.addSlot(new OutputSlot(inv, 1, 105, 52, -1)); this.addSlot(new OutputSlot(inv, 1, 105, 52, -1));
@@ -163,7 +163,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
private I getHostFromPlayerInventory(PlayerEntity player, ContainerLocator locator) { private I getHostFromPlayerInventory(PlayerEntity player, ContainerLocator locator) {
ItemStack it = player.inventory.getStackInSlot(locator.getItemIndex()); ItemStack it = player.inventory.getStack(locator.getItemIndex());
if (it.isEmpty()) { if (it.isEmpty()) {
AELog.debug("Cannot open container for player %s since they no longer hold the item in slot %d", player, AELog.debug("Cannot open container for player %s since they no longer hold the item in slot %d", player,
@@ -256,7 +256,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
// :P // :P
} }
} catch (final Throwable e) { } catch (final Throwable e) {
this.getPlayerInv().player.sendMessage(new LiteralText("Error: " + e.toString())); this.getPlayerInv().player.sendSystemMessage(new LiteralText("Error: " + e.toString()), Util.NIL_UUID);
AELog.debug(e); AELog.debug(e);
this.setValidContainer(false); this.setValidContainer(false);
this.result = null; this.result = null;
@@ -18,15 +18,15 @@
package appeng.container.implementations; package appeng.container.implementations;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.recipe.Recipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.wrapper.PlayerInvWrapper; import net.minecraftforge.items.wrapper.PlayerInvWrapper;
@@ -64,13 +64,13 @@ public class CraftingTermContainer extends MEMonitorableContainer
private final AppEngInternalInventory output = new AppEngInternalInventory(this, 1); private final AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
private final CraftingMatrixSlot[] craftingSlots = new CraftingMatrixSlot[9]; private final CraftingMatrixSlot[] craftingSlots = new CraftingMatrixSlot[9];
private final CraftingTermSlot outputSlot; private final CraftingTermSlot outputSlot;
private IRecipe<CraftingInventory> currentRecipe; private Recipe<CraftingInventory> currentRecipe;
public CraftingTermContainer(int id, final PlayerInventory ip, final ITerminalHost monitorable) { public CraftingTermContainer(int id, final PlayerInventory ip, final ITerminalHost monitorable) {
super(TYPE, id, ip, monitorable, false); super(TYPE, id, ip, monitorable, false);
this.ct = (CraftingTerminalPart) monitorable; this.ct = (CraftingTerminalPart) monitorable;
final ItemTransferable crafting = this.ct.getInventoryByName("crafting"); final FixedItemInv crafting = this.ct.getInventoryByName("crafting");
for (int y = 0; y < 3; y++) { for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
@@ -92,23 +92,23 @@ public class CraftingTermContainer extends MEMonitorableContainer
*/ */
@Override @Override
public void onCraftMatrixChanged(IInventory inventory) { public void onCraftMatrixChanged(Inventory inventory) {
final ContainerNull cn = new ContainerNull(); final ContainerNull cn = new ContainerNull();
final CraftingInventory ic = new CraftingInventory(cn, 3, 3); final CraftingInventory ic = new CraftingInventory(cn, 3, 3);
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, this.craftingSlots[x].getStack()); ic.setStack(x, this.craftingSlots[x].getStack());
} }
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, this.getPlayerInv().player.world)) { if (this.currentRecipe == null || !this.currentRecipe.matches(ic, this.getPlayerInv().player.world)) {
World world = this.getPlayerInv().player.world; World world = this.getPlayerInv().player.world;
this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); this.currentRecipe = world.getRecipeManager().getRecipe(RecipeType.CRAFTING, ic, world).orElse(null);
} }
if (this.currentRecipe == null) { if (this.currentRecipe == null) {
this.outputSlot.putStack(ItemStack.EMPTY); this.outputSlot.putStack(ItemStack.EMPTY);
} else { } else {
final ItemStack craftingResult = this.currentRecipe.getCraftingResult(ic); final ItemStack craftingResult = this.currentRecipe.craft(ic);
this.outputSlot.putStack(craftingResult); this.outputSlot.putStack(craftingResult);
} }
@@ -120,13 +120,13 @@ public class CraftingTermContainer extends MEMonitorableContainer
} }
@Override @Override
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc, public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) { final ItemStack removedStack, final ItemStack newStack) {
} }
@Override @Override
public ItemTransferable getInventoryByName(final String name) { public FixedItemInv getInventoryByName(final String name) {
if (name.equals("player")) { if (name.equals("player")) {
return new PlayerInvWrapper(this.getPlayerInventory()); return new PlayerInvWrapper(this.getPlayerInventory());
} }
@@ -138,7 +138,7 @@ public class CraftingTermContainer extends MEMonitorableContainer
return true; return true;
} }
public IRecipe<CraftingInventory> getCurrentRecipe() { public Recipe<CraftingInventory> getCurrentRecipe() {
return this.currentRecipe; return this.currentRecipe;
} }
} }
@@ -18,7 +18,7 @@
package appeng.container.implementations; package appeng.container.implementations;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -69,7 +69,7 @@ public class FormationPlaneContainer extends UpgradeableContainer {
final int xo = 8; final int xo = 8;
final int yo = 23 + 6; final int yo = 23 + 6;
final ItemTransferable config = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv config = this.getUpgradeable().getInventoryByName("config");
for (int y = 0; y < 7; y++) { for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
if (y < 2) { if (y < 2) {
@@ -80,7 +80,7 @@ public class FormationPlaneContainer extends UpgradeableContainer {
} }
} }
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
@@ -22,7 +22,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
@@ -49,7 +49,7 @@ public class GrinderContainer extends AEBaseContainer {
public GrinderContainer(int id, final PlayerInventory ip, final GrinderBlockEntity grinder) { public GrinderContainer(int id, final PlayerInventory ip, final GrinderBlockEntity grinder) {
super(TYPE, id, ip, grinder, null); super(TYPE, id, ip, grinder, null);
ItemTransferable inv = grinder.getInternalInventory(); FixedItemInv inv = grinder.getInternalInventory();
this.addSlot(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.ORE, inv, 0, 12, 17, this.addSlot(new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.ORE, inv, 0, 12, 17,
this.getPlayerInventory())); this.getPlayerInventory()));
@@ -18,7 +18,7 @@
package appeng.container.implementations; package appeng.container.implementations;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -70,7 +70,7 @@ public class IOPortContainer extends UpgradeableContainer {
int offX = 19; int offX = 19;
int offY = 17; int offY = 17;
final ItemTransferable cells = this.getUpgradeable().getInventoryByName("cells"); final FixedItemInv cells = this.getUpgradeable().getInventoryByName("cells");
for (int y = 0; y < 3; y++) { for (int y = 0; y < 3; y++) {
for (int x = 0; x < 2; x++) { for (int x = 0; x < 2; x++) {
@@ -88,7 +88,7 @@ public class IOPortContainer extends UpgradeableContainer {
} }
} }
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
@@ -24,7 +24,7 @@ import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
@@ -74,7 +74,7 @@ public class InscriberContainer extends UpgradeableContainer implements IProgres
super(TYPE, id, ip, te); super(TYPE, id, ip, te);
this.ti = te; this.ti = te;
ItemTransferable inv = te.getInternalInventory(); FixedItemInv inv = te.getInternalInventory();
RestrictedInputSlot top = new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.INSCRIBER_PLATE, inv, 0, RestrictedInputSlot top = new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.INSCRIBER_PLATE, inv, 0,
45, 16, this.getPlayerInventory()); 45, 16, this.getPlayerInventory());
@@ -127,8 +127,8 @@ public class InscriberContainer extends UpgradeableContainer implements IProgres
@Override @Override
public boolean isValidForSlot(final Slot s, final ItemStack is) { public boolean isValidForSlot(final Slot s, final ItemStack is) {
final ItemStack top = this.ti.getInternalInventory().getStackInSlot(0); final ItemStack top = this.ti.getInternalInventory().getInvStack(0);
final ItemStack bot = this.ti.getInternalInventory().getStackInSlot(1); final ItemStack bot = this.ti.getInternalInventory().getInvStack(1);
if (s == this.middle) { if (s == this.middle) {
IItemDefinition press = AEApi.instance().definitions().materials().namePress(); IItemDefinition press = AEApi.instance().definitions().materials().namePress();
@@ -31,7 +31,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings; import appeng.api.config.Settings;
@@ -54,10 +54,9 @@ import appeng.tile.misc.InterfaceBlockEntity;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.WrapperRangeItemHandler;
import appeng.util.inv.filter.IAEItemFilter; import appeng.util.inv.filter.IAEItemFilter;
public final class InterfaceTerminalContainer extends AEBaseContainer { public final class InterfaceTerminalContainer extends AEBaseContainer {
@@ -167,8 +166,8 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
} else { } else {
for (final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet()) { for (final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet()) {
final InvTracker inv = en.getValue(); final InvTracker inv = en.getValue();
for (int x = 0; x < inv.server.getSlots(); x++) { for (int x = 0; x < inv.server.getSlotCount(); x++) {
if (this.isDifferent(inv.server.getStackInSlot(x), inv.client.getStackInSlot(x))) { if (this.isDifferent(inv.server.getInvStack(x), inv.client.getInvStack(x))) {
this.addItems(this.data, inv, x, 1); this.addItems(this.data, inv, x, 1);
} }
} }
@@ -191,20 +190,20 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
public void doAction(final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id) { public void doAction(final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id) {
final InvTracker inv = this.byId.get(id); final InvTracker inv = this.byId.get(id);
if (inv != null) { if (inv != null) {
final ItemStack is = inv.server.getStackInSlot(slot); final ItemStack is = inv.server.getInvStack(slot);
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty(); final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
final InventoryAdaptor playerHand = new AdaptorItemHandler(new WrapperCursorItemHandler(player.inventory)); final InventoryAdaptor playerHand = new AdaptorFixedInv(new WrapperCursorItemHandler(player.inventory));
final ItemTransferable theSlot = new WrapperFilteredItemHandler( final FixedItemInv theSlot = new WrapperFilteredItemHandler(
new WrapperRangeItemHandler(inv.server, slot, slot + 1), new PatternSlotFilter()); inv.server.getSubInv(slot, slot + 1), new PatternSlotFilter());
final InventoryAdaptor interfaceSlot = new AdaptorItemHandler(theSlot); final InventoryAdaptor interfaceSlot = new AdaptorFixedInv(theSlot);
switch (action) { switch (action) {
case PICKUP_OR_SET_DOWN: case PICKUP_OR_SET_DOWN:
if (hasItemInHand) { if (hasItemInHand) {
ItemStack inSlot = theSlot.getStackInSlot(0); ItemStack inSlot = theSlot.getInvStack(0);
if (inSlot.isEmpty()) { if (inSlot.isEmpty()) {
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack())); player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
} else { } else {
@@ -224,7 +223,7 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
} }
} }
} else { } else {
ItemHandlerUtil.setStackInSlot(theSlot, 0, playerHand.addItems(theSlot.getStackInSlot(0))); ItemHandlerUtil.setStackInSlot(theSlot, 0, playerHand.addItems(theSlot.getInvStack(0)));
} }
break; break;
@@ -253,15 +252,15 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player); final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player);
ItemHandlerUtil.setStackInSlot(theSlot, 0, playerInv.addItems(theSlot.getStackInSlot(0))); ItemHandlerUtil.setStackInSlot(theSlot, 0, playerInv.addItems(theSlot.getInvStack(0)));
break; break;
case MOVE_REGION: case MOVE_REGION:
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player); final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player);
for (int x = 0; x < inv.server.getSlots(); x++) { for (int x = 0; x < inv.server.getSlotCount(); x++) {
ItemHandlerUtil.setStackInSlot(inv.server, x, ItemHandlerUtil.setStackInSlot(inv.server, x,
playerInvAd.addItems(inv.server.getStackInSlot(x))); playerInvAd.addItems(inv.server.getInvStack(x)));
} }
break; break;
@@ -311,7 +310,7 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
for (final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet()) { for (final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet()) {
final InvTracker inv = en.getValue(); final InvTracker inv = en.getValue();
this.byId.put(inv.which, inv); this.byId.put(inv.which, inv);
this.addItems(data, inv, 0, inv.server.getSlots()); this.addItems(data, inv, 0, inv.server.getSlotCount());
} }
} }
@@ -324,7 +323,7 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
return true; return true;
} }
return !ItemStack.areItemStacksEqual(a, b); return !ItemStack.areEqual(a, b);
} }
private void addItems(final CompoundTag data, final InvTracker inv, final int offset, final int length) { private void addItems(final CompoundTag data, final InvTracker inv, final int offset, final int length) {
@@ -339,13 +338,13 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
for (int x = 0; x < length; x++) { for (int x = 0; x < length; x++) {
final CompoundTag itemNBT = new CompoundTag(); final CompoundTag itemNBT = new CompoundTag();
final ItemStack is = inv.server.getStackInSlot(x + offset); final ItemStack is = inv.server.getInvStack(x + offset);
// "update" client side. // "update" client side.
ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy()); ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy());
if (!is.isEmpty()) { if (!is.isEmpty()) {
is.write(itemNBT); is.toTag(itemNBT);
} }
tag.put(Integer.toString(x + offset), itemNBT); tag.put(Integer.toString(x + offset), itemNBT);
@@ -359,12 +358,12 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
private final long sortBy; private final long sortBy;
private final long which = autoBase++; private final long which = autoBase++;
private final Text name; private final Text name;
private final ItemTransferable client; private final FixedItemInv client;
private final ItemTransferable server; private final FixedItemInv server;
public InvTracker(final DualityInterface dual, final ItemTransferable patterns, final Text name) { public InvTracker(final DualityInterface dual, final FixedItemInv patterns, final Text name) {
this.server = patterns; this.server = patterns;
this.client = new AppEngInternalInventory(null, this.server.getSlots()); this.client = new AppEngInternalInventory(null, this.server.getSlotCount());
this.name = name; this.name = name;
this.sortBy = dual.getSortValue(); this.sortBy = dual.getSortValue();
} }
@@ -372,12 +371,12 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
private static class PatternSlotFilter implements IAEItemFilter { private static class PatternSlotFilter implements IAEItemFilter {
@Override @Override
public boolean allowExtract(ItemTransferable inv, int slot, int amount) { public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
return true; return true;
} }
@Override @Override
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) { public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
return !stack.isEmpty() && stack.getItem() instanceof EncodedPatternItem; return !stack.isEmpty() && stack.getItem() instanceof EncodedPatternItem;
} }
} }
@@ -18,7 +18,7 @@
package appeng.container.implementations; package appeng.container.implementations;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.gui.widget.TextFieldWidget;
@@ -84,7 +84,7 @@ public class LevelEmitterContainer extends UpgradeableContainer {
@Override @Override
protected void setupConfig() { protected void setupConfig() {
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
if (this.availableUpgrades() > 0) { if (this.availableUpgrades() > 0) {
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
@@ -102,7 +102,7 @@ public class LevelEmitterContainer extends UpgradeableContainer {
8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable());
} }
final ItemTransferable inv = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv inv = this.getUpgradeable().getInventoryByName("config");
final int y = 40; final int y = 40;
final int x = 80 + 44; final int x = 80 + 44;
this.addSlot(new FakeTypeOnlySlot(inv, 0, x, y)); this.addSlot(new FakeTypeOnlySlot(inv, 0, x, y));
@@ -73,13 +73,13 @@ public class MEPortableCellContainer extends MEMonitorableContainer {
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem()
: this.getPlayerInv().getStackInSlot(this.slot); : this.getPlayerInv().getStack(this.slot);
if (this.civ == null || currentItem.isEmpty()) { if (this.civ == null || currentItem.isEmpty()) {
this.setValidContainer(false); this.setValidContainer(false);
} else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) { } else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) {
if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) { if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack()); this.getPlayerInv().setStack(this.getPlayerInv().currentItem, this.civ.getItemStack());
} else { } else {
this.setValidContainer(false); this.setValidContainer(false);
} }
@@ -18,7 +18,7 @@
package appeng.container.implementations; package appeng.container.implementations;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -70,9 +70,9 @@ public class MolecularAssemblerContainer extends UpgradeableContainer implements
} }
public boolean isValidItemForSlot(final int slotIndex, final ItemStack i) { public boolean isValidItemForSlot(final int slotIndex, final ItemStack i) {
final ItemTransferable mac = this.getUpgradeable().getInventoryByName(MolecularAssemblerBlockEntity.INVENTORY_MAIN); final FixedItemInv mac = this.getUpgradeable().getInventoryByName(MolecularAssemblerBlockEntity.INVENTORY_MAIN);
final ItemStack is = mac.getStackInSlot(10); final ItemStack is = mac.getInvStack(10);
if (is.isEmpty()) { if (is.isEmpty()) {
return false; return false;
} }
@@ -99,7 +99,7 @@ public class MolecularAssemblerContainer extends UpgradeableContainer implements
int offX = 29; int offX = 29;
int offY = 30; int offY = 30;
final ItemTransferable mac = this.getUpgradeable().getInventoryByName(MolecularAssemblerBlockEntity.INVENTORY_MAIN); final FixedItemInv mac = this.getUpgradeable().getInventoryByName(MolecularAssemblerBlockEntity.INVENTORY_MAIN);
for (int y = 0; y < 3; y++) { for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
@@ -120,7 +120,7 @@ public class MolecularAssemblerContainer extends UpgradeableContainer implements
offX = 122; offX = 122;
offY = 17; offY = 17;
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
@@ -80,7 +80,7 @@ public class NetworkToolContainer extends AEBaseContainer {
if (currentItem != this.toolInv.getItemStack()) { if (currentItem != this.toolInv.getItemStack()) {
if (!currentItem.isEmpty()) { if (!currentItem.isEmpty()) {
if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) { if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.getPlayerInv().setStack(this.getPlayerInv().currentItem,
this.toolInv.getItemStack()); this.toolInv.getItemStack());
} else { } else {
this.setValidContainer(false); this.setValidContainer(false);
@@ -22,9 +22,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.inventory.CraftResultInventory; import net.minecraft.inventory.CraftResultInventory;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
@@ -33,8 +35,6 @@ import net.minecraft.inventory.container.CraftingResultSlot;
import net.minecraft.inventory.container.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.INBT; import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
@@ -68,7 +68,7 @@ import appeng.parts.reporting.PatternTerminalPart;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperCursorItemHandler;
@@ -92,14 +92,14 @@ public class PatternTermContainer extends MEMonitorableContainer
private final PatternTerminalPart patternTerminal; private final PatternTerminalPart patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1); private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
private final ItemTransferable crafting; private final FixedItemInv crafting;
private final FakeCraftingMatrixSlot[] craftingSlots = new FakeCraftingMatrixSlot[9]; private final FakeCraftingMatrixSlot[] craftingSlots = new FakeCraftingMatrixSlot[9];
private final OptionalFakeSlot[] outputSlots = new OptionalFakeSlot[3]; private final OptionalFakeSlot[] outputSlots = new OptionalFakeSlot[3];
private final PatternTermSlot craftSlot; private final PatternTermSlot craftSlot;
private final RestrictedInputSlot patternSlotIN; private final RestrictedInputSlot patternSlotIN;
private final RestrictedInputSlot patternSlotOUT; private final RestrictedInputSlot patternSlotOUT;
private IRecipe<CraftingInventory> currentRecipe; private Recipe<CraftingInventory> currentRecipe;
@GuiSync(97) @GuiSync(97)
public boolean craftingMode = true; public boolean craftingMode = true;
@GuiSync(96) @GuiSync(96)
@@ -109,8 +109,8 @@ public class PatternTermContainer extends MEMonitorableContainer
super(TYPE, id, ip, monitorable, false); super(TYPE, id, ip, monitorable, false);
this.patternTerminal = (PatternTerminalPart) monitorable; this.patternTerminal = (PatternTerminalPart) monitorable;
final ItemTransferable patternInv = this.getPatternTerminal().getInventoryByName("pattern"); final FixedItemInv patternInv = this.getPatternTerminal().getInventoryByName("pattern");
final ItemTransferable output = this.getPatternTerminal().getInventoryByName("output"); final FixedItemInv output = this.getPatternTerminal().getInventoryByName("output");
this.crafting = this.getPatternTerminal().getInventoryByName("crafting"); this.crafting = this.getPatternTerminal().getInventoryByName("crafting");
@@ -168,12 +168,12 @@ public class PatternTermContainer extends MEMonitorableContainer
final World world = this.getPlayerInv().player.world; final World world = this.getPlayerInv().player.world;
final CraftingInventory ic = new CraftingInventory(this, 3, 3); final CraftingInventory ic = new CraftingInventory(this, 3, 3);
for (int x = 0; x < ic.getSizeInventory(); x++) { for (int x = 0; x < ic.size(); x++) {
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x)); ic.setStack(x, this.crafting.getInvStack(x));
} }
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, world)) { if (this.currentRecipe == null || !this.currentRecipe.matches(ic, world)) {
this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); this.currentRecipe = world.getRecipeManager().getRecipe(RecipeType.CRAFTING, ic, world).orElse(null);
} }
final ItemStack is; final ItemStack is;
@@ -181,7 +181,7 @@ public class PatternTermContainer extends MEMonitorableContainer
if (this.currentRecipe == null) { if (this.currentRecipe == null) {
is = ItemStack.EMPTY; is = ItemStack.EMPTY;
} else { } else {
is = this.currentRecipe.getCraftingResult(ic); is = this.currentRecipe.craft(ic);
} }
this.cOut.setStackInSlot(0, is); this.cOut.setStackInSlot(0, is);
@@ -194,7 +194,7 @@ public class PatternTermContainer extends MEMonitorableContainer
} }
@Override @Override
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc, public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) { final ItemStack removedStack, final ItemStack newStack) {
} }
@@ -319,7 +319,7 @@ public class PatternTermContainer extends MEMonitorableContainer
final CompoundTag c = new CompoundTag(); final CompoundTag c = new CompoundTag();
if (!i.isEmpty()) { if (!i.isEmpty()) {
i.write(c); i.toTag(c);
} }
return c; return c;
@@ -339,7 +339,7 @@ public class PatternTermContainer extends MEMonitorableContainer
public void craftOrGetItem(final PatternSlotPacket packetPatternSlot) { public void craftOrGetItem(final PatternSlotPacket packetPatternSlot) {
if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) { if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) {
final IAEItemStack out = packetPatternSlot.slotItem.copy(); final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorItemHandler( InventoryAdaptor inv = new AdaptorFixedInv(
new WrapperCursorItemHandler(this.getPlayerInv().player.inventory)); new WrapperCursorItemHandler(this.getPlayerInv().player.inventory));
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(this.getPlayerInv().player); final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(this.getPlayerInv().player);
@@ -368,11 +368,11 @@ public class PatternTermContainer extends MEMonitorableContainer
final CraftingInventory real = new CraftingInventory(new ContainerNull(), 3, 3); final CraftingInventory real = new CraftingInventory(new ContainerNull(), 3, 3);
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY ic.setStack(x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY
: packetPatternSlot.pattern[x].createItemStack()); : packetPatternSlot.pattern[x].createItemStack());
} }
final IRecipe<CraftingInventory> r = p.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, p.world) final Recipe<CraftingInventory> r = p.world.getRecipeManager().getRecipe(RecipeType.CRAFTING, ic, p.world)
.orElse(null); .orElse(null);
if (r == null) { if (r == null) {
@@ -383,29 +383,29 @@ public class PatternTermContainer extends MEMonitorableContainer
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IItemList<IAEItemStack> all = storage.getStorageList(); final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.getCraftingResult(ic); final ItemStack is = r.craft(ic);
for (int x = 0; x < ic.getSizeInventory(); x++) { for (int x = 0; x < ic.size(); x++) {
if (!ic.getStackInSlot(x).isEmpty()) { if (!ic.getStack(x).isEmpty()) {
final ItemStack pulled = Platform.extractItemsByRecipe(this.getPowerSource(), final ItemStack pulled = Platform.extractItemsByRecipe(this.getPowerSource(),
this.getActionSource(), storage, p.world, r, is, ic, ic.getStackInSlot(x), x, all, this.getActionSource(), storage, p.world, r, is, ic, ic.getStack(x), x, all,
Actionable.MODULATE, ViewCellItem.createFilter(this.getViewCells())); Actionable.MODULATE, ViewCellItem.createFilter(this.getViewCells()));
real.setInventorySlotContents(x, pulled); real.setStack(x, pulled);
} }
} }
final IRecipe<CraftingInventory> rr = p.world.getRecipeManager() final Recipe<CraftingInventory> rr = p.world.getRecipeManager()
.getRecipe(IRecipeType.CRAFTING, real, p.world).orElse(null); .getRecipe(RecipeType.CRAFTING, real, p.world).orElse(null);
if (rr == r && Platform.itemComparisons().isSameItem(rr.getCraftingResult(real), is)) { if (rr == r && Platform.itemComparisons().isSameItem(rr.craft(real), is)) {
final CraftResultInventory craftingResult = new CraftResultInventory(); final CraftResultInventory craftingResult = new CraftResultInventory();
craftingResult.setRecipeUsed(rr); craftingResult.setRecipeUsed(rr);
final CraftingResultSlot sc = new CraftingResultSlot(p, real, craftingResult, 0, 0, 0); final CraftingResultSlot sc = new CraftingResultSlot(p, real, craftingResult, 0, 0, 0);
sc.onTake(p, is); sc.onTake(p, is);
for (int x = 0; x < real.getSizeInventory(); x++) { for (int x = 0; x < real.size(); x++) {
final ItemStack failed = playerInv.addItems(real.getStackInSlot(x)); final ItemStack failed = playerInv.addItems(real.getStack(x));
if (!failed.isEmpty()) { if (!failed.isEmpty()) {
p.dropItem(failed, false); p.dropItem(failed, false);
@@ -418,8 +418,8 @@ public class PatternTermContainer extends MEMonitorableContainer
} }
this.detectAndSendChanges(); this.detectAndSendChanges();
} else { } else {
for (int x = 0; x < real.getSizeInventory(); x++) { for (int x = 0; x < real.size(); x++) {
final ItemStack failed = real.getStackInSlot(x); final ItemStack failed = real.getStack(x);
if (!failed.isEmpty()) { if (!failed.isEmpty()) {
this.getCellInventory().injectItems(AEItemStack.fromItemStack(failed), Actionable.MODULATE, this.getCellInventory().injectItems(AEItemStack.fromItemStack(failed), Actionable.MODULATE,
new MachineSource(this.getPatternTerminal())); new MachineSource(this.getPatternTerminal()));
@@ -487,7 +487,7 @@ public class PatternTermContainer extends MEMonitorableContainer
} }
@Override @Override
public ItemTransferable getInventoryByName(final String name) { public FixedItemInv getInventoryByName(final String name) {
if (name.equals("player")) { if (name.equals("player")) {
return new PlayerInvWrapper(this.getPlayerInventory()); return new PlayerInvWrapper(this.getPlayerInventory());
} }
@@ -20,7 +20,7 @@ package appeng.container.implementations;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -57,7 +57,7 @@ public class QuartzKnifeContainer extends AEBaseContainer {
private final QuartzKnifeObj toolInv; private final QuartzKnifeObj toolInv;
private final ItemTransferable inSlot = new AppEngInternalInventory(null, 1, 1); private final FixedItemInv inSlot = new AppEngInternalInventory(null, 1, 1);
private String myName = ""; private String myName = "";
public QuartzKnifeContainer(int id, final PlayerInventory ip, final QuartzKnifeObj te) { public QuartzKnifeContainer(int id, final PlayerInventory ip, final QuartzKnifeObj te) {
@@ -84,7 +84,7 @@ public class QuartzKnifeContainer extends AEBaseContainer {
if (currentItem != this.toolInv.getItemStack()) { if (currentItem != this.toolInv.getItemStack()) {
if (!currentItem.isEmpty()) { if (!currentItem.isEmpty()) {
if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) { if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.getPlayerInv().setStack(this.getPlayerInv().currentItem,
this.toolInv.getItemStack()); this.toolInv.getItemStack());
} else { } else {
this.setValidContainer(false); this.setValidContainer(false);
@@ -99,20 +99,20 @@ public class QuartzKnifeContainer extends AEBaseContainer {
@Override @Override
public void onContainerClosed(final PlayerEntity par1PlayerEntity) { public void onContainerClosed(final PlayerEntity par1PlayerEntity) {
if (this.inSlot.getStackInSlot(0) != null) { if (this.inSlot.getInvStack(0) != null) {
par1PlayerEntity.dropItem(this.inSlot.getStackInSlot(0), false); par1PlayerEntity.dropItem(this.inSlot.getInvStack(0), false);
} }
} }
private class QuartzKniveSlot extends OutputSlot { private class QuartzKniveSlot extends OutputSlot {
QuartzKniveSlot(ItemTransferable a, int b, int c, int d, int i) { QuartzKniveSlot(FixedItemInv a, int b, int c, int d, int i) {
super(a, b, c, d, i); super(a, b, c, d, i);
} }
@Override @Override
public ItemStack getStack() { public ItemStack getStack() {
final ItemTransferable baseInv = this.getItemHandler(); final FixedItemInv baseInv = this.getItemHandler();
final ItemStack input = baseInv.getStackInSlot(0); final ItemStack input = baseInv.getInvStack(0);
if (input == ItemStack.EMPTY) { if (input == ItemStack.EMPTY) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
@@ -153,7 +153,7 @@ public class QuartzKnifeContainer extends AEBaseContainer {
final ItemStack item = QuartzKnifeContainer.this.toolInv.getItemStack(); final ItemStack item = QuartzKnifeContainer.this.toolInv.getItemStack();
final ItemStack before = item.copy(); final ItemStack before = item.copy();
item.damageItem(1, QuartzKnifeContainer.this.getPlayerInv().player, p -> { item.damageItem(1, QuartzKnifeContainer.this.getPlayerInv().player, p -> {
QuartzKnifeContainer.this.getPlayerInv().setInventorySlotContents( QuartzKnifeContainer.this.getPlayerInv().setStack(
QuartzKnifeContainer.this.getPlayerInv().currentItem, ItemStack.EMPTY); QuartzKnifeContainer.this.getPlayerInv().currentItem, ItemStack.EMPTY);
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent( MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(
QuartzKnifeContainer.this.getPlayerInv().player, before, null)); QuartzKnifeContainer.this.getPlayerInv().player, before, null));
@@ -24,7 +24,7 @@ import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
@@ -139,7 +139,7 @@ public class SecurityStationContainer extends MEMonitorableContainer implements
} }
@Override @Override
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc, public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) { final ItemStack removedStack, final ItemStack newStack) {
if (!this.wirelessOut.getHasStack()) { if (!this.wirelessOut.getHasStack()) {
if (this.wirelessIn.getHasStack()) { if (this.wirelessIn.getHasStack()) {
@@ -20,7 +20,7 @@ package appeng.container.implementations;
import java.util.Iterator; import java.util.Iterator;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -86,7 +86,7 @@ public class StorageBusContainer extends UpgradeableContainer {
final int xo = 8; final int xo = 8;
final int yo = 23 + 6; final int yo = 23 + 6;
final ItemTransferable config = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv config = this.getUpgradeable().getInventoryByName("config");
for (int y = 0; y < 7; y++) { for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
if (y < 2) { if (y < 2) {
@@ -97,7 +97,7 @@ public class StorageBusContainer extends UpgradeableContainer {
} }
} }
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
@@ -148,7 +148,7 @@ public class StorageBusContainer extends UpgradeableContainer {
} }
public void partition() { public void partition() {
final ItemTransferable inv = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv inv = this.getUpgradeable().getInventoryByName("config");
final IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler(); final IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler();
@@ -159,7 +159,7 @@ public class StorageBusContainer extends UpgradeableContainer {
i = list.iterator(); i = list.iterator();
} }
for (int x = 0; x < inv.getSlots(); x++) { for (int x = 0; x < inv.getSlotCount(); x++) {
if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) { if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) {
// TODO: check if ok // TODO: check if ok
final ItemStack g = i.next().asItemStackRepresentation(); final ItemStack g = i.next().asItemStackRepresentation();
@@ -21,13 +21,13 @@ package appeng.container.implementations;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode; import appeng.api.config.RedstoneMode;
@@ -111,8 +111,8 @@ public class UpgradeableContainer extends AEBaseContainer implements IOptionalSl
zCoord = mk.getPos().getZ(); zCoord = mk.getPos().getZ();
} }
final IInventory pi = this.getPlayerInv(); final Inventory pi = this.getPlayerInv();
for (int x = 0; x < pi.getSizeInventory(); x++) { for (int x = 0; x < pi.size(); x++) {
final ItemStack pii = pi.getStackInSlot(x); final ItemStack pii = pi.getStackInSlot(x);
if (!pii.isEmpty() && pii.getItem() instanceof NetworkToolItem) { if (!pii.isEmpty() && pii.getItem() instanceof NetworkToolItem) {
this.lockPlayerInventorySlot(x); this.lockPlayerInventorySlot(x);
@@ -149,7 +149,7 @@ public class UpgradeableContainer extends AEBaseContainer implements IOptionalSl
protected void setupConfig() { protected void setupConfig() {
this.setupUpgrades(); this.setupUpgrades();
final ItemTransferable inv = this.getUpgradeable().getInventoryByName("config"); final FixedItemInv inv = this.getUpgradeable().getInventoryByName("config");
final int y = 40; final int y = 40;
final int x = 80; final int x = 80;
this.addSlot(new FakeTypeOnlySlot(inv, 0, x, y)); this.addSlot(new FakeTypeOnlySlot(inv, 0, x, y));
@@ -168,7 +168,7 @@ public class UpgradeableContainer extends AEBaseContainer implements IOptionalSl
} }
protected void setupUpgrades() { protected void setupUpgrades() {
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
if (this.availableUpgrades() > 0) { if (this.availableUpgrades() > 0) {
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
@@ -229,12 +229,12 @@ public class UpgradeableContainer extends AEBaseContainer implements IOptionalSl
protected void checkToolbox() { protected void checkToolbox() {
if (this.hasToolbox()) { if (this.hasToolbox()) {
final ItemStack currentItem = this.getPlayerInv().getStackInSlot(this.tbSlot); final ItemStack currentItem = this.getPlayerInv().getStack(this.tbSlot);
if (currentItem != this.tbInventory.getItemStack()) { if (currentItem != this.tbInventory.getItemStack()) {
if (!currentItem.isEmpty()) { if (!currentItem.isEmpty()) {
if (ItemStack.areItemsEqual(this.tbInventory.getItemStack(), currentItem)) { if (ItemStack.areItemsEqual(this.tbInventory.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.tbSlot, this.tbInventory.getItemStack()); this.getPlayerInv().setStack(this.tbSlot, this.tbInventory.getItemStack());
} else { } else {
this.setValidContainer(false); this.setValidContainer(false);
} }
@@ -57,7 +57,7 @@ public class WirelessTermContainer extends MEPortableCellContainer {
if (!this.wirelessTerminalGUIObject.rangeCheck()) { if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) { if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get()); this.getPlayerInv().player.sendSystemMessage(PlayerMessages.OutOfRange.get(), Util.NIL_UUID);
} }
this.setValidContainer(false); this.setValidContainer(false);
@@ -18,11 +18,11 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.hooks.BasicEventHooks; import net.minecraftforge.fml.hooks.BasicEventHooks;
@@ -35,7 +35,7 @@ public class AppEngCraftingSlot extends AppEngSlot {
/** /**
* The craft matrix inventory linked to this result slot. * The craft matrix inventory linked to this result slot.
*/ */
private final ItemTransferable craftMatrix; private final FixedItemInv craftMatrix;
/** /**
* The player that is using the GUI where this slot resides. * The player that is using the GUI where this slot resides.
@@ -48,8 +48,8 @@ public class AppEngCraftingSlot extends AppEngSlot {
*/ */
private int amountCrafted; private int amountCrafted;
public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final ItemTransferable par2IInventory, public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final FixedItemInv par2IInventory,
final ItemTransferable par3IInventory, final int par4, final int par5, final int par6) { final FixedItemInv par3IInventory, final int par4, final int par5, final int par6) {
super(par3IInventory, par4, par5, par6); super(par3IInventory, par4, par5, par6);
this.thePlayer = par1PlayerEntity; this.thePlayer = par1PlayerEntity;
this.craftMatrix = par2IInventory; this.craftMatrix = par2IInventory;
@@ -92,8 +92,8 @@ public class AppEngCraftingSlot extends AppEngSlot {
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
final CraftingInventory ic = new CraftingInventory(this.getContainer(), 3, 3); final CraftingInventory ic = new CraftingInventory(this.getContainer(), 3, 3);
for (int x = 0; x < this.craftMatrix.getSlots(); x++) { for (int x = 0; x < this.craftMatrix.getSlotCount(); x++) {
ic.setInventorySlotContents(x, this.craftMatrix.getStackInSlot(x)); ic.setStack(x, this.craftMatrix.getInvStack(x));
} }
final NonNullList<ItemStack> aitemstack = this.getRemainingItems(ic, playerIn.world); final NonNullList<ItemStack> aitemstack = this.getRemainingItems(ic, playerIn.world);
@@ -103,7 +103,7 @@ public class AppEngCraftingSlot extends AppEngSlot {
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
for (int i = 0; i < aitemstack.size(); ++i) { for (int i = 0; i < aitemstack.size(); ++i) {
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); final ItemStack itemstack1 = this.craftMatrix.getInvStack(i);
final ItemStack itemstack2 = aitemstack.get(i); final ItemStack itemstack2 = aitemstack.get(i);
if (!itemstack1.isEmpty()) { if (!itemstack1.isEmpty()) {
@@ -111,7 +111,7 @@ public class AppEngCraftingSlot extends AppEngSlot {
} }
if (!itemstack2.isEmpty()) { if (!itemstack2.isEmpty()) {
if (this.craftMatrix.getStackInSlot(i).isEmpty()) { if (this.craftMatrix.getInvStack(i).isEmpty()) {
ItemHandlerUtil.setStackInSlot(this.craftMatrix, i, itemstack2); ItemHandlerUtil.setStackInSlot(this.craftMatrix, i, itemstack2);
} else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { } else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
this.thePlayer.dropItem(itemstack2, false); this.thePlayer.dropItem(itemstack2, false);
@@ -138,7 +138,7 @@ public class AppEngCraftingSlot extends AppEngSlot {
// TODO: This is really hacky and NEEDS to be solved with a full container/gui // TODO: This is really hacky and NEEDS to be solved with a full container/gui
// refactoring. // refactoring.
protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) { protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world) return world.getRecipeManager().getRecipe(RecipeType.CRAFTING, ic, world)
.map(iCraftingRecipe -> iCraftingRecipe.getRemainingItems(ic)) .map(iCraftingRecipe -> iCraftingRecipe.getRemainingItems(ic))
.orElse(NonNullList.withSize(9, ItemStack.EMPTY)); .orElse(NonNullList.withSize(9, ItemStack.EMPTY));
} }
@@ -20,11 +20,10 @@ package appeng.container.slot;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -33,8 +32,8 @@ import appeng.container.AEBaseContainer;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
public class AppEngSlot extends Slot { public class AppEngSlot extends Slot {
private static IInventory emptyInventory = new Inventory(0); private static Inventory emptyInventory = new Inventory(0);
private final ItemTransferable itemHandler; private final FixedItemInv itemHandler;
private final int index; private final int index;
private final int defX; private final int defX;
@@ -46,7 +45,7 @@ public class AppEngSlot extends Slot {
private CalculatedValidity isValid; private CalculatedValidity isValid;
private boolean isDisplay = false; private boolean isDisplay = false;
public AppEngSlot(final ItemTransferable inv, final int idx, final int x, final int y) { public AppEngSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
super(emptyInventory, idx, x, y); super(emptyInventory, idx, x, y);
this.itemHandler = inv; this.itemHandler = inv;
this.index = idx; this.index = idx;
@@ -89,7 +88,7 @@ public class AppEngSlot extends Slot {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
if (this.itemHandler.getSlots() <= this.getSlotIndex()) { if (this.itemHandler.getSlotCount() <= this.getSlotIndex()) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
@@ -98,7 +97,7 @@ public class AppEngSlot extends Slot {
return this.getDisplayStack(); return this.getDisplayStack();
} }
return this.itemHandler.getStackInSlot(this.index); return this.itemHandler.getInvStack(this.index);
} }
@Override @Override
@@ -115,7 +114,7 @@ public class AppEngSlot extends Slot {
} }
} }
public ItemTransferable getItemHandler() { public FixedItemInv getItemHandler() {
return this.itemHandler; return this.itemHandler;
} }
@@ -166,7 +165,7 @@ public class AppEngSlot extends Slot {
} }
public ItemStack getDisplayStack() { public ItemStack getDisplayStack() {
return this.itemHandler.getStackInSlot(this.index); return this.itemHandler.getInvStack(this.index);
} }
public float getOpacityOfIcon() { public float getOpacityOfIcon() {
@@ -18,8 +18,8 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
@@ -27,9 +27,9 @@ import appeng.util.inv.WrapperInvItemHandler;
public class CraftingMatrixSlot extends AppEngSlot { public class CraftingMatrixSlot extends AppEngSlot {
private final AEBaseContainer c; private final AEBaseContainer c;
private final IInventory wrappedInventory; private final Inventory wrappedInventory;
public CraftingMatrixSlot(final AEBaseContainer c, final ItemTransferable par1iInventory, final int par2, public CraftingMatrixSlot(final AEBaseContainer c, final FixedItemInv par1iInventory, final int par2,
final int par3, final int par4) { final int par3, final int par4) {
super(par1iInventory, par2, par3, par4); super(par1iInventory, par2, par3, par4);
this.c = c; this.c = c;
@@ -22,13 +22,13 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.recipe.Recipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -50,15 +50,15 @@ import appeng.items.storage.ViewCellItem;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.inv.WrapperInvItemHandler; import appeng.util.inv.WrapperInvItemHandler;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
public class CraftingTermSlot extends AppEngCraftingSlot { public class CraftingTermSlot extends AppEngCraftingSlot {
private final ItemTransferable craftInv; private final FixedItemInv craftInv;
private final ItemTransferable pattern; private final FixedItemInv pattern;
private final IActionSource mySrc; private final IActionSource mySrc;
private final IEnergySource energySrc; private final IEnergySource energySrc;
@@ -66,8 +66,8 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
private final IContainerCraftingPacket container; private final IContainerCraftingPacket container;
public CraftingTermSlot(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, public CraftingTermSlot(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
final IStorageMonitorable storage, final ItemTransferable cMatrix, final ItemTransferable secondMatrix, final IStorageMonitorable storage, final FixedItemInv cMatrix, final FixedItemInv secondMatrix,
final ItemTransferable output, final int x, final int y, final IContainerCraftingPacket ccp) { final FixedItemInv output, final int x, final int y, final IContainerCraftingPacket ccp) {
super(player, cMatrix, output, 0, x, y); super(player, cMatrix, output, 0, x, y);
this.energySrc = energySrc; this.energySrc = energySrc;
this.storage = storage; this.storage = storage;
@@ -77,7 +77,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
this.container = ccp; this.container = ccp;
} }
public ItemTransferable getCraftingMatrix() { public FixedItemInv getCraftingMatrix() {
return this.craftInv; return this.craftInv;
} }
@@ -111,12 +111,12 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft); maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack } else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack
{ {
ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory)); ia = new AdaptorFixedInv(new WrapperCursorItemHandler(who.inventory));
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft); maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
} else } else
// pick up what was crafted... // pick up what was crafted...
{ {
ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory)); ia = new AdaptorFixedInv(new WrapperCursorItemHandler(who.inventory));
maxTimesToCraft = 1; maxTimesToCraft = 1;
} }
@@ -139,7 +139,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
final List<ItemStack> drops = new ArrayList<>(); final List<ItemStack> drops = new ArrayList<>();
drops.add(extra); drops.add(extra);
Platform.spawnDrops(who.world, Platform.spawnDrops(who.world,
new BlockPos((int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ()), drops); new BlockPos((int) who.getX(), (int) who.getY(), (int) who.getPosZ()), drops);
return; return;
} }
} }
@@ -148,17 +148,17 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
// TODO: This is really hacky and NEEDS to be solved with a full container/gui // TODO: This is really hacky and NEEDS to be solved with a full container/gui
// refactoring. // refactoring.
protected IRecipe<CraftingInventory> findRecipe(CraftingInventory ic, World world) { protected Recipe<CraftingInventory> findRecipe(CraftingInventory ic, World world) {
if (this.container instanceof CraftingTermContainer) { if (this.container instanceof CraftingTermContainer) {
final CraftingTermContainer containerTerminal = (CraftingTermContainer) this.container; final CraftingTermContainer containerTerminal = (CraftingTermContainer) this.container;
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe(); final Recipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
if (recipe != null && recipe.matches(ic, world)) { if (recipe != null && recipe.matches(ic, world)) {
return containerTerminal.getCurrentRecipe(); return containerTerminal.getCurrentRecipe();
} }
} }
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); return world.getRecipeManager().getRecipe(RecipeType.CRAFTING, ic, world).orElse(null);
} }
// TODO: This is really hacky and NEEDS to be solved with a full container/gui // TODO: This is really hacky and NEEDS to be solved with a full container/gui
@@ -167,7 +167,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) { protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
if (this.container instanceof CraftingTermContainer) { if (this.container instanceof CraftingTermContainer) {
final CraftingTermContainer containerTerminal = (CraftingTermContainer) this.container; final CraftingTermContainer containerTerminal = (CraftingTermContainer) this.container;
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe(); final Recipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
if (recipe != null && recipe.matches(ic, world)) { if (recipe != null && recipe.matches(ic, world)) {
return containerTerminal.getCurrentRecipe().getRemainingItems(ic); return containerTerminal.getCurrentRecipe().getRemainingItems(ic);
@@ -187,7 +187,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
ItemStack is = this.getStack(); ItemStack is = this.getStack();
if (!is.isEmpty() && ItemStack.areItemsEqual(request, is)) { if (!is.isEmpty() && ItemStack.areItemsEqual(request, is)) {
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()]; final ItemStack[] set = new ItemStack[this.getPattern().getSlotCount()];
// Safeguard for empty slots in the inventory for now // Safeguard for empty slots in the inventory for now
Arrays.fill(set, ItemStack.EMPTY); Arrays.fill(set, ItemStack.EMPTY);
@@ -195,17 +195,17 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
if (Platform.isServer()) { if (Platform.isServer()) {
final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3); final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3);
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x)); ic.setStack(x, this.getPattern().getInvStack(x));
} }
final IRecipe<CraftingInventory> r = this.findRecipe(ic, p.world); final Recipe<CraftingInventory> r = this.findRecipe(ic, p.world);
if (r == null) { if (r == null) {
final Item target = request.getItem(); final Item target = request.getItem();
if (target.isDamageable() && target.isRepairable(request)) { if (target.isDamageable() && target.isRepairable(request)) {
boolean isBad = false; boolean isBad = false;
for (int x = 0; x < ic.getSizeInventory(); x++) { for (int x = 0; x < ic.size(); x++) {
final ItemStack pis = ic.getStackInSlot(x); final ItemStack pis = ic.getStack(x);
if (pis.isEmpty()) { if (pis.isEmpty()) {
continue; continue;
} }
@@ -223,15 +223,15 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
is = r.getCraftingResult(ic); is = r.craft(ic);
if (inv != null) { if (inv != null) {
for (int x = 0; x < this.getPattern().getSlots(); x++) { for (int x = 0; x < this.getPattern().getSlotCount(); x++) {
if (!this.getPattern().getStackInSlot(x).isEmpty()) { if (!this.getPattern().getInvStack(x).isEmpty()) {
set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.world, r, is, ic, set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.world, r, is, ic,
this.getPattern().getStackInSlot(x), x, all, Actionable.MODULATE, this.getPattern().getInvStack(x), x, all, Actionable.MODULATE,
ViewCellItem.createFilter(this.container.getViewCells())); ViewCellItem.createFilter(this.container.getViewCells()));
ic.setInventorySlotContents(x, set[x]); ic.setStack(x, set[x]);
} }
} }
} }
@@ -267,8 +267,8 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
// add one of each item to the items on the board... // add one of each item to the items on the board...
if (Platform.isServer()) { if (Platform.isServer()) {
// set new items onto the crafting table... // set new items onto the crafting table...
for (int x = 0; x < this.craftInv.getSlots(); x++) { for (int x = 0; x < this.craftInv.getSlotCount(); x++) {
if (this.craftInv.getStackInSlot(x).isEmpty()) { if (this.craftInv.getInvStack(x).isEmpty()) {
ItemHandlerUtil.setStackInSlot(this.craftInv, x, set[x]); ItemHandlerUtil.setStackInSlot(this.craftInv, x, set[x]);
} else if (!set[x].isEmpty()) { } else if (!set[x].isEmpty()) {
// eek! put it back! // eek! put it back!
@@ -282,11 +282,11 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
} }
if (drops.size() > 0) { if (drops.size() > 0) {
Platform.spawnDrops(p.world, new BlockPos((int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ()), drops); Platform.spawnDrops(p.world, new BlockPos((int) p.getX(), (int) p.getY(), (int) p.getPosZ()), drops);
} }
} }
ItemTransferable getPattern() { FixedItemInv getPattern() {
return this.pattern; return this.pattern;
} }
} }
@@ -20,11 +20,11 @@ package appeng.container.slot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class DisabledSlot extends AppEngSlot { public class DisabledSlot extends AppEngSlot {
public DisabledSlot(final ItemTransferable par1iInventory, final int slotIndex, final int x, final int y) { public DisabledSlot(final FixedItemInv par1iInventory, final int slotIndex, final int x, final int y) {
super(par1iInventory, slotIndex, x, y); super(par1iInventory, slotIndex, x, y);
} }
@@ -18,11 +18,11 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class FakeBlacklistSlot extends FakeTypeOnlySlot { public class FakeBlacklistSlot extends FakeTypeOnlySlot {
public FakeBlacklistSlot(final ItemTransferable inv, final int idx, final int x, final int y) { public FakeBlacklistSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
super(inv, idx, x, y); super(inv, idx, x, y);
} }
@@ -18,11 +18,11 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class FakeCraftingMatrixSlot extends FakeSlot { public class FakeCraftingMatrixSlot extends FakeSlot {
public FakeCraftingMatrixSlot(final ItemTransferable inv, final int idx, final int x, final int y) { public FakeCraftingMatrixSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
super(inv, idx, x, y); super(inv, idx, x, y);
} }
} }
@@ -18,13 +18,13 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class FakeSlot extends AppEngSlot { public class FakeSlot extends AppEngSlot {
public FakeSlot(final ItemTransferable inv, final int idx, final int x, final int y) { public FakeSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
super(inv, idx, x, y); super(inv, idx, x, y);
} }
@@ -18,12 +18,12 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class FakeTypeOnlySlot extends FakeSlot { public class FakeTypeOnlySlot extends FakeSlot {
public FakeTypeOnlySlot(final ItemTransferable inv, final int idx, final int x, final int y) { public FakeTypeOnlySlot(final FixedItemInv inv, final int idx, final int x, final int y) {
super(inv, idx, x, y); super(inv, idx, x, y);
} }
@@ -20,13 +20,13 @@ package appeng.container.slot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class InaccessibleSlot extends AppEngSlot { public class InaccessibleSlot extends AppEngSlot {
private ItemStack dspStack = ItemStack.EMPTY; private ItemStack dspStack = ItemStack.EMPTY;
public InaccessibleSlot(final ItemTransferable i, final int slotIdx, final int x, final int y) { public InaccessibleSlot(final FixedItemInv i, final int slotIdx, final int x, final int y) {
super(i, slotIdx, x, y); super(i, slotIdx, x, y);
} }
@@ -19,7 +19,7 @@
package appeng.container.slot; package appeng.container.slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.container.implementations.MolecularAssemblerContainer; import appeng.container.implementations.MolecularAssemblerContainer;
@@ -27,7 +27,7 @@ public class MolecularAssemblerPatternSlot extends AppEngSlot {
private final MolecularAssemblerContainer mac; private final MolecularAssemblerContainer mac;
public MolecularAssemblerPatternSlot(final MolecularAssemblerContainer mac, final ItemTransferable i, final int slotIdx, public MolecularAssemblerPatternSlot(final MolecularAssemblerContainer mac, final FixedItemInv i, final int slotIdx,
final int x, final int y) { final int x, final int y) {
super(i, slotIdx, x, y); super(i, slotIdx, x, y);
this.mac = mac; this.mac = mac;
@@ -18,11 +18,11 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class NormalSlot extends AppEngSlot { public class NormalSlot extends AppEngSlot {
public NormalSlot(final ItemTransferable inv, final int slot, final int xPos, final int yPos) { public NormalSlot(final FixedItemInv inv, final int slot, final int xPos, final int yPos) {
super(inv, slot, xPos, yPos); super(inv, slot, xPos, yPos);
} }
} }
@@ -21,7 +21,7 @@ package appeng.container.slot;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class OptionalFakeSlot extends FakeSlot implements IOptionalSlot { public class OptionalFakeSlot extends FakeSlot implements IOptionalSlot {
@@ -31,7 +31,7 @@ public class OptionalFakeSlot extends FakeSlot implements IOptionalSlot {
private final IOptionalSlotHost host; private final IOptionalSlotHost host;
private boolean renderDisabled = true; private boolean renderDisabled = true;
public OptionalFakeSlot(final ItemTransferable inv, final IOptionalSlotHost containerBus, final int idx, final int x, public OptionalFakeSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int idx, final int x,
final int y, final int offX, final int offY, final int groupNum) { final int y, final int offX, final int offY, final int groupNum) {
super(inv, idx, x + offX * 18, y + offY * 18); super(inv, idx, x + offX * 18, y + offY * 18);
this.srcX = x; this.srcX = x;
@@ -18,14 +18,14 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class OptionalNormalSlot extends AppEngSlot implements IOptionalSlot { public class OptionalNormalSlot extends AppEngSlot implements IOptionalSlot {
private final int groupNum; private final int groupNum;
private final IOptionalSlotHost host; private final IOptionalSlotHost host;
public OptionalNormalSlot(final ItemTransferable inv, final IOptionalSlotHost containerBus, final int slot, public OptionalNormalSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int slot,
final int xPos, final int yPos, final int groupNum) { final int xPos, final int yPos, final int groupNum) {
super(inv, slot, xPos, yPos); super(inv, slot, xPos, yPos);
this.groupNum = groupNum; this.groupNum = groupNum;
@@ -18,7 +18,7 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
public class OptionalRestrictedInputSlot extends RestrictedInputSlot { public class OptionalRestrictedInputSlot extends RestrictedInputSlot {
@@ -26,7 +26,7 @@ public class OptionalRestrictedInputSlot extends RestrictedInputSlot {
private final int groupNum; private final int groupNum;
private final IOptionalSlotHost host; private final IOptionalSlotHost host;
public OptionalRestrictedInputSlot(final PlacableItemType valid, final ItemTransferable i, final IOptionalSlotHost host, public OptionalRestrictedInputSlot(final PlacableItemType valid, final FixedItemInv i, final IOptionalSlotHost host,
final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) { final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) {
super(valid, i, slotIndex, x, y, invPlayer); super(valid, i, slotIndex, x, y, invPlayer);
this.groupNum = grpNum; this.groupNum = grpNum;
@@ -19,11 +19,11 @@
package appeng.container.slot; package appeng.container.slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class OptionalTypeOnlyFakeSlot extends OptionalFakeSlot { public class OptionalTypeOnlyFakeSlot extends OptionalFakeSlot {
public OptionalTypeOnlyFakeSlot(final ItemTransferable inv, final IOptionalSlotHost containerBus, final int idx, public OptionalTypeOnlyFakeSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int idx,
final int x, final int y, final int offX, final int offY, final int groupNum) { final int x, final int y, final int offX, final int offY, final int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum); super(inv, containerBus, idx, x, y, offX, offY, groupNum);
} }
@@ -19,11 +19,11 @@
package appeng.container.slot; package appeng.container.slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class OutputSlot extends AppEngSlot { public class OutputSlot extends AppEngSlot {
public OutputSlot(final ItemTransferable a, final int b, final int c, final int d, final int i) { public OutputSlot(final FixedItemInv a, final int b, final int c, final int d, final int i) {
super(a, b, c, d); super(a, b, c, d);
this.setIIcon(i); this.setIIcon(i);
} }
@@ -18,11 +18,11 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class PatternOutputsSlot extends OptionalFakeSlot { public class PatternOutputsSlot extends OptionalFakeSlot {
public PatternOutputsSlot(final ItemTransferable inv, final IOptionalSlotHost containerBus, final int idx, final int x, public PatternOutputsSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int idx, final int x,
final int y, final int offX, final int offY, final int groupNum) { final int y, final int offX, final int offY, final int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum); super(inv, containerBus, idx, x, y, offX, offY, groupNum);
} }
@@ -18,7 +18,7 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -37,8 +37,8 @@ public class PatternTermSlot extends CraftingTermSlot {
private final IOptionalSlotHost host; private final IOptionalSlotHost host;
public PatternTermSlot(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, public PatternTermSlot(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
final IStorageMonitorable storage, final ItemTransferable cMatrix, final ItemTransferable secondMatrix, final IStorageMonitorable storage, final FixedItemInv cMatrix, final FixedItemInv secondMatrix,
final ItemTransferable output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final FixedItemInv output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber,
final IContainerCraftingPacket c) { final IContainerCraftingPacket c) {
super(player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c); super(player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c);
@@ -18,11 +18,11 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
public class PlayerHotBarSlot extends AppEngSlot { public class PlayerHotBarSlot extends AppEngSlot {
public PlayerHotBarSlot(final ItemTransferable par1iInventory, final int par2, final int par3, final int par4) { public PlayerHotBarSlot(final FixedItemInv par1iInventory, final int par2, final int par3, final int par4) {
super(par1iInventory, par2, par3, par4); super(par1iInventory, par2, par3, par4);
this.setPlayerSide(true); this.setPlayerSide(true);
} }
@@ -18,13 +18,13 @@
package appeng.container.slot; package appeng.container.slot;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot. // there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
public class PlayerInvSlot extends AppEngSlot { public class PlayerInvSlot extends AppEngSlot {
public PlayerInvSlot(final ItemTransferable par1iInventory, final int idx, final int x, final int y) { public PlayerInvSlot(final FixedItemInv par1iInventory, final int idx, final int x, final int y) {
super(par1iInventory, idx, x, y); super(par1iInventory, idx, x, y);
this.setPlayerSide(true); this.setPlayerSide(true);
@@ -21,7 +21,7 @@ package appeng.container.slot;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -70,7 +70,7 @@ public class RestrictedInputSlot extends AppEngSlot {
private boolean allowEdit = true; private boolean allowEdit = true;
private int stackLimit = -1; private int stackLimit = -1;
public RestrictedInputSlot(final PlacableItemType valid, final ItemTransferable i, final int slotIndex, final int x, public RestrictedInputSlot(final PlacableItemType valid, final FixedItemInv i, final int slotIndex, final int x,
final int y, final PlayerInventory p) { final int y, final PlayerInventory p) {
super(i, slotIndex, x, y); super(i, slotIndex, x, y);
this.which = valid; this.which = valid;
@@ -233,7 +233,7 @@ public class RestrictedInputSlot extends AppEngSlot {
final ItemStack is = super.getStack(); final ItemStack is = super.getStack();
if (!is.isEmpty() && is.getItem() instanceof EncodedPatternItem) { if (!is.isEmpty() && is.getItem() instanceof EncodedPatternItem) {
final EncodedPatternItem iep = (EncodedPatternItem) is.getItem(); final EncodedPatternItem iep = (EncodedPatternItem) is.getItem();
final ItemStack out = iep.getOutput(is); final ItemStack out = iep.getOutput(p.player.world, is);
if (!out.isEmpty()) { if (!out.isEmpty()) {
return out; return out;
} }
+3 -3
View File
@@ -1,10 +1,10 @@
package appeng.core; package appeng.core;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.recipe.Recipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class AERecipeType<T extends IRecipe<?>> implements IRecipeType<T> { public class AERecipeType<T extends Recipe<?>> implements RecipeType<T> {
private final String id; private final String id;
public AERecipeType(Identifier registryName) { public AERecipeType(Identifier registryName) {
+2 -2
View File
@@ -32,7 +32,7 @@ import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.particles.ParticleType; import net.minecraft.particles.ParticleType;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -120,7 +120,7 @@ public final class AppEng {
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes); modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
modEventBus.addGenericListener(BlockEntityType.class, registration::registerTileEntities); modEventBus.addGenericListener(BlockEntityType.class, registration::registerTileEntities);
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes); modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers); modEventBus.addGenericListener(RecipeSerializer.class, registration::registerRecipeSerializers);
modEventBus.addGenericListener(Feature.class, registration::registerWorldGen); modEventBus.addGenericListener(Feature.class, registration::registerWorldGen);
modEventBus.addGenericListener(Biome.class, registration::registerBiomes); modEventBus.addGenericListener(Biome.class, registration::registerBiomes);
modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension); modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension);
@@ -37,8 +37,6 @@ import appeng.core.sync.BasePacket;
public abstract class CommonHelper { public abstract class CommonHelper {
public abstract World getWorld();
public abstract void bindTileEntitySpecialRenderer(Class<? extends BlockEntity> tile, AEBaseBlock blk); public abstract void bindTileEntitySpecialRenderer(Class<? extends BlockEntity> tile, AEBaseBlock blk);
public abstract List<? extends PlayerEntity> getPlayers(); public abstract List<? extends PlayerEntity> getPlayers();
+3 -3
View File
@@ -30,7 +30,7 @@ import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.particle.ParticleManager; import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.particles.ParticleType; import net.minecraft.particles.ParticleType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -309,8 +309,8 @@ final class Registration {
return type; return type;
} }
public void registerRecipeSerializers(RegistryEvent.Register<IRecipeSerializer<?>> event) { public void registerRecipeSerializers(RegistryEvent.Register<RecipeSerializer<?>> event) {
IForgeRegistry<IRecipeSerializer<?>> r = event.getRegistry(); IForgeRegistry<RecipeSerializer<?>> r = event.getRegistry();
GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName()); GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName());
InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName()); InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName());
@@ -24,6 +24,7 @@ import java.util.List;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import appeng.api.AEApi; import appeng.api.AEApi;
@@ -77,28 +78,28 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
} }
if (!this.isWirelessTerminal(item)) { if (!this.isWirelessTerminal(item)) {
player.sendMessage(PlayerMessages.DeviceNotWirelessTerminal.get()); player.sendSystemMessage(PlayerMessages.DeviceNotWirelessTerminal.get(), Util.NIL_UUID);
return; return;
} }
final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item); final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item); final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) { if (unparsedKey.isEmpty()) {
player.sendMessage(PlayerMessages.DeviceNotLinked.get()); player.sendSystemMessage(PlayerMessages.DeviceNotLinked.get(), Util.NIL_UUID);
return; return;
} }
final long parsedKey = Long.parseLong(unparsedKey); final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey); final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) { if (securityStation == null) {
player.sendMessage(PlayerMessages.StationCanNotBeLocated.get()); player.sendSystemMessage(PlayerMessages.StationCanNotBeLocated.get(), Util.NIL_UUID);
return; return;
} }
if (handler.hasPower(player, 0.5, item)) { if (handler.hasPower(player, 0.5, item)) {
ContainerOpener.openContainer(WirelessTermContainer.TYPE, player, ContainerLocator.forHand(player, hand)); ContainerOpener.openContainer(WirelessTermContainer.TYPE, player, ContainerLocator.forHand(player, hand));
} else { } else {
player.sendMessage(PlayerMessages.DeviceNotPowered.get()); player.sendSystemMessage(PlayerMessages.DeviceNotPowered.get(), Util.NIL_UUID);
} }
} }
} }
@@ -72,8 +72,6 @@ public class ItemTransitionEffectPacket extends BasePacket {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
final World world = AppEng.proxy.getWorld();
EnergyParticleData data = new EnergyParticleData(true, this.d); EnergyParticleData data = new EnergyParticleData(true, this.d);
for (int zz = 0; zz < 8; zz++) { for (int zz = 0; zz < 8; zz++) {
if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) { if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) {
@@ -18,7 +18,7 @@
package appeng.core.sync.packets; package appeng.core.sync.packets;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -47,7 +47,7 @@ import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ViewCellItem; import appeng.items.storage.ViewCellItem;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.WrapperInvItemHandler; import appeng.util.inv.WrapperInvItemHandler;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.prioritylist.IPartitionList; import appeng.util.prioritylist.IPartitionList;
@@ -65,7 +65,7 @@ public class JEIRecipePacket extends BasePacket {
if (list.size() > 0) { if (list.size() > 0) {
this.recipe[x] = new ItemStack[list.size()]; this.recipe[x] = new ItemStack[list.size()];
for (int y = 0; y < list.size(); y++) { for (int y = 0; y < list.size(); y++) {
this.recipe[x][y] = ItemStack.read(list.getCompound(y)); this.recipe[x][y] = ItemStack.fromTag(list.getCompound(y));
} }
} }
} }
@@ -108,16 +108,16 @@ public class JEIRecipePacket extends BasePacket {
final IEnergyGrid energy = grid.getCache(IEnergyGrid.class); final IEnergyGrid energy = grid.getCache(IEnergyGrid.class);
final ISecurityGrid security = grid.getCache(ISecurityGrid.class); final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class); final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class);
final ItemTransferable craftMatrix = cct.getInventoryByName("crafting"); final FixedItemInv craftMatrix = cct.getInventoryByName("crafting");
final ItemTransferable playerInventory = cct.getInventoryByName("player"); final FixedItemInv playerInventory = cct.getInventoryByName("player");
if (inv != null && this.recipe != null && security != null) { if (inv != null && this.recipe != null && security != null) {
final IMEMonitor<IAEItemStack> storage = inv final IMEMonitor<IAEItemStack> storage = inv
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IPartitionList<IAEItemStack> filter = ViewCellItem.createFilter(cct.getViewCells()); final IPartitionList<IAEItemStack> filter = ViewCellItem.createFilter(cct.getViewCells());
for (int x = 0; x < craftMatrix.getSlots(); x++) { for (int x = 0; x < craftMatrix.getSlotCount(); x++) {
ItemStack currentItem = craftMatrix.getStackInSlot(x); ItemStack currentItem = craftMatrix.getInvStack(x);
// prepare slots // prepare slots
if (!currentItem.isEmpty()) { if (!currentItem.isEmpty()) {
@@ -168,7 +168,7 @@ public class JEIRecipePacket extends BasePacket {
// try inventory // try inventory
if (currentItem.isEmpty()) { if (currentItem.isEmpty()) {
AdaptorItemHandler ad = new AdaptorItemHandler(playerInventory); AdaptorFixedInv ad = new AdaptorFixedInv(playerInventory);
if (cct.useRealItems()) { if (cct.useRealItems()) {
currentItem = ad.removeItems(1, this.recipe[x][y], null); currentItem = ad.removeItems(1, this.recipe[x][y], null);
@@ -62,7 +62,6 @@ public class MockExplosionPacket extends BasePacket {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
final World world = AppEng.proxy.getWorld(); player.world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
} }
} }
@@ -18,7 +18,7 @@
package appeng.core.sync.packets; package appeng.core.sync.packets;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -63,7 +63,7 @@ public class PatternSlotPacket extends BasePacket {
} }
// api // api
public PatternSlotPacket(final ItemTransferable pat, final IAEItemStack slotItem, final boolean shift) { public PatternSlotPacket(final FixedItemInv pat, final IAEItemStack slotItem, final boolean shift) {
this.slotItem = slotItem; this.slotItem = slotItem;
this.shift = shift; this.shift = shift;
@@ -77,7 +77,7 @@ public class PatternSlotPacket extends BasePacket {
this.writeItem(slotItem, data); this.writeItem(slotItem, data);
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
this.pattern[x] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) this.pattern[x] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(pat.getStackInSlot(x)); .createStack(pat.getInvStack(x));
this.writeItem(this.pattern[x], data); this.writeItem(this.pattern[x], data);
} }
@@ -22,6 +22,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import appeng.util.FakePlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -68,15 +70,15 @@ public class CraftingTreeProcess {
final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3); final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3);
final IAEItemStack[] is = details.getInputs(); final IAEItemStack[] is = details.getInputs();
for (int x = 0; x < ic.getSizeInventory(); x++) { for (int x = 0; x < ic.size(); x++) {
ic.setInventorySlotContents(x, is[x] == null ? ItemStack.EMPTY : is[x].createItemStack()); ic.setStack(x, is[x] == null ? ItemStack.EMPTY : is[x].createItemStack());
} }
BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) world), BasicEventHooks.firePlayerCraftingEvent((PlayerEntity) FakePlayer.getOrCreate((ServerWorld) world),
details.getOutput(ic, world), ic); details.getOutput(ic, world), ic);
for (int x = 0; x < ic.getSizeInventory(); x++) { for (int x = 0; x < ic.size(); x++) {
final ItemStack g = ic.getStackInSlot(x); final ItemStack g = ic.getStack(x);
if (!g.isEmpty() && g.getCount() > 1) { if (!g.isEmpty() && g.getCount() > 1) {
this.fullSimulation = true; this.fullSimulation = true;
} }
@@ -96,7 +98,7 @@ public class CraftingTreeProcess {
this.limitQty = true; this.limitQty = true;
} }
if (g.getItem().hasContainerItem(g)) { if (g.getItem().hasRecipeRemainder(g)) {
this.limitQty = this.containerItems = true; this.limitQty = this.containerItems = true;
} }
} }
@@ -170,15 +172,15 @@ public class CraftingTreeProcess {
final IAEItemStack item = entry.getKey().getStack(entry.getValue()); final IAEItemStack item = entry.getKey().getStack(entry.getValue());
final IAEItemStack stack = entry.getKey().request(inv, item.getStackSize(), src); final IAEItemStack stack = entry.getKey().request(inv, item.getStackSize(), src);
ic.setInventorySlotContents(entry.getKey().getSlot(), stack.createItemStack()); ic.setStack(entry.getKey().getSlot(), stack.createItemStack());
} }
BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) this.world), BasicEventHooks.firePlayerCraftingEvent((PlayerEntity) FakePlayer.getOrCreate((ServerWorld) this.world),
this.details.getOutput(ic, this.world), ic); this.details.getOutput(ic, this.world), ic);
for (int x = 0; x < ic.getSizeInventory(); x++) { for (int x = 0; x < ic.size(); x++) {
ItemStack is = ic.getStackInSlot(x); ItemStack is = ic.getStack(x);
is = Platform.getContainerItem(is); is = Platform.getRecipeRemainder(is);
final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(is); .createStack(is);
@@ -194,7 +196,7 @@ public class CraftingTreeProcess {
final IAEItemStack stack = entry.getKey().request(inv, item.getStackSize() * i, src); final IAEItemStack stack = entry.getKey().request(inv, item.getStackSize() * i, src);
if (this.containerItems) { if (this.containerItems) {
final ItemStack is = Platform.getContainerItem(stack.createItemStack()); final ItemStack is = Platform.getRecipeRemainder(stack.createItemStack());
final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(is); .createStack(is);
if (o != null) { if (o != null) {
@@ -51,7 +51,7 @@ public class CubeGeneratorBlockEntity extends AEBaseBlockEntity implements ITick
if (this.countdown % 20 == 0) { if (this.countdown % 20 == 0) {
for (final PlayerEntity e : AppEng.proxy.getPlayers()) { for (final PlayerEntity e : AppEng.proxy.getPlayers()) {
e.sendMessage(new LiteralText("Spawning in... " + (this.countdown / 20))); e.sendSystemMessage(new LiteralText("Spawning in... " + (this.countdown / 20)), Util.NIL_UUID);
} }
} }
@@ -102,7 +102,7 @@ public class CubeGeneratorBlockEntity extends AEBaseBlockEntity implements ITick
this.size = 64; this.size = 64;
} }
player.sendMessage(new LiteralText("Size: " + this.size)); player.sendSystemMessage(new LiteralText("Size: " + this.size), Util.NIL_UUID);
} else { } else {
this.countdown = 20 * 10; this.countdown = 20 * 10;
this.is = hand; this.is = hand;
@@ -49,19 +49,19 @@ public class DebugPartPlacerItem extends AEBaseItem {
} }
if (!player.abilities.isCreativeMode) { if (!player.abilities.isCreativeMode) {
player.sendMessage(new LiteralText("Only usable in creative mode")); player.sendSystemMessage(new LiteralText("Only usable in creative mode"), Util.NIL_UUID);
return ActionResult.FAIL; return ActionResult.FAIL;
} }
BlockEntity te = world.getBlockEntity(pos); BlockEntity te = world.getBlockEntity(pos);
if (!(te instanceof IPartHost)) { if (!(te instanceof IPartHost)) {
player.sendMessage(new LiteralText("Right-click something that will accept parts")); player.sendSystemMessage(new LiteralText("Right-click something that will accept parts"), Util.NIL_UUID);
return ActionResult.FAIL; return ActionResult.FAIL;
} }
IPartHost center = (IPartHost) te; IPartHost center = (IPartHost) te;
IPart cable = center.getPart(AEPartLocation.INTERNAL); IPart cable = center.getPart(AEPartLocation.INTERNAL);
if (cable == null) { if (cable == null) {
player.sendMessage(new LiteralText("Clicked part host must have an INSIDE part")); player.sendSystemMessage(new LiteralText("Clicked part host must have an INSIDE part"), Util.NIL_UUID);
return ActionResult.FAIL; return ActionResult.FAIL;
} }
@@ -24,7 +24,7 @@ import java.util.Queue;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -42,7 +42,7 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity {
private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>(); private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>();
private final ItemTransferable handler = new QueuedItemHandler(); private final FixedItemInv handler = new QueuedItemHandler();
public ItemGenBlockEntity(BlockEntityType<?> tileEntityTypeIn) { public ItemGenBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn); super(tileEntityTypeIn);
@@ -81,7 +81,7 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity {
return super.getCapability(capability, facing); return super.getCapability(capability, facing);
} }
class QueuedItemHandler implements ItemTransferable { class QueuedItemHandler implements FixedItemInv {
@Override @Override
@Nonnull @Nonnull
@@ -69,7 +69,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
CraterType craterType = CraterType.values()[tag.getByte(MODE_TAG)]; CraterType craterType = CraterType.values()[tag.getByte(MODE_TAG)];
player.sendMessage(new LiteralText(craterType.name())); player.sendSystemMessage(new LiteralText(craterType.name()), Util.NIL_UUID);
return TypedActionResult.resultSuccess(itemStack); return TypedActionResult.resultSuccess(itemStack);
} }
@@ -22,7 +22,7 @@ import java.util.List;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.IPacket; import net.minecraft.network.IPacket;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
@@ -39,14 +39,14 @@ public abstract class AEBaseItemEntity extends ItemEntity {
final double y, final double z, final ItemStack stack) { final double y, final double z, final ItemStack stack) {
this(entityType, world); this(entityType, world);
this.setPosition(x, y, z); this.setPosition(x, y, z);
this.rotationYaw = this.rand.nextFloat() * 360.0F; this.yaw = this.rand.nextFloat() * 360.0F;
this.setMotion(this.rand.nextDouble() * 0.2D - 0.1D, 0.2D, this.rand.nextDouble() * 0.2D - 0.1D); this.setMotion(this.rand.nextDouble() * 0.2D - 0.1D, 0.2D, this.rand.nextDouble() * 0.2D - 0.1D);
this.setItem(stack); this.setItem(stack);
this.lifespan = stack.getEntityLifespan(world); this.lifespan = stack.getEntityLifespan(world);
} }
protected List<Entity> getCheckedEntitiesWithinAABBExcludingEntity(final Box region) { protected List<Entity> getCheckedEntitiesWithinAABBExcludingEntity(final Box region) {
return this.world.getEntitiesWithinAABBExcludingEntity(this, region); return this.world.getEntities(this, region);
} }
@Override @Override
@@ -24,7 +24,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
@@ -64,7 +64,7 @@ public final class ChargedQuartzEntity extends AEBaseItemEntity {
} }
if (world.isClient && this.delay > 30 && AEConfig.instance().isEnableEffects()) { if (world.isClient && this.delay > 30 && AEConfig.instance().isEnableEffects()) {
AppEng.proxy.spawnEffect(EffectType.Lightning, this.world, this.getPosX(), this.getPosY(), this.getPosZ(), AppEng.proxy.spawnEffect(EffectType.Lightning, this.world, this.getX(), this.getY(), this.getZ(),
null); null);
this.delay = 0; this.delay = 0;
} }
@@ -95,8 +95,8 @@ public final class ChargedQuartzEntity extends AEBaseItemEntity {
final IMaterials materials = AEApi.instance().definitions().materials(); final IMaterials materials = AEApi.instance().definitions().materials();
if (materials.certusQuartzCrystalCharged().isSameAs(item)) { if (materials.certusQuartzCrystalCharged().isSameAs(item)) {
final Box region = new Box(this.getPosX() - 1, this.getPosY() - 1, this.getPosZ() - 1, final Box region = new Box(this.getX() - 1, this.getY() - 1, this.getZ() - 1,
this.getPosX() + 1, this.getPosY() + 1, this.getPosZ() + 1); this.getX() + 1, this.getY() + 1, this.getZ() + 1);
final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity(region); final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity(region);
ItemEntity redstone = null; ItemEntity redstone = null;
@@ -135,10 +135,10 @@ public final class ChargedQuartzEntity extends AEBaseItemEntity {
} }
materials.fluixCrystal().maybeStack(2).ifPresent(is -> { materials.fluixCrystal().maybeStack(2).ifPresent(is -> {
final ItemEntity entity = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), final ItemEntity entity = new ItemEntity(this.world, this.getX(), this.getY(), this.getZ(),
is); is);
this.world.addEntity(entity); this.world.spawnEntity(entity);
}); });
return true; return true;
@@ -117,8 +117,8 @@ public final class GrowingCrystalEntity extends AEBaseItemEntity {
if (this.progress_1000 >= len) { if (this.progress_1000 >= len) {
this.progress_1000 = 0; this.progress_1000 = 0;
AppEng.proxy.spawnEffect(EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2, AppEng.proxy.spawnEffect(EffectType.Vibrant, this.world, this.getX(), this.getY() + 0.2,
this.getPosZ(), null); this.getZ(), null);
} }
} else { } else {
if (this.progress_1000 > 1000) { if (this.progress_1000 > 1000) {
@@ -23,7 +23,7 @@ import java.util.List;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
@@ -74,8 +74,8 @@ public final class SingularityEntity extends AEBaseItemEntity {
final IMaterials materials = AEApi.instance().definitions().materials(); final IMaterials materials = AEApi.instance().definitions().materials();
if (materials.singularity().isSameAs(item)) { if (materials.singularity().isSameAs(item)) {
final Box region = new Box(this.getPosX() - 4, this.getPosY() - 4, this.getPosZ() - 4, final Box region = new Box(this.getX() - 4, this.getY() - 4, this.getZ() - 4,
this.getPosX() + 4, this.getPosY() + 4, this.getPosZ() + 4); this.getX() + 4, this.getY() + 4, this.getZ() + 4);
final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity(region); final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity(region);
for (final Entity e : l) { for (final Entity e : l) {
@@ -86,7 +86,7 @@ public final class SingularityEntity extends AEBaseItemEntity {
if (matches) { if (matches) {
while (item.getCount() > 0 && other.getCount() > 0) { while (item.getCount() > 0 && other.getCount() > 0) {
other.grow(-1); other.increment(-1);
; ;
if (other.getCount() == 0) { if (other.getCount() == 0) {
e.remove(); e.remove();
@@ -96,11 +96,11 @@ public final class SingularityEntity extends AEBaseItemEntity {
final CompoundTag cmp = singularityStack.getOrCreateTag(); final CompoundTag cmp = singularityStack.getOrCreateTag();
cmp.putLong("freq", (new Date()).getTime() * 100 + (randTickSeed) % 100); cmp.putLong("freq", (new Date()).getTime() * 100 + (randTickSeed) % 100);
randTickSeed++; randTickSeed++;
item.grow(-1); item.increment(-1);
final SingularityEntity entity = new SingularityEntity(this.world, this.getPosX(), final SingularityEntity entity = new SingularityEntity(this.world, this.getX(),
this.getPosY(), this.getPosZ(), singularityStack); this.getY(), this.getZ(), singularityStack);
this.world.addEntity(entity); this.world.spawnEntity(entity);
}); });
} }
@@ -27,7 +27,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MoverType; import net.minecraft.entity.MoverType;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.item.TNTEntity; import net.minecraft.entity.item.TNTEntity;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.particles.ParticleTypes; import net.minecraft.particles.ParticleTypes;
@@ -69,9 +69,9 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
public void tick() { public void tick() {
this.handleWaterMovement(); this.handleWaterMovement();
this.prevPosX = this.getPosX(); this.prevX = this.getX();
this.prevPosY = this.getPosY(); this.prevY = this.getY();
this.prevPosZ = this.getPosZ(); this.prevZ = this.getZ();
this.setMotion(this.getMotion().subtract(0, 0.03999999910593033D, 0)); this.setMotion(this.getMotion().subtract(0, 0.03999999910593033D, 0));
this.move(MoverType.SELF, this.getMotion()); this.move(MoverType.SELF, this.getMotion());
this.setMotion(this.getMotion().mul(0.9800000190734863D, 0.9800000190734863D, 0.9800000190734863D)); this.setMotion(this.getMotion().mul(0.9800000190734863D, 0.9800000190734863D, 0.9800000190734863D));
@@ -83,15 +83,15 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
if (this.isInWater() && Platform.isServer()) // put out the fuse. if (this.isInWater() && Platform.isServer()) // put out the fuse.
{ {
AEApi.instance().definitions().blocks().tinyTNT().maybeStack(1).ifPresent(tntStack -> { AEApi.instance().definitions().blocks().tinyTNT().maybeStack(1).ifPresent(tntStack -> {
final ItemEntity item = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), final ItemEntity item = new ItemEntity(this.world, this.getX(), this.getY(), this.getZ(),
tntStack); tntStack);
item.setMotion(this.getMotion()); item.setMotion(this.getMotion());
item.prevPosX = this.prevPosX; item.prevX = this.prevX;
item.prevPosY = this.prevPosY; item.prevY = this.prevY;
item.prevPosZ = this.prevPosZ; item.prevZ = this.prevZ;
this.world.addEntity(item); this.world.spawnEntity(item);
this.remove(); this.remove();
}); });
} }
@@ -103,7 +103,7 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
this.explode(); this.explode();
} }
} else { } else {
this.world.addParticle(ParticleTypes.SMOKE, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, this.world.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D,
0.0D); 0.0D);
} }
this.setFuse(this.getFuse() - 1); this.setFuse(this.getFuse() - 1);
@@ -112,7 +112,7 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
// override :P // override :P
@Override @Override
protected void explode() { protected void explode() {
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, this.world.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE,
SoundCategory.BLOCKS, 4.0F, SoundCategory.BLOCKS, 4.0F,
(1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 32.9F); (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 32.9F);
@@ -120,11 +120,11 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
return; return;
} }
final Explosion ex = new Explosion(this.world, this, this.getPosX(), this.getPosY(), this.getPosZ(), 0.2f, final Explosion ex = new Explosion(this.world, this, this.getX(), this.getY(), this.getZ(), 0.2f,
false, Mode.BREAK); false, Mode.BREAK);
final Box area = new Box(this.getPosX() - 1.5, this.getPosY() - 1.5f, this.getPosZ() - 1.5, final Box area = new Box(this.getX() - 1.5, this.getY() - 1.5f, this.getZ() - 1.5,
this.getPosX() + 1.5, this.getPosY() + 1.5, this.getPosZ() + 1.5); this.getX() + 1.5, this.getY() + 1.5, this.getZ() + 1.5);
final List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, area); final List<Entity> list = this.world.getEntities(this, area);
net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, ex, list, 0.2f * 2d); net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, ex, list, 0.2f * 2d);
@@ -133,11 +133,11 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
} }
if (AEConfig.instance().isFeatureEnabled(AEFeature.TINY_TNT_BLOCK_DAMAGE)) { if (AEConfig.instance().isFeatureEnabled(AEFeature.TINY_TNT_BLOCK_DAMAGE)) {
this.setPosition(this.getPosX(), this.getPosY() - 0.25, this.getPosZ()); this.setPosition(this.getX(), this.getY() - 0.25, this.getPosZ());
for (int x = (int) (this.getPosX() - 2); x <= this.getPosX() + 2; x++) { for (int x = (int) (this.getX() - 2); x <= this.getX() + 2; x++) {
for (int y = (int) (this.getPosY() - 2); y <= this.getPosY() + 2; y++) { for (int y = (int) (this.getY() - 2); y <= this.getY() + 2; y++) {
for (int z = (int) (this.getPosZ() - 2); z <= this.getPosZ() + 2; z++) { for (int z = (int) (this.getZ() - 2); z <= this.getZ() + 2; z++) {
final BlockPos point = new BlockPos(x, y, z); final BlockPos point = new BlockPos(x, y, z);
final BlockState state = this.world.getBlockState(point); final BlockState state = this.world.getBlockState(point);
final Block block = state.getBlock(); final Block block = state.getBlock();
@@ -166,8 +166,8 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
} }
} }
AppEng.proxy.sendToAllNearExcept(null, this.getPosX(), this.getPosY(), this.getPosZ(), 64, this.world, AppEng.proxy.sendToAllNearExcept(null, this.getX(), this.getY(), this.getZ(), 64, this.world,
new MockExplosionPacket(this.getPosX(), this.getPosY(), this.getPosZ())); new MockExplosionPacket(this.getX(), this.getY(), this.getPosZ()));
} }
@Override @Override
@@ -91,7 +91,7 @@ public class FacadeContainer implements IFacadeContainer {
for (int x = 0; x < this.facades; x++) { for (int x = 0; x < this.facades; x++) {
if (this.storage.getFacade(x) != null) { if (this.storage.getFacade(x) != null) {
final CompoundTag data = new CompoundTag(); final CompoundTag data = new CompoundTag();
this.storage.getFacade(x).getItemStack().write(data); this.storage.getFacade(x).getItemStack().toTag(data);
c.put("facade:" + x, data); c.put("facade:" + x, data);
} }
} }
@@ -135,7 +135,7 @@ public class FacadeContainer implements IFacadeContainer {
final CompoundTag t = c.getCompound("facade:" + x); final CompoundTag t = c.getCompound("facade:" + x);
if (t != null) { if (t != null) {
final ItemStack is = ItemStack.read(t); final ItemStack is = ItemStack.fromTag(t);
if (!is.isEmpty()) { if (!is.isEmpty()) {
final net.minecraft.item.Item i = is.getItem(); final net.minecraft.item.Item i = is.getItem();
if (i instanceof IFacadeItem) { if (i instanceof IFacadeItem) {
@@ -1,7 +1,7 @@
package appeng.fluids.container; package appeng.fluids.container;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -50,7 +50,7 @@ public class FluidFormationPlaneContainer extends FluidConfigurableContainer {
@Override @Override
protected void setupConfig() { protected void setupConfig() {
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
@@ -24,7 +24,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
@@ -86,7 +86,7 @@ public class FluidStorageBusContainer extends FluidConfigurableContainer {
@Override @Override
protected void setupConfig() { protected void setupConfig() {
final ItemTransferable upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final FixedItemInv upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
this.getPlayerInventory())).setNotDraggable()); this.getPlayerInventory())).setNotDraggable());
this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.addSlot((new RestrictedInputSlot(RestrictedInputSlot.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
@@ -20,7 +20,7 @@ package appeng.fluids.helper;
import java.util.Optional; import java.util.Optional;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -491,7 +491,7 @@ public class DualityFluidInterface
} }
@Override @Override
public ItemTransferable getInventoryByName(String name) { public FixedItemInv getInventoryByName(String name) {
return null; return null;
} }
@@ -20,7 +20,7 @@ package appeng.fluids.items;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
@@ -88,7 +88,7 @@ public final class BasicFluidStorageCell extends AbstractStorageCell<IAEFluidSta
} }
@Override @Override
public ItemTransferable getConfigInventory(final ItemStack is) { public FixedItemInv getConfigInventory(final ItemStack is) {
return new FluidCellConfig(is); return new FluidCellConfig(is);
} }
@@ -31,7 +31,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
@@ -200,7 +200,7 @@ public class FluidInterfacePart extends BasicStatePart
} }
@Override @Override
public ItemTransferable getInventoryByName(String name) { public FixedItemInv getInventoryByName(String name) {
return this.duality.getInventoryByName(name); return this.duality.getInventoryByName(name);
} }
@@ -22,7 +22,7 @@ import java.util.EnumSet;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -153,7 +153,7 @@ public class FluidInterfaceBlockEntity extends AENetworkBlockEntity
} }
@Override @Override
public ItemTransferable getInventoryByName(String name) { public FixedItemInv getInventoryByName(String name) {
return this.duality.getInventoryByName(name); return this.duality.getInventoryByName(name);
} }
@@ -10,7 +10,7 @@ import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider; import net.minecraft.data.RecipeProvider;
import net.minecraft.data.ShapedRecipeBuilder; import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.data.SingleItemRecipeBuilder; import net.minecraft.data.SingleItemRecipeBuilder;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.recipe.Ingredient;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.common.crafting.ConditionalRecipe;
@@ -28,7 +28,7 @@ import java.util.Optional;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@@ -106,7 +106,7 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.IInventoryDestination; import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
@@ -169,7 +169,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
@Override @Override
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc, public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
final ItemStack removed, final ItemStack added) { final ItemStack removed, final ItemStack added) {
if (this.isWorking == slot) { if (this.isWorking == slot) {
return; return;
@@ -213,7 +213,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if (this.waitingToSend != null) { if (this.waitingToSend != null) {
for (final ItemStack is : this.waitingToSend) { for (final ItemStack is : this.waitingToSend) {
final CompoundTag item = new CompoundTag(); final CompoundTag item = new CompoundTag();
is.write(item); is.toTag(item);
waitingToSend.add(item); waitingToSend.add(item);
} }
} }
@@ -227,7 +227,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for (int x = 0; x < waitingList.size(); x++) { for (int x = 0; x < waitingList.size(); x++) {
final CompoundTag c = waitingList.getCompound(x); final CompoundTag c = waitingList.getCompound(x);
if (c != null) { if (c != null) {
final ItemStack is = ItemStack.read(c); final ItemStack is = ItemStack.fromTag(c);
this.addToSendList(is); this.addToSendList(is);
} }
} }
@@ -445,11 +445,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
// return after.stackSize != stack.stackSize; // return after.stackSize != stack.stackSize;
} }
public ItemTransferable getConfig() { public FixedItemInv getConfig() {
return this.config; return this.config;
} }
public ItemTransferable getPatterns() { public FixedItemInv getPatterns() {
return this.patterns; return this.patterns;
} }
@@ -475,7 +475,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return new DimensionalCoord(this.iHost.getBlockEntity()); return new DimensionalCoord(this.iHost.getBlockEntity());
} }
public ItemTransferable getInternalInventory() { public FixedItemInv getInternalInventory() {
return this.storage; return this.storage;
} }
@@ -631,7 +631,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
private InventoryAdaptor getAdaptor(final int slot) { private InventoryAdaptor getAdaptor(final int slot) {
return new AdaptorItemHandler(new RangedWrapper(this.storage, slot, slot + 1)); return new AdaptorFixedInv(new RangedWrapper(this.storage, slot, slot + 1));
} }
private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) { private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) {
@@ -685,7 +685,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
@Override @Override
public ItemTransferable getInventoryByName(final String name) { public FixedItemInv getInventoryByName(final String name) {
if (name.equals("storage")) { if (name.equals("storage")) {
return this.storage; return this.storage;
} }
@@ -705,7 +705,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return null; return null;
} }
public ItemTransferable getStorage() { public FixedItemInv getStorage() {
return this.storage; return this.storage;
} }
@@ -786,8 +786,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
if (this.acceptsItems(ad, table)) { if (this.acceptsItems(ad, table)) {
for (int x = 0; x < table.getSizeInventory(); x++) { for (int x = 0; x < table.size(); x++) {
final ItemStack is = table.getStackInSlot(x); final ItemStack is = table.getStack(x);
if (!is.isEmpty()) { if (!is.isEmpty()) {
final ItemStack added = ad.addItems(is); final ItemStack added = ad.addItems(is);
this.addToSendList(added); this.addToSendList(added);
@@ -844,8 +844,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
private boolean acceptsItems(final InventoryAdaptor ad, final CraftingInventory table) { private boolean acceptsItems(final InventoryAdaptor ad, final CraftingInventory table) {
for (int x = 0; x < table.getSizeInventory(); x++) { for (int x = 0; x < table.size(); x++) {
final ItemStack is = table.getStackInSlot(x); final ItemStack is = table.getStack(x);
if (is.isEmpty()) { if (is.isEmpty()) {
continue; continue;
} }
@@ -1077,7 +1077,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private class InterfaceInventory extends MEMonitorIInventory { private class InterfaceInventory extends MEMonitorIInventory {
public InterfaceInventory(final DualityInterface tileInterface) { public InterfaceInventory(final DualityInterface tileInterface) {
super(new AdaptorItemHandler(tileInterface.storage)); super(new AdaptorFixedInv(tileInterface.storage));
this.setActionSource(new MachineSource(DualityInterface.this.iHost)); this.setActionSource(new MachineSource(DualityInterface.this.iHost));
} }
@@ -18,7 +18,7 @@
package appeng.helpers; package appeng.helpers;
import alexiil.mc.lib.attributes.item.ItemTransferable; import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@@ -36,7 +36,7 @@ public interface IContainerCraftingPacket {
* *
* @return the inventory of the part/tile by name. * @return the inventory of the part/tile by name.
*/ */
ItemTransferable getInventoryByName(String string); FixedItemInv getInventoryByName(String string);
/** /**
* @return who are we? * @return who are we?
@@ -26,7 +26,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.Formatting;
import appeng.util.Platform; import appeng.util.Platform;
@@ -90,7 +90,7 @@ public class InvalidPatternHelper {
private ItemStack stack; private ItemStack stack;
public PatternIngredient(CompoundTag tag) { public PatternIngredient(CompoundTag tag) {
this.stack = ItemStack.read(tag); this.stack = ItemStack.fromTag(tag);
if (this.stack.isEmpty()) { if (this.stack.isEmpty()) {
this.id = tag.getString("id"); this.id = tag.getString("id");
@@ -128,7 +128,7 @@ public class InvalidPatternHelper {
Text result = new LiteralText(this.getCount() + " ").append(this.getName()); Text result = new LiteralText(this.getCount() + " ").append(this.getName());
if (!this.isValid()) { if (!this.isValid()) {
result.applyTextStyle(TextFormatting.RED); result.formatted(Formatting.RED);
} }
return result; return result;
+15 -15
View File
@@ -29,7 +29,7 @@ import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -80,27 +80,27 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
for (int x = 0; x < inTag.size(); x++) { for (int x = 0; x < inTag.size(); x++) {
CompoundTag ingredient = inTag.getCompound(x); CompoundTag ingredient = inTag.getCompound(x);
final ItemStack gs = ItemStack.read(ingredient); final ItemStack gs = ItemStack.fromTag(ingredient);
if (!ingredient.isEmpty() && gs.isEmpty()) { if (!ingredient.isEmpty() && gs.isEmpty()) {
throw new IllegalArgumentException("No pattern here!"); throw new IllegalArgumentException("No pattern here!");
} }
this.crafting.setInventorySlotContents(x, gs); this.crafting.setStack(x, gs);
if (!gs.isEmpty() && (!this.isCrafting || !gs.hasTag())) { if (!gs.isEmpty() && (!this.isCrafting || !gs.hasTag())) {
this.markItemAs(x, gs, TestStatus.ACCEPT); this.markItemAs(x, gs, TestStatus.ACCEPT);
} }
in.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs)); in.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs));
this.testFrame.setInventorySlotContents(x, gs); this.testFrame.setStack(x, gs);
} }
if (this.isCrafting) { if (this.isCrafting) {
this.standardRecipe = w.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, w).orElse(null); this.standardRecipe = w.getRecipeManager().getRecipe(RecipeType.CRAFTING, this.crafting, w).orElse(null);
if (this.standardRecipe != null) { if (this.standardRecipe != null) {
this.correctOutput = this.standardRecipe.getCraftingResult(this.crafting); this.correctOutput = this.standardRecipe.craft(this.crafting);
out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(this.correctOutput)); .createStack(this.correctOutput));
} else { } else {
@@ -112,7 +112,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
for (int x = 0; x < outTag.size(); x++) { for (int x = 0; x < outTag.size(); x++) {
CompoundTag resultItemTag = outTag.getCompound(x); CompoundTag resultItemTag = outTag.getCompound(x);
final ItemStack gs = ItemStack.read(resultItemTag); final ItemStack gs = ItemStack.fromTag(resultItemTag);
if (!resultItemTag.isEmpty() && gs.isEmpty()) { if (!resultItemTag.isEmpty() && gs.isEmpty()) {
throw new IllegalArgumentException("No pattern here!"); throw new IllegalArgumentException("No pattern here!");
@@ -211,11 +211,11 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
break; break;
} }
for (int x = 0; x < this.crafting.getSizeInventory(); x++) { for (int x = 0; x < this.crafting.size(); x++) {
this.testFrame.setInventorySlotContents(x, this.crafting.getStackInSlot(x)); this.testFrame.setStack(x, this.crafting.getStack(x));
} }
this.testFrame.setInventorySlotContents(slotIndex, i); this.testFrame.setStack(slotIndex, i);
// If we cannot substitute, the items must match exactly // If we cannot substitute, the items must match exactly
if (!canSubstitute && slotIndex < inputs.length) { if (!canSubstitute && slotIndex < inputs.length) {
@@ -226,10 +226,10 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
} }
if (this.standardRecipe.matches(this.testFrame, w)) { if (this.standardRecipe.matches(this.testFrame, w)) {
final ItemStack testOutput = this.standardRecipe.getCraftingResult(this.testFrame); final ItemStack testOutput = this.standardRecipe.craft(this.testFrame);
if (Platform.itemComparisons().isSameItem(this.correctOutput, testOutput)) { if (Platform.itemComparisons().isSameItem(this.correctOutput, testOutput)) {
this.testFrame.setInventorySlotContents(slotIndex, this.crafting.getStackInSlot(slotIndex)); this.testFrame.setStack(slotIndex, this.crafting.getStack(slotIndex));
this.markItemAs(slotIndex, i, TestStatus.ACCEPT); this.markItemAs(slotIndex, i, TestStatus.ACCEPT);
return true; return true;
} }
@@ -275,8 +275,8 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
throw new IllegalStateException("Only crafting recipes supported."); throw new IllegalStateException("Only crafting recipes supported.");
} }
for (int x = 0; x < craftingInv.getSizeInventory(); x++) { for (int x = 0; x < craftingInv.size(); x++) {
if (!this.isValidItemForSlot(x, craftingInv.getStackInSlot(x), w)) { if (!this.isValidItemForSlot(x, craftingInv.getStack(x), w)) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }
@@ -289,7 +289,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
} }
private TestStatus getStatus(final int slotIndex, final ItemStack i) { private TestStatus getStatus(final int slotIndex, final ItemStack i) {
if (this.crafting.getStackInSlot(slotIndex).isEmpty()) { if (this.crafting.getStack(slotIndex).isEmpty()) {
return i.isEmpty() ? TestStatus.ACCEPT : TestStatus.DECLINE; return i.isEmpty() ? TestStatus.ACCEPT : TestStatus.DECLINE;
} }

Some files were not shown because too many files have changed in this diff Show More