Update Iron Chests to 1.14.2!

This commit is contained in:
alexbegt 2019-06-15 21:18:15 -04:00
parent d9b9654775
commit 21310672a8
88 changed files with 2699 additions and 1997 deletions

View File

@ -4,15 +4,15 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Mod Version Information
mod_version=8.0
mod_version=9.0
# Minecraft Version Information
minecraft_version=1.13.2
minecraft_version_toml=13
minecraft_version=1.14.2
minecraft_version_toml=14
# Forge Version Information
forge_version=25.0.34
forge_version_toml=25
forge_version=26.0.16
forge_version_toml=26
# Mappings Information
mappings_version=20190215-1.13.1
mappings_version=20190609-1.14.2

View File

@ -12,13 +12,12 @@ package com.progwml6.ironchest;
import com.progwml6.ironchest.client.ClientProxy;
import com.progwml6.ironchest.common.ServerProxy;
import com.progwml6.ironchest.common.ai.OcelotsSitOnChestsHandler;
import com.progwml6.ironchest.common.ai.CatsSitOnChestsHandler;
import com.progwml6.ironchest.common.inventory.ChestContainerType;
import com.progwml6.ironchest.common.network.PacketHandler;
import com.progwml6.ironchest.common.gui.GuiHandler;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@ -36,14 +35,15 @@ public class IronChest
{
instance = this;
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::preInit);
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> GuiHandler::openGui);
MinecraftForge.EVENT_BUS.register(new CatsSitOnChestsHandler());
}
private void preInit(final FMLCommonSetupEvent event)
{
proxy.preInit();
DistExecutor.runWhenOn(Dist.CLIENT, () -> ChestContainerType::registerScreenFactories);
PacketHandler.register();
}
}

View File

@ -10,9 +10,9 @@
******************************************************************************/
package com.progwml6.ironchest.client;
import com.progwml6.ironchest.client.renderer.TileEntityIronChestRenderer;
import com.progwml6.ironchest.client.renderer.IronChestTileEntityRenderer;
import com.progwml6.ironchest.common.ServerProxy;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import net.minecraft.client.Minecraft;
import net.minecraft.world.World;
import net.minecraftforge.fml.client.registry.ClientRegistry;
@ -30,11 +30,11 @@ public class ClientProxy extends ServerProxy
{
super.preInit();
for (IronChestType type : IronChestType.values())
for (ChestType type : ChestType.values())
{
if (type.clazz != null)
{
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronChestRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new IronChestTileEntityRenderer());
}
}
}

View File

@ -1,137 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.client.gui;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.gui.ContainerIronChest;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GUIChest extends GuiContainer
{
public enum ResourceList
{
IRON(new ResourceLocation("ironchest", "textures/gui/iron_container.png")),
COPPER(new ResourceLocation("ironchest", "textures/gui/copper_container.png")),
SILVER(new ResourceLocation("ironchest", "textures/gui/silver_container.png")),
GOLD(new ResourceLocation("ironchest", "textures/gui/gold_container.png")),
DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamond_container.png")),
DIRT(new ResourceLocation("ironchest", "textures/gui/dirt_container.png"));
public final ResourceLocation location;
ResourceList(ResourceLocation loc)
{
this.location = loc;
}
}
public enum GUI
{
IRON(184, 202, ResourceList.IRON, IronChestType.IRON, new ResourceLocation("ironchest:iron")),
GOLD(184, 256, ResourceList.GOLD, IronChestType.GOLD, new ResourceLocation("ironchest:gold")),
DIAMOND(238, 256, ResourceList.DIAMOND, IronChestType.DIAMOND, new ResourceLocation("ironchest:diamond")),
COPPER(184, 184, ResourceList.COPPER, IronChestType.COPPER, new ResourceLocation("ironchest:copper")),
SILVER(184, 238, ResourceList.SILVER, IronChestType.SILVER, new ResourceLocation("ironchest:silver")),
CRYSTAL(238, 256, ResourceList.DIAMOND, IronChestType.CRYSTAL, new ResourceLocation("ironchest:diamond")),
OBSIDIAN(238, 256, ResourceList.DIAMOND, IronChestType.OBSIDIAN, new ResourceLocation("ironchest:obsidian")),
DIRTCHEST9000(184, 184, ResourceList.DIRT, IronChestType.DIRTCHEST9000, new ResourceLocation("ironchest:dirt"));
private int xSize;
private int ySize;
private ResourceList guiResourceList;
private IronChestType mainType;
private ResourceLocation guiId;
GUI(int xSize, int ySize, ResourceList guiResourceList, IronChestType mainType, ResourceLocation guiId)
{
this.xSize = xSize;
this.ySize = ySize;
this.guiResourceList = guiResourceList;
this.mainType = mainType;
this.guiId = guiId;
}
protected Container makeContainer(IInventory playerInventory, IInventory chestInventory, EntityPlayer player)
{
return new ContainerIronChest(playerInventory, chestInventory, this.mainType, player, this.xSize, this.ySize);
}
public ResourceLocation getGuiId()
{
return this.guiId;
}
}
private GUI type;
private final IInventory upperChestInventory;
private final IInventory lowerChestInventory;
public GUIChest(GUI type, IInventory playerInventory, IInventory chestInventory)
{
super(type.makeContainer(playerInventory, chestInventory, Minecraft.getInstance().player));
this.type = type;
this.xSize = type.xSize;
this.ySize = type.ySize;
this.upperChestInventory = playerInventory;
this.lowerChestInventory = chestInventory;
this.allowUserInput = false;
}
/**
* Draws the screen and all the components in it.
*/
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
super.render(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
}
/*
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRenderer.drawString(this.lowerChestInventory.getDisplayName().getString(), 8.0F, 6.0F, 4210752);
this.fontRenderer.drawString(this.upperChestInventory.getDisplayName().getString(), 8.0F, this.ySize - 96 + 2, 4210752);
}*/
/**
* Draws the background layer of this container (behind the items).
*/
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(this.type.guiResourceList.location);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
}

View File

@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.client.inventory;
import com.mojang.blaze3d.platform.GlStateManager;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.client.gui.IHasContainer;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ChestScreen extends ContainerScreen<ChestContainer> implements IHasContainer<ChestContainer>
{
private ChestType chestType;
private int textureXSize;
private int textureYSize;
public ChestScreen(ChestContainer container, PlayerInventory playerInventory, ITextComponent title)
{
super(container, playerInventory, title);
this.chestType = container.getChestType();
this.xSize = container.getChestType().xSize;
this.ySize = container.getChestType().ySize;
this.textureXSize = container.getChestType().textureXSize;
this.textureYSize = container.getChestType().textureYSize;
this.passEvents = false;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.renderBackground();
super.render(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.font.drawString(this.title.getFormattedText(), 8.0F, 6.0F, 4210752);
this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float) (this.ySize - 96 + 2), 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.minecraft.getTextureManager().bindTexture(this.chestType.guiTexture);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.blit(x, y, 0, 0, this.xSize, this.ySize, textureXSize, textureYSize);
}
}

View File

@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.client.renderer;
import com.progwml6.ironchest.common.blocks.ChestBlock;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.tileentity.CopperChestTileEntity;
import com.progwml6.ironchest.common.tileentity.CrystalChestTileEntity;
import com.progwml6.ironchest.common.tileentity.DiamondChestTileEntity;
import com.progwml6.ironchest.common.tileentity.DirtChestTileEntity;
import com.progwml6.ironchest.common.tileentity.GoldChestTileEntity;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import com.progwml6.ironchest.common.tileentity.ObsidianChestTileEntity;
import com.progwml6.ironchest.common.tileentity.SilverChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class IronChestItemStackTileEntityRenderer extends ItemStackTileEntityRenderer
{
private static final IronChestTileEntity IRON_CHEST = new IronChestTileEntity();
private static final GoldChestTileEntity GOLD_CHEST = new GoldChestTileEntity();
private static final DiamondChestTileEntity DIAMOND_CHEST = new DiamondChestTileEntity();
private static final CopperChestTileEntity COPPER_CHEST = new CopperChestTileEntity();
private static final SilverChestTileEntity SILVER_CHEST = new SilverChestTileEntity();
private static final CrystalChestTileEntity CRYSTAL_CHEST = new CrystalChestTileEntity();
private static final ObsidianChestTileEntity OBSIDIAN_CHEST = new ObsidianChestTileEntity();
private static final DirtChestTileEntity DIRT_CHEST = new DirtChestTileEntity();
private static final IronChestTileEntity[] CHESTS = { IRON_CHEST, GOLD_CHEST, DIAMOND_CHEST, COPPER_CHEST, SILVER_CHEST, CRYSTAL_CHEST, OBSIDIAN_CHEST, DIRT_CHEST };
public static IronChestItemStackTileEntityRenderer instance = new IronChestItemStackTileEntityRenderer();
@Override
public void renderByItem(ItemStack itemStackIn)
{
Item item = itemStackIn.getItem();
if (Block.getBlockFromItem(item) instanceof ChestBlock)
{
ChestType typeOut = ChestBlock.getTypeFromItem(item);
if (typeOut == null)
{
TileEntityRendererDispatcher.instance.renderAsItem(IRON_CHEST);
}
else
{
TileEntityRendererDispatcher.instance.renderAsItem(CHESTS[typeOut.ordinal()]);
}
}
else
{
super.renderByItem(itemStackIn);
}
}
}

View File

@ -0,0 +1,216 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.client.renderer;
import com.google.common.primitives.SignedBytes;
import com.mojang.blaze3d.platform.GlStateManager;
import com.progwml6.ironchest.common.blocks.ChestBlock;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.tileentity.CrystalChestTileEntity;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.model.ChestModel;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.IChestLid;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Random;
@OnlyIn(Dist.CLIENT)
public class IronChestTileEntityRenderer<T extends TileEntity & IChestLid> extends TileEntityRenderer<T>
{
private final ChestModel chestModel = new ChestModel();
private static ItemEntity customItem;
private Random random = new Random();
private ItemRenderer itemRenderer;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F } };
@Override
public void render(T tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage)
{
GlStateManager.enableDepthTest();
GlStateManager.depthFunc(515);
GlStateManager.depthMask(true);
IronChestTileEntity tileEntity = (IronChestTileEntity) tileEntityIn;
BlockState blockstate = tileEntity.hasWorld() ? tileEntity.getBlockState() : (BlockState) tileEntity.getBlockToUse().getDefaultState().with(ChestBlock.FACING, Direction.SOUTH);
ChestType chestType = ChestType.IRON;
ChestType actualType = ChestBlock.getTypeFromBlock(blockstate.getBlock());
if (actualType != null)
{
chestType = actualType;
}
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scalef(4.0F, 4.0F, 1.0F);
GlStateManager.translatef(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
}
else
{
this.bindTexture(new ResourceLocation("ironchest", "textures/model/" + chestType.modelTexture));
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
GlStateManager.pushMatrix();
if (chestType == ChestType.CRYSTAL)
{
GlStateManager.disableCull();
}
GlStateManager.enableRescaleNormal();
GlStateManager.translatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
GlStateManager.scalef(1.0F, -1.0F, -1.0F);
float f = blockstate.get(ChestBlock.FACING).getHorizontalAngle();
if ((double) Math.abs(f) > 1.0E-5D)
{
GlStateManager.translatef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(f, 0.0F, 1.0F, 0.0F);
GlStateManager.translatef(-0.5F, -0.5F, -0.5F);
}
if (chestType.isTransparent())
{
GlStateManager.scalef(1F, 0.99F, 1F);
}
this.rotateChestLid(tileEntityIn, partialTicks, this.chestModel);
this.chestModel.renderAll();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
if (chestType == ChestType.CRYSTAL)
{
GlStateManager.enableCull();
}
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
if (this.rendererDispatcher.renderInfo != null)
{
if (chestType.isTransparent() && tileEntity.getDistanceSq(this.rendererDispatcher.renderInfo.func_216785_c().x, this.rendererDispatcher.renderInfo.func_216785_c().y, this.rendererDispatcher.renderInfo.func_216785_c().z) < 128d)
{
this.random.setSeed(254L);
float shiftX;
float shiftY;
float shiftZ;
int shift = 0;
float blockScale = 0.70F;
float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks;
if (((CrystalChestTileEntity) tileEntity).getTopItems().get(1).isEmpty())
{
shift = 8;
blockScale = 0.85F;
}
GlStateManager.pushMatrix();
GlStateManager.translatef((float) x, (float) y, (float) z);
if (customItem == null)
{
customItem = new ItemEntity(EntityType.ITEM, this.getWorld());
}
for (ItemStack item : ((CrystalChestTileEntity) tileEntity).getTopItems())
{
if (shift > shifts.length || shift > 8)
{
break;
}
if (item.isEmpty())
{
shift++;
continue;
}
shiftX = shifts[shift][0];
shiftY = shifts[shift][1];
shiftZ = shifts[shift][2];
shift++;
GlStateManager.pushMatrix();
GlStateManager.translatef(shiftX, shiftY, shiftZ);
GlStateManager.rotatef(timeD, 0F, 1F, 0F);
GlStateManager.scalef(blockScale, blockScale, blockScale);
customItem.setItem(item);
if (this.itemRenderer == null)
{
this.itemRenderer = new ItemRenderer(Minecraft.getInstance().getRenderManager(), Minecraft.getInstance().getItemRenderer())
{
@Override
public int getModelCount(ItemStack stack)
{
return SignedBytes.saturatedCast(Math.min(stack.getCount() / 32, 15) + 1);
}
@Override
public boolean shouldBob()
{
return false;
}
@Override
public boolean shouldSpreadItems()
{
return true;
}
};
}
this.itemRenderer.doRender(customItem, 0D, 0D, 0D, 0F, partialTicks);
GlStateManager.popMatrix();
}
GlStateManager.popMatrix();
}
}
}
private void rotateChestLid(T tileEntity, float partialTicks, ChestModel chestModel)
{
float f = ((IChestLid) tileEntity).getLidAngle(partialTicks);
f = 1.0F - f;
f = 1.0F - f * f * f;
chestModel.getLid().rotateAngleX = -(f * ((float) Math.PI / 2F));
}
}

View File

