Revert "Perform some minor code clean ups (Such as cleaning up imports, some lines of code, etc) Move the entire TopStacks code to the Crystal versions of the chests/Shulker Boxes to match 1.13 code, Fix chests and Shulker Boxes losing their custom names on upgrading. Finally fix the inventories missing due to tinker construct smelteries. Closes #162"

This reverts commit 930ea9a725.
This commit is contained in:
alexbegt 2019-06-10 21:06:08 -04:00
parent 930ea9a725
commit 4b51dbf062
38 changed files with 765 additions and 920 deletions

View File

@ -37,19 +37,15 @@ public class ClientProxy extends CommonProxy
for (IronChestType type : IronChestType.values()) for (IronChestType type : IronChestType.values())
{ {
if (type.clazz != null) if (type.clazz != null)
{
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronChestRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronChestRenderer());
} }
}
for (IronShulkerBoxType type : IronShulkerBoxType.values()) for (IronShulkerBoxType type : IronShulkerBoxType.values())
{ {
if (type.clazz != null) if (type.clazz != null)
{
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronShulkerBoxRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronShulkerBoxRenderer());
} }
} }
}
@Override @Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)

View File

@ -10,11 +10,13 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.client.renderer.chest; package cpw.mods.ironchest.client.renderer.chest;
import java.util.Random;
import com.google.common.primitives.SignedBytes; import com.google.common.primitives.SignedBytes;
import cpw.mods.ironchest.common.blocks.chest.BlockIronChest; import cpw.mods.ironchest.common.blocks.chest.BlockIronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.core.IronChestBlocks; import cpw.mods.ironchest.common.core.IronChestBlocks;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityCrystalChest;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest; import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -26,8 +28,6 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import java.util.Random;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileEntityIronChest> public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileEntityIronChest>
{ {
private Random random; private Random random;
@ -174,7 +174,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
float blockScale = 0.70F; float blockScale = 0.70F;
float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks; float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks;
if (((TileEntityCrystalChest) te).getTopItems().get(1).isEmpty()) if (te.getTopItems().get(1).isEmpty())
{ {
shift = 8; shift = 8;
blockScale = 0.85F; blockScale = 0.85F;
@ -190,7 +190,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
customItem.hoverStart = 0F; customItem.hoverStart = 0F;
for (ItemStack item : ((TileEntityCrystalChest) te).getTopItems()) for (ItemStack item : te.getTopItems())
{ {
if (shift > shifts.length || shift > 8) if (shift > shifts.length || shift > 8)
{ {

View File

@ -16,7 +16,6 @@ import com.google.common.primitives.SignedBytes;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityCrystalShulkerBox;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox; import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -166,7 +165,7 @@ public class TileEntityIronShulkerBoxRenderer extends TileEntitySpecialRenderer<
float blockScale = 0.70F; float blockScale = 0.70F;
float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks; float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks;
if (((TileEntityCrystalShulkerBox) te).getTopItems().get(1).isEmpty()) if (te.getTopItems().get(1).isEmpty())
{ {
shift = 8; shift = 8;
blockScale = 0.85F; blockScale = 0.85F;
@ -182,7 +181,7 @@ public class TileEntityIronShulkerBoxRenderer extends TileEntitySpecialRenderer<
customItem.hoverStart = 0F; customItem.hoverStart = 0F;
for (ItemStack item : ((TileEntityCrystalShulkerBox) te).getTopItems()) for (ItemStack item : te.getTopItems())
{ {
if (shift > shifts.length || shift > 8) if (shift > shifts.length || shift > 8)
{ {

View File

@ -10,6 +10,10 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.blocks.chest; package cpw.mods.ironchest.common.blocks.chest;
import java.util.Random;
import javax.annotation.Nullable;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.core.IronChestCreativeTabs; import cpw.mods.ironchest.common.core.IronChestCreativeTabs;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest; import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
@ -49,9 +53,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.Random;
public class BlockIronChest extends Block public class BlockIronChest extends Block
{ {
public static final PropertyEnum<IronChestType> VARIANT_PROP = PropertyEnum.create("variant", IronChestType.class); public static final PropertyEnum<IronChestType> VARIANT_PROP = PropertyEnum.create("variant", IronChestType.class);

View File

@ -10,6 +10,10 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.blocks.shulker; package cpw.mods.ironchest.common.blocks.shulker;
import java.util.List;
import javax.annotation.Nullable;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.core.IronChestBlocks; import cpw.mods.ironchest.common.core.IronChestBlocks;
import cpw.mods.ironchest.common.core.IronChestCreativeTabs; import cpw.mods.ironchest.common.core.IronChestCreativeTabs;
@ -46,9 +50,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BlockIronShulkerBox extends Block public class BlockIronShulkerBox extends Block
{ {

View File

@ -1,10 +1,11 @@
package cpw.mods.ironchest.common.config; package cpw.mods.ironchest.common.config;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class Config public final class Config
{ {

View File

@ -1,5 +1,7 @@
package cpw.mods.ironchest.common.core; package cpw.mods.ironchest.common.core;
import javax.annotation.Nonnull;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.util.CreativeTabItems; import cpw.mods.ironchest.common.util.CreativeTabItems;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -9,8 +11,6 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
public final class IronChestCreativeTabs public final class IronChestCreativeTabs
{ {
private IronChestCreativeTabs() private IronChestCreativeTabs()

View File

@ -1,13 +1,14 @@
package cpw.mods.ironchest.common.crafting.condition; package cpw.mods.ironchest.common.crafting.condition;
import java.util.function.BooleanSupplier;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import cpw.mods.ironchest.common.config.Config; import cpw.mods.ironchest.common.config.Config;
import net.minecraft.util.JsonUtils; import net.minecraft.util.JsonUtils;
import net.minecraftforge.common.crafting.IConditionFactory; import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.JsonContext; import net.minecraftforge.common.crafting.JsonContext;
import java.util.function.BooleanSupplier;
public class IsConfigOptionEnabledConditionFactory implements IConditionFactory public class IsConfigOptionEnabledConditionFactory implements IConditionFactory
{ {
@Override @Override

View File

@ -11,6 +11,7 @@
package cpw.mods.ironchest.common.crafting.recipe; package cpw.mods.ironchest.common.crafting.recipe;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Items; import net.minecraft.init.Items;

View File

@ -10,7 +10,10 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.crafting.recipe; package cpw.mods.ironchest.common.crafting.recipe;
import javax.annotation.Nonnull;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -25,8 +28,6 @@ import net.minecraftforge.common.crafting.IRecipeFactory;
import net.minecraftforge.common.crafting.JsonContext; import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import javax.annotation.Nonnull;
public class ShulkerBoxRecipeFactory implements IRecipeFactory public class ShulkerBoxRecipeFactory implements IRecipeFactory
{ {
@Override @Override

View File

@ -114,7 +114,8 @@ public class ContainerIronChest extends Container
{ {
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
{ {
this.addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10)); this.addSlotToContainer(
new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
} }
} }

View File

@ -53,7 +53,9 @@ public class ContainerIronShulkerBox extends Container
{ {
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
{ {
//@formatter:off
this.addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10)); this.addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
//@formatter:on
} }
} }

View File

@ -27,6 +27,8 @@ public class ValidatingShulkerBoxSlot extends Slot
@Override @Override
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack)
{ {
//@formatter:off
return !(Block.getBlockFromItem(stack.getItem()) instanceof BlockIronShulkerBox) && !(Block.getBlockFromItem(stack.getItem()) instanceof BlockShulkerBox); return !(Block.getBlockFromItem(stack.getItem()) instanceof BlockIronShulkerBox) && !(Block.getBlockFromItem(stack.getItem()) instanceof BlockShulkerBox);
//@formatter:on
} }
} }

View File

@ -6,11 +6,6 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.items; package cpw.mods.ironchest.common.items;
import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.items.chest.ItemChestChanger;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;
import static cpw.mods.ironchest.common.blocks.chest.IronChestType.COPPER; import static cpw.mods.ironchest.common.blocks.chest.IronChestType.COPPER;
import static cpw.mods.ironchest.common.blocks.chest.IronChestType.CRYSTAL; import static cpw.mods.ironchest.common.blocks.chest.IronChestType.CRYSTAL;
import static cpw.mods.ironchest.common.blocks.chest.IronChestType.DIAMOND; import static cpw.mods.ironchest.common.blocks.chest.IronChestType.DIAMOND;
@ -20,6 +15,11 @@ import static cpw.mods.ironchest.common.blocks.chest.IronChestType.OBSIDIAN;
import static cpw.mods.ironchest.common.blocks.chest.IronChestType.SILVER; import static cpw.mods.ironchest.common.blocks.chest.IronChestType.SILVER;
import static cpw.mods.ironchest.common.blocks.chest.IronChestType.WOOD; import static cpw.mods.ironchest.common.blocks.chest.IronChestType.WOOD;
import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.items.chest.ItemChestChanger;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;
public enum ChestChangerType public enum ChestChangerType
{ {
//@formatter:off //@formatter:off

View File

@ -6,11 +6,6 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.items; package cpw.mods.ironchest.common.items;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.items.shulker.ItemShulkerBoxChanger;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;
import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.COPPER; import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.COPPER;
import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.CRYSTAL; import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.CRYSTAL;
import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.DIAMOND; import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.DIAMOND;
@ -20,6 +15,11 @@ import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.OBSIDI
import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.SILVER; import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.SILVER;
import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.VANILLA; import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.VANILLA;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.items.shulker.ItemShulkerBoxChanger;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;
public enum ShulkerBoxChangerType public enum ShulkerBoxChangerType
{ {
//@formatter:off //@formatter:off

View File

@ -10,6 +10,8 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.items.chest; package cpw.mods.ironchest.common.items.chest;
import java.util.Locale;
import cpw.mods.ironchest.common.blocks.chest.BlockIronChest; import cpw.mods.ironchest.common.blocks.chest.BlockIronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.core.IronChestBlocks; import cpw.mods.ironchest.common.core.IronChestBlocks;
@ -30,8 +32,6 @@ 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;
import java.util.Locale;
public class ItemChestChanger extends ItemTooltip public class ItemChestChanger extends ItemTooltip
{ {
public final ChestChangerType type; public final ChestChangerType type;
@ -48,7 +48,9 @@ public class ItemChestChanger extends ItemTooltip
* Called when a Block is right-clicked with this Item * Called when a Block is right-clicked with this Item
*/ */
@Override @Override
//@formatter:off
public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
//@formatter:on
{ {
ItemStack itemstack = playerIn.getHeldItem(hand); ItemStack itemstack = playerIn.getHeldItem(hand);
@ -79,8 +81,6 @@ public class ItemChestChanger extends ItemTooltip
NonNullList<ItemStack> chestContents = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY); NonNullList<ItemStack> chestContents = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY);
EnumFacing chestFacing = EnumFacing.DOWN; EnumFacing chestFacing = EnumFacing.DOWN;
boolean hasCustomName = false;
String customName = "";
if (te != null) if (te != null)
{ {
@ -88,13 +88,6 @@ public class ItemChestChanger extends ItemTooltip
{ {
chestContents = ((TileEntityIronChest) te).getItems(); chestContents = ((TileEntityIronChest) te).getItems();
chestFacing = ((TileEntityIronChest) te).getFacing(); chestFacing = ((TileEntityIronChest) te).getFacing();
if (((TileEntityIronChest) te).hasCustomName())
{
hasCustomName = true;
customName = ((TileEntityIronChest) te).getName();
}
newchest = this.type.target.makeEntity(); newchest = this.type.target.makeEntity();
if (newchest == null) if (newchest == null)
@ -124,12 +117,6 @@ public class ItemChestChanger extends ItemTooltip
chestContents.set(i, chest.getStackInSlot(i)); chestContents.set(i, chest.getStackInSlot(i));
} }
if (chest.hasCustomName())
{
hasCustomName = true;
customName = chest.getName();
}
newchest = this.type.target.makeEntity(); newchest = this.type.target.makeEntity();
} }
} }
@ -157,11 +144,6 @@ public class ItemChestChanger extends ItemTooltip
{ {
((TileEntityIronChest) te2).setContents(chestContents); ((TileEntityIronChest) te2).setContents(chestContents);
((TileEntityIronChest) te2).setFacing(chestFacing); ((TileEntityIronChest) te2).setFacing(chestFacing);
if (hasCustomName)
{
((TileEntityIronChest) te2).setCustomName(customName);
}
} }
if (!playerIn.capabilities.isCreativeMode) if (!playerIn.capabilities.isCreativeMode)

View File

@ -10,13 +10,13 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.items.chest; package cpw.mods.ironchest.common.items.chest;
import java.util.Locale;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.Locale;
public class ItemIronChest extends ItemBlock public class ItemIronChest extends ItemBlock
{ {
public ItemIronChest(Block block) public ItemIronChest(Block block)

View File

@ -10,14 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.items.shulker; package cpw.mods.ironchest.common.items.shulker;
import java.util.Locale;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.Locale;
public class ItemIronShulkerBox extends ItemBlock public class ItemIronShulkerBox extends ItemBlock
{ {
private final String colorName; private final String colorName;

View File

@ -10,6 +10,8 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.items.shulker; package cpw.mods.ironchest.common.items.shulker;
import java.util.Locale;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.core.IronChestCreativeTabs; import cpw.mods.ironchest.common.core.IronChestCreativeTabs;
@ -32,8 +34,6 @@ 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;
import java.util.Locale;
public class ItemShulkerBoxChanger extends ItemTooltip public class ItemShulkerBoxChanger extends ItemTooltip
{ {
public final ShulkerBoxChangerType type; public final ShulkerBoxChangerType type;
@ -88,7 +88,9 @@ public class ItemShulkerBoxChanger extends ItemTooltip
* Called when a Block is right-clicked with this Item * Called when a Block is right-clicked with this Item
*/ */
@Override @Override
//@formatter:off
public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
//@formatter:on
{ {
ItemStack itemstack = playerIn.getHeldItem(hand); ItemStack itemstack = playerIn.getHeldItem(hand);
@ -128,8 +130,6 @@ public class ItemShulkerBoxChanger extends ItemTooltip
NonNullList<ItemStack> shulkerBoxContents = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY); NonNullList<ItemStack> shulkerBoxContents = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY);
EnumFacing shulkerBoxFacing = EnumFacing.UP; EnumFacing shulkerBoxFacing = EnumFacing.UP;
EnumDyeColor shulkerBoxColor = EnumDyeColor.PURPLE; EnumDyeColor shulkerBoxColor = EnumDyeColor.PURPLE;
boolean hasCustomName = false;
String customName = "";
if (te != null) if (te != null)
{ {
@ -140,12 +140,6 @@ public class ItemShulkerBoxChanger extends ItemTooltip
shulkerBoxColor = getColorFromTileEntity(te, worldIn); shulkerBoxColor = getColorFromTileEntity(te, worldIn);
((TileEntityIronShulkerBox) te).setHasBeenUpgraded(); ((TileEntityIronShulkerBox) te).setHasBeenUpgraded();
if (((TileEntityIronShulkerBox) te).hasCustomName())
{
hasCustomName = true;
customName = ((TileEntityIronShulkerBox) te).getName();
}
newShulkerBox = this.type.target.makeEntity(shulkerBoxColor); newShulkerBox = this.type.target.makeEntity(shulkerBoxColor);
if (newShulkerBox == null) if (newShulkerBox == null)
@ -171,12 +165,6 @@ public class ItemShulkerBoxChanger extends ItemTooltip
shulkerBoxContents.set(i, shulkerBox.getStackInSlot(i)); shulkerBoxContents.set(i, shulkerBox.getStackInSlot(i));
} }
if (shulkerBox.hasCustomName())
{
hasCustomName = true;
customName = shulkerBox.getName();
}
shulkerBoxColor = getColorFromTileEntity(te, worldIn); shulkerBoxColor = getColorFromTileEntity(te, worldIn);
shulkerBox.clear(); shulkerBox.clear();
@ -214,11 +202,6 @@ public class ItemShulkerBoxChanger extends ItemTooltip
{ {
((TileEntityIronShulkerBox) te2).setContents(shulkerBoxContents); ((TileEntityIronShulkerBox) te2).setContents(shulkerBoxContents);
((TileEntityIronShulkerBox) te2).setFacing(shulkerBoxFacing); ((TileEntityIronShulkerBox) te2).setFacing(shulkerBoxFacing);
if (hasCustomName)
{
((TileEntityIronShulkerBox) te2).setCustomName(customName);
}
} }
if (!playerIn.capabilities.isCreativeMode) if (!playerIn.capabilities.isCreativeMode)

View File

@ -1,6 +1,9 @@
package cpw.mods.ironchest.common.lib; package cpw.mods.ironchest.common.lib;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import cpw.mods.ironchest.common.core.IronChestBlocks; import cpw.mods.ironchest.common.core.IronChestBlocks;
import cpw.mods.ironchest.common.util.BehaviorDispenseIronShulkerBox; import cpw.mods.ironchest.common.util.BehaviorDispenseIronShulkerBox;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -9,8 +12,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import java.util.List;
public class BlockLists public class BlockLists
{ {
//@formatter:off //@formatter:off

View File

@ -8,14 +8,14 @@
package cpw.mods.ironchest.common.lib; package cpw.mods.ironchest.common.lib;
import javax.annotation.Nonnull;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest; import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
public class ICChestInventoryHandler implements IItemHandlerModifiable public class ICChestInventoryHandler implements IItemHandlerModifiable
{ {
TileEntityIronChest inv; TileEntityIronChest inv;
@ -41,36 +41,29 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
{ {
if (stack.isEmpty()) if (stack.isEmpty())
{
return stack; return stack;
}
stack = stack.copy(); stack = stack.copy();
if (!this.inv.isItemValidForSlot(slot, stack)) if (!inv.isItemValidForSlot(slot, stack))
{
return stack; return stack;
}
ItemStack currentStack = this.inv.getItems().get(slot); int offsetSlot = slot;
ItemStack currentStack = inv.getItems().get(offsetSlot);
if (currentStack.isEmpty()) if (currentStack.isEmpty())
{ {
int accepted = Math.min(stack.getMaxStackSize(), this.inv.getInventoryStackLimit()); int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit());
if (accepted < stack.getCount()) if (accepted < stack.getCount())
{ {
if (!simulate) if (!simulate)
{ {
this.inv.getItems().set(slot, stack.splitStack(accepted)); inv.getItems().set(offsetSlot, stack.splitStack(accepted));
this.inv.markDirty(); inv.markDirty();
return stack; return stack;
} }
else else
{ {
stack.shrink(accepted); stack.shrink(accepted);
return stack; return stack;
} }
} }
@ -78,21 +71,18 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
{ {
if (!simulate) if (!simulate)
{ {
this.inv.getItems().set(slot, stack); inv.getItems().set(offsetSlot, stack);
this.inv.markDirty(); inv.markDirty();
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }
else else
{ {
int accepted = Math.min(stack.getMaxStackSize(), this.inv.getInventoryStackLimit()) - currentStack.getCount(); int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
if (accepted <= 0 || !ItemHandlerHelper.canItemStacksStack(stack, currentStack)) if (accepted <= 0 || !ItemHandlerHelper.canItemStacksStack(stack, currentStack))
{
return stack; return stack;
}
if (accepted < stack.getCount()) if (accepted < stack.getCount())
{ {
@ -100,15 +90,13 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
{ {
ItemStack newStack = stack.splitStack(accepted); ItemStack newStack = stack.splitStack(accepted);
newStack.grow(currentStack.getCount()); newStack.grow(currentStack.getCount());
this.inv.getItems().set(slot, newStack); inv.getItems().set(offsetSlot, newStack);
this.inv.markDirty(); inv.markDirty();
return stack; return stack;
} }
else else
{ {
stack.shrink(accepted); stack.shrink(accepted);
return stack; return stack;
} }
} }
@ -118,10 +106,9 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
{ {
ItemStack newStack = stack.copy(); ItemStack newStack = stack.copy();
newStack.grow(currentStack.getCount()); newStack.grow(currentStack.getCount());
this.inv.getItems().set(slot, newStack); inv.getItems().set(offsetSlot, newStack);
this.inv.markDirty(); inv.markDirty();
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }
@ -131,55 +118,45 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
public ItemStack extractItem(int slot, int amount, boolean simulate) public ItemStack extractItem(int slot, int amount, boolean simulate)
{ {
if (amount == 0) if (amount == 0)
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
ItemStack currentStack = this.inv.getItems().get(slot); int offsetSlot = slot;
ItemStack currentStack = inv.getItems().get(offsetSlot);
if (currentStack.isEmpty()) if (currentStack.isEmpty())
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
int extracted = Math.min(currentStack.getCount(), amount); int extracted = Math.min(currentStack.getCount(), amount);
ItemStack copy = currentStack.copy(); ItemStack copy = currentStack.copy();
copy.setCount(extracted); copy.setCount(extracted);
if (!simulate) if (!simulate)
{ {
if (extracted < currentStack.getCount()) if (extracted < currentStack.getCount())
{
currentStack.shrink(extracted); currentStack.shrink(extracted);
}
else else
{
currentStack = ItemStack.EMPTY; currentStack = ItemStack.EMPTY;
inv.getItems().set(offsetSlot, currentStack);
inv.markDirty();
} }
this.inv.getItems().set(slot, currentStack);
this.inv.markDirty();
}
return copy; return copy;
} }
@Override @Override
public int getSlotLimit(int slot) public int getSlotLimit(int slot)
{ {
return this.getInv().getInventoryStackLimit(); return getInv().getInventoryStackLimit();
} }
@Override @Override
public void setStackInSlot(int slot, @Nonnull ItemStack stack) public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{ {
this.inv.getItems().set(slot, stack); inv.getItems().set(slot, stack);
this.inv.markDirty(); inv.markDirty();
} }
public IInventory getInv() public IInventory getInv()
{ {
return this.inv; return inv;
} }
} }

View File

@ -8,14 +8,14 @@
package cpw.mods.ironchest.common.lib; package cpw.mods.ironchest.common.lib;
import javax.annotation.Nonnull;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox; import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
public class ICShulkerInventoryHandler implements IItemHandlerModifiable public class ICShulkerInventoryHandler implements IItemHandlerModifiable
{ {
TileEntityIronShulkerBox inv; TileEntityIronShulkerBox inv;
@ -41,36 +41,29 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
{ {
if (stack.isEmpty()) if (stack.isEmpty())
{
return stack; return stack;
}
stack = stack.copy(); stack = stack.copy();
if (!this.inv.isItemValidForSlot(slot, stack)) if (!inv.isItemValidForSlot(slot, stack))
{
return stack; return stack;
}
ItemStack currentStack = this.inv.getItems().get(slot); int offsetSlot = slot;
ItemStack currentStack = inv.getItems().get(offsetSlot);
if (currentStack.isEmpty()) if (currentStack.isEmpty())
{ {
int accepted = Math.min(stack.getMaxStackSize(), this.inv.getInventoryStackLimit()); int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit());
if (accepted < stack.getCount()) if (accepted < stack.getCount())
{ {
if (!simulate) if (!simulate)
{ {
this.inv.getItems().set(slot, stack.splitStack(accepted)); inv.getItems().set(offsetSlot, stack.splitStack(accepted));
this.inv.markDirty(); inv.markDirty();
return stack; return stack;
} }
else else
{ {
stack.shrink(accepted); stack.shrink(accepted);
return stack; return stack;
} }
} }
@ -78,21 +71,18 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
{ {
if (!simulate) if (!simulate)
{ {
this.inv.getItems().set(slot, stack); inv.getItems().set(offsetSlot, stack);
this.inv.markDirty(); inv.markDirty();
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }
else else
{ {
int accepted = Math.min(stack.getMaxStackSize(), this.inv.getInventoryStackLimit()) - currentStack.getCount(); int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
if (accepted <= 0 || !ItemHandlerHelper.canItemStacksStack(stack, currentStack)) if (accepted <= 0 || !ItemHandlerHelper.canItemStacksStack(stack, currentStack))
{
return stack; return stack;
}
if (accepted < stack.getCount()) if (accepted < stack.getCount())
{ {
@ -100,15 +90,13 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
{ {
ItemStack newStack = stack.splitStack(accepted); ItemStack newStack = stack.splitStack(accepted);
newStack.grow(currentStack.getCount()); newStack.grow(currentStack.getCount());
this.inv.getItems().set(slot, newStack); inv.getItems().set(offsetSlot, newStack);
this.inv.markDirty(); inv.markDirty();
return stack; return stack;
} }
else else
{ {
stack.shrink(accepted); stack.shrink(accepted);
return stack; return stack;
} }
} }
@ -118,10 +106,9 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
{ {
ItemStack newStack = stack.copy(); ItemStack newStack = stack.copy();
newStack.grow(currentStack.getCount()); newStack.grow(currentStack.getCount());
this.inv.getItems().set(slot, newStack); inv.getItems().set(offsetSlot, newStack);
this.inv.markDirty(); inv.markDirty();
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }
@ -131,55 +118,45 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
public ItemStack extractItem(int slot, int amount, boolean simulate) public ItemStack extractItem(int slot, int amount, boolean simulate)
{ {
if (amount == 0) if (amount == 0)
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
ItemStack currentStack = this.inv.getItems().get(slot); int offsetSlot = slot;
ItemStack currentStack = inv.getItems().get(offsetSlot);
if (currentStack.isEmpty()) if (currentStack.isEmpty())
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
int extracted = Math.min(currentStack.getCount(), amount); int extracted = Math.min(currentStack.getCount(), amount);
ItemStack copy = currentStack.copy(); ItemStack copy = currentStack.copy();
copy.setCount(extracted); copy.setCount(extracted);
if (!simulate) if (!simulate)
{ {
if (extracted < currentStack.getCount()) if (extracted < currentStack.getCount())
{
currentStack.shrink(extracted); currentStack.shrink(extracted);
}
else else
{
currentStack = ItemStack.EMPTY; currentStack = ItemStack.EMPTY;
inv.getItems().set(offsetSlot, currentStack);
inv.markDirty();
} }
this.inv.getItems().set(slot, currentStack);
this.inv.markDirty();
}
return copy; return copy;
} }
@Override @Override
public int getSlotLimit(int slot) public int getSlotLimit(int slot)
{ {
return this.getInv().getInventoryStackLimit(); return getInv().getInventoryStackLimit();
} }
@Override @Override
public void setStackInSlot(int slot, @Nonnull ItemStack stack) public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{ {
this.inv.getItems().set(slot, stack); inv.getItems().set(slot, stack);
this.inv.markDirty(); inv.markDirty();
} }
public IInventory getInv() public IInventory getInv()
{ {
return this.inv; return inv;
} }
} }

View File

@ -11,7 +11,6 @@
package cpw.mods.ironchest.common.network; package cpw.mods.ironchest.common.network;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityCrystalChest;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest; import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -27,21 +26,14 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class MessageCrystalChestSync implements IMessage public class MessageCrystalChestSync implements IMessage
{ {
int dimension; int dimension;
BlockPos pos; BlockPos pos;
private NonNullList<ItemStack> topStacks; private NonNullList<ItemStack> topStacks;
public MessageCrystalChestSync(int dimensionId, BlockPos tilePos, NonNullList<ItemStack> stackList) public MessageCrystalChestSync(TileEntityIronChest tile, NonNullList<ItemStack> stack)
{ {
this.dimension = dimensionId; this.dimension = tile.getWorld().provider.getDimension();
this.pos = tilePos; this.pos = tile.getPos();
this.topStacks = stackList; this.topStacks = stack;
}
public MessageCrystalChestSync(TileEntityIronChest tile, NonNullList<ItemStack> stacklist)
{
this(tile.getWorld().provider.getDimension(), tile.getPos(), stacklist);
} }
public MessageCrystalChestSync() public MessageCrystalChestSync()
@ -91,10 +83,8 @@ public class MessageCrystalChestSync implements IMessage
{ {
TileEntity tile = world.getTileEntity(message.pos); TileEntity tile = world.getTileEntity(message.pos);
if (tile instanceof TileEntityCrystalChest) if (tile instanceof TileEntityIronChest)
{ ((TileEntityIronChest) tile).receiveMessageFromServer(message.topStacks);
((TileEntityCrystalChest) tile).receiveMessageFromServer(message.topStacks);
}
} }
return null; return null;

View File

@ -11,7 +11,6 @@
package cpw.mods.ironchest.common.network; package cpw.mods.ironchest.common.network;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityCrystalShulkerBox;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox; import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -32,16 +31,11 @@ public class MessageCrystalShulkerSync implements IMessage
private NonNullList<ItemStack> topStacks; private NonNullList<ItemStack> topStacks;
public MessageCrystalShulkerSync(int dimensionId, BlockPos tilePos, NonNullList<ItemStack> stackList) public MessageCrystalShulkerSync(TileEntityIronShulkerBox tile, NonNullList<ItemStack> stack)
{ {
this.dimension = dimensionId; this.dimension = tile.getWorld().provider.getDimension();
this.pos = tilePos; this.pos = tile.getPos();
this.topStacks = stackList; this.topStacks = stack;
}
public MessageCrystalShulkerSync(TileEntityIronShulkerBox tile, NonNullList<ItemStack> stacklist)
{
this(tile.getWorld().provider.getDimension(), tile.getPos(), stacklist);
} }
public MessageCrystalShulkerSync() public MessageCrystalShulkerSync()
@ -91,10 +85,8 @@ public class MessageCrystalShulkerSync implements IMessage
{ {
TileEntity tile = world.getTileEntity(message.pos); TileEntity tile = world.getTileEntity(message.pos);
if (tile instanceof TileEntityCrystalShulkerBox) if (tile instanceof TileEntityIronShulkerBox)
{ ((TileEntityIronShulkerBox) tile).receiveMessageFromServer(message.topStacks);
((TileEntityCrystalShulkerBox) tile).receiveMessageFromServer(message.topStacks);
}
} }
return null; return null;

View File

@ -10,238 +10,16 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.chest; package cpw.mods.ironchest.common.tileentity.chest;
import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.network.MessageCrystalChestSync;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import java.util.Collections;
public class TileEntityCrystalChest extends TileEntityIronChest public class TileEntityCrystalChest extends TileEntityIronChest
{ {
/** Crystal Chest top stacks */
private NonNullList<ItemStack> topStacks;
/** If the inventory got touched */
private boolean inventoryTouched;
/** If the inventory had items */
private boolean hadStuff;
public TileEntityCrystalChest() public TileEntityCrystalChest()
{ {
super(IronChestType.CRYSTAL); super(IronChestType.CRYSTAL);
this.topStacks = NonNullList.<ItemStack>withSize(8, ItemStack.EMPTY);
}
public NonNullList<ItemStack> getTopItems()
{
return this.topStacks;
}
@Override
public void setContents(NonNullList<ItemStack> contents)
{
super.setContents(contents);
this.inventoryTouched = true;
}
@Override
public ItemStack getStackInSlot(int index)
{
this.fillWithLoot((EntityPlayer) null);
this.inventoryTouched = true;
return this.getItems().get(index);
}
@Override
public void markDirty()
{
super.markDirty();
this.sortTopStacks();
}
@Override
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
this.sortTopStacks();
}
@Override
public void update()
{
super.update();
if (!this.world.isRemote && this.inventoryTouched)
{
this.inventoryTouched = false;
this.sortTopStacks();
}
}
protected void sortTopStacks()
{
if (!this.getType().isTransparent() || (this.world != null && this.world.isRemote))
{
return;
}
NonNullList<ItemStack> tempCopy = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
boolean hasStuff = false;
int compressedIdx = 0;
mainLoop:
for (int i = 0; i < this.getSizeInventory(); i++)
{
ItemStack itemStack = this.getItems().get(i);
if (!itemStack.isEmpty())
{
for (int j = 0; j < compressedIdx; j++)
{
ItemStack tempCopyStack = tempCopy.get(j);
if (ItemStack.areItemsEqualIgnoreDurability(tempCopyStack, itemStack))
{
if (itemStack.getCount() != tempCopyStack.getCount())
{
tempCopyStack.grow(itemStack.getCount());
}
continue mainLoop;
}
}
tempCopy.set(compressedIdx, itemStack.copy());
compressedIdx++;
hasStuff = true;
}
}
if (!hasStuff && this.hadStuff)
{
this.hadStuff = false;
for (int i = 0; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
if (this.world != null)
{
IBlockState iblockstate = this.world.getBlockState(this.pos);
this.world.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
}
return;
}
this.hadStuff = true;
Collections.sort(tempCopy, (stack1, stack2) -> {
if (stack1.isEmpty())
{
return 1;
}
else if (stack2.isEmpty())
{
return -1;
}
else
{
return stack2.getCount() - stack1.getCount();
}
});
int p = 0;
for (ItemStack element : tempCopy)
{
if (!element.isEmpty() && element.getCount() > 0)
{
if (p == this.getTopItems().size())
{
break;
}
this.getTopItems().set(p, element);
p++;
}
}
for (int i = p; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
if (this.world != null)
{
IBlockState iblockstate = this.world.getBlockState(this.pos);
this.world.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
}
this.sendTopStacksPacket();
}
public NonNullList<ItemStack> buildItemStackDataList()
{
if (this.getType().isTransparent())
{
NonNullList<ItemStack> sortList = NonNullList.<ItemStack>withSize(this.getTopItems().size(), ItemStack.EMPTY);
int pos = 0;
for (ItemStack is : this.topStacks)
{
if (!is.isEmpty())
{
sortList.set(pos, is);
}
else
{
sortList.set(pos, ItemStack.EMPTY);
}
pos++;
}
return sortList;
}
return NonNullList.<ItemStack>withSize(this.getTopItems().size(), ItemStack.EMPTY);
}
protected void sendTopStacksPacket()
{
NonNullList<ItemStack> stacks = this.buildItemStackDataList();
IronChest.packetHandler.sendToAllAround(new MessageCrystalChestSync(this.getWorld().provider.getDimension(), this.getPos(), stacks), new NetworkRegistry.TargetPoint(world.provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 128));
}
public void receiveMessageFromServer(NonNullList<ItemStack> topStacks)
{
this.topStacks = topStacks;
} }
public static void registerFixesChest(DataFixer fixer) public static void registerFixesChest(DataFixer fixer)

View File

@ -10,11 +10,16 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.chest; package cpw.mods.ironchest.common.tileentity.chest;
import java.util.Collections;
import java.util.Comparator;
import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.blocks.chest.BlockIronChest; import cpw.mods.ironchest.common.blocks.chest.BlockIronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.core.IronChestBlocks; import cpw.mods.ironchest.common.core.IronChestBlocks;
import cpw.mods.ironchest.common.gui.chest.ContainerIronChest; import cpw.mods.ironchest.common.gui.chest.ContainerIronChest;
import cpw.mods.ironchest.common.lib.ICChestInventoryHandler; import cpw.mods.ironchest.common.lib.ICChestInventoryHandler;
import cpw.mods.ironchest.common.network.MessageCrystalChestSync;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -37,6 +42,7 @@ import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@ -45,6 +51,9 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
/** Chest Contents */ /** Chest Contents */
public NonNullList<ItemStack> chestContents; public NonNullList<ItemStack> chestContents;
/** Crystal Chest top stacks */
private NonNullList<ItemStack> topStacks;
/** The current angle of the lid (between 0 and 1) */ /** The current angle of the lid (between 0 and 1) */
public float lidAngle; public float lidAngle;
@ -60,6 +69,12 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
/** Direction chest is facing */ /** Direction chest is facing */
private EnumFacing facing; private EnumFacing facing;
/** If the inventory got touched */
private boolean inventoryTouched;
/** If the inventory had items */
private boolean hadStuff;
private String customName; private String customName;
private IronChestType chestType; private IronChestType chestType;
@ -73,13 +88,14 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
{ {
super(); super();
this.chestType = type; this.chestType = type;
this.chestContents = NonNullList.withSize(type.size, ItemStack.EMPTY); this.chestContents = NonNullList.<ItemStack> withSize(type.size, ItemStack.EMPTY);
this.topStacks = NonNullList.<ItemStack> withSize(8, ItemStack.EMPTY);
this.facing = EnumFacing.NORTH; this.facing = EnumFacing.NORTH;
} }
public void setContents(NonNullList<ItemStack> contents) public void setContents(NonNullList<ItemStack> contents)
{ {
this.chestContents = NonNullList.withSize(this.getType().size, ItemStack.EMPTY); this.chestContents = NonNullList.<ItemStack> withSize(this.getType().size, ItemStack.EMPTY);
for (int i = 0; i < contents.size(); i++) for (int i = 0; i < contents.size(); i++)
{ {
@ -88,6 +104,8 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
this.getItems().set(i, contents.get(i)); this.getItems().set(i, contents.get(i));
} }
} }
this.inventoryTouched = true;
} }
@Override @Override
@ -121,7 +139,9 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
@Override @Override
public ItemStack getStackInSlot(int index) public ItemStack getStackInSlot(int index)
{ {
this.fillWithLoot(null); this.fillWithLoot((EntityPlayer) null);
this.inventoryTouched = true;
return this.getItems().get(index); return this.getItems().get(index);
} }
@ -130,6 +150,124 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
public void markDirty() public void markDirty()
{ {
super.markDirty(); super.markDirty();
this.sortTopStacks();
}
protected void sortTopStacks()
{
if (!this.getType().isTransparent() || (this.world != null && this.world.isRemote))
{
return;
}
NonNullList<ItemStack> tempCopy = NonNullList.<ItemStack> withSize(this.getSizeInventory(), ItemStack.EMPTY);
boolean hasStuff = false;
int compressedIdx = 0;
mainLoop:
for (int i = 0; i < this.getSizeInventory(); i++)
{
ItemStack itemStack = this.getItems().get(i);
if (!itemStack.isEmpty())
{
for (int j = 0; j < compressedIdx; j++)
{
ItemStack tempCopyStack = tempCopy.get(j);
if (ItemStack.areItemsEqualIgnoreDurability(tempCopyStack, itemStack))
{
if (itemStack.getCount() != tempCopyStack.getCount())
{
tempCopyStack.grow(itemStack.getCount());
}
continue mainLoop;
}
}
tempCopy.set(compressedIdx, itemStack.copy());
compressedIdx++;
hasStuff = true;
}
}
if (!hasStuff && this.hadStuff)
{
this.hadStuff = false;
for (int i = 0; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
if (this.world != null)
{
IBlockState iblockstate = this.world.getBlockState(this.pos);
this.world.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
}
return;
}
this.hadStuff = true;
Collections.sort(tempCopy, new Comparator<ItemStack>()
{
@Override
public int compare(ItemStack stack1, ItemStack stack2)
{
if (stack1.isEmpty())
{
return 1;
}
else if (stack2.isEmpty())
{
return -1;
}
else
{
return stack2.getCount() - stack1.getCount();
}
}
});
int p = 0;
for (ItemStack element : tempCopy)
{
if (!element.isEmpty() && element.getCount() > 0)
{
if (p == this.getTopItems().size())
{
break;
}
this.getTopItems().set(p, element);
p++;
}
}
for (int i = p; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
if (this.world != null)
{
IBlockState iblockstate = this.world.getBlockState(this.pos);
this.world.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
}
sendTopStacksPacket();
} }
@Override @Override
@ -155,7 +293,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
{ {
super.readFromNBT(compound); super.readFromNBT(compound);
this.chestContents = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); this.chestContents = NonNullList.<ItemStack> withSize(this.getSizeInventory(), ItemStack.EMPTY);
if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING))
{ {
@ -168,6 +306,8 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
this.facing = EnumFacing.VALUES[compound.getByte("facing")]; this.facing = EnumFacing.VALUES[compound.getByte("facing")];
this.sortTopStacks();
} }
@Override @Override
@ -215,17 +355,18 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
@Override @Override
public void update() public void update()
{ {
int x = this.pos.getX();
int y = this.pos.getY();
int z = this.pos.getZ();
++this.ticksSinceSync;
// Resynchronizes clients with the server state // Resynchronizes clients with the server state
if (this.world != null && !this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + x + y + z) % 200 == 0) //@formatter:off
if (this.world != null && !this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.pos.getX() + this.pos.getY() + this.pos.getZ()) % 200 == 0)
//@formatter:on
{ {
this.numPlayersUsing = 0; this.numPlayersUsing = 0;
for (EntityPlayer player : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(x - 5.0F, y - 5.0F, z - 5.0F, x + 1 + 5.0F, y + 1 + 5.0F, z + 1 + 5.0F))) float f = 5.0F;
//@formatter:off
for (EntityPlayer player : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.pos.getX() - f, this.pos.getY() - f, this.pos.getZ() - f, this.pos.getX() + 1 + f, this.pos.getY() + 1 + f, this.pos.getZ() + 1 + f)))
//@formatter:on
{ {
if (player.openContainer instanceof ContainerIronChest) if (player.openContainer instanceof ContainerIronChest)
{ {
@ -239,16 +380,26 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
this.world.addBlockEvent(this.pos, IronChestBlocks.ironChestBlock, 3, ((this.numPlayersUsing << 3) & 0xF8) | (this.facing.ordinal() & 0x7)); this.world.addBlockEvent(this.pos, IronChestBlocks.ironChestBlock, 3, ((this.numPlayersUsing << 3) & 0xF8) | (this.facing.ordinal() & 0x7));
} }
if (!this.world.isRemote && this.inventoryTouched)
{
this.inventoryTouched = false;
this.sortTopStacks();
}
this.ticksSinceSync++;
this.prevLidAngle = this.lidAngle; this.prevLidAngle = this.lidAngle;
float angle = 0.1F; float angle = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F) if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
{ {
double soundX = x + 0.5D; double x = this.pos.getX() + 0.5D;
double soundY = y + 0.5D; double y = this.pos.getY() + 0.5D;
double soundZ = z + 0.5D; double z = this.pos.getZ() + 0.5D;
this.world.playSound(null, soundX, soundY, soundZ, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); this.world.playSound(null, x, y, z, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
} }
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
@ -273,11 +424,11 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
if (this.lidAngle < maxAngle && currentAngle >= maxAngle) if (this.lidAngle < maxAngle && currentAngle >= maxAngle)
{ {
double soundX = x + 0.5D; double x = this.pos.getX() + 0.5D;
double soundY = y + 0.5D; double y = this.pos.getY() + 0.5D;
double soundZ = z + 0.5D; double z = this.pos.getZ() + 0.5D;
this.world.playSound(null, soundX, soundY, soundZ, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); this.world.playSound(null, x, y, z, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
} }
if (this.lidAngle < 0.0F) if (this.lidAngle < 0.0F)
@ -304,7 +455,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
this.numPlayersUsing = (type & 0xF8) >> 3; this.numPlayersUsing = (type & 0xF8) >> 3;
} }
return super.receiveClientEvent(id, type); return true;
} }
@Override @Override
@ -312,6 +463,11 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
{ {
if (!player.isSpectator()) if (!player.isSpectator())
{ {
if (this.world == null)
{
return;
}
if (this.numPlayersUsing < 0) if (this.numPlayersUsing < 0)
{ {
this.numPlayersUsing = 0; this.numPlayersUsing = 0;
@ -321,6 +477,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
this.world.addBlockEvent(this.pos, IronChestBlocks.ironChestBlock, 1, this.numPlayersUsing); this.world.addBlockEvent(this.pos, IronChestBlocks.ironChestBlock, 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, IronChestBlocks.ironChestBlock, false); this.world.notifyNeighborsOfStateChange(this.pos, IronChestBlocks.ironChestBlock, false);
this.world.notifyNeighborsOfStateChange(this.pos.down(), IronChestBlocks.ironChestBlock, false);
} }
} }
@ -329,10 +486,16 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
{ {
if (!player.isSpectator()) if (!player.isSpectator())
{ {
if (this.world == null)
{
return;
}
--this.numPlayersUsing; --this.numPlayersUsing;
this.world.addBlockEvent(this.pos, IronChestBlocks.ironChestBlock, 1, this.numPlayersUsing); this.world.addBlockEvent(this.pos, IronChestBlocks.ironChestBlock, 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, IronChestBlocks.ironChestBlock, false); this.world.notifyNeighborsOfStateChange(this.pos, IronChestBlocks.ironChestBlock, false);
this.world.notifyNeighborsOfStateChange(this.pos.down(), IronChestBlocks.ironChestBlock, false);
} }
} }
@ -362,6 +525,34 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
} }
public NonNullList<ItemStack> buildItemStackDataList()
{
if (this.getType().isTransparent())
{
NonNullList<ItemStack> sortList = NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
int pos = 0;
for (ItemStack is : this.topStacks)
{
if (!is.isEmpty())
{
sortList.set(pos, is);
}
else
{
sortList.set(pos, ItemStack.EMPTY);
}
pos++;
}
return sortList;
}
return NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
}
@Override @Override
public boolean isItemValidForSlot(int index, ItemStack stack) public boolean isItemValidForSlot(int index, ItemStack stack)
{ {
@ -407,19 +598,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
public NBTTagCompound getUpdateTag() public NBTTagCompound getUpdateTag()
{ {
NBTTagCompound compound = super.getUpdateTag(); NBTTagCompound compound = super.getUpdateTag();
if (!this.checkLootAndWrite(compound))
{
ItemStackHelper.saveAllItems(compound, this.chestContents);
}
compound.setByte("facing", (byte) this.facing.ordinal()); compound.setByte("facing", (byte) this.facing.ordinal());
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
return compound; return compound;
} }
@ -429,6 +608,11 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
return this.chestContents; return this.chestContents;
} }
public NonNullList<ItemStack> getTopItems()
{
return this.topStacks;
}
@Override @Override
public boolean isEmpty() public boolean isEmpty()
{ {
@ -443,18 +627,29 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
return true; return true;
} }
protected void sendTopStacksPacket()
{
NonNullList<ItemStack> stacks = this.buildItemStackDataList();
//@formatter:off
IronChest.packetHandler.sendToAllAround(new MessageCrystalChestSync(this, stacks), new TargetPoint(world.provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 128));
//@formatter:on
}
public void receiveMessageFromServer(NonNullList<ItemStack> topStacks)
{
this.topStacks = topStacks;
}
public static void registerFixesChest(DataFixer fixer) public static void registerFixesChest(DataFixer fixer)
{ {
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronChest.class, "Items")); fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronChest.class, new String[] { "Items" }));
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) public boolean hasCapability(Capability<?> capability, EnumFacing facing)
{ {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
{
return true; return true;
}
return super.hasCapability(capability, facing); return super.hasCapability(capability, facing);
} }
@ -471,9 +666,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
public <T> T getCapability(Capability<T> capability, EnumFacing facing) public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{ {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
{ return (T) (itemHandler == null ? (itemHandler = createUnSidedHandler()) : itemHandler);
return (T) (this.itemHandler == null ? (this.itemHandler = this.createUnSidedHandler()) : this.itemHandler);
}
return super.getCapability(capability, facing); return super.getCapability(capability, facing);
} }
} }

View File

@ -10,14 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import javax.annotation.Nullable;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import javax.annotation.Nullable;
public class TileEntityCopperShulkerBox extends TileEntityIronShulkerBox public class TileEntityCopperShulkerBox extends TileEntityIronShulkerBox
{ {
public TileEntityCopperShulkerBox() public TileEntityCopperShulkerBox()

View File

@ -10,32 +10,16 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import cpw.mods.ironchest.IronChest; import javax.annotation.Nullable;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.network.MessageCrystalShulkerSync;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import javax.annotation.Nullable;
import java.util.Collections;
public class TileEntityCrystalShulkerBox extends TileEntityIronShulkerBox public class TileEntityCrystalShulkerBox extends TileEntityIronShulkerBox
{ {
/** Crystal Shulker Boxes top stacks */
private NonNullList<ItemStack> topStacks;
/** If the inventory got touched */
private boolean inventoryTouched;
/** If the inventory had items */
private boolean hadStuff;
public TileEntityCrystalShulkerBox() public TileEntityCrystalShulkerBox()
{ {
this(null); this(null);
@ -44,199 +28,10 @@ public class TileEntityCrystalShulkerBox extends TileEntityIronShulkerBox
public TileEntityCrystalShulkerBox(@Nullable EnumDyeColor colorIn) public TileEntityCrystalShulkerBox(@Nullable EnumDyeColor colorIn)
{ {
super(colorIn, IronShulkerBoxType.CRYSTAL); super(colorIn, IronShulkerBoxType.CRYSTAL);
this.topStacks = NonNullList.withSize(8, ItemStack.EMPTY);
}
@Override
public void setContents(NonNullList<ItemStack> contents)
{
super.setContents(contents);
this.inventoryTouched = true;
}
@Override
public ItemStack getStackInSlot(int index)
{
this.fillWithLoot(null);
this.inventoryTouched = true;
return this.getItems().get(index);
}
@Override
public void markDirty()
{
super.markDirty();
this.sortTopStacks();
}
@Override
public void loadFromNbt(NBTTagCompound compound)
{
super.loadFromNbt(compound);
this.sortTopStacks();
}
@Override
public void update()
{
super.update();
if (!this.world.isRemote && this.inventoryTouched)
{
this.inventoryTouched = false;
this.sortTopStacks();
}
}
protected void sortTopStacks()
{
if (!this.getType().isTransparent() || (this.world != null && this.world.isRemote))
{
return;
}
NonNullList<ItemStack> tempCopy = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
boolean hasStuff = false;
int compressedIdx = 0;
mainLoop:
for (int i = 0; i < this.getSizeInventory(); i++)
{
ItemStack itemStack = this.getItems().get(i);
if (!itemStack.isEmpty())
{
for (int j = 0; j < compressedIdx; j++)
{
ItemStack tempCopyStack = tempCopy.get(j);
if (ItemStack.areItemsEqualIgnoreDurability(tempCopyStack, itemStack))
{
if (itemStack.getCount() != tempCopyStack.getCount())
{
tempCopyStack.grow(itemStack.getCount());
}
continue mainLoop;
}
}
tempCopy.set(compressedIdx, itemStack.copy());
compressedIdx++;
hasStuff = true;
}
}
if (!hasStuff && this.hadStuff)
{
this.hadStuff = false;
for (int i = 0; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
return;
}
this.hadStuff = true;
Collections.sort(tempCopy, (stack1, stack2) -> {
if (stack1.isEmpty())
{
return 1;
}
else if (stack2.isEmpty())
{
return -1;
}
else
{
return stack2.getCount() - stack1.getCount();
}
});
int p = 0;
for (ItemStack element : tempCopy)
{
if (!element.isEmpty() && element.getCount() > 0)
{
if (p == this.getTopItems().size())
{
break;
}
this.getTopItems().set(p, element);
p++;
}
}
for (int i = p; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
this.sendTopStacksPacket();
}
public NonNullList<ItemStack> getTopItems()
{
return this.topStacks;
}
public NonNullList<ItemStack> buildItemStackDataList()
{
if (this.getType().isTransparent())
{
NonNullList<ItemStack> sortList = NonNullList.withSize(this.getTopItems().size(), ItemStack.EMPTY);
int pos = 0;
for (ItemStack is : this.topStacks)
{
if (!is.isEmpty())
{
sortList.set(pos, is);
}
else
{
sortList.set(pos, ItemStack.EMPTY);
}
pos++;
}
return sortList;
}
return NonNullList.withSize(this.getTopItems().size(), ItemStack.EMPTY);
}
protected void sendTopStacksPacket()
{
NonNullList<ItemStack> stacks = this.buildItemStackDataList();
IronChest.packetHandler.sendToAllAround(new MessageCrystalShulkerSync(this.getWorld().provider.getDimension(), this.getPos(), stacks), new NetworkRegistry.TargetPoint(this.world.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 128));
}
public void receiveMessageFromServer(NonNullList<ItemStack> topStacks)
{
this.topStacks = topStacks;
} }
public static void registerFixesShulkerBox(DataFixer fixer) public static void registerFixesShulkerBox(DataFixer fixer)
{ {
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityCrystalShulkerBox.class, "Items")); fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityCrystalShulkerBox.class, new String[] { "Items" }));
} }
} }

View File

@ -10,14 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import javax.annotation.Nullable;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import javax.annotation.Nullable;
public class TileEntityDiamondShulkerBox extends TileEntityIronShulkerBox public class TileEntityDiamondShulkerBox extends TileEntityIronShulkerBox
{ {
public TileEntityDiamondShulkerBox() public TileEntityDiamondShulkerBox()

View File

@ -10,14 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import javax.annotation.Nullable;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import javax.annotation.Nullable;
public class TileEntityGoldShulkerBox extends TileEntityIronShulkerBox public class TileEntityGoldShulkerBox extends TileEntityIronShulkerBox
{ {
public TileEntityGoldShulkerBox() public TileEntityGoldShulkerBox()

View File

@ -10,10 +10,18 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.annotation.Nullable;
import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.gui.shulker.ContainerIronShulkerBox; import cpw.mods.ironchest.common.gui.shulker.ContainerIronShulkerBox;
import cpw.mods.ironchest.common.lib.ICShulkerInventoryHandler; import cpw.mods.ironchest.common.lib.ICShulkerInventoryHandler;
import cpw.mods.ironchest.common.network.MessageCrystalShulkerSync;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockShulkerBox; import net.minecraft.block.BlockShulkerBox;
import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.EnumPushReaction;
@ -42,14 +50,12 @@ import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
import java.util.List;
public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements ITickable, ISidedInventory public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements ITickable, ISidedInventory
{ {
private final int[] SLOTS; private final int[] SLOTS;
@ -57,12 +63,21 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
/** Shulker Box Contents */ /** Shulker Box Contents */
private NonNullList<ItemStack> items; private NonNullList<ItemStack> items;
/** Crystal Shulker Boxes top stacks */
private NonNullList<ItemStack> topStacks;
/** Direction Shulker ox is facing */ /** Direction Shulker ox is facing */
private EnumFacing facing; private EnumFacing facing;
/** If the inventory got touched */
private boolean inventoryTouched;
/** Server sync counter (once per 20 ticks) */ /** Server sync counter (once per 20 ticks) */
private int ticksSinceSync; private int ticksSinceSync;
/** If the inventory had items */
private boolean hadStuff;
private boolean hasBeenCleared; private boolean hasBeenCleared;
private int openCount; private int openCount;
@ -100,7 +115,8 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
this.SLOTS = new int[typeIn.size]; this.SLOTS = new int[typeIn.size];
this.items = NonNullList.withSize(typeIn.size, ItemStack.EMPTY); this.items = NonNullList.<ItemStack> withSize(typeIn.size, ItemStack.EMPTY);
this.topStacks = NonNullList.<ItemStack> withSize(8, ItemStack.EMPTY);
this.animationStatus = AnimationStatus.CLOSED; this.animationStatus = AnimationStatus.CLOSED;
this.color = colorIn; this.color = colorIn;
@ -112,7 +128,7 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
public void setContents(NonNullList<ItemStack> contents) public void setContents(NonNullList<ItemStack> contents)
{ {
this.items = NonNullList.withSize(this.getType().size, ItemStack.EMPTY); this.items = NonNullList.<ItemStack> withSize(this.getType().size, ItemStack.EMPTY);
for (int i = 0; i < contents.size(); i++) for (int i = 0; i < contents.size(); i++)
{ {
@ -121,6 +137,8 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
this.getItems().set(i, contents.get(i)); this.getItems().set(i, contents.get(i));
} }
} }
this.inventoryTouched = true;
} }
@Override @Override
@ -154,7 +172,9 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
@Override @Override
public ItemStack getStackInSlot(int index) public ItemStack getStackInSlot(int index)
{ {
this.fillWithLoot(null); this.fillWithLoot((EntityPlayer) null);
this.inventoryTouched = true;
return this.getItems().get(index); return this.getItems().get(index);
} }
@ -163,6 +183,110 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
public void markDirty() public void markDirty()
{ {
super.markDirty(); super.markDirty();
this.sortTopStacks();
}
protected void sortTopStacks()
{
if (!this.getType().isTransparent() || (this.world != null && this.world.isRemote))
{
return;
}
NonNullList<ItemStack> tempCopy = NonNullList.<ItemStack> withSize(this.getSizeInventory(), ItemStack.EMPTY);
boolean hasStuff = false;
int compressedIdx = 0;
mainLoop:
for (int i = 0; i < this.getSizeInventory(); i++)
{
ItemStack itemStack = this.getItems().get(i);
if (!itemStack.isEmpty())
{
for (int j = 0; j < compressedIdx; j++)
{
ItemStack tempCopyStack = tempCopy.get(j);
if (ItemStack.areItemsEqualIgnoreDurability(tempCopyStack, itemStack))
{
if (itemStack.getCount() != tempCopyStack.getCount())
{
tempCopyStack.grow(itemStack.getCount());
}
continue mainLoop;
}
}
tempCopy.set(compressedIdx, itemStack.copy());
compressedIdx++;
hasStuff = true;
}
}
if (!hasStuff && this.hadStuff)
{
this.hadStuff = false;
for (int i = 0; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
return;
}
this.hadStuff = true;
Collections.sort(tempCopy, new Comparator<ItemStack>()
{
@Override
public int compare(ItemStack stack1, ItemStack stack2)
{
if (stack1.isEmpty())
{
return 1;
}
else if (stack2.isEmpty())
{
return -1;
}
else
{
return stack2.getCount() - stack1.getCount();
}
}
});
int p = 0;
for (ItemStack element : tempCopy)
{
if (!element.isEmpty() && element.getCount() > 0)
{
if (p == this.getTopItems().size())
{
break;
}
this.getTopItems().set(p, element);
p++;
}
}
for (int i = p; i < this.getTopItems().size(); i++)
{
this.getTopItems().set(i, ItemStack.EMPTY);
}
sendTopStacksPacket();
} }
/** /**
@ -192,7 +316,7 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
public void loadFromNbt(NBTTagCompound compound) public void loadFromNbt(NBTTagCompound compound)
{ {
this.items = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); this.items = NonNullList.<ItemStack> withSize(this.getSizeInventory(), ItemStack.EMPTY);
if (!this.checkLootAndRead(compound) && compound.hasKey("Items", 9)) if (!this.checkLootAndRead(compound) && compound.hasKey("Items", 9))
{ {
@ -205,6 +329,8 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
} }
this.facing = EnumFacing.VALUES[compound.getByte("facing")]; this.facing = EnumFacing.VALUES[compound.getByte("facing")];
this.sortTopStacks();
} }
public NBTTagCompound saveToNbt(NBTTagCompound compound) public NBTTagCompound saveToNbt(NBTTagCompound compound)
@ -258,6 +384,13 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
this.world.addBlockEvent(this.pos, this.getBlockType(), 3, ((this.openCount << 3) & 0xF8) | (this.facing.ordinal() & 0x7)); this.world.addBlockEvent(this.pos, this.getBlockType(), 3, ((this.openCount << 3) & 0xF8) | (this.facing.ordinal() & 0x7));
} }
if (!this.world.isRemote && this.inventoryTouched)
{
this.inventoryTouched = false;
this.sortTopStacks();
}
this.ticksSinceSync++; this.ticksSinceSync++;
} }
@ -328,7 +461,7 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
{ {
EnumFacing enumfacing = this.getFacing(); EnumFacing enumfacing = this.getFacing();
AxisAlignedBB axisalignedbb = this.getTopBoundingBox(enumfacing).offset(this.pos); AxisAlignedBB axisalignedbb = this.getTopBoundingBox(enumfacing).offset(this.pos);
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb); List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity((Entity) null, axisalignedbb);
if (!list.isEmpty()) if (!list.isEmpty())
{ {
@ -385,7 +518,9 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
d2 = d2 + 0.01D; d2 = d2 + 0.01D;
} }
//@formatter:off
entity.move(MoverType.SHULKER_BOX, d0 * enumfacing.getFrontOffsetX(), d1 * enumfacing.getFrontOffsetY(), d2 * enumfacing.getFrontOffsetZ()); entity.move(MoverType.SHULKER_BOX, d0 * enumfacing.getFrontOffsetX(), d1 * enumfacing.getFrontOffsetY(), d2 * enumfacing.getFrontOffsetZ());
//@formatter:on
} }
} }
} }
@ -447,7 +582,9 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
if (this.openCount == 1) if (this.openCount == 1)
{ {
this.world.playSound(null, this.pos, SoundEvents.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); //@formatter:off
this.world.playSound((EntityPlayer) null, this.pos, SoundEvents.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
//@formatter:on
} }
} }
} }
@ -463,7 +600,9 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
if (this.openCount <= 0) if (this.openCount <= 0)
{ {
this.world.playSound(null, this.pos, SoundEvents.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); //@formatter:off
this.world.playSound((EntityPlayer) null, this.pos, SoundEvents.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
//@formatter:on
} }
} }
} }
@ -495,6 +634,34 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
} }
} }
public NonNullList<ItemStack> buildItemStackDataList()
{
if (this.getType().isTransparent())
{
NonNullList<ItemStack> sortList = NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
int pos = 0;
for (ItemStack is : this.topStacks)
{
if (!is.isEmpty())
{
sortList.set(pos, is);
}
else
{
sortList.set(pos, ItemStack.EMPTY);
}
pos++;
}
return sortList;
}
return NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
}
@Override @Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{ {
@ -519,19 +686,7 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
public NBTTagCompound getUpdateTag() public NBTTagCompound getUpdateTag()
{ {
NBTTagCompound compound = super.getUpdateTag(); NBTTagCompound compound = super.getUpdateTag();
if (!this.checkLootAndWrite(compound))
{
ItemStackHelper.saveAllItems(compound, this.items, false);
}
compound.setByte("facing", (byte) this.facing.ordinal()); compound.setByte("facing", (byte) this.facing.ordinal());
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
return compound; return compound;
} }
@ -541,6 +696,11 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
return this.items; return this.items;
} }
public NonNullList<ItemStack> getTopItems()
{
return this.topStacks;
}
@Override @Override
public boolean isEmpty() public boolean isEmpty()
{ {
@ -558,7 +718,7 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
@Override @Override
public int[] getSlotsForFace(EnumFacing side) public int[] getSlotsForFace(EnumFacing side)
{ {
return this.SLOTS; return SLOTS;
} }
/** /**
@ -661,14 +821,27 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
public enum AnimationStatus protected void sendTopStacksPacket()
{ {
CLOSED, OPENING, OPENED, CLOSING NonNullList<ItemStack> stacks = this.buildItemStackDataList();
//@formatter:off
IronChest.packetHandler.sendToAllAround(new MessageCrystalShulkerSync(this, stacks), new TargetPoint(world.provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 128));
//@formatter:on
}
public void receiveMessageFromServer(NonNullList<ItemStack> topStacks)
{
this.topStacks = topStacks;
}
public static enum AnimationStatus
{
CLOSED, OPENING, OPENED, CLOSING;
} }
public static void registerFixesShulkerBox(DataFixer fixer) public static void registerFixesShulkerBox(DataFixer fixer)
{ {
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronShulkerBox.class, "Items")); fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronShulkerBox.class, new String[] { "Items" }));
} }
private IItemHandler itemHandler; private IItemHandler itemHandler;
@ -684,9 +857,7 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
public <T> T getCapability(Capability<T> capability, EnumFacing facing) public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{ {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
{ return (T) (itemHandler == null ? (itemHandler = createUnSidedHandler()) : itemHandler);
return (T) (this.itemHandler == null ? (this.itemHandler = this.createUnSidedHandler()) : this.itemHandler);
}
return super.getCapability(capability, facing); return super.getCapability(capability, facing);
} }

View File

@ -10,14 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import javax.annotation.Nullable;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import javax.annotation.Nullable;
public class TileEntityObsidianShulkerBox extends TileEntityIronShulkerBox public class TileEntityObsidianShulkerBox extends TileEntityIronShulkerBox
{ {
public TileEntityObsidianShulkerBox() public TileEntityObsidianShulkerBox()

View File

@ -10,14 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.tileentity.shulker; package cpw.mods.ironchest.common.tileentity.shulker;
import javax.annotation.Nullable;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import javax.annotation.Nullable;
public class TileEntitySilverShulkerBox extends TileEntityIronShulkerBox public class TileEntitySilverShulkerBox extends TileEntityIronShulkerBox
{ {
public TileEntitySilverShulkerBox() public TileEntitySilverShulkerBox()

View File

@ -10,7 +10,12 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.util; package cpw.mods.ironchest.common.util;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -20,9 +25,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class ItemTooltip extends Item public class ItemTooltip extends Item
{ {
@ -56,9 +58,7 @@ public class ItemTooltip extends Item
{ {
List<String> list = Lists.newLinkedList(); List<String> list = Lists.newLinkedList();
if (text == null) if (text == null)
{
return list; return list;
}
int j = 0; int j = 0;
int k; int k;
while ((k = text.indexOf("\\n", j)) >= 0) while ((k = text.indexOf("\\n", j)) >= 0)

View File

@ -10,6 +10,8 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.util; package cpw.mods.ironchest.common.util;
import javax.annotation.Nonnull;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -18,8 +20,6 @@ import net.minecraftforge.event.RegistryEvent.MissingMappings.Mapping;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.ForgeRegistries;
import javax.annotation.Nonnull;
public class MissingMappingsHandler public class MissingMappingsHandler
{ {
@SubscribeEvent @SubscribeEvent

View File

@ -10,6 +10,8 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common.util; package cpw.mods.ironchest.common.util;
import java.util.HashSet;
import cpw.mods.ironchest.common.ai.IronChestAIOcelotSit; import cpw.mods.ironchest.common.ai.IronChestAIOcelotSit;
import net.minecraft.entity.ai.EntityAIOcelotSit; import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
@ -17,8 +19,6 @@ import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.HashSet;
public class OcelotsSitOnChestsHandler public class OcelotsSitOnChestsHandler
{ {
@SubscribeEvent @SubscribeEvent