1
0
Fork 0

change hotbar behaviour

This commit is contained in:
Sen 2025-09-04 13:58:29 +02:00
parent c10996bbda
commit 771a8bfa89
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
17 changed files with 169 additions and 114 deletions

View file

@ -33,7 +33,7 @@ import common.inventory.IInventory;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.GuiPosition;
@ -1019,7 +1019,7 @@ public class Block {
return true;
}
public StackSize getMaxAmount() {
public ItemWeight getWeight() {
return null;
}

View file

@ -7,7 +7,7 @@ import common.entity.npc.EntityNPC;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.ModelRotation;
@ -199,8 +199,8 @@ public class BlockBed extends Block implements Rotatable {
return this.getState().withProperty(PART, EnumPartType.HEAD).withProperty(FACING, Facing.NORTH);
}
public StackSize getMaxAmount() {
return StackSize.S;
public ItemWeight getWeight() {
return ItemWeight.L;
}
public boolean place(ItemStack stack, EntityNPC playerIn, World worldIn, LocalPos pos, Facing side, float hitX, float hitY, float hitZ)

View file

@ -11,7 +11,7 @@ import common.init.Blocks;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.item.tool.ItemKey;
import common.model.Model;
import common.model.Model.ModelProvider;
@ -299,8 +299,8 @@ public class BlockDoor extends Block implements Rotatable {
return this == Blocks.iron_door;
}
public StackSize getMaxAmount() {
return StackSize.S;
public ItemWeight getWeight() {
return ItemWeight.L;
}
public boolean place(ItemStack stack, EntityNPC playerIn, World worldIn, LocalPos pos, Facing side, float hitX, float hitY, float hitZ)

View file

@ -9,7 +9,7 @@ import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.item.tool.ItemTool;
import common.model.Model;
import common.model.Model.ModelProvider;
@ -279,8 +279,8 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
return this.getState().withProperty(HALF, EnumBlockHalf.UPPER);
}
public StackSize getMaxAmount() {
return StackSize.S;
public ItemWeight getWeight() {
return ItemWeight.L;
}
public static enum EnumBlockHalf implements Identifyable

View file

@ -3,7 +3,7 @@ package common.block.foliage;
import common.block.Block;
import common.block.Material;
import common.init.Blocks;
import common.item.StackSize;
import common.item.ItemWeight;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.GuiPosition;
@ -151,8 +151,8 @@ public class BlockReed extends Block
return new Property[] {AGE};
}
public StackSize getMaxAmount() {
return StackSize.L;
public ItemWeight getWeight() {
return ItemWeight.S;
}
public GuiPosition getItemPosition() {

View file

@ -5,7 +5,7 @@ import java.util.List;
import common.block.Block;
import common.block.Material;
import common.entity.Entity;
import common.item.StackSize;
import common.item.ItemWeight;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.ModelRotation;
@ -298,8 +298,8 @@ public class BlockString extends Block
return new Property[] {TOUCHED};
}
public StackSize getMaxAmount() {
return StackSize.XXXL;
public ItemWeight getWeight() {
return ItemWeight.XXXS;
}
protected Property[] getUnsavedProperties() {

View file

@ -7,7 +7,7 @@ import java.util.Set;
import common.block.Block;
import common.block.Material;
import common.collect.Sets;
import common.item.StackSize;
import common.item.ItemWeight;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.ModelRotation;
@ -525,8 +525,8 @@ public class BlockWire extends Block
.u("wire_line").uv(2, 2, 14, 14).noCull();
}
public StackSize getMaxAmount() {
return StackSize.XL;
public ItemWeight getWeight() {
return ItemWeight.XS;
}
protected Property[] getUnsavedProperties() {

View file

@ -22,7 +22,7 @@ import common.entity.npc.SpeciesInfo;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.item.consumable.ItemAppleGold;
import common.item.consumable.ItemMilkBottle;
import common.item.consumable.ItemFishFood;
@ -163,13 +163,13 @@ public abstract class ItemRegistry {
register("minecart", (new ItemMinecart()).setDisplay("Lore", "Füße zu träge? Keine Kraft mehr in den Beinen?", "Diese Lore wird dich garantiert mühelos an dein Ziel bringen!", "Hinweis: Keine Haftung bei Schäden oder spontanem Tod durch", "ungünstig platzierte Schienen oder darüber laufende Kreaturen"));
for(EntityInfo egg : EntityRegistry.DNA.values()) {
register("dna_sample_" + egg.id().toLowerCase(), (new ItemMobTemplate(egg.id()))
.setMaxAmount(StackSize.L));
.setWeight(ItemWeight.S));
}
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
for(CharacterInfo charinfo : species.chars) {
if(charinfo.dna)
register("dna_sample_" + charinfo.skin, (new ItemCharTemplate(charinfo))
.setMaxAmount(StackSize.L));
.setWeight(ItemWeight.S));
}
}
@ -178,16 +178,16 @@ public abstract class ItemRegistry {
register("trident", (new ItemTrident()).setDisplay("Geladenes Zepter"));
register("banhammer", (new ItemBanHammer()).setDisplay("Hammer der Verbannung"));
ItemKey key;
register("key", (key = new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("black_key", (new ItemKey()).setDisplay("Schwarzer Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("shiny_key", (new ItemKey()).setDisplay("Glänzender Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("rusty_key", (new ItemKey()).setDisplay("Rostiger Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("red_keycard", (new ItemKey()).setDisplay("Rote Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("green_keycard", (new ItemKey()).setDisplay("Grüne Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("blue_keycard", (new ItemKey()).setDisplay("Blaue Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("black_keycard", (new ItemKey()).setDisplay("Schwarze Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("key", (key = new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("black_key", (new ItemKey()).setDisplay("Schwarzer Schlüssel").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("shiny_key", (new ItemKey()).setDisplay("Glänzender Schlüssel").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("rusty_key", (new ItemKey()).setDisplay("Rostiger Schlüssel").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("red_keycard", (new ItemKey()).setDisplay("Rote Schlüsselkarte").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("green_keycard", (new ItemKey()).setDisplay("Grüne Schlüsselkarte").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("blue_keycard", (new ItemKey()).setDisplay("Blaue Schlüsselkarte").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
register("black_keycard", (new ItemKey()).setDisplay("Schwarze Schlüsselkarte").setTab(CheatTab.TOOLS).setWeight(ItemWeight.S));
for(Pair<Integer, Color> sides : ItemDie.DIE_SIDES) {
register("die_" + sides.first(), (new ItemDie(sides.first(), sides.second())).setMaxAmount(StackSize.L));
register("die_" + sides.first(), (new ItemDie(sides.first(), sides.second())).setWeight(ItemWeight.S));
}
register("chick_magnet", (new ItemMagnet(true)).setDisplay("Kükenmagnet"));
register("magnet", (new ItemMagnet(false)).setDisplay("Magnet"));
@ -201,20 +201,20 @@ public abstract class ItemRegistry {
register("burning_soul", (new ItemFire(Blocks.soul_fire)).setDisplay("Brennende Seele"));
register("dark_lighter", (new ItemFire(Blocks.black_fire)).setDisplay("Verdunkelndes Feuerzeug"));
register("hoe", (new ItemHoe()).setDisplay("Hacke"));
register("apple", (new ItemFood(4, false)).setDisplay("Apfel").setMaxAmount(StackSize.L));
register("apple", (new ItemFood(4, false)).setDisplay("Apfel").setWeight(ItemWeight.S));
register("bow", (new ItemBow()).setDisplay("Bogen"));
register("boltgun", (new ItemBoltgun()).setDisplay("Bolter"));
register("bolt", (new ItemAmmo(5, 1.0f, StackSize.L)).setDisplay("Bolter-Munition"));
register("bolt", (new ItemAmmo(5, 1.0f, ItemWeight.S)).setDisplay("Bolter-Munition"));
register("rocket_launcher", (new ItemRocketLauncher()).setDisplay("Raketenwerfer"));
register("rocket", (new ItemAmmo(6, 6.0f, StackSize.L)).setDisplay("Rakete").setExplosive(4));
register("arrow", (new ItemArrow()).setDisplay("Pfeil").setTab(CheatTab.WEAPONS).setMaxAmount(StackSize.L));
register("rocket", (new ItemAmmo(6, 6.0f, ItemWeight.S)).setDisplay("Rakete").setExplosive(4));
register("arrow", (new ItemArrow()).setDisplay("Pfeil").setTab(CheatTab.WEAPONS).setWeight(ItemWeight.S));
register("charcoal", (new Item()).setDisplay("Holzkohle").setTab(CheatTab.METALS).setFuelAmount(1200));
register("stick", (new Item()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(100));
register("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XXL));
register("gunpowder", (new Item()).setDisplay("Schwarzpulver").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setExplosive(1));
register("wheat", (new Item()).setDisplay("Weizen").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("stick", (new Item()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS).setFuelAmount(100));
register("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XXS));
register("gunpowder", (new Item()).setDisplay("Schwarzpulver").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS).setExplosive(1));
register("wheat", (new Item()).setDisplay("Weizen").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.S));
register("bread", (new ItemFood(5, false)).setDisplay("Brot"));
register("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.S));
register("porkchop", (new ItemFood(3, true)).setDisplay("Rohes Schweinefleisch"));
register("cooked_porkchop", (new ItemFood(8, true)).setDisplay("Gebratenes Schweinefleisch"));
register("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Effect.REGENERATION, 5, 1, 1.0F)
@ -222,19 +222,19 @@ public abstract class ItemRegistry {
register("charged_apple", (new ItemAppleGold(4, true)).setPotionEffect(Effect.REGENERATION, 5, 1, 1.0F)
.setDisplay("Geladener Apfel").setExplosive(3));
register("saddle", (new ItemSaddle()).setDisplay("Sattel"));
register("snowball", (new ItemSnowball()).setDisplay("Schneeball").setMaxAmount(StackSize.L));
register("snowball", (new ItemSnowball()).setDisplay("Schneeball").setWeight(ItemWeight.S));
register("leather", (new Item()).setDisplay("Leder").setTab(CheatTab.MATERIALS));
register("brick", (new Item()).setDisplay("Ziegel").setTab(CheatTab.MATERIALS));
register("clay_lump", (new Item()).setDisplay("Ton").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setDefaultColor(0xffffff).setFuelAmount(40));
register("clay_lump", (new Item()).setDisplay("Ton").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.S));
register("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS).setDefaultColor(0xffffff).setFuelAmount(40));
register("book", (new ItemBook()).setDisplay("Buch").setTab(CheatTab.MATERIALS).setFuelAmount(60));
register("slime_blob", (new Item()).setDisplay("Schleim").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("egg", (new ItemEgg()).setDisplay("Ei").setMaxAmount(StackSize.L));
register("slime_blob", (new Item()).setDisplay("Schleim").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.S));
register("egg", (new ItemEgg()).setDisplay("Ei").setWeight(ItemWeight.S));
register("navigator", (new ItemSpaceNavigator()).setDisplay("Elektronischer Navigator").setTab(CheatTab.TOOLS));
register("exterminator", (new ItemExterminator()).setDisplay("Weltenzerstörer"));
register("fishing_rod", (new ItemFishingRod()).setDisplay("Angel"));
register("glowing_powder", (new Item()).setDisplay("Glühender Staub")
.setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(600));
.setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS).setFuelAmount(600));
for(ItemFishFood.FishType type : ItemFishFood.FishType.values()) {
register(type.getName(), (new ItemFishFood(false, type)));
register("cooked_" + type.getName(), (new ItemFishFood(true, type)));
@ -242,9 +242,9 @@ public abstract class ItemRegistry {
for(Color color : Color.values()) {
register(color.getName() + "_dye", new ItemDye(color));
}
register("bone", (new Item()).setDisplay("Knochen").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("sugar", (new Item()).setDisplay("Zucker").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XXL));
register("cookie", (new ItemFood(2, false)).setDisplay("Keks").setMaxAmount(StackSize.L));
register("bone", (new Item()).setDisplay("Knochen").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.S));
register("sugar", (new Item()).setDisplay("Zucker").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XXS));
register("cookie", (new ItemFood(2, false)).setDisplay("Keks").setWeight(ItemWeight.S));
register("melon", (new ItemFood(2, false)).setDisplay("Melone"));
register("beef", (new ItemFood(3, true)).setDisplay("Rohes Rindfleisch"));
register("cooked_beef", (new ItemFood(8, true)).setDisplay("Steak"));
@ -252,9 +252,9 @@ public abstract class ItemRegistry {
register("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen"));
register("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch"));
register("orb", (new Item()).setDisplay("Kugel").setTab(CheatTab.MAGIC).setFragile());
register("demon_rod", (new Item()).setDisplay("Dämonenrute").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(2400));
register("gold_coin", (new Item()).setDisplay("Goldmünze").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("gold_nugget", (new Item()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(StackSize.XL));
register("demon_rod", (new Item()).setDisplay("Dämonenrute").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS).setFuelAmount(2400));
register("gold_coin", (new Item()).setDisplay("Goldmünze").setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS));
register("gold_nugget", (new Item()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setWeight(ItemWeight.XS));
Item bottle;
register("bottle", (bottle = new ItemBottle()).setDisplay("Flasche"));
for(Pair<String, Effect> pot : ItemPotion.getBasePotions()) {
@ -265,22 +265,22 @@ public abstract class ItemRegistry {
}
register("milk_bottle", (new ItemMilkBottle()).setDisplay("Flasche mit Milch").setContainerItem(bottle));
register("eye", (new ItemFood(2, false)).setPotionEffect(Effect.POISON, 5, 0, 1.0F).setDisplay("Auge")
.setMaxAmount(StackSize.L));
.setWeight(ItemWeight.S));
register("blazing_powder", (new Item()).setDisplay("Schillernder Staub")
.setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(600));
.setTab(CheatTab.MATERIALS).setWeight(ItemWeight.XS).setFuelAmount(600));
register("charged_orb", (new ItemChargedOrb()).setDisplay("Geladene Kugel"));
register("fireball", (new ItemFireball()).setDisplay("Feuerkugel").setFuelAmount(1000));
register("cocoa_powder", new Item().setTab(CheatTab.MATERIALS).setDisplay("Gemahlene Kakaobohnen").setMaxAmount(StackSize.L));
register("grinded_bones", new ItemGrindedBones().setTab(CheatTab.MATERIALS).setDisplay("Gemahlene Knochen").setMaxAmount(StackSize.L));
register("ink_sack", new Item().setTab(CheatTab.MATERIALS).setDisplay("Tintenbeutel").setMaxAmount(StackSize.L));
register("cocoa_powder", new Item().setTab(CheatTab.MATERIALS).setDisplay("Gemahlene Kakaobohnen").setWeight(ItemWeight.S));
register("grinded_bones", new ItemGrindedBones().setTab(CheatTab.MATERIALS).setDisplay("Gemahlene Knochen").setWeight(ItemWeight.S));
register("ink_sack", new Item().setTab(CheatTab.MATERIALS).setDisplay("Tintenbeutel").setWeight(ItemWeight.S));
register("carrot", new ItemSeedFood(3, Blocks.carrots, Blocks.farmland).setDisplay("Karotte").setMaxAmount(StackSize.L));
register("potato", new ItemSeedFood(1, Blocks.potatoes, Blocks.farmland).setDisplay("Kartoffel").setMaxAmount(StackSize.L));
register("wheat_seed", new ItemSeeds(Blocks.wheats, Blocks.farmland).setDisplay("Weizenkörner").setMaxAmount(StackSize.XL));
register("soul_seed", new ItemSeeds(Blocks.soul_grass, Blocks.soul_sand).setDisplay("Seelenwarze").setMaxAmount(StackSize.L));
register("pumpkin_seed", new ItemSeeds(Blocks.pumpkin_stem, Blocks.farmland).setDisplay("Kürbiskerne").setMaxAmount(StackSize.XL));
register("melon_seed", new ItemSeeds(Blocks.melon_stem, Blocks.farmland).setDisplay("Melonenkerne").setMaxAmount(StackSize.XL));
register("carrot", new ItemSeedFood(3, Blocks.carrots, Blocks.farmland).setDisplay("Karotte").setWeight(ItemWeight.S));
register("potato", new ItemSeedFood(1, Blocks.potatoes, Blocks.farmland).setDisplay("Kartoffel").setWeight(ItemWeight.S));
register("wheat_seed", new ItemSeeds(Blocks.wheats, Blocks.farmland).setDisplay("Weizenkörner").setWeight(ItemWeight.XS));
register("soul_seed", new ItemSeeds(Blocks.soul_grass, Blocks.soul_sand).setDisplay("Seelenwarze").setWeight(ItemWeight.S));
register("pumpkin_seed", new ItemSeeds(Blocks.pumpkin_stem, Blocks.farmland).setDisplay("Kürbiskerne").setWeight(ItemWeight.XS));
register("melon_seed", new ItemSeeds(Blocks.melon_stem, Blocks.farmland).setDisplay("Melonenkerne").setWeight(ItemWeight.XS));
register("whip", (new ItemWhip()).setDisplay("Peitsche"));
register("charge_crystal", (new Item()).setDisplay("Energiekristall").setTab(CheatTab.MATERIALS).setColor(Color.DARK_MAGENTA).setFuelAmount(120000));
@ -294,7 +294,7 @@ public abstract class ItemRegistry {
}
register("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS));
register("blackbrick", (new Item()).setDisplay("Schwarzer Ziegel").setTab(CheatTab.MATERIALS));
register("lead", (new ItemLead()).setDisplay("Leine").setMaxAmount(StackSize.L));
register("lead", (new ItemLead()).setDisplay("Leine").setWeight(ItemWeight.S));
register("name_tag", (new ItemNameTag()).setDisplay("Namensschild"));
for(int z = 0; z < ItemDynamite.DYNAMITE.length; z++) {
register("dynamite" + (z == 0 ? "" : ("_" + z)), (new ItemDynamite(z)).setDisplay("Dynamit" + Util.getTierSuffix(z)).setColor(Color.RED));

View file

@ -25,7 +25,8 @@ import common.world.World;
public class Item {
private final Block block;
private int maxAmount = StackSize.M.getAmount();
private boolean stackable = true;
private int weight = ItemWeight.M.getWeight();
private int maxDamage = 0;
private Item containerItem;
private String display;
@ -48,8 +49,8 @@ public class Item {
this.setTab(this.block.getTab());
if(this.block.isMagnetic())
this.setMagnetic();
if(this.block.getMaxAmount() != null)
this.setMaxAmount(this.block.getMaxAmount());
if(this.block.getWeight() != null)
this.setWeight(this.block.getWeight());
if(this.block.getItemColor() != null)
this.setColor(this.block.getItemColor());
if(this.block.getExplosive() > 0)
@ -59,19 +60,22 @@ public class Item {
}
public final Item setUnstackable() {
this.maxAmount = 1;
this.stackable = false;
this.maxDamage = 0;
return this;
}
public final Item setMaxAmount(StackSize size) {
this.maxAmount = size.getAmount();
this.maxDamage = 0;
public final Item setWeight(int weight) {
this.weight = weight;
return this;
}
public final Item setWeight(ItemWeight size) {
return this.setWeight(size.getWeight());
}
public final Item setMaxDamage(int max) {
this.maxAmount = 1;
this.stackable = false;
this.maxDamage = max;
return this;
}
@ -128,7 +132,7 @@ public class Item {
}
public final int getMaxAmount() {
return this.maxAmount;
return this.stackable ? 67108864 : 1;
}
public final int getMaxDamage() {

View file

@ -21,6 +21,24 @@ import common.util.Color;
import common.util.Equipment;
public final class ItemStack {
public class ItemKey {
public ItemStack getStack() {
return ItemStack.this;
}
public int hashCode() {
return ItemStack.this.item.hashCode();
}
public boolean equals(Object other) {
if(other == this)
return true;
if(other instanceof ItemKey key)
return ItemStack.this == key.getStack() || (ItemStack.this.isStackable() && key.getStack().isStackable() && ItemStack.this.itemEquals(key.getStack()) && ItemStack.this.dataEquals(key.getStack()));
return false;
}
}
private Item item;
private int size;
private String name;
@ -28,6 +46,7 @@ public final class ItemStack {
private int damage;
private int repairCost;
private Map<Enchantment, Integer> enchantments;
private ItemKey key;
public static ItemStack readFromTag(TagObject tag) {
Item item = tag.hasString("id") ? ItemRegistry.byName(tag.getString("id")) : null;
@ -410,4 +429,10 @@ public final class ItemStack {
public void damage(int amount, EntityLiving entity) {
this.damage(amount, entity, entity.getRNG());
}
public ItemKey getKey() {
if(this.key == null)
this.key = new ItemKey();
return this.key;
}
}

View file

@ -0,0 +1,23 @@
package common.item;
public enum ItemWeight {
XXXL(100),
XXL(70),
XL(35),
L(20),
M(10),
S(6),
XS(4),
XXS(2),
XXXS(1);
private final int amount;
private ItemWeight(int amount) {
this.amount = amount;
}
public int getWeight() {
return this.amount;
}
}

View file

@ -1,22 +0,0 @@
package common.item;
public enum StackSize {
XXS(8),
XS(16),
S(32),
M(64),
L(128),
XL(256),
XXL(512),
XXXL(1024);
private final int amount;
private StackSize(int amount) {
this.amount = amount;
}
public int getAmount() {
return this.amount;
}
}

View file

@ -15,7 +15,7 @@ import common.item.Item;
import common.item.ItemAction;
import common.item.ItemControl;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.tileentity.TileEntity;
import common.util.LocalPos;
import common.util.Clientside;
@ -72,7 +72,7 @@ public class ItemPotion extends Item
{
this.type = type;
this.effect = effect;
this.setMaxAmount(StackSize.XS);
this.setWeight(ItemWeight.XL);
this.setTab(CheatTab.POTIONS);
this.setColor(Color.ORK);
this.setDisplay(getDisplay(this));

View file

@ -10,7 +10,7 @@ import common.init.Blocks;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
import common.util.LocalPos;
import common.util.Facing;
import common.util.Color;
@ -31,7 +31,7 @@ public class ItemDye extends Item {
this.color = color;
this.setTab(CheatTab.MATERIALS);
this.setDisplay(color.getSubject(1) + " Farbstoff");
this.setMaxAmount(StackSize.XXL);
this.setWeight(ItemWeight.XXS);
DIES[this.color.ordinal()] = this;
}

View file

@ -3,14 +3,14 @@ package common.item.weapon;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.item.ItemWeight;
public class ItemAmmo extends Item {
private final int damage;
private final float explosion;
public ItemAmmo(int damage, float explosion, StackSize stack) {
this.setMaxAmount(stack);
public ItemAmmo(int damage, float explosion, ItemWeight stack) {
this.setWeight(stack);
this.setTab(CheatTab.WEAPONS);
this.setMagnetic();
this.damage = damage;