@ -1,73 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.client.renderer;
import com.progwml6.ironchest.common.blocks.BlockChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.tileentity.TileEntityCopperChest;
import com.progwml6.ironchest.common.tileentity.TileEntityCrystalChest;
import com.progwml6.ironchest.common.tileentity.TileEntityDiamondChest;
import com.progwml6.ironchest.common.tileentity.TileEntityDirtChest;
import com.progwml6.ironchest.common.tileentity.TileEntityGoldChest;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import com.progwml6.ironchest.common.tileentity.TileEntityObsidianChest;
import com.progwml6.ironchest.common.tileentity.TileEntitySilverChest;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class TileEntityIronChestItemRenderer extends TileEntityItemStackRenderer
{
private static final TileEntityIronChest IRON_CHEST = new TileEntityIronChest();
private static final TileEntityGoldChest GOLD_CHEST = new TileEntityGoldChest();
private static final TileEntityDiamondChest DIAMOND_CHEST = new TileEntityDiamondChest();
private static final TileEntityCopperChest COPPER_CHEST = new TileEntityCopperChest();
private static final TileEntitySilverChest SILVER_CHEST = new TileEntitySilverChest();
private static final TileEntityCrystalChest CRYSTAL_CHEST = new TileEntityCrystalChest();
private static final TileEntityObsidianChest OBSIDIAN_CHEST = new TileEntityObsidianChest();
private static final TileEntityDirtChest DIRT_CHEST = new TileEntityDirtChest();
private static final TileEntityIronChest[] CHESTS = { IRON_CHEST, GOLD_CHEST, DIAMOND_CHEST, COPPER_CHEST, SILVER_CHEST, CRYSTAL_CHEST, OBSIDIAN_CHEST, DIRT_CHEST };
public static TileEntityIronChestItemRenderer instance = new TileEntityIronChestItemRenderer();
@Override
public void renderByItem(ItemStack itemStackIn)
{
Item item = itemStackIn.getItem();
if (Block.getBlockFromItem(item) instanceof BlockChest)
{
IronChestType typeOut = BlockChest.getTypeFromItem(item);
if (typeOut == null)
{
TileEntityRendererDispatcher.instance.renderAsItem(IRON_CHEST);
}
else
{
TileEntityRendererDispatcher.instance.renderAsItem(CHESTS[typeOut.ordinal()]);
}
}
else
{
super.renderByItem(itemStackIn);
}
}
}

View File

@ -1,224 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.client.renderer;
import com.google.common.primitives.SignedBytes;
import com.progwml6.ironchest.common.blocks.BlockChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.tileentity.TileEntityCrystalChest;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.client.renderer.entity.model.ModelChest;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.IChestLid;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import java.util.Random;
public class TileEntityIronChestRenderer<T extends TileEntity & IChestLid> extends TileEntityRenderer<T>
{
private Random random;
private RenderEntityItem itemRenderer;
private ModelChest model;
//@formatter:off
private static float[][] shifts = {
{ 0.3F, 0.45F, 0.3F },
{ 0.7F, 0.45F, 0.3F },
{ 0.3F, 0.45F, 0.7F },
{ 0.7F, 0.45F, 0.7F },
{ 0.3F, 0.1F, 0.3F },
{ 0.7F, 0.1F, 0.3F },
{ 0.3F, 0.1F, 0.7F },
{ 0.7F, 0.1F, 0.7F },
{ 0.5F, 0.32F, 0.5F } };
//@formatter:on
private static EntityItem customitem = new EntityItem(null);
public TileEntityIronChestRenderer()
{
this.model = new ModelChest();
this.random = new Random();
}
@Override
public void render(T tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage)
{
GlStateManager.enableDepthTest();
GlStateManager.depthFunc(515);
GlStateManager.depthMask(true);
TileEntityIronChest tileEntity = (TileEntityIronChest) tileEntityIn;
IBlockState iBlockState = tileEntity.hasWorld() ? tileEntity.getBlockState() : (IBlockState) tileEntity.getBlockToUse().getDefaultState().with(BlockChest.FACING, EnumFacing.NORTH);
IronChestType chestType = IronChestType.IRON;
IronChestType typeNew = BlockChest.getTypeFromBlock(iBlockState.getBlock());
if (typeNew != null)
{
chestType = typeNew;
}
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scalef(4F, 4F, 1F);
GlStateManager.translatef(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
}
else
{
this.bindTexture(chestType.modelTexture);
}
GlStateManager.pushMatrix();
if (chestType == IronChestType.CRYSTAL)
{
GlStateManager.disableCull();
}
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.translatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
GlStateManager.scalef(1.0F, -1.0F, -1.0F);
float f = iBlockState.get(BlockChest.FACING).getHorizontalAngle();
if (Math.abs(f) > 1.0E-5D)
{
GlStateManager.translatef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(f, 0.0F, 1.0F, 0.0F);
GlStateManager.translatef(-0.5F, -0.5F, -0.5F);
}
if (chestType.isTransparent())
{
GlStateManager.scalef(1F, 0.99F, 1F);
}
this.rotateChestLid(tileEntityIn, partialTicks, model);
model.renderAll();
if (chestType == IronChestType.CRYSTAL)
{
GlStateManager.enableCull();
}
GlStateManager.popMatrix();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
if (chestType.isTransparent() && tileEntity.getDistanceSq(this.rendererDispatcher.entityX, this.rendererDispatcher.entityY, this.rendererDispatcher.entityZ) < 128d)
{
this.random.setSeed(254L);
float shiftX;
float shiftY;
float shiftZ;
int shift = 0;
float blockScale = 0.70F;
float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks;
if (((TileEntityCrystalChest) tileEntity).getTopItems().get(1).isEmpty())
{
shift = 8;
blockScale = 0.85F;
}
GlStateManager.pushMatrix();
GlStateManager.translatef((float) x, (float) y, (float) z);
customitem.setWorld(this.getWorld());
customitem.hoverStart = 0F;
for (ItemStack item : ((TileEntityCrystalChest) tileEntity).getTopItems())
{
if (shift > shifts.length || shift > 8)
{
break;
}
if (item.isEmpty())
{
shift++;
continue;
}
shiftX = shifts[shift][0];
shiftY = shifts[shift][1];
shiftZ = shifts[shift][2];
shift++;
GlStateManager.pushMatrix();
GlStateManager.translatef(shiftX, shiftY, shiftZ);
GlStateManager.rotatef(timeD, 0F, 1F, 0F);
GlStateManager.scalef(blockScale, blockScale, blockScale);
customitem.setItem(item);
if (this.itemRenderer == null)
{
this.itemRenderer = new RenderEntityItem(Minecraft.getInstance().getRenderManager(), Minecraft.getInstance().getItemRenderer())
{
@Override
public int getModelCount(ItemStack stack)
{
return SignedBytes.saturatedCast(Math.min(stack.getCount() / 32, 15) + 1);
}
@Override
public boolean shouldBob()
{
return false;
}
@Override
public boolean shouldSpreadItems()
{
return true;
}
};
}
this.itemRenderer.doRender(customitem, 0D, 0D, 0D, 0F, partialTicks);
GlStateManager.popMatrix();
}
GlStateManager.popMatrix();
}
}
private void rotateChestLid(T tileEntityIn, float lidAngleIn, ModelChest modelIn)
{
float f = ((IChestLid) tileEntityIn).getLidAngle(lidAngleIn);
f = 1.0F - f;
f = 1.0F - f * f * f;
modelIn.getLid().rotateAngleX = -(f * ((float) Math.PI / 2F));
}
}

View File

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.ai;
import net.minecraft.entity.ai.goal.CatSitOnBlockGoal;
import net.minecraft.entity.ai.goal.PrioritizedGoal;
import net.minecraft.entity.passive.CatEntity;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.HashSet;
public class CatsSitOnChestsHandler
{
@SubscribeEvent
public void changeSittingTaskForOcelots(final LivingEvent.LivingUpdateEvent evt)
{
/*
if (evt.getEntityLiving().ticksExisted < 5 && evt.getEntityLiving() instanceof CatEntity)
{
HashSet<PrioritizedGoal> goals = new HashSet<>();
CatEntity catEntity = (CatEntity) evt.getEntityLiving();
for (PrioritizedGoal goal : catEntity.goalSelector.goals)
{
if (goal.func_220772_j().getClass() == CatSitOnBlockGoal.class)
{
goals.add(goal);
}
}
for (PrioritizedGoal goal : goals)
{
catEntity.goalSelector.removeGoal(goal.func_220772_j());
catEntity.goalSelector.addGoal(goal.getPriority(), new IronChestCatSitOnBlockGoal1(catEntity, 0.4F));
}
}*/
}
}

View File

