mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Added medium and large storage crate
This commit is contained in:
parent
73ff44851c
commit
925b259d8f
16 changed files with 200 additions and 16 deletions
|
@ -12,10 +12,14 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -29,25 +33,35 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockGiantChest extends BlockContainerBase{
|
||||
|
||||
public BlockGiantChest(String name){
|
||||
public final int type;
|
||||
|
||||
public BlockGiantChest(String name, int type){
|
||||
super(Material.WOOD, name);
|
||||
this.type = type;
|
||||
|
||||
this.setHarvestLevel("axe", 0);
|
||||
this.setHardness(0.5F);
|
||||
this.setResistance(15.0F);
|
||||
this.setSoundType(SoundType.WOOD);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2){
|
||||
return new TileEntityGiantChest();
|
||||
switch(this.type){
|
||||
case 1: return new TileEntityGiantChestMedium();
|
||||
case 2: return new TileEntityGiantChestLarge();
|
||||
default: return new TileEntityGiantChest();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,4 +147,27 @@ public class BlockGiantChest extends BlockContainerBase{
|
|||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemBlockBase getItemBlock(){
|
||||
return new TheItemBlock(this);
|
||||
}
|
||||
|
||||
public static class TheItemBlock extends ItemBlockBase{
|
||||
|
||||
public TheItemBlock(Block block){
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced){
|
||||
int type = this.block instanceof BlockGiantChest ? ((BlockGiantChest)this.block).type : -1;
|
||||
if(type == 2){
|
||||
tooltip.add(TextFormatting.ITALIC+"Supersolid");
|
||||
}
|
||||
else if(type == 0){
|
||||
tooltip.add(TextFormatting.ITALIC+"'Small'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ public final class InitBlocks{
|
|||
public static Block blockWildPlant;
|
||||
public static Block blockFeeder;
|
||||
public static Block blockGiantChest;
|
||||
public static Block blockGiantChestMedium;
|
||||
public static Block blockGiantChestLarge;
|
||||
|
||||
public static Block blockGrinder;
|
||||
public static Block blockGrinderDouble;
|
||||
|
@ -174,7 +176,9 @@ public final class InitBlocks{
|
|||
blockCompost = new BlockCompost("blockCompost");
|
||||
blockMisc = new BlockMisc("blockMisc");
|
||||
blockFeeder = new BlockFeeder("blockFeeder");
|
||||
blockGiantChest = new BlockGiantChest("blockGiantChest");
|
||||
blockGiantChest = new BlockGiantChest("blockGiantChest", 0);
|
||||
blockGiantChestMedium = new BlockGiantChest("blockGiantChestMedium", 1);
|
||||
blockGiantChestLarge = new BlockGiantChest("blockGiantChestLarge", 2);
|
||||
blockGrinder = new BlockGrinder(false, "blockGrinder");
|
||||
blockGrinderDouble = new BlockGrinder(true, "blockGrinderDouble");
|
||||
blockFurnaceDouble = new BlockFurnaceDouble("blockFurnaceDouble");
|
||||
|
|
|
@ -24,7 +24,6 @@ public class ItemBlockBase extends ItemBlock{
|
|||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack){
|
||||
return this.getUnlocalizedName();
|
||||
|
@ -35,7 +34,6 @@ public class ItemBlockBase extends ItemBlock{
|
|||
return damage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
if(this.block instanceof BlockBase){
|
||||
|
|
|
@ -105,6 +105,8 @@ public class CreativeTab extends CreativeTabs{
|
|||
this.add(InitBlocks.blockFeeder);
|
||||
this.add(InitBlocks.blockCompost);
|
||||
this.add(InitBlocks.blockGiantChest);
|
||||
this.add(InitBlocks.blockGiantChestMedium);
|
||||
this.add(InitBlocks.blockGiantChestLarge);
|
||||
this.add(InitBlocks.blockCanolaPress);
|
||||
this.add(InitBlocks.blockFermentingBarrel);
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ public class ContainerGiantChest extends Container{
|
|||
|
||||
public final TileEntityGiantChest tileChest;
|
||||
|
||||
public ContainerGiantChest(InventoryPlayer inventory, TileEntityBase tile){
|
||||
public ContainerGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page){
|
||||
this.tileChest = (TileEntityGiantChest)tile;
|
||||
|
||||
for(int i = 0; i < 9; i++){
|
||||
for(int j = 0; j < 13; j++){
|
||||
this.addSlotToContainer(new Slot(this.tileChest, j+(i*13), 5+j*18, 5+i*18));
|
||||
this.addSlotToContainer(new Slot(this.tileChest, (9*13*page)+j+(i*13), 5+j*18, 5+i*18));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,11 @@ public class GuiHandler implements IGuiHandler{
|
|||
case FEEDER:
|
||||
return new ContainerFeeder(entityPlayer.inventory, tile);
|
||||
case GIANT_CHEST:
|
||||
return new ContainerGiantChest(entityPlayer.inventory, tile);
|
||||
return new ContainerGiantChest(entityPlayer.inventory, tile, 0);
|
||||
case GIANT_CHEST_PAGE_2:
|
||||
return new ContainerGiantChest(entityPlayer.inventory, tile, 1);
|
||||
case GIANT_CHEST_PAGE_3:
|
||||
return new ContainerGiantChest(entityPlayer.inventory, tile, 2);
|
||||
case CRAFTER:
|
||||
return new ContainerCrafter(entityPlayer);
|
||||
case GRINDER:
|
||||
|
@ -107,7 +111,11 @@ public class GuiHandler implements IGuiHandler{
|
|||
case FEEDER:
|
||||
return new GuiFeeder(entityPlayer.inventory, tile);
|
||||
case GIANT_CHEST:
|
||||
return new GuiGiantChest(entityPlayer.inventory, tile);
|
||||
return new GuiGiantChest(entityPlayer.inventory, tile, 0);
|
||||
case GIANT_CHEST_PAGE_2:
|
||||
return new GuiGiantChest(entityPlayer.inventory, tile, 1);
|
||||
case GIANT_CHEST_PAGE_3:
|
||||
return new GuiGiantChest(entityPlayer.inventory, tile, 2);
|
||||
case CRAFTER:
|
||||
return new GuiCrafter(entityPlayer);
|
||||
case GRINDER:
|
||||
|
@ -172,6 +180,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
public enum GuiTypes{
|
||||
FEEDER,
|
||||
GIANT_CHEST,
|
||||
GIANT_CHEST_PAGE_2,
|
||||
GIANT_CHEST_PAGE_3,
|
||||
CRAFTER(false),
|
||||
GRINDER,
|
||||
GRINDER_DOUBLE,
|
||||
|
|
|
@ -11,31 +11,67 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerGiantChest;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiGiantChest extends GuiContainer{
|
||||
|
||||
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiGiantChest");
|
||||
|
||||
final TileEntityGiantChest chest;
|
||||
private final TileEntityGiantChest chest;
|
||||
private final int page;
|
||||
|
||||
public GuiGiantChest(InventoryPlayer inventory, TileEntityBase tile){
|
||||
super(new ContainerGiantChest(inventory, tile));
|
||||
public GuiGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page){
|
||||
super(new ContainerGiantChest(inventory, tile, page));
|
||||
this.chest = (TileEntityGiantChest)tile;
|
||||
this.page = page;
|
||||
|
||||
this.xSize = 242;
|
||||
this.ySize = 172+86;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
if(this.page > 0){
|
||||
this.buttonList.add(new GuiButton(this.page-1, this.guiLeft+13, this.guiTop+172, 20, 20, "<"));
|
||||
}
|
||||
|
||||
if((this.page == 0 && this.chest instanceof TileEntityGiantChestMedium) || (this.page <= 1 && this.chest instanceof TileEntityGiantChestLarge)){
|
||||
this.buttonList.add(new GuiButton(this.page+1, this.guiLeft+209, this.guiTop+172, 20, 20, ">"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.chest.getPos().getX());
|
||||
compound.setInteger("Y", this.chest.getPos().getY());
|
||||
compound.setInteger("Z", this.chest.getPos().getZ());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("WorldID", this.chest.getWorld().provider.getDimension());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerForegroundLayer(int x, int y){
|
||||
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.chest.getName());
|
||||
|
|
|
@ -53,6 +53,8 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
GameRegistry.registerTileEntity(TileEntityCompost.class, ModUtil.MOD_ID+":tileEntityCompost");
|
||||
GameRegistry.registerTileEntity(TileEntityFeeder.class, ModUtil.MOD_ID+":tileEntityFeeder");
|
||||
GameRegistry.registerTileEntity(TileEntityGiantChest.class, ModUtil.MOD_ID+":tileEntityGiantChest");
|
||||
GameRegistry.registerTileEntity(TileEntityGiantChestMedium.class, ModUtil.MOD_ID+":tileEntityGiantChestMedium");
|
||||
GameRegistry.registerTileEntity(TileEntityGiantChestLarge.class, ModUtil.MOD_ID+":tileEntityGiantChestLarge");
|
||||
GameRegistry.registerTileEntity(TileEntityGrinder.class, ModUtil.MOD_ID+":tileEntityGrinder");
|
||||
GameRegistry.registerTileEntity(TileEntityFurnaceDouble.class, ModUtil.MOD_ID+":tileEntityFurnaceDouble");
|
||||
GameRegistry.registerTileEntity(TileEntityInputter.class, ModUtil.MOD_ID+":tileEntityInputter");
|
||||
|
|
|
@ -11,13 +11,21 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TileEntityGiantChest extends TileEntityInventoryBase{
|
||||
public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor{
|
||||
|
||||
public TileEntityGiantChest(int slotAmount){
|
||||
super(slotAmount, "giantChest");
|
||||
}
|
||||
|
||||
public TileEntityGiantChest(){
|
||||
super(9*13, "giantChest");
|
||||
this(9*13);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,4 +42,21 @@ public class TileEntityGiantChest extends TileEntityInventoryBase{
|
|||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonPressed(int buttonID, EntityPlayer player){
|
||||
GuiHandler.GuiTypes type;
|
||||
|
||||
if(buttonID == 0){
|
||||
type = GuiHandler.GuiTypes.GIANT_CHEST;
|
||||
}
|
||||
else if(buttonID == 1){
|
||||
type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2;
|
||||
}
|
||||
else{
|
||||
type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3;
|
||||
}
|
||||
|
||||
player.openGui(ActuallyAdditions.instance, type.ordinal(), this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* This file ("TileEntityGiantChestLarge.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
public class TileEntityGiantChestLarge extends TileEntityGiantChest{
|
||||
|
||||
public TileEntityGiantChestLarge(){
|
||||
super(9*13*3);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* This file ("TileEntityGiantChestMedium.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
public class TileEntityGiantChestMedium extends TileEntityGiantChest{
|
||||
|
||||
public TileEntityGiantChestMedium(){
|
||||
super(9*13*2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "actuallyadditions:blocks/blockGiantChestLarge",
|
||||
"bottom": "actuallyadditions:blocks/blockGiantChestBottom",
|
||||
"top": "actuallyadditions:blocks/blockGiantChestTop"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "actuallyadditions:blocks/blockGiantChestMedium",
|
||||
"bottom": "actuallyadditions:blocks/blockGiantChestBottom",
|
||||
"top": "actuallyadditions:blocks/blockGiantChestTop"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -108,7 +108,9 @@ tile.actuallyadditions.blockMiscBlackQuartz.name=Block of Black Quartz
|
|||
tile.actuallyadditions.blockMiscBlackQuartzChiseled.name=Chiseled Block of Black Quartz
|
||||
tile.actuallyadditions.blockMiscBlackQuartzPillar.name=Pillar of Black Quartz
|
||||
tile.actuallyadditions.blockFeeder.name=Automatic Feeder
|
||||
tile.actuallyadditions.blockGiantChest.name=Storage Crate
|
||||
tile.actuallyadditions.blockGiantChest.name=Small Storage Crate
|
||||
tile.actuallyadditions.blockGiantChestMedium.name=Medium Storage Crate
|
||||
tile.actuallyadditions.blockGiantChestLarge.name=Large Storage Crate
|
||||
tile.actuallyadditions.blockGrinder.name=Crusher
|
||||
tile.actuallyadditions.blockGrinderDouble.name=Double Crusher
|
||||
tile.actuallyadditions.blockFurnaceDouble.name=Double Furnace
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 737 B |
Binary file not shown.
After Width: | Height: | Size: 756 B |
Loading…
Reference in a new issue