mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
Regenerate patches with relative headers. This should lower conflicts in future PRs.
Convert Forge to use Official mappings. Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive. It is clear that their intent is to allow us to use their names for developing mods like this. See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
1 parent
802298d99d
commit
a95b968c13
832 files changed
+4464
-4373
No files matched your search
@@ -51,7 +51,7 @@ public class CapabilityItemHandler
|
||||
{
|
||||
CompoundNBT itemTag = new CompoundNBT();
|
||||
itemTag.putInt("Slot", i);
|
||||
stack.write(itemTag);
|
||||
stack.save(itemTag);
|
||||
nbtTagList.add(itemTag);
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class CapabilityItemHandler
|
||||
|
||||
if (j >= 0 && j < instance.getSlots())
|
||||
{
|
||||
itemHandlerModifiable.setStackInSlot(j, ItemStack.read(itemTags));
|
||||
itemHandlerModifiable.setStackInSlot(j, ItemStack.of(itemTags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ItemHandlerHelper
|
||||
|
||||
public static boolean canItemStacksStack(@Nonnull ItemStack a, @Nonnull ItemStack b)
|
||||
{
|
||||
if (a.isEmpty() || !a.isItemEqual(b) || a.hasTag() != b.hasTag())
|
||||
if (a.isEmpty() || !a.sameItem(b) || a.hasTag() != b.hasTag())
|
||||
return false;
|
||||
|
||||
return (!a.hasTag() || a.getTag().equals(b.getTag())) && a.areCapsCompatible(b);
|
||||
@@ -165,7 +165,7 @@ public class ItemHandlerHelper
|
||||
if (stack.isEmpty()) return;
|
||||
|
||||
IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
|
||||
World world = player.world;
|
||||
World world = player.level;
|
||||
|
||||
// try adding it into the inventory
|
||||
ItemStack remainder = stack;
|
||||
@@ -183,18 +183,18 @@ public class ItemHandlerHelper
|
||||
// play sound if something got picked up
|
||||
if (remainder.isEmpty() || remainder.getCount() != stack.getCount())
|
||||
{
|
||||
world.playSound(null, player.getPosX(), player.getPosY() + 0.5, player.getPosZ(),
|
||||
SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
world.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(),
|
||||
SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.random.nextFloat() - world.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
|
||||
// drop remaining itemstack into the world
|
||||
if (!remainder.isEmpty() && !world.isRemote)
|
||||
if (!remainder.isEmpty() && !world.isClientSide)
|
||||
{
|
||||
ItemEntity entityitem = new ItemEntity(world, player.getPosX(), player.getPosY() + 0.5, player.getPosZ(), remainder);
|
||||
entityitem.setPickupDelay(40);
|
||||
entityitem.setMotion(entityitem.getMotion().mul(0, 1, 0));
|
||||
ItemEntity entityitem = new ItemEntity(world, player.getX(), player.getY() + 0.5, player.getZ(), remainder);
|
||||
entityitem.setPickUpDelay(40);
|
||||
entityitem.setDeltaMovement(entityitem.getDeltaMovement().multiply(0, 1, 0));
|
||||
|
||||
world.addEntity(entityitem);
|
||||
world.addFreshEntity(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
|
||||
{
|
||||
CompoundNBT itemTag = new CompoundNBT();
|
||||
itemTag.putInt("Slot", i);
|
||||
stacks.get(i).write(itemTag);
|
||||
stacks.get(i).save(itemTag);
|
||||
nbtTagList.add(itemTag);
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
|
||||
|
||||
if (slot >= 0 && slot < stacks.size())
|
||||
{
|
||||
stacks.set(slot, ItemStack.read(itemTags));
|
||||
stacks.set(slot, ItemStack.of(itemTags));
|
||||
}
|
||||
}
|
||||
onLoad();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SlotItemHandler extends Slot
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(@Nonnull ItemStack stack)
|
||||
public boolean mayPlace(@Nonnull ItemStack stack)
|
||||
{
|
||||
if (stack.isEmpty())
|
||||
return false;
|
||||
@@ -49,33 +49,33 @@ public class SlotItemHandler extends Slot
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
public ItemStack getItem()
|
||||
{
|
||||
return this.getItemHandler().getStackInSlot(index);
|
||||
}
|
||||
|
||||
// Override if your IItemHandler does not implement IItemHandlerModifiable
|
||||
@Override
|
||||
public void putStack(@Nonnull ItemStack stack)
|
||||
public void set(@Nonnull ItemStack stack)
|
||||
{
|
||||
((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(index, stack);
|
||||
this.onSlotChanged();
|
||||
this.setChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(@Nonnull ItemStack oldStackIn, @Nonnull ItemStack newStackIn)
|
||||
public void onQuickCraft(@Nonnull ItemStack oldStackIn, @Nonnull ItemStack newStackIn)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
public int getMaxStackSize()
|
||||
{
|
||||
return this.itemHandler.getSlotLimit(this.index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(@Nonnull ItemStack stack)
|
||||
public int getMaxStackSize(@Nonnull ItemStack stack)
|
||||
{
|
||||
ItemStack maxAdd = stack.copy();
|
||||
int maxInput = stack.getMaxStackSize();
|
||||
@@ -105,14 +105,14 @@ public class SlotItemHandler extends Slot
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(PlayerEntity playerIn)
|
||||
public boolean mayPickup(PlayerEntity playerIn)
|
||||
{
|
||||
return !this.getItemHandler().extractItem(index, 1, true).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize(int amount)
|
||||
public ItemStack remove(int amount)
|
||||
{
|
||||
return this.getItemHandler().extractItem(index, amount, false);
|
||||
}
|
||||
|
||||
@@ -52,14 +52,14 @@ public class VanillaHopperItemHandler extends InvWrapper
|
||||
|
||||
if (wasEmpty && originalStackSize > stack.getCount())
|
||||
{
|
||||
if (!hopper.mayTransfer())
|
||||
if (!hopper.isOnCustomCooldown())
|
||||
{
|
||||
// This cooldown is always set to 8 in vanilla with one exception:
|
||||
// Hopper -> Hopper transfer sets this cooldown to 7 when this hopper
|
||||
// has not been updated as recently as the one pushing items into it.
|
||||
// This vanilla behavior is preserved by VanillaInventoryCodeHooks#insertStack,
|
||||
// the cooldown is set properly by the hopper that is pushing items into this one.
|
||||
hopper.setTransferCooldown(8);
|
||||
hopper.setCooldown(8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,20 +58,20 @@ public class VanillaInventoryCodeHooks
|
||||
ItemStack extractItem = handler.extractItem(i, 1, true);
|
||||
if (!extractItem.isEmpty())
|
||||
{
|
||||
for (int j = 0; j < dest.getSizeInventory(); j++)
|
||||
for (int j = 0; j < dest.getContainerSize(); j++)
|
||||
{
|
||||
ItemStack destStack = dest.getStackInSlot(j);
|
||||
if (dest.isItemValidForSlot(j, extractItem) && (destStack.isEmpty() || destStack.getCount() < destStack.getMaxStackSize() && destStack.getCount() < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack)))
|
||||
ItemStack destStack = dest.getItem(j);
|
||||
if (dest.canPlaceItem(j, extractItem) && (destStack.isEmpty() || destStack.getCount() < destStack.getMaxStackSize() && destStack.getCount() < dest.getMaxStackSize() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack)))
|
||||
{
|
||||
extractItem = handler.extractItem(i, 1, false);
|
||||
if (destStack.isEmpty())
|
||||
dest.setInventorySlotContents(j, extractItem);
|
||||
dest.setItem(j, extractItem);
|
||||
else
|
||||
{
|
||||
destStack.grow(1);
|
||||
dest.setInventorySlotContents(j, destStack);
|
||||
dest.setItem(j, destStack);
|
||||
}
|
||||
dest.markDirty();
|
||||
dest.setChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ public class VanillaInventoryCodeHooks
|
||||
*/
|
||||
public static boolean dropperInsertHook(World world, BlockPos pos, DispenserTileEntity dropper, int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
Direction enumfacing = world.getBlockState(pos).get(DropperBlock.FACING);
|
||||
BlockPos blockpos = pos.offset(enumfacing);
|
||||
Direction enumfacing = world.getBlockState(pos).getValue(DropperBlock.FACING);
|
||||
BlockPos blockpos = pos.relative(enumfacing);
|
||||
return getItemHandler(world, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), enumfacing.getOpposite())
|
||||
.map(destinationResult -> {
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
@@ -107,7 +107,7 @@ public class VanillaInventoryCodeHooks
|
||||
remainder = stack.copy();
|
||||
}
|
||||
|
||||
dropper.setInventorySlotContents(slot, remainder);
|
||||
dropper.setItem(slot, remainder);
|
||||
return false;
|
||||
})
|
||||
.orElse(true);
|
||||
@@ -118,7 +118,7 @@ public class VanillaInventoryCodeHooks
|
||||
*/
|
||||
public static boolean insertHook(HopperTileEntity hopper)
|
||||
{
|
||||
Direction hopperFacing = hopper.getBlockState().get(HopperBlock.FACING);
|
||||
Direction hopperFacing = hopper.getBlockState().getValue(HopperBlock.FACING);
|
||||
return getItemHandler(hopper, hopperFacing)
|
||||
.map(destinationResult -> {
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
@@ -129,12 +129,12 @@ public class VanillaInventoryCodeHooks
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < hopper.getSizeInventory(); ++i)
|
||||
for (int i = 0; i < hopper.getContainerSize(); ++i)
|
||||
{
|
||||
if (!hopper.getStackInSlot(i).isEmpty())
|
||||
if (!hopper.getItem(i).isEmpty())
|
||||
{
|
||||
ItemStack originalSlotContents = hopper.getStackInSlot(i).copy();
|
||||
ItemStack insertStack = hopper.decrStackSize(i, 1);
|
||||
ItemStack originalSlotContents = hopper.getItem(i).copy();
|
||||
ItemStack insertStack = hopper.removeItem(i, 1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(hopper, destination, itemHandler, insertStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
@@ -142,7 +142,7 @@ public class VanillaInventoryCodeHooks
|
||||
return true;
|
||||
}
|
||||
|
||||
hopper.setInventorySlotContents(i, originalSlotContents);
|
||||
hopper.setItem(i, originalSlotContents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class VanillaInventoryCodeHooks
|
||||
{
|
||||
HopperTileEntity destinationHopper = (HopperTileEntity)destination;
|
||||
|
||||
if (!destinationHopper.mayTransfer())
|
||||
if (!destinationHopper.isOnCustomCooldown())
|
||||
{
|
||||
int k = 0;
|
||||
if (source instanceof HopperTileEntity)
|
||||
@@ -202,7 +202,7 @@ public class VanillaInventoryCodeHooks
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
destinationHopper.setTransferCooldown(8 - k);
|
||||
destinationHopper.setCooldown(8 - k);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,10 +213,10 @@ public class VanillaInventoryCodeHooks
|
||||
|
||||
private static Optional<Pair<IItemHandler, Object>> getItemHandler(IHopper hopper, Direction hopperFacing)
|
||||
{
|
||||
double x = hopper.getXPos() + (double) hopperFacing.getXOffset();
|
||||
double y = hopper.getYPos() + (double) hopperFacing.getYOffset();
|
||||
double z = hopper.getZPos() + (double) hopperFacing.getZOffset();
|
||||
return getItemHandler(hopper.getWorld(), x, y, z, hopperFacing.getOpposite());
|
||||
double x = hopper.getLevelX() + (double) hopperFacing.getStepX();
|
||||
double y = hopper.getLevelY() + (double) hopperFacing.getStepY();
|
||||
double z = hopper.getLevelZ() + (double) hopperFacing.getStepZ();
|
||||
return getItemHandler(hopper.getLevel(), x, y, z, hopperFacing.getOpposite());
|
||||
}
|
||||
|
||||
private static boolean isFull(IItemHandler itemHandler)
|
||||
@@ -255,7 +255,7 @@ public class VanillaInventoryCodeHooks
|
||||
|
||||
if (state.hasTileEntity())
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
TileEntity tileentity = worldIn.getBlockEntity(blockpos);
|
||||
if (tileentity != null)
|
||||
{
|
||||
return tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
|
||||
for (final EquipmentSlotType slot : EquipmentSlotType.values())
|
||||
{
|
||||
if (slot.getSlotType() == slotType)
|
||||
if (slot.getType() == slotType)
|
||||
{
|
||||
slots.add(slot);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
@Override
|
||||
public ItemStack getStackInSlot(final int slot)
|
||||
{
|
||||
return entity.getItemStackFromSlot(validateSlotIndex(slot));
|
||||
return entity.getItemBySlot(validateSlotIndex(slot));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -95,7 +95,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
|
||||
final ItemStack existing = entity.getItemStackFromSlot(equipmentSlot);
|
||||
final ItemStack existing = entity.getItemBySlot(equipmentSlot);
|
||||
|
||||
int limit = getStackLimit(slot, stack);
|
||||
|
||||
@@ -116,7 +116,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
{
|
||||
if (existing.isEmpty())
|
||||
{
|
||||
entity.setItemStackToSlot(equipmentSlot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
|
||||
entity.setItemSlot(equipmentSlot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -136,7 +136,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
|
||||
final ItemStack existing = entity.getItemStackFromSlot(equipmentSlot);
|
||||
final ItemStack existing = entity.getItemBySlot(equipmentSlot);
|
||||
|
||||
if (existing.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
@@ -147,7 +147,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
{
|
||||
if (!simulate)
|
||||
{
|
||||
entity.setItemStackToSlot(equipmentSlot, ItemStack.EMPTY);
|
||||
entity.setItemSlot(equipmentSlot, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
return existing;
|
||||
@@ -156,7 +156,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
{
|
||||
if (!simulate)
|
||||
{
|
||||
entity.setItemStackToSlot(equipmentSlot, ItemHandlerHelper.copyStackWithSize(existing, existing.getCount() - toExtract));
|
||||
entity.setItemSlot(equipmentSlot, ItemHandlerHelper.copyStackWithSize(existing, existing.getCount() - toExtract));
|
||||
}
|
||||
|
||||
return ItemHandlerHelper.copyStackWithSize(existing, toExtract);
|
||||
@@ -167,7 +167,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
public int getSlotLimit(final int slot)
|
||||
{
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
return equipmentSlot.getSlotType() == EquipmentSlotType.Group.ARMOR ? 1 : 64;
|
||||
return equipmentSlot.getType() == EquipmentSlotType.Group.ARMOR ? 1 : 64;
|
||||
}
|
||||
|
||||
protected int getStackLimit(final int slot, @Nonnull final ItemStack stack)
|
||||
@@ -179,9 +179,9 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
public void setStackInSlot(final int slot, @Nonnull final ItemStack stack)
|
||||
{
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
if (ItemStack.areItemStacksEqual(entity.getItemStackFromSlot(equipmentSlot), stack))
|
||||
if (ItemStack.matches(entity.getItemBySlot(equipmentSlot), stack))
|
||||
return;
|
||||
entity.setItemStackToSlot(equipmentSlot, stack);
|
||||
entity.setItemSlot(equipmentSlot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,14 +58,14 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return getInv().getSizeInventory();
|
||||
return getInv().getContainerSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return getInv().getStackInSlot(slot);
|
||||
return getInv().getItem(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +75,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
if (stack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack stackInSlot = getInv().getStackInSlot(slot);
|
||||
ItemStack stackInSlot = getInv().getItem(slot);
|
||||
|
||||
int m;
|
||||
if (!stackInSlot.isEmpty())
|
||||
@@ -86,7 +86,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
|
||||
return stack;
|
||||
|
||||
if (!getInv().isItemValidForSlot(slot, stack))
|
||||
if (!getInv().canPlaceItem(slot, stack))
|
||||
return stack;
|
||||
|
||||
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.getCount();
|
||||
@@ -97,8 +97,8 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
{
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(stackInSlot.getCount());
|
||||
getInv().setInventorySlotContents(slot, copy);
|
||||
getInv().markDirty();
|
||||
getInv().setItem(slot, copy);
|
||||
getInv().setChanged();
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
@@ -111,8 +111,8 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
{
|
||||
ItemStack copy = stack.split(m);
|
||||
copy.grow(stackInSlot.getCount());
|
||||
getInv().setInventorySlotContents(slot, copy);
|
||||
getInv().markDirty();
|
||||
getInv().setItem(slot, copy);
|
||||
getInv().setChanged();
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
@@ -124,7 +124,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!getInv().isItemValidForSlot(slot, stack))
|
||||
if (!getInv().canPlaceItem(slot, stack))
|
||||
return stack;
|
||||
|
||||
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
|
||||
@@ -134,8 +134,8 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
stack = stack.copy();
|
||||
if (!simulate)
|
||||
{
|
||||
getInv().setInventorySlotContents(slot, stack.split(m));
|
||||
getInv().markDirty();
|
||||
getInv().setItem(slot, stack.split(m));
|
||||
getInv().setChanged();
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
@@ -148,8 +148,8 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
{
|
||||
if (!simulate)
|
||||
{
|
||||
getInv().setInventorySlotContents(slot, stack);
|
||||
getInv().markDirty();
|
||||
getInv().setItem(slot, stack);
|
||||
getInv().setChanged();
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
if (amount == 0)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack stackInSlot = getInv().getStackInSlot(slot);
|
||||
ItemStack stackInSlot = getInv().getItem(slot);
|
||||
|
||||
if (stackInSlot.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
@@ -186,8 +186,8 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
{
|
||||
int m = Math.min(stackInSlot.getCount(), amount);
|
||||
|
||||
ItemStack decrStackSize = getInv().decrStackSize(slot, m);
|
||||
getInv().markDirty();
|
||||
ItemStack decrStackSize = getInv().removeItem(slot, m);
|
||||
getInv().setChanged();
|
||||
return decrStackSize;
|
||||
}
|
||||
}
|
||||
@@ -195,19 +195,19 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
@Override
|
||||
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
getInv().setInventorySlotContents(slot, stack);
|
||||
getInv().setItem(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot)
|
||||
{
|
||||
return getInv().getInventoryStackLimit();
|
||||
return getInv().getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
return getInv().isItemValidForSlot(slot, stack);
|
||||
return getInv().canPlaceItem(slot, stack);
|
||||
}
|
||||
|
||||
public IInventory getInv()
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PlayerArmorInvWrapper extends RangedWrapper
|
||||
|
||||
public PlayerArmorInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new InvWrapper(inv), inv.mainInventory.size(), inv.mainInventory.size() + inv.armorInventory.size());
|
||||
super(new InvWrapper(inv), inv.items.size(), inv.items.size() + inv.armor.size());
|
||||
inventoryPlayer = inv;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class PlayerArmorInvWrapper extends RangedWrapper
|
||||
EquipmentSlotType equ = null;
|
||||
for (EquipmentSlotType s : EquipmentSlotType.values())
|
||||
{
|
||||
if (s.getSlotType() == EquipmentSlotType.Group.ARMOR && s.getIndex() == slot)
|
||||
if (s.getType() == EquipmentSlotType.Group.ARMOR && s.getIndex() == slot)
|
||||
{
|
||||
equ = s;
|
||||
break;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PlayerMainInvWrapper extends RangedWrapper
|
||||
|
||||
public PlayerMainInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new InvWrapper(inv), 0, inv.mainInventory.size());
|
||||
super(new InvWrapper(inv), 0, inv.items.size());
|
||||
inventoryPlayer = inv;
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ public class PlayerMainInvWrapper extends RangedWrapper
|
||||
ItemStack inSlot = getStackInSlot(slot);
|
||||
if(!inSlot.isEmpty())
|
||||
{
|
||||
if (getInventoryPlayer().player.world.isRemote)
|
||||
if (getInventoryPlayer().player.level.isClientSide)
|
||||
{
|
||||
inSlot.setAnimationsToGo(5);
|
||||
inSlot.setPopTime(5);
|
||||
}
|
||||
else if(getInventoryPlayer().player instanceof ServerPlayerEntity) {
|
||||
getInventoryPlayer().player.openContainer.detectAndSendChanges();
|
||||
getInventoryPlayer().player.containerMenu.broadcastChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PlayerOffhandInvWrapper extends RangedWrapper
|
||||
{
|
||||
public PlayerOffhandInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new InvWrapper(inv), inv.mainInventory.size() + inv.armorInventory.size(),
|
||||
inv.mainInventory.size() + inv.armorInventory.size() + inv.offHandInventory.size());
|
||||
super(new InvWrapper(inv), inv.items.size() + inv.armor.size(),
|
||||
inv.items.size() + inv.armor.size() + inv.offhand.size());
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class RecipeWrapper implements IInventory {
|
||||
* Returns the size of this inventory. Must be equivalent to {@link #getHeight()} * {@link #getWidth()}.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
public int getContainerSize()
|
||||
{
|
||||
return inv.getSlots();
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class RecipeWrapper implements IInventory {
|
||||
* Returns the stack in this slot. This stack should be a modifiable reference, not a copy of a stack in your inventory.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
public ItemStack getItem(int slot)
|
||||
{
|
||||
return inv.getStackInSlot(slot);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class RecipeWrapper implements IInventory {
|
||||
* Attempts to remove n items from the specified slot. Returns the split stack that was removed. Modifies the inventory.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count)
|
||||
public ItemStack removeItem(int slot, int count)
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot(slot);
|
||||
return stack.isEmpty() ? ItemStack.EMPTY : stack.split(count);
|
||||
@@ -65,7 +65,7 @@ public class RecipeWrapper implements IInventory {
|
||||
* Sets the contents of this slot to the provided stack.
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
public void setItem(int slot, ItemStack stack)
|
||||
{
|
||||
inv.setStackInSlot(slot, stack);
|
||||
}
|
||||
@@ -74,11 +74,11 @@ public class RecipeWrapper implements IInventory {
|
||||
* Removes the stack contained in this slot from the underlying handler, and returns it.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
public ItemStack removeItemNoUpdate(int index)
|
||||
{
|
||||
ItemStack s = getStackInSlot(index);
|
||||
ItemStack s = getItem(index);
|
||||
if(s.isEmpty()) return ItemStack.EMPTY;
|
||||
setInventorySlotContents(index, ItemStack.EMPTY);
|
||||
setItem(index, ItemStack.EMPTY);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -93,13 +93,13 @@ public class RecipeWrapper implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
||||
public boolean canPlaceItem(int slot, ItemStack stack)
|
||||
{
|
||||
return inv.isItemValid(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
public void clearContent()
|
||||
{
|
||||
for(int i = 0; i < inv.getSlots(); i++)
|
||||
{
|
||||
@@ -109,14 +109,14 @@ public class RecipeWrapper implements IInventory {
|
||||
|
||||
//The following methods are never used by vanilla in crafting. They are defunct as mods need not override them.
|
||||
@Override
|
||||
public int getInventoryStackLimit() { return 0; }
|
||||
public int getMaxStackSize() { return 0; }
|
||||
@Override
|
||||
public void markDirty() {}
|
||||
public void setChanged() {}
|
||||
@Override
|
||||
public boolean isUsableByPlayer(PlayerEntity player) { return false; }
|
||||
public boolean stillValid(PlayerEntity player) { return false; }
|
||||
@Override
|
||||
public void openInventory(PlayerEntity player) {}
|
||||
public void startOpen(PlayerEntity player) {}
|
||||
@Override
|
||||
public void closeInventory(PlayerEntity player) {}
|
||||
public void stopOpen(PlayerEntity player) {}
|
||||
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
int i = getSlot(inv, slot, side);
|
||||
return i == -1 ? ItemStack.EMPTY : inv.getStackInSlot(i);
|
||||
return i == -1 ? ItemStack.EMPTY : inv.getItem(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +106,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
if (slot1 == -1)
|
||||
return stack;
|
||||
|
||||
ItemStack stackInSlot = inv.getStackInSlot(slot1);
|
||||
ItemStack stackInSlot = inv.getItem(slot1);
|
||||
|
||||
int m;
|
||||
if (!stackInSlot.isEmpty())
|
||||
@@ -117,7 +117,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
|
||||
return stack;
|
||||
|
||||
if (!inv.canInsertItem(slot1, stack, side) || !inv.isItemValidForSlot(slot1, stack))
|
||||
if (!inv.canPlaceItemThroughFace(slot1, stack, side) || !inv.canPlaceItem(slot1, stack))
|
||||
return stack;
|
||||
|
||||
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.getCount();
|
||||
@@ -153,7 +153,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!inv.canInsertItem(slot1, stack, side) || !inv.isItemValidForSlot(slot1, stack))
|
||||
if (!inv.canPlaceItemThroughFace(slot1, stack, side) || !inv.canPlaceItem(slot1, stack))
|
||||
return stack;
|
||||
|
||||
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
|
||||
@@ -192,8 +192,8 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
}
|
||||
|
||||
private void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inv.markDirty(); //Notify vanilla of updates, We change the handler to be responsible for this instead of the caller. So mimic vanilla behavior
|
||||
inv.setInventorySlotContents(slot, stack);
|
||||
inv.setChanged(); //Notify vanilla of updates, We change the handler to be responsible for this instead of the caller. So mimic vanilla behavior
|
||||
inv.setItem(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,12 +208,12 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
if (slot1 == -1)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack stackInSlot = inv.getStackInSlot(slot1);
|
||||
ItemStack stackInSlot = inv.getItem(slot1);
|
||||
|
||||
if (stackInSlot.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
if (!inv.canExtractItem(slot1, stackInSlot, side))
|
||||
if (!inv.canTakeItemThroughFace(slot1, stackInSlot, side))
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
if (simulate)
|
||||
@@ -232,8 +232,8 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
else
|
||||
{
|
||||
int m = Math.min(stackInSlot.getCount(), amount);
|
||||
ItemStack ret = inv.decrStackSize(slot1, m);
|
||||
inv.markDirty();
|
||||
ItemStack ret = inv.removeItem(slot1, m);
|
||||
inv.setChanged();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -241,13 +241,13 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
@Override
|
||||
public int getSlotLimit(int slot)
|
||||
{
|
||||
return inv.getInventoryStackLimit();
|
||||
return inv.getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
int slot1 = getSlot(inv, slot, side);
|
||||
return slot1 == -1 ? false : inv.isItemValidForSlot(slot1, stack);
|
||||
return slot1 == -1 ? false : inv.canPlaceItem(slot1, stack);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user