@ -10,27 +10,27 @@
******************************************************************************/
package com.progwml6.ironchest.common.ai;
import com.progwml6.ironchest.common.blocks.BlockChest;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import com.progwml6.ironchest.common.blocks.ChestBlock;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.block.BlockState;
import net.minecraft.entity.ai.goal.CatSitOnBlockGoal;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReaderBase;
import net.minecraft.world.IWorldReader;
public class IronChestAIOcelotSit extends EntityAIOcelotSit
public class IronChestCatSitOnBlockGoal extends CatSitOnBlockGoal
{
public IronChestAIOcelotSit(EntityOcelot ocelotIn, float speedIn)
public IronChestCatSitOnBlockGoal(CatEntity catEntity, float speedIn)
{
super(ocelotIn, speedIn);
super(catEntity, speedIn);
}
/**
* Return true to set given position as destination
*/
@Override
protected boolean shouldMoveTo(IWorldReaderBase worldIn, BlockPos pos)
protected boolean shouldMoveTo(IWorldReader worldIn, BlockPos pos)
{
if (!worldIn.isAirBlock(pos.up()))
{
@ -38,12 +38,12 @@ public class IronChestAIOcelotSit extends EntityAIOcelotSit
}
else
{
IBlockState iBlockState = worldIn.getBlockState(pos);
BlockState iBlockState = worldIn.getBlockState(pos);
Block block = iBlockState.getBlock();
if (block instanceof BlockChest)
if (block instanceof ChestBlock)
{
return TileEntityIronChest.getPlayersUsing(worldIn, pos) < 1;
return IronChestTileEntity.getPlayersUsing(worldIn, pos) < 1;
}
return super.shouldMoveTo(worldIn, pos);

View File

@ -1,47 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.ai;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.HashSet;
public class OcelotsSitOnChestsHandler
{
@SubscribeEvent
public void changeSittingTaskForOcelots(final LivingUpdateEvent evt)
{
if (evt.getEntityLiving().ticksExisted < 5 && evt.getEntityLiving() instanceof EntityOcelot)
{
HashSet<EntityAITaskEntry> hashset = new HashSet<EntityAITaskEntry>();
EntityOcelot ocelot = (EntityOcelot) evt.getEntityLiving();
for (EntityAITaskEntry task : ocelot.tasks.taskEntries)
{
if (task.action.getClass() == EntityAIOcelotSit.class)
{
hashset.add(task);
}
}
for (EntityAITaskEntry task : hashset)
{
ocelot.tasks.removeTask(task.action);
ocelot.tasks.addTask(task.priority, new IronChestAIOcelotSit(ocelot, 0.4F));
}
}
}
}

View File

@ -1,293 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Enchantments;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathType;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.INameable;
import net.minecraft.util.Mirror;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
public abstract class BlockChest extends Block
{
public static final DirectionProperty FACING = BlockHorizontal.HORIZONTAL_FACING;
protected static final VoxelShape IRON_CHEST_SHAPE = Block.makeCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 14.0D, 15.0D);
private final IronChestType type;
public BlockChest(Properties propertiesIn, IronChestType typeIn)
{
super(propertiesIn);
this.type = typeIn;
this.setDefaultState((IBlockState) ((IBlockState) this.stateContainer.getBaseState()).with(FACING, EnumFacing.NORTH));
this.setRegistryName(new ResourceLocation(type.itemName));
}
@Override
public VoxelShape getShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return IRON_CHEST_SHAPE;
}
@Override
public boolean isSolid(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean hasCustomBreakingProgress(IBlockState state)
{
return true;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
}
@Override
public IBlockState getStateForPlacement(BlockItemUseContext context)
{
EnumFacing enumfacing = context.getPlacementHorizontalFacing().getOpposite();
return this.getDefaultState().with(FACING, enumfacing);
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity != null && tileentity instanceof TileEntityIronChest)
{
TileEntityIronChest teic = (TileEntityIronChest) tileentity;
teic.wasPlaced(placer, stack);
if (stack.hasDisplayName())
{
teic.setCustomName(stack.getDisplayName());
}
}
}
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getContainer(state, worldIn, pos);
if (ilockablecontainer != null)
{
if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer))
{
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
NetworkHooks.openGui(entityPlayerMP, ilockablecontainer, buf -> buf.writeBlockPos(pos));
}
player.addStat(StatList.OPEN_CHEST);
}
return true;
}
}
@SuppressWarnings("deprecation")
@Override
public void onReplaced(IBlockState state, World worldIn, BlockPos pos, IBlockState newState, boolean isMoving)
{
if (state.getBlock() != newState.getBlock())
{
TileEntityIronChest tileentity = (TileEntityIronChest) worldIn.getTileEntity(pos);
if (tileentity != null)
{
tileentity.removeAdornments();
InventoryHelper.dropInventoryItems(worldIn, pos, tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
@SuppressWarnings("deprecation")
@Override
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param)
{
super.eventReceived(state, worldIn, pos, id, param);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity == null ? false : tileentity.receiveClientEvent(id, param);
}
@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}
@Nullable
public ILockableContainer getContainer(IBlockState state, World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (!(tileentity instanceof TileEntityIronChest))
{
return null;
}
else
{
return (ILockableContainer) tileentity;
}
}
@SuppressWarnings("deprecation")
@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
if (te instanceof INameable && ((INameable) te).hasCustomName())
{
player.addStat(StatList.BLOCK_MINED.get(this));
player.addExhaustion(0.005F);
if (worldIn.isRemote)
{
return;
}
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
Item item = this.getItemDropped(state, worldIn, pos, i).asItem();
if (item == Items.AIR)
{
return;
}
ItemStack itemstack = new ItemStack(item, this.quantityDropped(state, worldIn.rand));
itemstack.setDisplayName(((INameable) te).getCustomName());
spawnAsEntity(worldIn, pos, itemstack);
}
else
{
super.harvestBlock(worldIn, player, pos, state, (TileEntity) null, stack);
}
}
@Override
public boolean hasComparatorInputOverride(IBlockState state)
{
return true;
}
@Override
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
return Container.calcRedstoneFromInventory(this.getContainer(blockState, worldIn, pos));
}
@Override
public IBlockState rotate(IBlockState state, Rotation rot)
{
return (IBlockState) state.with(FACING, rot.rotate((EnumFacing) state.get(FACING)));
}
@Override
public IBlockState mirror(IBlockState state, Mirror mirrorIn)
{
return state.rotate(mirrorIn.toRotation((EnumFacing) state.get(FACING)));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
{
builder.add(FACING);
}
@Override
public BlockFaceShape getBlockFaceShape(IBlockReader worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{
return BlockFaceShape.UNDEFINED;
}
@Override
public boolean allowsMovement(IBlockState state, IBlockReader worldIn, BlockPos pos, PathType type)
{
return false;
}
public static IronChestType getTypeFromItem(Item itemIn)
{
return getTypeFromBlock(Block.getBlockFromItem(itemIn));
}
public static IronChestType getTypeFromBlock(Block blockIn)
{
return blockIn instanceof BlockChest ? ((BlockChest) blockIn).getType() : null;
}
public IronChestType getType()
{
return this.type;
}
}

View File

@ -1,45 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityDirtChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class BlockDirtChest extends BlockChest
{
public BlockDirtChest(Properties properties)
{
super(properties, IronChestType.DIRTCHEST9000);
}
@SuppressWarnings("deprecation")
@Override
public void getDrops(IBlockState state, net.minecraft.util.NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune)
{
ItemStack stack = getItem(world, pos, state);
stack.setTagInfo("dirtchest", new NBTTagByte((byte) 1));
drops.add(stack);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
{
return new TileEntityDirtChest();
}
}

View File

@ -1,30 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityObsidianChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockObsidianChest extends BlockChest
{
public BlockObsidianChest(Properties properties)
{
super(properties, IronChestType.OBSIDIAN);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
{
return new TileEntityObsidianChest();
}
}

View File

@ -1,30 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntitySilverChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockSilverChest extends BlockChest
{
public BlockSilverChest(Properties properties)
{
super(properties, IronChestType.SILVER);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
{
return new TileEntitySilverChest();
}
}

View File

@ -0,0 +1,282 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathType;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.Mirror;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
import java.util.List;
public class ChestBlock extends Block implements IWaterLoggable
{
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
protected static final VoxelShape IRON_CHEST_SHAPE = Block.makeCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 14.0D, 15.0D);
private final ChestType type;
public ChestBlock(Properties properties, ChestType type)
{
super(properties);
this.type = type;
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(WATERLOGGED, Boolean.valueOf(false)));
this.setRegistryName(new ResourceLocation(type.itemName));
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean hasCustomBreakingProgress(BlockState state)
{
return true;
}
@Override
public BlockRenderType getRenderType(BlockState state)
{
return BlockRenderType.ENTITYBLOCK_ANIMATED;
}
@Override
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos)
{
if (stateIn.get(WATERLOGGED))
{
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
}
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader iBlockReader, BlockPos pos, ISelectionContext selectionContext)
{
return IRON_CHEST_SHAPE;
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context)
{
Direction direction = context.getPlacementHorizontalFacing().getOpposite();
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
return this.getDefaultState().with(FACING, direction).with(WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
}
@Override
public IFluidState getFluidState(BlockState state)
{
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof IronChestTileEntity)
{
((IronChestTileEntity) tileentity).wasPlaced(placer, stack);
if (stack.hasDisplayName())
{
((IronChestTileEntity) tileentity).setCustomName(stack.getDisplayName());
}
}
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
{
if (state.getBlock() != newState.getBlock())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof IronChestTileEntity)
{
((IronChestTileEntity) tileentity).removeAdornments();
InventoryHelper.dropInventoryItems(worldIn, pos, (IronChestTileEntity) tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit)
{
if (worldIn.isRemote)
{
return true;
}
else
{
INamedContainerProvider inamedcontainerprovider = this.getContainer(state, worldIn, pos);
if (inamedcontainerprovider != null)
{
player.openContainer(inamedcontainerprovider);
player.addStat(this.getOpenStat());
}
return true;
}
}
protected Stat<ResourceLocation> getOpenStat()
{
return Stats.CUSTOM.get(Stats.OPEN_CHEST);
}
@Override
@Nullable
public INamedContainerProvider getContainer(BlockState state, World world, BlockPos pos)
{
TileEntity tileentity = world.getTileEntity(pos);
return tileentity instanceof INamedContainerProvider ? (INamedContainerProvider) tileentity : null;
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Override
public boolean eventReceived(BlockState state, World worldIn, BlockPos pos, int id, int param)
{
super.eventReceived(state, worldIn, pos, id, param);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity == null ? false : tileentity.receiveClientEvent(id, param);
}
private static boolean isBlocked(IWorld iWorld, BlockPos blockPos)
{
return isBelowSolidBlock(iWorld, blockPos) || isCatSittingOn(iWorld, blockPos);
}
private static boolean isBelowSolidBlock(IBlockReader iBlockReader, BlockPos worldIn)
{
BlockPos blockpos = worldIn.up();
return iBlockReader.getBlockState(blockpos).isNormalCube(iBlockReader, blockpos);
}
private static boolean isCatSittingOn(IWorld iWorld, BlockPos blockPos)
{
List<CatEntity> list = iWorld.getEntitiesWithinAABB(CatEntity.class, new AxisAlignedBB((double) blockPos.getX(), (double) (blockPos.getY() + 1), (double) blockPos.getZ(), (double) (blockPos.getX() + 1), (double) (blockPos.getY() + 2), (double) (blockPos.getZ() + 1)));
if (!list.isEmpty())
{
for (CatEntity catentity : list)
{
if (catentity.isSitting())
{
return true;
}
}
}
return false;
}
@Override
public boolean hasComparatorInputOverride(BlockState state)
{
return true;
}
@Override
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos)
{
return Container.calcRedstoneFromInventory((IInventory) worldIn.getTileEntity(pos));
}
@Override
public BlockState rotate(BlockState state, Rotation rot)
{
return state.with(FACING, rot.rotate(state.get(FACING)));
}
@Override
public BlockState mirror(BlockState state, Mirror mirrorIn)
{
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
{
builder.add(FACING, WATERLOGGED);
}
@Override
public boolean allowsMovement(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type)
{
return false;
}
public static ChestType getTypeFromItem(Item itemIn)
{
return getTypeFromBlock(Block.getBlockFromItem(itemIn));
}
public static ChestType getTypeFromBlock(Block blockIn)
{
return blockIn instanceof ChestBlock ? ((ChestBlock) blockIn).getType() : null;
}
public ChestType getType()
{
return this.type;
}
}

View File

@ -11,39 +11,33 @@
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.gui.slot.ValidatingChestSlot;
import com.progwml6.ironchest.common.tileentity.CopperChestTileEntity;
import com.progwml6.ironchest.common.tileentity.CrystalChestTileEntity;
import com.progwml6.ironchest.common.tileentity.DiamondChestTileEntity;
import com.progwml6.ironchest.common.tileentity.DirtChestTileEntity;
import com.progwml6.ironchest.common.tileentity.GoldChestTileEntity;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import com.progwml6.ironchest.common.tileentity.ObsidianChestTileEntity;
import com.progwml6.ironchest.common.tileentity.SilverChestTileEntity;
import com.progwml6.ironchest.common.util.BlockNames;
import com.progwml6.ironchest.common.tileentity.TileEntityCopperChest;
import com.progwml6.ironchest.common.tileentity.TileEntityCrystalChest;
import com.progwml6.ironchest.common.tileentity.TileEntityDiamondChest;
import com.progwml6.ironchest.common.tileentity.TileEntityDirtChest;
import com.progwml6.ironchest.common.tileentity.TileEntityGoldChest;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import com.progwml6.ironchest.common.tileentity.TileEntityObsidianChest;
import com.progwml6.ironchest.common.tileentity.TileEntitySilverChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
public enum IronChestType implements IStringSerializable
public enum ChestType implements IStringSerializable
{
//@formatter:off
IRON(54, 9, true, "iron_chest.png", TileEntityIronChest.class, 184, 202, BlockNames.IRON_CHEST),
GOLD(81, 9, true, "gold_chest.png", TileEntityGoldChest.class, 184, 256, BlockNames.GOLD_CHEST),
DIAMOND(108, 12, true, "diamond_chest.png", TileEntityDiamondChest.class, 184, 256, BlockNames.DIAMOND_CHEST),
COPPER(45, 9, false, "copper_chest.png", TileEntityCopperChest.class, 184, 184, BlockNames.COPPER_CHEST),
SILVER(72, 9, false, "silver_chest.png", TileEntitySilverChest.class, 184, 238, BlockNames.SILVER_CHEST),
CRYSTAL(108, 12, true, "crystal_chest.png", TileEntityCrystalChest.class, 238, 256, BlockNames.CRYSTAL_CHEST),
OBSIDIAN(108, 12, false, "obsidian_chest.png", TileEntityObsidianChest.class, 238, 256, BlockNames.OBSIDIAN_CHEST),
DIRTCHEST9000(1, 1, false, "dirt_chest.png", TileEntityDirtChest.class, 184, 184, BlockNames.DIRT_CHEST),
WOOD(0, 0, false, "", null, 0, 0, null);
//@formatter:on
IRON(54, 9, "iron_chest.png", IronChestTileEntity.class, BlockNames.IRON_CHEST, 184, 222, new ResourceLocation("ironchest", "textures/gui/iron_container.png"), 256, 256),
GOLD(81, 9, "gold_chest.png", GoldChestTileEntity.class, BlockNames.GOLD_CHEST, 184, 276, new ResourceLocation("ironchest", "textures/gui/gold_container.png"), 256, 276),
DIAMOND(108, 12, "diamond_chest.png", DiamondChestTileEntity.class, BlockNames.DIAMOND_CHEST, 238, 276, new ResourceLocation("ironchest", "textures/gui/diamond_container.png"), 256, 276),
COPPER(45, 9, "copper_chest.png", CopperChestTileEntity.class, BlockNames.COPPER_CHEST, 184, 204, new ResourceLocation("ironchest", "textures/gui/copper_container.png"), 256, 256),
SILVER(72, 9, "silver_chest.png", SilverChestTileEntity.class, BlockNames.SILVER_CHEST, 184, 258, new ResourceLocation("ironchest", "textures/gui/silver_container.png"), 256, 276),
CRYSTAL(108, 12, "crystal_chest.png", CrystalChestTileEntity.class, BlockNames.CRYSTAL_CHEST, 238, 276, new ResourceLocation("ironchest", "textures/gui/diamond_container.png"), 256, 276),
OBSIDIAN(108, 12, "obsidian_chest.png", ObsidianChestTileEntity.class, BlockNames.OBSIDIAN_CHEST, 238, 276, new ResourceLocation("ironchest", "textures/gui/diamond_container.png"), 256, 276),
DIRTCHEST9000(1, 1, "dirt_chest.png", DirtChestTileEntity.class, BlockNames.DIRT_CHEST, 184, 184, new ResourceLocation("ironchest", "textures/gui/dirt_container.png"), 256, 256),
WOOD(0, 0, "", null, null, 0, 0, null, 0, 0);
public static final ChestType VALUES[] = values();
public final String name;
@ -51,30 +45,35 @@ public enum IronChestType implements IStringSerializable
public final int rowLength;
public final boolean tieredChest;
public final ResourceLocation modelTexture;
public final String modelTexture;
public final Class<? extends TileEntity> clazz;
public final String itemName;
public final int xSize;
public final int ySize;
public final String itemName;
public final ResourceLocation guiTexture;
IronChestType(int size, int rowLength, boolean tieredChest, String modelTexture, Class<? extends TileEntityIronChest> clazz, int xSize, int ySize,
String itemName)
public final int textureXSize;
public final int textureYSize;
ChestType(int size, int rowLength, String modelTexture, Class<? extends IronChestTileEntity> clazz, String itemName, int xSize, int ySize, ResourceLocation guiTexture, int textureXSize, int textureYSize)
{
this.name = this.name().toLowerCase();
this.size = size;
this.rowLength = rowLength;
this.tieredChest = tieredChest;
this.modelTexture = new ResourceLocation("ironchest", "textures/model/" + modelTexture);
this.modelTexture = modelTexture;
this.clazz = clazz;
this.itemName = itemName;
this.xSize = xSize;
this.ySize = ySize;
this.itemName = itemName;
this.guiTexture = guiTexture;
this.textureXSize = textureXSize;
this.textureYSize = textureYSize;
}
@Override
@ -93,25 +92,7 @@ public enum IronChestType implements IStringSerializable
return this == CRYSTAL;
}
public Slot makeSlot(IInventory chestInventory, int index, int x, int y)
{
return new ValidatingChestSlot(chestInventory, index, x, y, this);
}
@SuppressWarnings("deprecation")
private static final Item DIRT_ITEM = Item.getItemFromBlock(Blocks.DIRT);
public boolean acceptsStack(ItemStack itemstack)
{
if (this == DIRTCHEST9000)
{
return itemstack.isEmpty() || itemstack.getItem() == DIRT_ITEM;
}
return true;
}
public static IronChestType get(ResourceLocation resourceLocation)
public static ChestType get(ResourceLocation resourceLocation)
{
switch (resourceLocation.toString())
{
@ -136,7 +117,7 @@ public enum IronChestType implements IStringSerializable
}
}
public static IBlockState get(IronChestType type)
public static BlockState get(ChestType type)
{
switch (type)
{
@ -161,26 +142,26 @@ public enum IronChestType implements IStringSerializable
}
}
public TileEntityIronChest makeEntity()
public IronChestTileEntity makeEntity()
{
switch (this)
{
case IRON:
return new TileEntityIronChest();
return new IronChestTileEntity();
case GOLD:
return new TileEntityGoldChest();
return new GoldChestTileEntity();
case DIAMOND:
return new TileEntityDiamondChest();
return new DiamondChestTileEntity();
case COPPER:
return new TileEntityCopperChest();
return new CopperChestTileEntity();
case SILVER:
return new TileEntitySilverChest();
return new SilverChestTileEntity();
case CRYSTAL:
return new TileEntityCrystalChest();
return new CrystalChestTileEntity();
case OBSIDIAN:
return new TileEntityObsidianChest();
return new ObsidianChestTileEntity();
case DIRTCHEST9000:
return new TileEntityDirtChest();
return new DirtChestTileEntity();
default:
return null;
}

View File

@ -10,21 +10,21 @@
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import net.minecraft.block.state.IBlockState;
import com.progwml6.ironchest.common.tileentity.CopperChestTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockIronChest extends BlockChest
public class CopperChestBlock extends ChestBlock
{
public BlockIronChest(Properties properties)
public CopperChestBlock(Properties properties)
{
super(properties, IronChestType.IRON);
super(properties, ChestType.COPPER);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileEntityIronChest();
return new CopperChestTileEntity();
}
}

View File

@ -10,22 +10,21 @@
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityGoldChest;
import net.minecraft.block.state.IBlockState;
import com.progwml6.ironchest.common.tileentity.CrystalChestTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockGoldChest extends BlockChest
public class CrystalChestBlock extends ChestBlock
{
public BlockGoldChest(Properties properties)
public CrystalChestBlock(Properties properties)
{
super(properties, IronChestType.GOLD);
super(properties, ChestType.CRYSTAL);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileEntityGoldChest();
return new CrystalChestTileEntity();
}
}

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.DiamondChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class DiamondChestBlock extends ChestBlock
{
public DiamondChestBlock(Block.Properties properties)
{
super(properties, ChestType.DIAMOND);
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new DiamondChestTileEntity();
}
}

View File

@ -10,21 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityCrystalChest;
import net.minecraft.block.state.IBlockState;
import com.progwml6.ironchest.common.tileentity.DirtChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockCrystalChest extends BlockChest
public class DirtChestBlock extends ChestBlock
{
public BlockCrystalChest(Properties properties)
public DirtChestBlock(Block.Properties properties)
{
super(properties, IronChestType.CRYSTAL);
super(properties, ChestType.DIRTCHEST9000);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileEntityCrystalChest();
return new DirtChestTileEntity();
}
}

View File

@ -10,22 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityDiamondChest;
import net.minecraft.block.state.IBlockState;
import com.progwml6.ironchest.common.tileentity.GoldChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockDiamondChest extends BlockChest
public class GoldChestBlock extends ChestBlock
{
public BlockDiamondChest(Properties properties)
public GoldChestBlock(Block.Properties properties)
{
super(properties, IronChestType.DIAMOND);
super(properties, ChestType.GOLD);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileEntityDiamondChest();
return new GoldChestTileEntity();
}
}

View File

@ -10,21 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.TileEntityCopperChest;
import net.minecraft.block.state.IBlockState;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class BlockCopperChest extends BlockChest
public class IronChestBlock extends ChestBlock
{
public BlockCopperChest(Properties properties)
public IronChestBlock(Block.Properties properties)
{
super(properties, IronChestType.COPPER);
super(properties, ChestType.IRON);
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileEntityCopperChest();
return new IronChestTileEntity();
}
}

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.ObsidianChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class ObsidianChestBlock extends ChestBlock
{
public ObsidianChestBlock(Block.Properties properties)
{
super(properties, ChestType.OBSIDIAN);
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new ObsidianChestTileEntity();
}
}

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.blocks;
import com.progwml6.ironchest.common.tileentity.SilverChestTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class SilverChestBlock extends ChestBlock
{
public SilverChestBlock(Block.Properties properties)
{
super(properties, ChestType.SILVER);
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new SilverChestTileEntity();
}
}

View File

@ -10,18 +10,18 @@
******************************************************************************/
package com.progwml6.ironchest.common.core;
import com.progwml6.ironchest.client.renderer.TileEntityIronChestItemRenderer;
import com.progwml6.ironchest.IronChest;
import com.progwml6.ironchest.common.blocks.BlockChest;
import com.progwml6.ironchest.common.blocks.BlockCopperChest;
import com.progwml6.ironchest.common.blocks.BlockCrystalChest;
import com.progwml6.ironchest.common.blocks.BlockDiamondChest;
import com.progwml6.ironchest.common.blocks.BlockDirtChest;
import com.progwml6.ironchest.common.blocks.BlockGoldChest;
import com.progwml6.ironchest.common.blocks.BlockIronChest;
import com.progwml6.ironchest.common.blocks.BlockObsidianChest;
import com.progwml6.ironchest.common.blocks.BlockSilverChest;
import com.progwml6.ironchest.common.items.ItemChest;
import com.progwml6.ironchest.client.renderer.IronChestItemStackTileEntityRenderer;
import com.progwml6.ironchest.common.blocks.ChestBlock;
import com.progwml6.ironchest.common.blocks.CopperChestBlock;
import com.progwml6.ironchest.common.blocks.CrystalChestBlock;
import com.progwml6.ironchest.common.blocks.DiamondChestBlock;
import com.progwml6.ironchest.common.blocks.DirtChestBlock;
import com.progwml6.ironchest.common.blocks.GoldChestBlock;
import com.progwml6.ironchest.common.blocks.IronChestBlock;
import com.progwml6.ironchest.common.blocks.ObsidianChestBlock;
import com.progwml6.ironchest.common.blocks.SilverChestBlock;
import com.progwml6.ironchest.common.items.ChestItem;
import com.progwml6.ironchest.common.util.BlockNames;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -38,49 +38,49 @@ public class IronChestBlocks
public static Properties itemBuilder;
@ObjectHolder(BlockNames.IRON_CHEST)
public static BlockChest ironChestBlock;
public static ChestBlock ironChestBlock;
@ObjectHolder(BlockNames.IRON_CHEST)
public static Item ironChestItemBlock;
@ObjectHolder(BlockNames.GOLD_CHEST)
public static BlockChest goldChestBlock;
public static ChestBlock goldChestBlock;
@ObjectHolder(BlockNames.GOLD_CHEST)
public static Item goldChestItemBlock;
@ObjectHolder(BlockNames.DIAMOND_CHEST)
public static BlockChest diamondChestBlock;
public static ChestBlock diamondChestBlock;
@ObjectHolder(BlockNames.DIAMOND_CHEST)
public static Item diamondChestItemBlock;
@ObjectHolder(BlockNames.COPPER_CHEST)
public static BlockChest copperChestBlock;
public static ChestBlock copperChestBlock;
@ObjectHolder(BlockNames.COPPER_CHEST)
public static Item copperChestItemBlock;
@ObjectHolder(BlockNames.SILVER_CHEST)
public static BlockChest silverChestBlock;
public static ChestBlock silverChestBlock;
@ObjectHolder(BlockNames.SILVER_CHEST)
public static Item silverChestItemBlock;
@ObjectHolder(BlockNames.CRYSTAL_CHEST)
public static BlockChest crystalChestBlock;
public static ChestBlock crystalChestBlock;
@ObjectHolder(BlockNames.CRYSTAL_CHEST)
public static Item crystalChestItemBlock;
@ObjectHolder(BlockNames.OBSIDIAN_CHEST)
public static BlockChest obsidianChestBlock;
public static ChestBlock obsidianChestBlock;
@ObjectHolder(BlockNames.OBSIDIAN_CHEST)
public static Item obsidianChestItemBlock;
@ObjectHolder(BlockNames.DIRT_CHEST)
public static BlockChest dirtChestBlock;
public static ChestBlock dirtChestBlock;
@ObjectHolder(BlockNames.DIRT_CHEST)
public static Item dirtChestItemBlock;
@ -98,14 +98,14 @@ public class IronChestBlocks
{
IForgeRegistry<Block> blockRegistry = event.getRegistry();
blockRegistry.register(new BlockIronChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new BlockGoldChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new BlockDiamondChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new BlockCopperChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new BlockSilverChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new BlockCrystalChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new BlockObsidianChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 10000.0F)));
blockRegistry.register(new BlockDirtChest(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new IronChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new GoldChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new DiamondChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new CopperChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new SilverChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new CrystalChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
blockRegistry.register(new ObsidianChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 10000.0F)));
blockRegistry.register(new DirtChestBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(3.0F, 3.0F)));
}
@SubscribeEvent
@ -113,16 +113,16 @@ public class IronChestBlocks
{
IForgeRegistry<Item> itemRegistry = event.getRegistry();
itemBuilder = (new Properties()).group(IronChestCreativeTabs.IRON_CHESTS).setTEISR(() -> TileEntityIronChestItemRenderer::new);
itemBuilder = (new Properties()).group(IronChestItemGroups.IRON_CHESTS).setTEISR(() -> IronChestItemStackTileEntityRenderer::new);
itemRegistry.register(new ItemChest(ironChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(goldChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(diamondChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(copperChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(silverChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(crystalChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(obsidianChestBlock, itemBuilder));
itemRegistry.register(new ItemChest(dirtChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(ironChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(goldChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(diamondChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(copperChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(silverChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(crystalChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(obsidianChestBlock, itemBuilder));
itemRegistry.register(new ChestItem(dirtChestBlock, itemBuilder));
}
}
}

View File

@ -15,12 +15,8 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public final class IronChestCreativeTabs
public class IronChestItemGroups
{
private IronChestCreativeTabs()
{
}
public static final ItemGroup IRON_CHESTS = new ItemGroup("ironchest")
{
@Override

View File

@ -11,8 +11,8 @@
package com.progwml6.ironchest.common.core;
import com.progwml6.ironchest.IronChest;
import com.progwml6.ironchest.common.items.ChestChangerItem;
import com.progwml6.ironchest.common.items.ChestChangerType;
import com.progwml6.ironchest.common.items.ItemChestChanger;
import com.progwml6.ironchest.common.util.ItemNames;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Properties;
@ -66,17 +66,17 @@ public class IronChestItems
{
IForgeRegistry<Item> itemRegistry = event.getRegistry();
itemProperties = (new Properties()).group(IronChestCreativeTabs.IRON_CHESTS).maxStackSize(1);
itemProperties = (new Properties()).group(IronChestItemGroups.IRON_CHESTS).maxStackSize(1);
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.IRON_GOLD));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.GOLD_DIAMOND));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.COPPER_SILVER));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.SILVER_GOLD));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.COPPER_IRON));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.DIAMOND_CRYSTAL));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.WOOD_IRON));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.WOOD_COPPER));
itemRegistry.register(new ItemChestChanger(itemProperties, ChestChangerType.DIAMOND_OBSIDIAN));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.IRON_GOLD));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.GOLD_DIAMOND));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.COPPER_SILVER));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.SILVER_GOLD));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.COPPER_IRON));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.DIAMOND_CRYSTAL));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.WOOD_IRON));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.WOOD_COPPER));
itemRegistry.register(new ChestChangerItem(itemProperties, ChestChangerType.DIAMOND_OBSIDIAN));
}
}
}

