1
0
Fork 0

improve container gui

This commit is contained in:
Sen 2025-09-08 00:15:58 +02:00
parent fe4a8fa6a5
commit 10abaef2b4
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
9 changed files with 47 additions and 173 deletions

View file

@ -43,32 +43,26 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
public static final PropertyBool OPEN = PropertyBool.create("open");
private static final Map<Integer, BlockChest> CHESTS = Maps.newHashMap();
private final int width;
private final int height;
private final int capacity;
public static BlockChest getChest(int size) {
return CHESTS.get(size);
}
public BlockChest(int width, int height)
public BlockChest(int capacity)
{
super(width == 9 && height == 3 ? Material.WOOD : Material.SOLID);
super(capacity <= 30 ? Material.WOOD : Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(OPEN, false));
this.width = width;
this.height = height;
this.capacity = capacity;
this.setTab(CheatTab.TECHNOLOGY);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
this.setHardness(2.5F);
this.setSound(width == 9 && height == 3 ? SoundType.WOOD : SoundType.STONE);
CHESTS.put(this.width * this.height, this);
this.setSound(capacity <= 30 ? SoundType.WOOD : SoundType.STONE);
CHESTS.put(this.capacity, this);
}
public int getInventoryWidth() {
return this.width;
}
public int getInventoryHeight() {
return this.height;
public int getInventoryCapacity() {
return this.capacity;
}
public boolean isOpaqueCube()
@ -208,7 +202,7 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
public TileEntity createNewTileEntity()
{
return new TileEntityChest(this.width * this.height);
return new TileEntityChest(this.capacity);
}
private boolean isBlocked(World worldIn, LocalPos pos)
@ -261,12 +255,12 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
@Clientside
public void getTooltips(ItemStack stack, EntityNPC player, List<String> tooltip) {
super.getTooltips(stack, player, tooltip);
tooltip.add(Color.DARK_GREEN + "Kapazität" + Color.DARK_GRAY + ": " + Color.GREEN + (this.width * this.height));
tooltip.add(Color.DARK_GREEN + "Kapazität" + Color.DARK_GRAY + ": " + Color.GREEN + this.capacity);
}
@Clientside
public String getInfo(World world, LocalPos pos, State state, EntityNPC player) {
return Color.DARK_GREEN + "Kapazität für " + Color.GREEN + (this.width * this.height) + Color.DARK_GREEN + " Gegenstände";
return Color.DARK_GREEN + "Kapazität für " + Color.GREEN + this.capacity + Color.DARK_GREEN + " Gegenstände";
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -25,25 +25,14 @@ import common.world.AWorldServer;
public class EntityItem extends Entity
{
/**
* The age of this EntityItem (used to animate it up and down as well as expire it)
*/
private int age;
private int delayBeforeCanPickup;
/** The health of this EntityItem. (For example, damage for tools) */
private int health;
// private String thrower;
// private String owner;
/** The EntityItem's random initial float height. */
public float hoverStart;
public EntityItem(World worldIn, double x, double y, double z)
{
super(worldIn);
this.health = 5;
this.hoverStart = (float)(Math.random() * Math.PI * 2.0D);
this.setSize(0.25F, 0.25F);
this.setPosition(x, y, z);
this.rotYaw = (float)(Math.random() * 360.0D);
@ -58,11 +47,6 @@ public class EntityItem extends Entity
this.setEntityItemStack(stack);
}
// public EntityItem(World worldIn, double x, double y, double z, int data)
// {
// this(worldIn, x, y, z);
// }
public void fall(float distance, float damageMultiplier)
{
if(!this.worldObj.client && ((Vars.itemFallDamage && distance >= 1.0f && this.getEntityItem().getItem().isFragile()) || (Vars.itemExplosion && distance >= 2.0f && this.getEntityItem().getItem().getExplosive() > 0))) {
@ -90,7 +74,6 @@ public class EntityItem extends Entity
{
super(worldIn);
this.health = 5;
this.hoverStart = (float)(Math.random() * Math.PI * 2.0D);
this.setSize(0.25F, 0.25F);
this.setEntityItemStack(new ItemStack((Item)null, 0));
}

View file

@ -574,14 +574,14 @@ public abstract class BlockRegistry {
register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel").setTab(CheatTab.TECHNOLOGY));
register("effect_generator", (new BlockEffectGenerator()).setDisplay("Effektgenerator").setLight(0xffffff));
register("wood_chest", new BlockChest(9, 3).setDisplay("Holztruhe"));
register("stone_chest", new BlockChest(9, 6).setDisplay("Steintruhe"));
register("iron_chest", new BlockChest(12, 8).setDisplay("Eisentruhe"));
register("platinum_chest", new BlockChest(16, 10).setDisplay("Platintruhe"));
register("silver_chest", new BlockChest(18, 14).setDisplay("Silbertruhe"));
register("thetium_chest", new BlockChest(22, 18).setDisplay("Thetiumtruhe"));
register("black_metal_chest", new BlockChest(28, 18).setDisplay("Schwarzmetalltruhe"));
register("nichun_chest", new BlockChest(32, 18).setDisplay("Nichuntruhe"));
register("wood_chest", new BlockChest(22).setDisplay("Holztruhe"));
register("stone_chest", new BlockChest(48).setDisplay("Steintruhe"));
register("iron_chest", new BlockChest(90).setDisplay("Eisentruhe"));
register("platinum_chest", new BlockChest(150).setDisplay("Platintruhe"));
register("silver_chest", new BlockChest(240).setDisplay("Silbertruhe"));
register("thetium_chest", new BlockChest(384).setDisplay("Thetiumtruhe"));
register("black_metal_chest", new BlockChest(480).setDisplay("Schwarzmetalltruhe"));
register("nichun_chest", new BlockChest(550).setDisplay("Nichuntruhe"));
register("warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setSound(SoundType.STONE)
.setDisplay("Warptruhe").setLight(0x7f00af));

View file

@ -2,7 +2,6 @@ package common.inventory;
import java.util.List;
import common.block.tech.BlockChest;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
@ -12,24 +11,16 @@ public class ContainerChest extends Container
{
private final IInventory chest;
private final int chestSize;
private final int width;
private final int height;
public ContainerChest(EntityNPC player, IInventory chest)
{
this.chest = chest;
this.chestSize = chest.getSizeInventory();
BlockChest block = BlockChest.getChest(this.chestSize);
this.width = block.getInventoryWidth();
this.height = block.getInventoryHeight();
List<SlotCommon> list = Lists.newArrayList();
for (int j = 0; j < this.height; ++j)
for (int j = 0; j < this.chestSize; ++j)
{
for (int k = 0; k < this.width; ++k)
{
this.addSlotToContainer(new SlotCommon(list, chest, k + j * this.width, false));
}
this.addSlotToContainer(new SlotCommon(list, chest, j, false));
}
this.addPlayerSlots(player);
@ -100,14 +91,4 @@ public class ContainerChest extends Container
{
return this.chest;
}
public int getWidth()
{
return this.width;
}
public int getHeight()
{
return this.height;
}
}