mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 04:09:51 +00:00
Update to 1.14.2
This commit is contained in:
1 parent
d3e8804dbf
commit
a7df63e1a1
1010 files changed
+15254
-19520
No files matched your search
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
/**
|
||||
@@ -29,8 +29,8 @@ import net.minecraftforge.items.IItemHandler;
|
||||
*/
|
||||
public class EntityArmorInvWrapper extends EntityEquipmentInvWrapper
|
||||
{
|
||||
public EntityArmorInvWrapper(final EntityLivingBase entity)
|
||||
public EntityArmorInvWrapper(final LivingEntity entity)
|
||||
{
|
||||
super(entity, EntityEquipmentSlot.Type.ARMOR);
|
||||
super(entity, EquipmentSlotType.Group.ARMOR);
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,17 @@
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,24 +45,24 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
/**
|
||||
* The entity.
|
||||
*/
|
||||
protected final EntityLivingBase entity;
|
||||
protected final LivingEntity entity;
|
||||
|
||||
/**
|
||||
* The slots exposed by this wrapper, with {@link EntityEquipmentSlot#index} as the index.
|
||||
*/
|
||||
protected final List<EntityEquipmentSlot> slots;
|
||||
protected final List<EquipmentSlotType> slots;
|
||||
|
||||
/**
|
||||
* @param entity The entity.
|
||||
* @param slotType The slot type to expose.
|
||||
*/
|
||||
public EntityEquipmentInvWrapper(final EntityLivingBase entity, final EntityEquipmentSlot.Type slotType)
|
||||
public EntityEquipmentInvWrapper(final LivingEntity entity, final EquipmentSlotType.Group slotType)
|
||||
{
|
||||
this.entity = entity;
|
||||
|
||||
final List<EntityEquipmentSlot> slots = new ArrayList<EntityEquipmentSlot>();
|
||||
final List<EquipmentSlotType> slots = new ArrayList<EquipmentSlotType>();
|
||||
|
||||
for (final EntityEquipmentSlot slot : EntityEquipmentSlot.values())
|
||||
for (final EquipmentSlotType slot : EquipmentSlotType.values())
|
||||
{
|
||||
if (slot.getSlotType() == slotType)
|
||||
{
|
||||
@@ -89,7 +93,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
if (stack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
|
||||
final ItemStack existing = entity.getItemStackFromSlot(equipmentSlot);
|
||||
|
||||
@@ -130,7 +134,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
if (amount == 0)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
|
||||
final ItemStack existing = entity.getItemStackFromSlot(equipmentSlot);
|
||||
|
||||
@@ -162,8 +166,8 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
@Override
|
||||
public int getSlotLimit(final int slot)
|
||||
{
|
||||
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
|
||||
return equipmentSlot.getSlotType() == EntityEquipmentSlot.Type.ARMOR ? 1 : 64;
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
return equipmentSlot.getSlotType() == EquipmentSlotType.Group.ARMOR ? 1 : 64;
|
||||
}
|
||||
|
||||
protected int getStackLimit(final int slot, @Nonnull final ItemStack stack)
|
||||
@@ -174,7 +178,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
@Override
|
||||
public void setStackInSlot(final int slot, @Nonnull final ItemStack stack)
|
||||
{
|
||||
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
|
||||
final EquipmentSlotType equipmentSlot = validateSlotIndex(slot);
|
||||
if (ItemStack.areItemStacksEqual(entity.getItemStackFromSlot(equipmentSlot), stack))
|
||||
return;
|
||||
entity.setItemStackToSlot(equipmentSlot, stack);
|
||||
@@ -186,7 +190,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
return true;
|
||||
}
|
||||
|
||||
protected EntityEquipmentSlot validateSlotIndex(final int slot)
|
||||
protected EquipmentSlotType validateSlotIndex(final int slot)
|
||||
{
|
||||
if (slot < 0 || slot >= slots.size())
|
||||
throw new IllegalArgumentException("Slot " + slot + " not in valid range - [0," + slots.size() + ")");
|
||||
@@ -194,7 +198,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
return slots.get(slot);
|
||||
}
|
||||
|
||||
public static LazyOptional<IItemHandlerModifiable>[] create(EntityLivingBase entity)
|
||||
public static LazyOptional<IItemHandlerModifiable>[] create(LivingEntity entity)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
LazyOptional<IItemHandlerModifiable>[] ret = new LazyOptional[3];
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
/**
|
||||
@@ -29,8 +29,8 @@ import net.minecraftforge.items.IItemHandler;
|
||||
*/
|
||||
public class EntityHandsInvWrapper extends EntityEquipmentInvWrapper
|
||||
{
|
||||
public EntityHandsInvWrapper(EntityLivingBase entity)
|
||||
public EntityHandsInvWrapper(LivingEntity entity)
|
||||
{
|
||||
super(entity, EntityEquipmentSlot.Type.HAND);
|
||||
super(entity, EquipmentSlotType.Group.HAND);
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PlayerArmorInvWrapper extends RangedWrapper
|
||||
{
|
||||
private final InventoryPlayer inventoryPlayer;
|
||||
private final PlayerInventory inventoryPlayer;
|
||||
|
||||
public PlayerArmorInvWrapper(InventoryPlayer inv)
|
||||
public PlayerArmorInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new InvWrapper(inv), inv.mainInventory.size(), inv.mainInventory.size() + inv.armorInventory.size());
|
||||
inventoryPlayer = inv;
|
||||
@@ -39,10 +39,10 @@ public class PlayerArmorInvWrapper extends RangedWrapper
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
EntityEquipmentSlot equ = null;
|
||||
for (EntityEquipmentSlot s : EntityEquipmentSlot.values())
|
||||
EquipmentSlotType equ = null;
|
||||
for (EquipmentSlotType s : EquipmentSlotType.values())
|
||||
{
|
||||
if (s.getSlotType() == EntityEquipmentSlot.Type.ARMOR && s.getIndex() == slot)
|
||||
if (s.getSlotType() == EquipmentSlotType.Group.ARMOR && s.getIndex() == slot)
|
||||
{
|
||||
equ = s;
|
||||
break;
|
||||
@@ -56,7 +56,7 @@ public class PlayerArmorInvWrapper extends RangedWrapper
|
||||
return stack;
|
||||
}
|
||||
|
||||
public InventoryPlayer getInventoryPlayer()
|
||||
public PlayerInventory getInventoryPlayer()
|
||||
{
|
||||
return inventoryPlayer;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class PlayerInvWrapper extends CombinedInvWrapper
|
||||
{
|
||||
public PlayerInvWrapper(InventoryPlayer inv)
|
||||
public PlayerInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new PlayerMainInvWrapper(inv), new PlayerArmorInvWrapper(inv), new PlayerOffhandInvWrapper(inv));
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -31,9 +31,9 @@ import javax.annotation.Nonnull;
|
||||
*/
|
||||
public class PlayerMainInvWrapper extends RangedWrapper
|
||||
{
|
||||
private final InventoryPlayer inventoryPlayer;
|
||||
private final PlayerInventory inventoryPlayer;
|
||||
|
||||
public PlayerMainInvWrapper(InventoryPlayer inv)
|
||||
public PlayerMainInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new InvWrapper(inv), 0, inv.mainInventory.size());
|
||||
inventoryPlayer = inv;
|
||||
@@ -54,7 +54,7 @@ public class PlayerMainInvWrapper extends RangedWrapper
|
||||
{
|
||||
inSlot.setAnimationsToGo(5);
|
||||
}
|
||||
else if(getInventoryPlayer().player instanceof EntityPlayerMP) {
|
||||
else if(getInventoryPlayer().player instanceof ServerPlayerEntity) {
|
||||
getInventoryPlayer().player.openContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class PlayerMainInvWrapper extends RangedWrapper
|
||||
return rest;
|
||||
}
|
||||
|
||||
public InventoryPlayer getInventoryPlayer()
|
||||
public PlayerInventory getInventoryPlayer()
|
||||
{
|
||||
return inventoryPlayer;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class PlayerOffhandInvWrapper extends RangedWrapper
|
||||
{
|
||||
public PlayerOffhandInvWrapper(InventoryPlayer inv)
|
||||
public PlayerOffhandInvWrapper(PlayerInventory inv)
|
||||
{
|
||||
super(new InvWrapper(inv), inv.mainInventory.size() + inv.armorInventory.size(),
|
||||
inv.mainInventory.size() + inv.armorInventory.size() + inv.offHandInventory.size());
|
||||
|
||||
@@ -19,23 +19,18 @@
|
||||
|
||||
package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
public class RecipeWrapper implements IInventory {
|
||||
|
||||
protected final IItemHandlerModifiable inv;
|
||||
protected final int width;
|
||||
protected final int height;
|
||||
|
||||
public RecipeWrapper(IItemHandlerModifiable inv, int width, int height)
|
||||
public RecipeWrapper(IItemHandlerModifiable inv)
|
||||
{
|
||||
this.inv = inv;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +39,7 @@ public class RecipeWrapper implements IInventory {
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return getHeight() * getWidth();
|
||||
return inv.getSlots();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,24 +70,6 @@ public class RecipeWrapper implements IInventory {
|
||||
inv.setStackInSlot(slot, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of this inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of this inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the stack contained in this slot from the underlying handler, and returns it.
|
||||
*/
|
||||
@@ -136,22 +113,10 @@ public class RecipeWrapper implements IInventory {
|
||||
@Override
|
||||
public void markDirty() {}
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player) { return false; }
|
||||
public boolean isUsableByPlayer(PlayerEntity player) { return false; }
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {}
|
||||
public void openInventory(PlayerEntity player) {}
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {}
|
||||
@Override
|
||||
public int getField(int id) { return 0; }
|
||||
@Override
|
||||
public void setField(int id, int value) {}
|
||||
@Override
|
||||
public int getFieldCount() { return 0; }
|
||||
@Override
|
||||
public ITextComponent getName() { return null; }
|
||||
@Override
|
||||
public boolean hasCustomName() { return false; }
|
||||
@Override
|
||||
public ITextComponent getCustomName() { return null; }
|
||||
|
||||
public void closeInventory(PlayerEntity player) {}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.items.wrapper;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -31,25 +31,25 @@ import javax.annotation.Nonnull;
|
||||
public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
{
|
||||
protected final ISidedInventory inv;
|
||||
protected final EnumFacing side;
|
||||
protected final Direction side;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static LazyOptional<IItemHandlerModifiable>[] create(ISidedInventory inv, EnumFacing... sides) {
|
||||
public static LazyOptional<IItemHandlerModifiable>[] create(ISidedInventory inv, Direction... sides) {
|
||||
LazyOptional<IItemHandlerModifiable>[] ret = new LazyOptional[sides.length];
|
||||
for (int x = 0; x < sides.length; x++) {
|
||||
final EnumFacing side = sides[x];
|
||||
final Direction side = sides[x];
|
||||
ret[x] = LazyOptional.of(() -> new SidedInvWrapper(inv, side));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SidedInvWrapper(ISidedInventory inv, EnumFacing side)
|
||||
public SidedInvWrapper(ISidedInventory inv, Direction side)
|
||||
{
|
||||
this.inv = inv;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public static int getSlot(ISidedInventory inv, int slot, EnumFacing side)
|
||||
public static int getSlot(ISidedInventory inv, int slot, Direction side)
|
||||
{
|
||||
int[] slots = inv.getSlotsForFace(side);
|
||||
if (slot < slots.length)
|
||||
|
||||
Reference in new issue
Block a user