View File

@ -1,133 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.gui;
import com.progwml6.ironchest.common.blocks.IronChestType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerIronChest extends Container
{
private IronChestType type;
private EntityPlayer player;
private IInventory chest;
public ContainerIronChest(IInventory playerInventory, IInventory chestInventory, IronChestType type, EntityPlayer player, int xSize, int ySize)
{
this.chest = chestInventory;
this.player = player;
this.type = type;
chestInventory.openInventory(this.player);
this.layoutContainer(playerInventory, chestInventory, type, xSize, ySize);
}
@Override
public boolean canInteractWith(EntityPlayer playerIn)
{
return this.chest.isUsableByPlayer(playerIn);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemStack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemStack1 = slot.getStack();
itemStack = itemStack1.copy();
if (index < this.type.size)
{
if (!this.mergeItemStack(itemStack1, this.type.size, this.inventorySlots.size(), true))
{
return ItemStack.EMPTY;
}
}
else if (!this.type.acceptsStack(itemStack1))
{
return ItemStack.EMPTY;
}
else if (!this.mergeItemStack(itemStack1, 0, this.type.size, false))
{
return ItemStack.EMPTY;
}
if (itemStack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
}
return itemStack;
}
protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize)
{
if (type == IronChestType.DIRTCHEST9000)
{
this.addSlot(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
}
else
{
for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++)
{
for (int chestCol = 0; chestCol < type.rowLength; chestCol++)
{
this.addSlot(type.makeSlot(chestInventory, chestCol + chestRow * type.rowLength, 12 + chestCol * 18, 8 + chestRow * 18));
}
}
}
int leftCol = (xSize - 162) / 2 + 1;
for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++)
{
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
{
this.addSlot(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
}
}
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++)
{
this.addSlot(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24));
}
}
public EntityPlayer getPlayer()
{
return this.player;
}
@Override
public void onContainerClosed(EntityPlayer playerIn)
{
super.onContainerClosed(playerIn);
this.chest.closeInventory(playerIn);
}
public IInventory getChestInventory()
{
return this.chest;
}
}

View File

@ -1,26 +0,0 @@
package com.progwml6.ironchest.common.gui;
import com.progwml6.ironchest.client.gui.GUIChest;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.FMLPlayMessages;
public class GuiHandler
{
public static GuiScreen openGui(FMLPlayMessages.OpenContainer openContainer)
{
BlockPos pos = openContainer.getAdditionalData().readBlockPos();
for (GUIChest.GUI type : GUIChest.GUI.values())
{
if (type.getGuiId().equals(openContainer.getId()))
{
return new GUIChest(type, (IInventory) Minecraft.getInstance().player.inventory, (IInventory) Minecraft.getInstance().world.getTileEntity(pos));
}
}
return null;
}
}

View File

@ -0,0 +1,212 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.inventory;
import com.progwml6.ironchest.common.blocks.ChestType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class ChestContainer extends Container
{
private final IInventory inventory;
private final ChestType chestType;
private ChestContainer(ContainerType<?> containerType, int windowId, PlayerInventory playerInventory)
{
this(containerType, windowId, playerInventory, new Inventory(ChestType.WOOD.size), ChestType.WOOD);
}
public static ChestContainer createIronContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.IRON_CHEST, windowId, playerInventory, new Inventory(ChestType.IRON.size), ChestType.IRON);
}
public static ChestContainer createIronContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.IRON_CHEST, windowId, playerInventory, inventory, ChestType.IRON);
}
public static ChestContainer createGoldContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.GOLD_CHEST, windowId, playerInventory, new Inventory(ChestType.GOLD.size), ChestType.GOLD);
}
public static ChestContainer createGoldContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.GOLD_CHEST, windowId, playerInventory, inventory, ChestType.GOLD);
}
public static ChestContainer createDiamondContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.DIAMOND_CHEST, windowId, playerInventory, new Inventory(ChestType.DIAMOND.size), ChestType.DIAMOND);
}
public static ChestContainer createDiamondContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.DIAMOND_CHEST, windowId, playerInventory, inventory, ChestType.DIAMOND);
}
public static ChestContainer createCrystalContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.CRYSTAL_CHEST, windowId, playerInventory, new Inventory(ChestType.CRYSTAL.size), ChestType.CRYSTAL);
}
public static ChestContainer createCrystalContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.CRYSTAL_CHEST, windowId, playerInventory, inventory, ChestType.CRYSTAL);
}
public static ChestContainer createCopperContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.COPPER_CHEST, windowId, playerInventory, new Inventory(ChestType.COPPER.size), ChestType.COPPER);
}
public static ChestContainer createCopperContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.COPPER_CHEST, windowId, playerInventory, inventory, ChestType.COPPER);
}
public static ChestContainer createSilverContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.SILVER_CHEST, windowId, playerInventory, new Inventory(ChestType.CRYSTAL.size), ChestType.SILVER);
}
public static ChestContainer createSilverContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.SILVER_CHEST, windowId, playerInventory, inventory, ChestType.SILVER);
}
public static ChestContainer createObsidianContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.OBSIDIAN_CHEST, windowId, playerInventory, new Inventory(ChestType.OBSIDIAN.size), ChestType.OBSIDIAN);
}
public static ChestContainer createObsidianContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.OBSIDIAN_CHEST, windowId, playerInventory, inventory, ChestType.OBSIDIAN);
}
public static ChestContainer createDirtContainer(int windowId, PlayerInventory playerInventory)
{
return new ChestContainer(ChestContainerType.DIRT_CHEST, windowId, playerInventory, new Inventory(ChestType.DIRTCHEST9000.size), ChestType.DIRTCHEST9000);
}
public static ChestContainer createDirtContainer(int windowId, PlayerInventory playerInventory, IInventory inventory)
{
return new ChestContainer(ChestContainerType.DIRT_CHEST, windowId, playerInventory, inventory, ChestType.DIRTCHEST9000);
}
public ChestContainer(ContainerType<?> containerType, int windowId, PlayerInventory playerInventory, IInventory inventory, ChestType chestType)
{
super(containerType, windowId);
func_216962_a(inventory, chestType.size);
this.inventory = inventory;
this.chestType = chestType;
inventory.openInventory(playerInventory.player);
if (chestType == ChestType.DIRTCHEST9000)
{
this.addSlot(new DirtChestSlot(inventory, 0, 12 + 4 * 18, 8 + 2 * 18));
}
else
{
for (int chestRow = 0; chestRow < chestType.getRowCount(); chestRow++)
{
for (int chestCol = 0; chestCol < chestType.rowLength; chestCol++)
{
this.addSlot(new Slot(inventory, chestCol + chestRow * chestType.rowLength, 12 + chestCol * 18, 18 + chestRow * 18));
}
}
}
int leftCol = (chestType.xSize - 162) / 2 + 1;
for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++)
{
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
{
this.addSlot(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, chestType.ySize - (4 - playerInvRow) * 18 - 10));
}
}
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++)
{
this.addSlot(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, chestType.ySize - 24));
}
}
@Override
public boolean canInteractWith(PlayerEntity playerIn)
{
return this.inventory.isUsableByPlayer(playerIn);
}
@Override
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index)
{
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < this.chestType.size)
{
if (!this.mergeItemStack(itemstack1, this.chestType.size, this.inventorySlots.size(), true))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 0, this.chestType.size, false))
{
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
}
return itemstack;
}
@Override
public void onContainerClosed(PlayerEntity playerIn)
{
super.onContainerClosed(playerIn);
this.inventory.closeInventory(playerIn);
}
@OnlyIn(Dist.CLIENT)
public ChestType getChestType()
{
return this.chestType;
}
}

View File

@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.inventory;
import com.progwml6.ironchest.IronChest;
import com.progwml6.ironchest.client.inventory.ChestScreen;
import com.progwml6.ironchest.common.util.ContainerNames;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.inventory.container.ContainerType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;
public class ChestContainerType
{
@ObjectHolder(ContainerNames.IRON_CHEST)
public static ContainerType<ChestContainer> IRON_CHEST;
@ObjectHolder(ContainerNames.GOLD_CHEST)
public static ContainerType<ChestContainer> GOLD_CHEST;
@ObjectHolder(ContainerNames.DIAMOND_CHEST)
public static ContainerType<ChestContainer> DIAMOND_CHEST;
@ObjectHolder(ContainerNames.CRYSTAL_CHEST)
public static ContainerType<ChestContainer> CRYSTAL_CHEST;
@ObjectHolder(ContainerNames.COPPER_CHEST)
public static ContainerType<ChestContainer> COPPER_CHEST;
@ObjectHolder(ContainerNames.SILVER_CHEST)
public static ContainerType<ChestContainer> SILVER_CHEST;
@ObjectHolder(ContainerNames.OBSIDIAN_CHEST)
public static ContainerType<ChestContainer> OBSIDIAN_CHEST;
@ObjectHolder(ContainerNames.DIRT_CHEST)
public static ContainerType<ChestContainer> DIRT_CHEST;
@Mod.EventBusSubscriber(modid = IronChest.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class Registration
{
@SubscribeEvent
public static void onContainerTypeRegistry(final RegistryEvent.Register<ContainerType<?>> e)
{
e.getRegistry().registerAll(
new ContainerType<>(ChestContainer::createIronContainer).setRegistryName(ContainerNames.IRON_CHEST),
new ContainerType<>(ChestContainer::createGoldContainer).setRegistryName(ContainerNames.GOLD_CHEST),
new ContainerType<>(ChestContainer::createDiamondContainer).setRegistryName(ContainerNames.DIAMOND_CHEST),
new ContainerType<>(ChestContainer::createCrystalContainer).setRegistryName(ContainerNames.CRYSTAL_CHEST),
new ContainerType<>(ChestContainer::createCopperContainer).setRegistryName(ContainerNames.COPPER_CHEST),
new ContainerType<>(ChestContainer::createSilverContainer).setRegistryName(ContainerNames.SILVER_CHEST),
new ContainerType<>(ChestContainer::createObsidianContainer).setRegistryName(ContainerNames.OBSIDIAN_CHEST),
new ContainerType<>(ChestContainer::createDirtContainer).setRegistryName(ContainerNames.DIRT_CHEST)
);
}
}
@OnlyIn(Dist.CLIENT)
public static void registerScreenFactories()
{
ScreenManager.registerFactory(IRON_CHEST, ChestScreen::new);
ScreenManager.registerFactory(GOLD_CHEST, ChestScreen::new);
ScreenManager.registerFactory(DIAMOND_CHEST, ChestScreen::new);
ScreenManager.registerFactory(CRYSTAL_CHEST, ChestScreen::new);
ScreenManager.registerFactory(COPPER_CHEST, ChestScreen::new);
ScreenManager.registerFactory(SILVER_CHEST, ChestScreen::new);
ScreenManager.registerFactory(OBSIDIAN_CHEST, ChestScreen::new);
ScreenManager.registerFactory(DIRT_CHEST, ChestScreen::new);
}
}

View File

@ -8,26 +8,24 @@
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.gui.slot;
package com.progwml6.ironchest.common.inventory;
import com.progwml6.ironchest.common.blocks.IronChestType;
import net.minecraft.block.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ValidatingChestSlot extends Slot
public class DirtChestSlot extends Slot
{
private IronChestType type;
public ValidatingChestSlot(IInventory inventoryIn, int slotIndex, int xPosition, int yPosition, IronChestType type)
public DirtChestSlot(IInventory inventoryIn, int slotIndex, int xPosition, int yPosition)
{
super(inventoryIn, slotIndex, xPosition, yPosition);
this.type = type;
}
@Override
public boolean isItemValid(ItemStack stack)
{
return this.type.acceptsStack(stack);
return stack.isEmpty() || stack.getItem() == Item.getItemFromBlock(Blocks.DIRT);
}
}

View File

@ -10,28 +10,27 @@
******************************************************************************/
package com.progwml6.ironchest.common.items;
import com.progwml6.ironchest.common.blocks.BlockChest;
import com.progwml6.ironchest.common.blocks.BlockIronChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.tileentity.TileEntityIronChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import com.progwml6.ironchest.common.blocks.ChestBlock;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.tileentity.IronChestTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.ChestTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
public class ItemChestChanger extends ItemTooltip
public class ChestChangerItem extends TooltipItem
{
public final ChestChangerType type;
public ItemChestChanger(Properties properties, ChestChangerType chestChangerType)
public ChestChangerItem(Properties properties, ChestChangerType chestChangerType)
{
super(properties);
this.type = chestChangerType;
@ -39,72 +38,72 @@ public class ItemChestChanger extends ItemTooltip
}
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, ItemUseContext context)
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
{
EntityPlayer entityPlayer = context.getPlayer();
PlayerEntity entityPlayer = context.getPlayer();
BlockPos blockPos = context.getPos();
World world = context.getWorld();
ItemStack itemStack = context.getItem();
if (world.isRemote)
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
if (this.type.canUpgrade(IronChestType.WOOD))
if (this.type.canUpgrade(ChestType.WOOD))
{
if (!(world.getBlockState(blockPos).getBlock() instanceof net.minecraft.block.BlockChest))
if (!(world.getBlockState(blockPos).getBlock() instanceof net.minecraft.block.ChestBlock))
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
}
else
{
if (world.getBlockState(blockPos).getBlock().getDefaultState() != IronChestType.get(this.type.source))
if (world.getBlockState(blockPos).getBlock().getDefaultState() != ChestType.get(this.type.source))
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
}
TileEntity tileEntity = world.getTileEntity(blockPos);
TileEntityIronChest newChest = new TileEntityIronChest();
IronChestTileEntity newChest = new IronChestTileEntity();
ITextComponent customName = null;
NonNullList<ItemStack> chestContents = NonNullList.<ItemStack>withSize(27, ItemStack.EMPTY);
EnumFacing chestFacing = EnumFacing.NORTH;
Direction chestFacing = Direction.NORTH;
if (tileEntity != null)
{
if (tileEntity instanceof TileEntityIronChest)
if (tileEntity instanceof IronChestTileEntity)
{
TileEntityIronChest chest = (TileEntityIronChest) tileEntity;
IBlockState chestState = world.getBlockState(blockPos);
IronChestTileEntity chest = (IronChestTileEntity) tileEntity;
BlockState chestState = world.getBlockState(blockPos);
chestContents = chest.getItems();
chestFacing = chestState.get(BlockChest.FACING);
chestFacing = chestState.get(ChestBlock.FACING);
customName = chest.getCustomName();
newChest = this.type.target.makeEntity();
if (newChest == null)
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
}
else if (tileEntity instanceof TileEntityChest)
else if (tileEntity instanceof ChestTileEntity)
{
IBlockState chestState = world.getBlockState(blockPos);
chestFacing = chestState.get(net.minecraft.block.BlockChest.FACING);
TileEntityChest chest = (TileEntityChest) tileEntity;
BlockState chestState = world.getBlockState(blockPos);
chestFacing = chestState.get(net.minecraft.block.ChestBlock.FACING);
ChestTileEntity chest = (ChestTileEntity) tileEntity;
if (TileEntityChest.getPlayersUsing(world, blockPos) > 0)
if (ChestTileEntity.getPlayersUsing(world, blockPos) > 0)
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
if (!this.type.canUpgrade(IronChestType.WOOD))
if (!this.type.canUpgrade(ChestType.WOOD))
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
chestContents = NonNullList.<ItemStack>withSize(chest.getSizeInventory(), ItemStack.EMPTY);
@ -122,10 +121,10 @@ public class ItemChestChanger extends ItemTooltip
tileEntity.updateContainingBlockInfo();
world.removeBlock(blockPos, false);
world.removeTileEntity(blockPos);
world.removeBlock(blockPos);
IBlockState iBlockState = IronChestType.get(this.type.target).with(BlockIronChest.FACING, chestFacing);
BlockState iBlockState = ChestType.get(this.type.target).with(ChestBlock.FACING, chestFacing);
world.setTileEntity(blockPos, newChest);
world.setBlockState(blockPos, iBlockState, 3);
@ -134,14 +133,14 @@ public class ItemChestChanger extends ItemTooltip
TileEntity tileEntity2 = world.getTileEntity(blockPos);
if (tileEntity2 instanceof TileEntityIronChest)
if (tileEntity2 instanceof IronChestTileEntity)
{
if (customName != null)
{
((TileEntityIronChest) tileEntity2).setCustomName(customName);
((IronChestTileEntity) tileEntity2).setCustomName(customName);
}
((TileEntityIronChest) tileEntity2).setItems(chestContents);
((IronChestTileEntity) tileEntity2).setItems(chestContents);
}
if (!entityPlayer.abilities.isCreativeMode)
@ -149,6 +148,6 @@ public class ItemChestChanger extends ItemTooltip
itemStack.shrink(1);
}
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
}

View File

@ -10,18 +10,18 @@
******************************************************************************/
package com.progwml6.ironchest.common.items;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.util.ItemNames;
import net.minecraft.util.ResourceLocation;
import static com.progwml6.ironchest.common.blocks.IronChestType.COPPER;
import static com.progwml6.ironchest.common.blocks.IronChestType.CRYSTAL;
import static com.progwml6.ironchest.common.blocks.IronChestType.DIAMOND;
import static com.progwml6.ironchest.common.blocks.IronChestType.GOLD;
import static com.progwml6.ironchest.common.blocks.IronChestType.IRON;
import static com.progwml6.ironchest.common.blocks.IronChestType.OBSIDIAN;
import static com.progwml6.ironchest.common.blocks.IronChestType.SILVER;
import static com.progwml6.ironchest.common.blocks.IronChestType.WOOD;
import static com.progwml6.ironchest.common.blocks.ChestType.COPPER;
import static com.progwml6.ironchest.common.blocks.ChestType.CRYSTAL;
import static com.progwml6.ironchest.common.blocks.ChestType.DIAMOND;
import static com.progwml6.ironchest.common.blocks.ChestType.GOLD;
import static com.progwml6.ironchest.common.blocks.ChestType.IRON;
import static com.progwml6.ironchest.common.blocks.ChestType.OBSIDIAN;
import static com.progwml6.ironchest.common.blocks.ChestType.SILVER;
import static com.progwml6.ironchest.common.blocks.ChestType.WOOD;
public enum ChestChangerType
{
@ -37,20 +37,20 @@ public enum ChestChangerType
DIAMOND_OBSIDIAN(DIAMOND, OBSIDIAN, ItemNames.DIAMOND_OBSIDIAN_UPGRADE);
//@formatter:on
public final IronChestType source;
public final ChestType source;
public final IronChestType target;
public final ChestType target;
public final ResourceLocation itemName;
ChestChangerType(IronChestType source, IronChestType target, String itemName)
ChestChangerType(ChestType source, ChestType target, String itemName)
{
this.source = source;
this.target = target;
this.itemName = new ResourceLocation(itemName);
}
public boolean canUpgrade(IronChestType from)
public boolean canUpgrade(ChestType from)
{
return from == this.source;
}

View File

@ -11,12 +11,12 @@
package com.progwml6.ironchest.common.items;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
public class ItemChest extends ItemBlock
public class ChestItem extends BlockItem
{
public ItemChest(Block block, Item.Properties properties)
public ChestItem(Block block, Item.Properties properties)
{
super(block, properties);

View File

@ -16,7 +16,7 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@ -25,9 +25,9 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
import java.util.List;
public class ItemTooltip extends Item
public class TooltipItem extends Item
{
public ItemTooltip(Properties properties)
public TooltipItem(Properties properties)
{
super(properties);
}
@ -47,14 +47,14 @@ public class ItemTooltip extends Item
{
for (String tooltipString : getTooltips(TextFormatting.GRAY.toString() + translateRecursive(stack.getDisplayName() + ".tooltip")))
{
tooltip.add(new TextComponentString(tooltipString));
tooltip.add(new StringTextComponent(tooltipString));
}
}
else if (I18n.hasKey(stack.getDisplayName() + ".tooltip"))
{
for (String tooltipString : getTooltips(TextFormatting.GRAY.toString() + translateRecursive(stack.getDisplayName() + ".tooltip")))
{
tooltip.add(new TextComponentString(tooltipString));
tooltip.add(new StringTextComponent(tooltipString));
}
}
}

View File

@ -12,13 +12,7 @@ package com.progwml6.ironchest.common.network;
import com.progwml6.ironchest.IronChest;
import com.progwml6.ironchest.common.network.packets.PacketTopStackSyncChest;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fml.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.PacketDistributor;
import net.minecraftforge.fml.network.simple.SimpleChannel;

View File

@ -10,8 +10,8 @@
******************************************************************************/
package com.progwml6.ironchest.common.network.packets;
import com.progwml6.ironchest.common.tileentity.TileEntityCrystalChest;
import com.progwml6.ironchest.IronChest;
import com.progwml6.ironchest.common.tileentity.CrystalChestTileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
@ -80,9 +80,9 @@ public class PacketTopStackSyncChest
{
TileEntity tile = world.getTileEntity(message.pos);
if (tile instanceof TileEntityCrystalChest)
if (tile instanceof CrystalChestTileEntity)
{
((TileEntityCrystalChest) tile).receiveMessageFromServer(message.topStacks);
((CrystalChestTileEntity) tile).receiveMessageFromServer(message.topStacks);
}
}
});

View File

@ -0,0 +1,74 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.IronChest;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.util.TileEntityNames;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;
import java.util.function.Supplier;
public class ChestTileEntityType
{
@ObjectHolder(TileEntityNames.IRON_CHEST)
public static TileEntityType<?> IRON_CHEST;
@ObjectHolder(TileEntityNames.GOLD_CHEST)
public static TileEntityType<?> GOLD_CHEST;
@ObjectHolder(TileEntityNames.DIAMOND_CHEST)
public static TileEntityType<?> DIAMOND_CHEST;
@ObjectHolder(TileEntityNames.CRYSTAL_CHEST)
public static TileEntityType<?> CRYSTAL_CHEST;
@ObjectHolder(TileEntityNames.DIRT_CHEST)
public static TileEntityType<?> DIRT_CHEST;
@ObjectHolder(TileEntityNames.COPPER_CHEST)
public static TileEntityType<?> COPPER_CHEST;
@ObjectHolder(TileEntityNames.SILVER_CHEST)
public static TileEntityType<?> SILVER_CHEST;
@ObjectHolder(TileEntityNames.OBSIDIAN_CHEST)
public static TileEntityType<?> OBSIDIAN_CHEST;
public ChestTileEntityType()
{
}
@Mod.EventBusSubscriber(modid = IronChest.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class Registration
{
@SubscribeEvent
public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityType<?>> e)
{
e.getRegistry().registerAll(
TileEntityType.Builder.create((Supplier<TileEntity>) IronChestTileEntity::new, IronChestBlocks.ironChestBlock).build(null).setRegistryName(TileEntityNames.IRON_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) GoldChestTileEntity::new, IronChestBlocks.goldChestBlock).build(null).setRegistryName(TileEntityNames.GOLD_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) DiamondChestTileEntity::new, IronChestBlocks.diamondChestBlock).build(null).setRegistryName(TileEntityNames.DIAMOND_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) CrystalChestTileEntity::new, IronChestBlocks.crystalChestBlock).build(null).setRegistryName(TileEntityNames.CRYSTAL_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) DirtChestTileEntity::new, IronChestBlocks.dirtChestBlock).build(null).setRegistryName(TileEntityNames.DIRT_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) CopperChestTileEntity::new, IronChestBlocks.copperChestBlock).build(null).setRegistryName(TileEntityNames.COPPER_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) SilverChestTileEntity::new, IronChestBlocks.silverChestBlock).build(null).setRegistryName(TileEntityNames.SILVER_CHEST),
TileEntityType.Builder.create((Supplier<TileEntity>) ObsidianChestTileEntity::new, IronChestBlocks.obsidianChestBlock).build(null).setRegistryName(TileEntityNames.OBSIDIAN_CHEST)
);
}
}
}

View File

@ -10,20 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
public class TileEntityDiamondChest extends TileEntityIronChest
public class CopperChestTileEntity extends IronChestTileEntity
{
public TileEntityDiamondChest()
public CopperChestTileEntity()
{
super(IronChestEntityType.DIAMOND_CHEST, IronChestType.DIAMOND, IronChestBlocks.diamondChestBlock);
super(ChestTileEntityType.COPPER_CHEST, ChestType.COPPER, IronChestBlocks.copperChestBlock);
}
@Override
public String getGuiID()
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return GUIChest.GUI.DIAMOND.getGuiId().toString();
return ChestContainer.createCopperContainer(id, playerInventory, this);
}
}

View File

@ -10,36 +10,40 @@
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import com.progwml6.ironchest.common.network.PacketHandler;
import com.progwml6.ironchest.common.network.packets.PacketTopStackSyncChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.network.PacketDistributor;
import java.util.Collections;
public class TileEntityCrystalChest extends TileEntityIronChest
public class CrystalChestTileEntity extends IronChestTileEntity
{
/** 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 CrystalChestTileEntity()
{
super(IronChestEntityType.CRYSTAL_CHEST, IronChestType.CRYSTAL, IronChestBlocks.crystalChestBlock);
super(ChestTileEntityType.CRYSTAL_CHEST, ChestType.CRYSTAL, IronChestBlocks.crystalChestBlock);
this.topStacks = NonNullList.<ItemStack>withSize(8, ItemStack.EMPTY);
}
@Override
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return ChestContainer.createCrystalContainer(id, playerInventory, this);
}
@Override
public void tick()
{
@ -64,11 +68,9 @@ public class TileEntityCrystalChest extends TileEntityIronChest
@Override
public ItemStack getStackInSlot(int index)
{
this.fillWithLoot((EntityPlayer) null);
this.inventoryTouched = true;
return this.getItems().get(index);
return super.getStackInSlot(index);
}
public NonNullList<ItemStack> getTopItems()
@ -76,9 +78,9 @@ public class TileEntityCrystalChest extends TileEntityIronChest
return this.topStacks;
}
protected void sortTopStacks()
private void sortTopStacks()
{
if (!this.getIronChestType().isTransparent() || (this.world != null && this.world.isRemote))
if (!this.getChestType().isTransparent() || (this.world != null && this.world.isRemote))
{
return;
}
@ -130,7 +132,7 @@ public class TileEntityCrystalChest extends TileEntityIronChest
if (this.world != null)
{
IBlockState iblockstate = this.world.getBlockState(this.pos);
BlockState iblockstate = this.world.getBlockState(this.pos);
this.world.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
}
@ -179,7 +181,7 @@ public class TileEntityCrystalChest extends TileEntityIronChest
if (this.world != null)
{
IBlockState iblockstate = this.world.getBlockState(this.pos);
BlockState iblockstate = this.world.getBlockState(this.pos);
this.world.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
}
@ -189,7 +191,7 @@ public class TileEntityCrystalChest extends TileEntityIronChest
public NonNullList<ItemStack> buildItemStackDataList()
{
if (this.getIronChestType().isTransparent())
if (this.getChestType().isTransparent())
{
NonNullList<ItemStack> sortList = NonNullList.<ItemStack>withSize(this.getTopItems().size(), ItemStack.EMPTY);
@ -226,10 +228,4 @@ public class TileEntityCrystalChest extends TileEntityIronChest
{
this.topStacks = topStacks;
}
@Override
public String getGuiID()
{
return GUIChest.GUI.CRYSTAL.getGuiId().toString();
}
}

View File

@ -10,20 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
public class TileEntityObsidianChest extends TileEntityIronChest
public class DiamondChestTileEntity extends IronChestTileEntity
{
public TileEntityObsidianChest()
public DiamondChestTileEntity()
{
super(IronChestEntityType.OBSIDIAN_CHEST, IronChestType.OBSIDIAN, IronChestBlocks.obsidianChestBlock);
super(ChestTileEntityType.DIAMOND_CHEST, ChestType.DIAMOND, IronChestBlocks.diamondChestBlock);
}
@Override
public String getGuiID()
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return GUIChest.GUI.OBSIDIAN.getGuiId().toString();
return ChestContainer.createDiamondContainer(id, playerInventory, this);
}
}

View File

@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
public class DirtChestTileEntity extends IronChestTileEntity
{
private static ItemStack dirtChest9000GuideBook = new ItemStack(Items.WRITTEN_BOOK);
private static boolean bookDataCreated = false;
public DirtChestTileEntity()
{
super(ChestTileEntityType.DIRT_CHEST, ChestType.DIRTCHEST9000, IronChestBlocks.dirtChestBlock);
}
@Override
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return ChestContainer.createDirtContainer(id, playerInventory, this);
}
@Override
public void wasPlaced(LivingEntity entityLivingBase, ItemStack itemStack)
{
if (!(itemStack.hasTag() && itemStack.getTag().getBoolean("been_placed")))
{
this.setInventorySlotContents(0, dirtChest9000GuideBook.copy());
}
if (!bookDataCreated)
{
createBookData();
}
}
@Override
public void removeAdornments()
{
if (!this.getItems().get(0).isEmpty() && this.getItems().get(0).isItemEqual(dirtChest9000GuideBook))
{
this.getItems().set(0, ItemStack.EMPTY);
}
}
private static void createBookData()
{
dirtChest9000GuideBook.setTagInfo("author", new StringNBT("cpw"));
dirtChest9000GuideBook.setTagInfo("title", new StringNBT(I18n.format("book.ironchest.dirtchest9000.title")));
ListNBT pages = new ListNBT();
pages.add(new StringNBT(ITextComponent.Serializer.toJson(new TranslationTextComponent("book.ironchest.dirtchest9000.page1"))));
pages.add(new StringNBT(ITextComponent.Serializer.toJson(new TranslationTextComponent("book.ironchest.dirtchest9000.page2"))));
pages.add(new StringNBT(ITextComponent.Serializer.toJson(new TranslationTextComponent("book.ironchest.dirtchest9000.page3"))));
pages.add(new StringNBT(ITextComponent.Serializer.toJson(new TranslationTextComponent("book.ironchest.dirtchest9000.page4"))));
pages.add(new StringNBT(ITextComponent.Serializer.toJson(new TranslationTextComponent("book.ironchest.dirtchest9000.page5"))));
dirtChest9000GuideBook.setTagInfo("pages", pages);
bookDataCreated = true;
}
}

View File

@ -10,20 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
public class TileEntityCopperChest extends TileEntityIronChest
public class GoldChestTileEntity extends IronChestTileEntity
{
public TileEntityCopperChest()
public GoldChestTileEntity()
{
super(IronChestEntityType.COPPER_CHEST, IronChestType.COPPER, IronChestBlocks.copperChestBlock);
super(ChestTileEntityType.GOLD_CHEST, ChestType.GOLD, IronChestBlocks.goldChestBlock);
}
@Override
public String getGuiID()
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return GUIChest.GUI.COPPER.getGuiId().toString();
return ChestContainer.createGoldContainer(id, playerInventory, this);
}
}

View File

@ -1,110 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.mojang.datafixers.DataFixUtils;
import com.mojang.datafixers.types.Type;
import com.progwml6.ironchest.common.util.TileEntityNames;
import com.progwml6.ironchest.IronChest;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SharedConstants;
import net.minecraft.util.datafix.DataFixesManager;
import net.minecraft.util.datafix.TypeReferences;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.registries.ObjectHolder;
public class IronChestEntityType
{
@ObjectHolder(TileEntityNames.IRON_CHEST)
public static TileEntityType<?> IRON_CHEST;
@ObjectHolder(TileEntityNames.GOLD_CHEST)
public static TileEntityType<?> GOLD_CHEST;
@ObjectHolder(TileEntityNames.DIAMOND_CHEST)
public static TileEntityType<?> DIAMOND_CHEST;
@ObjectHolder(TileEntityNames.CRYSTAL_CHEST)
public static TileEntityType<?> CRYSTAL_CHEST;
@ObjectHolder(TileEntityNames.DIRT_CHEST)
public static TileEntityType<?> DIRT_CHEST;
@ObjectHolder(TileEntityNames.COPPER_CHEST)
public static TileEntityType<?> COPPER_CHEST;
@ObjectHolder(TileEntityNames.SILVER_CHEST)
public static TileEntityType<?> SILVER_CHEST;
@ObjectHolder(TileEntityNames.OBSIDIAN_CHEST)
public static TileEntityType<?> OBSIDIAN_CHEST;
public IronChestEntityType()
{
}
@Mod.EventBusSubscriber(modid = IronChest.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class Registration
{
@SubscribeEvent
public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityType<?>> e)
{
registerTileEntityType(e.getRegistry(), register("iron_chest", TileEntityType.Builder.create(TileEntityIronChest::new)), TileEntityNames.IRON_CHEST);
registerTileEntityType(e.getRegistry(), register("gold_chest", TileEntityType.Builder.create(TileEntityGoldChest::new)), TileEntityNames.GOLD_CHEST);
registerTileEntityType(e.getRegistry(), register("diamond_chest", TileEntityType.Builder.create(TileEntityDiamondChest::new)), TileEntityNames.DIAMOND_CHEST);
registerTileEntityType(e.getRegistry(), register("crystal_chest", TileEntityType.Builder.create(TileEntityCrystalChest::new)), TileEntityNames.CRYSTAL_CHEST);
registerTileEntityType(e.getRegistry(), register("dirt_chest", TileEntityType.Builder.create(TileEntityDirtChest::new)), TileEntityNames.DIRT_CHEST);
registerTileEntityType(e.getRegistry(), register("copper_chest", TileEntityType.Builder.create(TileEntityCopperChest::new)), TileEntityNames.COPPER_CHEST);
registerTileEntityType(e.getRegistry(), register("silver_chest", TileEntityType.Builder.create(TileEntitySilverChest::new)), TileEntityNames.SILVER_CHEST);
registerTileEntityType(e.getRegistry(), register("obsidian_chest", TileEntityType.Builder.create(TileEntityObsidianChest::new)), TileEntityNames.OBSIDIAN_CHEST);
}
}
protected static <T extends TileEntityType<?>> T registerTileEntityType(IForgeRegistry<TileEntityType<?>> registry, T tileEntityType, String name)
{
register(registry, tileEntityType, new ResourceLocation(name));
return tileEntityType;
}
protected static <T extends IForgeRegistryEntry<T>> T register(IForgeRegistry<T> registry, T thing, ResourceLocation name)
{
thing.setRegistryName(name);
registry.register(thing);
return thing;
}
public static <T extends TileEntity> TileEntityType<T> register(String id, TileEntityType.Builder<T> builder)
{
Type<?> type = null;
try
{
type = DataFixesManager.getDataFixer().getSchema(DataFixUtils.makeKey(1519)).getChoiceType(TypeReferences.BLOCK_ENTITY, id);
}
catch (IllegalArgumentException illegalstateexception)
{
if (SharedConstants.developmentMode)
{
throw illegalstateexception;
}
}
TileEntityType<T> tileEntityType = builder.build(type);
return tileEntityType;
}
}

View File

@ -10,86 +10,71 @@
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.BlockChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestBlock;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.gui.ContainerIronChest;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.Container;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.IChestLid;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.LockableLootTileEntity;
import net.minecraft.tileentity.LockableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityLockableLoot;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ITickable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class TileEntityIronChest extends TileEntityLockableLoot implements IChestLid, ITickable
@OnlyIn(
value = Dist.CLIENT,
_interface = IChestLid.class
)
public class IronChestTileEntity extends LockableLootTileEntity implements IChestLid, ITickableTileEntity
{
private NonNullList<ItemStack> chestContents;
/** The current angle of the lid (between 0 and 1) */
protected float lidAngle;
/** The angle of the lid last tick */
protected float prevLidAngle;
/** The number of players currently using this chest */
protected int numPlayersUsing;
/**
* A counter that is incremented once each tick. Used to determine when to recompute {@link #numPlayersUsing}; this
* is done every 200 ticks (but staggered between different chests). However, the new value isn't actually sent to
* clients when it is changed.
*/
private int ticksSinceSync;
private IronChestType chestType;
private ChestType chestType;
private Block blockToUse;
public TileEntityIronChest()
{
this(IronChestEntityType.IRON_CHEST, IronChestType.IRON, IronChestBlocks.ironChestBlock);
}
protected TileEntityIronChest(TileEntityType<?> typeIn, IronChestType chestTypeIn, Block blockToUseIn)
protected IronChestTileEntity(TileEntityType<?> typeIn, ChestType chestTypeIn, Block blockToUseIn)
{
super(typeIn);
this.chestType = chestTypeIn;
this.chestContents = NonNullList.<ItemStack>withSize(chestTypeIn.size, ItemStack.EMPTY);
this.chestType = chestTypeIn;
this.blockToUse = blockToUseIn;
}
@Override
public void setItems(NonNullList<ItemStack> contents)
public IronChestTileEntity()
{
this.chestContents = NonNullList.<ItemStack>withSize(this.getIronChestType().size, ItemStack.EMPTY);
for (int i = 0; i < contents.size(); i++)
{
if (i < this.chestContents.size())
{
this.getItems().set(i, contents.get(i));
}
}
this(ChestTileEntityType.IRON_CHEST, ChestType.IRON, IronChestBlocks.ironChestBlock);
}
@Override
@ -98,240 +83,6 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements IChes
return this.getItems().size();
}
public IronChestType getIronChestType()
{
IronChestType type = IronChestType.IRON;
if (this.hasWorld())
{
IronChestType typeNew = BlockChest.getTypeFromBlock(this.getBlockState().getBlock());
if (typeNew != null)
{
type = typeNew;
}
}
return type;
}
@Override
public ItemStack getStackInSlot(int index)
{
this.fillWithLoot((EntityPlayer) null);
return this.getItems().get(index);
}
@Override
public void markDirty()
{
super.markDirty();
}
@Override
public void tick()
{
int i = this.pos.getX();
int j = this.pos.getY();
int k = this.pos.getZ();
++this.ticksSinceSync;
if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0)
{
this.numPlayersUsing = 0;
for (EntityPlayer entityplayer : this.world
.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(i - 5.0F, j - 5.0F, k - 5.0F, i + 1 + 5.0F, j + 1 + 5.0F, k + 1 + 5.0F)))
{
if (entityplayer.openContainer instanceof ContainerIronChest)
{
++this.numPlayersUsing;
}
}
}
this.prevLidAngle = this.lidAngle;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
{
this.playSound(SoundEvents.BLOCK_CHEST_OPEN);
}
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
{
float f2 = this.lidAngle;
if (this.numPlayersUsing > 0)
{
this.lidAngle += 0.1F;
}
else
{
this.lidAngle -= 0.1F;
}
if (this.lidAngle > 1.0F)
{
this.lidAngle = 1.0F;
}
if (this.lidAngle < 0.5F && f2 >= 0.5F)
{
this.playSound(SoundEvents.BLOCK_CHEST_CLOSE);
}
if (this.lidAngle < 0.0F)
{
this.lidAngle = 0.0F;
}
}
}
private void playSound(SoundEvent soundIn)
{
double d0 = this.pos.getX() + 0.5D;
double d1 = this.pos.getY() + 0.5D;
double d2 = this.pos.getZ() + 0.5D;
this.world.playSound((EntityPlayer) null, d0, d1, d2, soundIn, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
@Override
public ITextComponent getName()
{
ITextComponent itextcomponent = this.getCustomName();
return itextcomponent != null ? itextcomponent : new TextComponentTranslation(this.getIronChestType().name(), new Object[0]);
}
@Override
public void read(NBTTagCompound compound)
{
super.read(compound);
this.chestContents = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
if (!this.checkLootAndRead(compound))
{
ItemStackHelper.loadAllItems(compound, this.chestContents);
}
if (compound.contains("CustomName", 8))
{
this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName"));
}
}
@Override
public NBTTagCompound write(NBTTagCompound compound)
{
super.write(compound);
if (!this.checkLootAndWrite(compound))
{
ItemStackHelper.saveAllItems(compound, this.chestContents);
}
ITextComponent itextcomponent = this.getCustomName();
if (itextcomponent != null)
{
compound.putString("CustomName", ITextComponent.Serializer.toJson(itextcomponent));
}
return compound;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
/**
* See {@link Block#eventReceived} for more information. This must return true serverside before it is called
* clientside.
*/
@Override
public boolean receiveClientEvent(int id, int type)
{
if (id == 1)
{
this.numPlayersUsing = type;
return true;
}
else
{
return super.receiveClientEvent(id, type);
}
}
@Override
public void openInventory(EntityPlayer player)
{
if (!player.isSpectator())
{
if (this.numPlayersUsing < 0)
{
this.numPlayersUsing = 0;
}
++this.numPlayersUsing;
this.onOpenOrClose();
}
}
@Override
public void closeInventory(EntityPlayer player)
{
if (!player.isSpectator())
{
--this.numPlayersUsing;
this.onOpenOrClose();
}
}
protected void onOpenOrClose()
{
Block block = this.getBlockState().getBlock();
if (block instanceof BlockChest)
{
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, block);
}
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack)
{
return this.getIronChestType().acceptsStack(stack);
}
public void wasPlaced(EntityLivingBase entityliving, ItemStack stack)
{
}
public void removeAdornments()
{
}
@Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
this.fillWithLoot(playerIn);
return new ContainerIronChest(playerInventory, this, this.chestType, playerIn, this.chestType.xSize, this.chestType.ySize);
}
@Override
public String getGuiID()
{
return GUIChest.GUI.IRON.getGuiId().toString();
}
@Override
public NonNullList<ItemStack> getItems()
{
return this.chestContents;
}
@Override
public boolean isEmpty()
{
@ -346,28 +97,241 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements IChes
return true;
}
@Override
protected ITextComponent getDefaultName()
{
return new TranslationTextComponent("container.chest");
}
@Override
public void read(CompoundNBT compound)
{
super.read(compound);
this.chestContents = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
if (!this.checkLootAndRead(compound))
{
ItemStackHelper.loadAllItems(compound, this.chestContents);
}
}
@Override
public CompoundNBT write(CompoundNBT compound)
{
super.write(compound);
if (!this.checkLootAndWrite(compound))
{
ItemStackHelper.saveAllItems(compound, this.chestContents);
}
return compound;
}
@Override
public void tick()
{
int i = this.pos.getX();
int j = this.pos.getY();
int k = this.pos.getZ();
++this.ticksSinceSync;
this.numPlayersUsing = getNumberOfPlayersUsing(this.world, this, this.ticksSinceSync, i, j, k, this.numPlayersUsing);
this.prevLidAngle = this.lidAngle;
float f = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
{
this.playSound(SoundEvents.BLOCK_CHEST_OPEN);
}
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
{
float f1 = this.lidAngle;
if (this.numPlayersUsing > 0)
{
this.lidAngle += 0.1F;
}
else
{
this.lidAngle -= 0.1F;
}
if (this.lidAngle > 1.0F)
{
this.lidAngle = 1.0F;
}
float f2 = 0.5F;
if (this.lidAngle < 0.5F && f1 >= 0.5F)
{
this.playSound(SoundEvents.BLOCK_CHEST_CLOSE);
}
if (this.lidAngle < 0.0F)
{
this.lidAngle = 0.0F;
}
}
}
public static int getNumberOfPlayersUsing(World worldIn, LockableTileEntity lockableTileEntity, int ticksSinceSync, int x, int y, int z, int numPlayersUsing)
{
if (!worldIn.isRemote && numPlayersUsing != 0 && (ticksSinceSync + x + y + z) % 200 == 0)
{
numPlayersUsing = getNumberOfPlayersUsing(worldIn, lockableTileEntity, x, y, z);
}
return numPlayersUsing;
}
public static int getNumberOfPlayersUsing(World world, LockableTileEntity lockableTileEntity, int x, int y, int z)
{
int i = 0;
for (PlayerEntity playerentity : world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB((double) ((float) x - 5.0F), (double) ((float) y - 5.0F), (double) ((float) z - 5.0F), (double) ((float) (x + 1) + 5.0F), (double) ((float) (y + 1) + 5.0F), (double) ((float) (z + 1) + 5.0F))))
{
if (playerentity.openContainer instanceof ChestContainer)
{
++i;
}
}
return i;
}
private void playSound(SoundEvent soundIn)
{
double d0 = (double) this.pos.getX() + 0.5D;
double d1 = (double) this.pos.getY() + 0.5D;
double d2 = (double) this.pos.getZ() + 0.5D;
this.world.playSound((PlayerEntity) null, d0, d1, d2, soundIn, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
@Override
public boolean receiveClientEvent(int id, int type)
{
if (id == 1)
{
this.numPlayersUsing = type;
return true;
}
else
{
return super.receiveClientEvent(id, type);
}
}
@Override
public void openInventory(PlayerEntity player)
{
if (!player.isSpectator())
{
if (this.numPlayersUsing < 0)
{
this.numPlayersUsing = 0;
}
++this.numPlayersUsing;
this.onOpenOrClose();
}
}
@Override
public void closeInventory(PlayerEntity player)
{
if (!player.isSpectator())
{
--this.numPlayersUsing;
this.onOpenOrClose();
}
}
protected void onOpenOrClose()
{
Block block = this.getBlockState().getBlock();
if (block instanceof ChestBlock)
{
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, block);
}
}
@Override
public NonNullList<ItemStack> getItems()
{
return this.chestContents;
}
@Override
public void setItems(NonNullList<ItemStack> itemsIn)
{
this.chestContents = NonNullList.<ItemStack>withSize(this.getChestType().size, ItemStack.EMPTY);
for (int i = 0; i < itemsIn.size(); i++)
{
if (i < this.chestContents.size())
{
this.getItems().set(i, itemsIn.get(i));
}
}
}
@Override
@OnlyIn(Dist.CLIENT)
public float getLidAngle(float partialTicks)
{
return this.prevLidAngle + (this.lidAngle - this.prevLidAngle) * partialTicks;
return MathHelper.func_219799_g(partialTicks, this.prevLidAngle, this.lidAngle);
}
public static int getPlayersUsing(IBlockReader reader, BlockPos posIn)
{
IBlockState iblockstate = reader.getBlockState(posIn);
if (iblockstate.hasTileEntity())
BlockState blockstate = reader.getBlockState(posIn);
if (blockstate.hasTileEntity())
{
TileEntity tileentity = reader.getTileEntity(posIn);
if (tileentity instanceof TileEntityIronChest)
if (tileentity instanceof IronChestTileEntity)
{
return ((TileEntityIronChest) tileentity).numPlayersUsing;
return ((IronChestTileEntity) tileentity).numPlayersUsing;
}
}
return 0;
}
@Override
protected Container createMenu(int windowId, PlayerInventory playerInventory)
{
return ChestContainer.createIronContainer(windowId, playerInventory, this);
}
public void wasPlaced(LivingEntity entityliving, ItemStack stack)
{
}
public void removeAdornments()
{
}
public ChestType getChestType()
{
ChestType type = ChestType.IRON;
if (this.hasWorld())
{
ChestType typeNew = ChestBlock.getTypeFromBlock(this.getBlockState().getBlock());
if (typeNew != null)
{
type = typeNew;
}
}
return type;
}
public Block getBlockToUse()
{
return this.blockToUse;

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
public class ObsidianChestTileEntity extends IronChestTileEntity
{
public ObsidianChestTileEntity()
{
super(ChestTileEntityType.OBSIDIAN_CHEST, ChestType.OBSIDIAN, IronChestBlocks.obsidianChestBlock);
}
@Override
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return ChestContainer.createObsidianContainer(id, playerInventory, this);
}
}

View File

@ -10,20 +10,22 @@
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.blocks.ChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import com.progwml6.ironchest.common.inventory.ChestContainer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
public class TileEntityGoldChest extends TileEntityIronChest
public class SilverChestTileEntity extends IronChestTileEntity
{
public TileEntityGoldChest()
public SilverChestTileEntity()
{
super(IronChestEntityType.GOLD_CHEST, IronChestType.GOLD, IronChestBlocks.goldChestBlock);
super(ChestTileEntityType.SILVER_CHEST, ChestType.SILVER, IronChestBlocks.silverChestBlock);
}
@Override
public String getGuiID()
protected Container createMenu(int id, PlayerInventory playerInventory)
{
return GUIChest.GUI.GOLD.getGuiId().toString();
return ChestContainer.createSilverContainer(id, playerInventory, this);
}
}

View File

@ -1,82 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
public class TileEntityDirtChest extends TileEntityIronChest
{
private static ItemStack dirtChest9000GuideBook = new ItemStack(Items.WRITTEN_BOOK);
private static boolean bookDataCreated = false;
public TileEntityDirtChest()
{
super(IronChestEntityType.DIRT_CHEST, IronChestType.DIRTCHEST9000, IronChestBlocks.dirtChestBlock);
}
@Override
public void wasPlaced(EntityLivingBase entityLivingBase, ItemStack itemStack)
{
if (!(itemStack.hasTag() && itemStack.getTag().getBoolean("dirtchest")))
{
this.setInventorySlotContents(0, dirtChest9000GuideBook.copy());
}
if (!bookDataCreated)
{
createBookData();
}
}
@Override
public void removeAdornments()
{
if (!this.getItems().get(0).isEmpty() && this.getItems().get(0).isItemEqual(dirtChest9000GuideBook))
{
this.getItems().set(0, ItemStack.EMPTY);
}
}
public static void createBookData()
{
dirtChest9000GuideBook.setTagInfo("author", new NBTTagString("cpw"));
dirtChest9000GuideBook.setTagInfo("title", new NBTTagString(I18n.format("book.ironchest.dirtchest9000.title")));
NBTTagList pages = new NBTTagList();
pages.add(new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentTranslation("book.ironchest.dirtchest9000.page1"))));
pages.add(new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentTranslation("book.ironchest.dirtchest9000.page2"))));
pages.add(new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentTranslation("book.ironchest.dirtchest9000.page3"))));
pages.add(new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentTranslation("book.ironchest.dirtchest9000.page4"))));
pages.add(new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentTranslation("book.ironchest.dirtchest9000.page5"))));
dirtChest9000GuideBook.setTagInfo("pages", pages);
bookDataCreated = true;
}
@Override
public String getGuiID()
{
return GUIChest.GUI.DIRTCHEST9000.getGuiId().toString();
}
}

View File

@ -1,29 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.tileentity;
import com.progwml6.ironchest.client.gui.GUIChest;
import com.progwml6.ironchest.common.blocks.IronChestType;
import com.progwml6.ironchest.common.core.IronChestBlocks;
public class TileEntitySilverChest extends TileEntityIronChest
{
public TileEntitySilverChest()
{
super(IronChestEntityType.SILVER_CHEST, IronChestType.SILVER, IronChestBlocks.silverChestBlock);
}
@Override
public String getGuiID()
{
return GUIChest.GUI.SILVER.getGuiId().toString();
}
}

View File

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
* <p>
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package com.progwml6.ironchest.common.util;
import com.progwml6.ironchest.IronChest;
public class ContainerNames
{
public static final String IRON_CHEST = IronChest.MOD_ID + ":iron_chest";
public static final String GOLD_CHEST = IronChest.MOD_ID + ":gold_chest";
public static final String DIAMOND_CHEST = IronChest.MOD_ID + ":diamond_chest";
public static final String COPPER_CHEST = IronChest.MOD_ID + ":copper_chest";
public static final String SILVER_CHEST = IronChest.MOD_ID + ":silver_chest";
public static final String CRYSTAL_CHEST = IronChest.MOD_ID + ":crystal_chest";
public static final String OBSIDIAN_CHEST = IronChest.MOD_ID + ":obsidian_chest";
public static final String DIRT_CHEST = IronChest.MOD_ID + ":dirt_chest";
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:copper_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:copper_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:crystal_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:crystal_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:diamond_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:diamond_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,30 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:dirt_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
},
{
"function": "minecraft:set_nbt",
"tag": "{been_placed:1}"
}
],
"name": "ironchest:dirt_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:gold_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:gold_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:iron_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:iron_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:obsidian_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:obsidian_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "ironchest:silver_chest",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "ironchest:silver_chest"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,57 +0,0 @@
[
{
"name": "ironchest:iron",
"tag": "forge:ingots/iron"
},
{
"name": "ironchest:gold",
"tag": "forge:ingots/gold"
},
{
"name": "ironchest:diamond",
"tag": "forge:gems/diamond"
},
{
"name": "ironchest:copper",
"tag": "forge:gems/lapis",
"_comment": "replaceme"
},
{
"name": "ironchest:silver",
"tag": "forge:ingots/nether_brick",
"_comment": "replaceme"
},
{
"name": "ironchest:glass",
"tag": "forge:storage_blocks",
"_comment": "replaceme"
},
{
"name": "ironchest:planks",
"tag": "minecraft:planks"
},
{
"name": "ironchest:chest",
"tag": "forge:chests/wooden"
},
{
"name": "ironchest:obsidian",
"item": {
"item": "minecraft:obsidian"
}
},
{
"name": "ironchest:dirt",
"items": [
{
"item": "minecraft:dirt"
},
{
"item": "minecraft:coarse_dirt"
},
{
"item": "minecraft:podzol"
}
]
}
]

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:iron"
},
"G": {
"constant": "ironchest:glass"
"tag": "forge:ingots/iron"
},
"S": {
"item": "ironchest:copper_chest"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:iron_chest"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,7 +7,7 @@
],
"key": {
"M": {
"constant": "ironchest:silver"
"tag": "forge:ingots/silver"
},
"S": {
"item": "ironchest:copper_chest"

View File

@ -6,14 +6,65 @@
"GGG"
],
"key": {
"G": {
"constant": "ironchest:glass"
},
"S": {
"item": "ironchest:diamond_chest"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:crystal_chest"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,7 +7,7 @@
],
"key": {
"M": {
"constant": "ironchest:obsidian"
"item": "minecraft:obsidian"
},
"S": {
"item": "ironchest:diamond_chest"

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:diamond"
},
"G": {
"constant": "ironchest:glass"
"tag": "forge:gems/diamond"
},
"S": {
"item": "ironchest:gold_chest"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:diamond_chest"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,7 +7,7 @@
],
"key": {
"M": {
"constant": "ironchest:gold"
"tag": "forge:ingots/gold"
},
"S": {
"item": "ironchest:iron_chest"

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:silver"
},
"G": {
"constant": "ironchest:glass"
"tag": "forge:ingots/silver"
},
"S": {
"item": "ironchest:iron_chest"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:silver_chest"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:diamond"
},
"G": {
"constant": "ironchest:glass"
"tag": "forge:gems/diamond"
},
"S": {
"item": "ironchest:silver_chest"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:diamond_chest"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:gold"
},
"G": {
"constant": "ironchest:glass"
"tag": "forge:ingots/gold"
},
"S": {
"item": "ironchest:silver_chest"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:gold_chest"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,10 +7,10 @@
],
"key": {
"M": {
"constant": "ironchest:copper"
"tag": "forge:ingots/copper"
},
"S": {
"constant": "ironchest:chest"
"tag": "forge:chests/wooden"
}
},
"result": {

View File

@ -6,14 +6,23 @@
"MMM"
],
"key": {
"M": {
"constant": "ironchest:dirt"
},
"S": {
"constant": "ironchest:chest"
"tag": "forge:chests/wooden"
},
"M": [
{
"item": "minecraft:dirt"
},
{
"item": "minecraft:coarse_dirt"
},
{
"item": "minecraft:podzol"
}
]
},
"result": {
"item": "ironchest:dirt_chest"
}
},
"_comment": "replaceme with tag forge:dirt when out."
}

View File

@ -7,10 +7,10 @@
],
"key": {
"M": {
"constant": "ironchest:iron"
"tag": "forge:ingots/iron"
},
"S": {
"constant": "ironchest:chest"
"tag": "forge:chests/wooden"
}
},
"result": {

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:iron"
"tag": "forge:ingots/iron"
},
"S": {
"constant": "ironchest:copper"
"tag": "forge:ingots/copper"
},
"G": {
"constant": "ironchest:glass"
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:copper_iron_chest_upgrade"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,10 +7,10 @@
],
"key": {
"M": {
"constant": "ironchest:silver"
"tag": "forge:ingots/silver"
},
"S": {
"constant": "ironchest:copper"
"tag": "forge:ingots/copper"
}
},
"result": {

View File

@ -6,14 +6,65 @@
"GGG"
],
"key": {
"G": {
"constant": "ironchest:glass"
},
"S": {
"constant": "ironchest:obsidian"
"item": "minecraft:obsidian"
},
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:diamond_crystal_chest_upgrade"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,13 +7,64 @@
],
"key": {
"M": {
"constant": "ironchest:obsidian"
"item": "minecraft:obsidian"
},
"G": {
"constant": "ironchest:glass"
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:diamond_obsidian_chest_upgrade"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:diamond"
"tag": "forge:gems/diamond"
},
"S": {
"constant": "ironchest:gold"
"tag": "forge:ingots/gold"
},
"G": {
"constant": "ironchest:glass"
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:gold_diamond_chest_upgrade"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,10 +7,10 @@
],
"key": {
"M": {
"constant": "ironchest:gold"
"tag": "forge:ingots/gold"
},
"S": {
"constant": "ironchest:iron"
"tag": "forge:ingots/iron"
}
},
"result": {

View File

@ -7,16 +7,67 @@
],
"key": {
"M": {
"constant": "ironchest:gold"
"tag": "forge:ingots/gold"
},
"S": {
"constant": "ironchest:silver"
"tag": "forge:ingots/silver"
},
"G": {
"constant": "ironchest:glass"
"G": [
{
"item": "minecraft:glass"
},
{
"item": "minecraft:white_stained_glass"
},
{
"item": "minecraft:orange_stained_glass"
},
{
"item": "minecraft:magenta_stained_glass"
},
{
"item": "minecraft:light_blue_stained_glass"
},
{
"item": "minecraft:yellow_stained_glass"
},
{
"item": "minecraft:lime_stained_glass"
},
{
"item": "minecraft:pink_stained_glass"
},
{
"item": "minecraft:gray_stained_glass"
},
{
"item": "minecraft:light_gray_stained_glass"
},
{
"item": "minecraft:cyan_stained_glass"
},
{
"item": "minecraft:purple_stained_glass"
},
{
"item": "minecraft:blue_stained_glass"
},
{
"item": "minecraft:brown_stained_glass"
},
{
"item": "minecraft:green_stained_glass"
},
{
"item": "minecraft:red_stained_glass"
},
{
"item": "minecraft:black_stained_glass"
}
]
},
"result": {
"item": "ironchest:silver_gold_chest_upgrade"
}
},
"_comment": "replaceme with tag forge:glass when out."
}

View File

@ -7,10 +7,10 @@
],
"key": {
"M": {
"constant": "ironchest:copper"
"tag": "forge:ingots/copper"
},
"S": {
"constant": "ironchest:planks"
"tag": "minecraft:planks"
}
},
"result": {

View File

@ -7,10 +7,10 @@
],
"key": {
"M": {
"constant": "ironchest:iron"
"tag": "forge:ingots/iron"
},
"S": {
"constant": "ironchest:planks"
"tag": "minecraft:planks"
}
},
"result": {