From 1272f87ea08ec0e4bda968c2506dcbda7353051e Mon Sep 17 00:00:00 2001 From: Sen Date: Thu, 31 Jul 2025 14:26:28 +0200 Subject: [PATCH] fix block harvest tools --- client/src/main/java/client/Client.java | 95 +++++++++++------- .../resources/textures/items/iron_pickaxe.png | Bin 178 -> 4781 bytes common/src/main/java/common/block/Block.java | 24 +++-- .../src/main/java/common/entity/Entity.java | 2 +- .../main/java/common/init/BlockRegistry.java | 10 +- .../src/main/java/common/init/MetalType.java | 4 +- common/src/main/java/common/init/OreType.java | 10 +- .../main/java/common/init/ToolMaterial.java | 18 ++-- .../src/main/java/common/init/ToolType.java | 4 +- .../main/java/common/item/tool/ItemAxe.java | 4 + .../java/common/item/tool/ItemPickaxe.java | 12 +++ .../java/common/item/tool/ItemShears.java | 32 +++--- .../java/common/item/tool/ItemShovel.java | 3 +- .../main/java/common/item/tool/ItemTool.java | 15 ++- .../java/common/item/weapon/ItemSword.java | 35 +++---- .../java/server/worldgen/ReplacerMesa.java | 24 ++--- 16 files changed, 173 insertions(+), 119 deletions(-) diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 5483ee7e..f05e9ae4 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -598,6 +598,8 @@ public class Client implements IThreadListener { private int crosshairColorBase = 0xffcfcfcf; @Variable(name = "crosshair_color_target", type = IntType.COLOR, category = CVarCategory.GUI, display = "Fadenkreuz-Farbe (mit Ziel)") private int crosshairColorTarget = 0xffffffff; + @Variable(name = "info_overlay", category = CVarCategory.GUI, display = "Informations-Overlay") + private boolean infoOverlay = true; @Variable(name = "tic_target", category = CVarCategory.SYSTEM, min = 1.0f, max = 1200.0f, callback = TickFunction.class, display = "Tickrate") private float tpsTarget = 20.0f; @@ -1164,6 +1166,44 @@ public class Client implements IThreadListener { this.player.getHorseJumpPower(), 0x4040ff); y = this.drawBar(x, y, String.format(Color.ACID + "EXP: " + Color.GREEN + "Level %d, %d/%d", this.player.experienceLevel, (int)((float)this.player.xpBarCap() * this.player.experience), this.player.xpBarCap()), this.player.experience, 0x40ff40); } + + if(this.infoOverlay && this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) { + String desc = null; + String line1 = null; + String line2 = null; + if(this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) { + State state = this.world.getState(this.pointed.block); + Block block = state.getBlock(); + if(block != Blocks.air) { + desc = block.getDisplay(); + if(block.getMiningLevel() >= 0) + line2 = "Werkzeug: Spitzhacke Level " + (block.getMiningLevel() + 1); + else if(block.canAxeHarvest()) + line2 = "Werkzeug: Axt"; + else if(block.canShovelHarvest()) + line2 = "Werkzeug: Schaufel"; + else if(block.canShearsHarvest()) + line2 = "Werkzeug: Schere"; + else if(block.canSwordHarvest()) + line2 = "Werkzeug: Schwert"; + } + } + else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null) { + Entity entity = this.pointed.entity; + desc = entity.getName(); + if(entity instanceof EntityLiving living) { + line1 = living.formatStats(); + } + } + if(desc != null) { + Drawing.drawRectBorder(this.fbX / 2 - 180, 20, 360, 60, 0xff6f6f6f, 0xff000000, 0xffafafaf, 0xff4f4f4f); + Drawing.drawTextCentered(desc, this.fbX / 2, 24, 0xffffffff); + if(line1 != null) + Drawing.drawTextCentered(line1, this.fbX / 2, 80 - 4 - Font.YGLYPH * 2, 0xffffffff); + if(line2 != null) + Drawing.drawTextCentered(line2, this.fbX / 2, 80 - 4 - Font.YGLYPH, 0xffffffff); + } + } GlState.bindTexture(0); GlState.setActiveTexture(GL13.GL_TEXTURE0); @@ -1186,18 +1226,19 @@ public class Client implements IThreadListener { } } - if(this.pointed != null && this.pointed.block != null) { - State state = this.world.getState(this.pointed.block); - if(state.getBlock() != Blocks.air) { - Item item = state.getBlock().getItem(); - if(item != null) { - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(40 + 1), 0.0f); - GL11.glScalef(2.0f, 2.0f, 2.0f); - GlState.enableDepth(); - this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), 0, 0); - } + if(this.infoOverlay) { + Item item = null; + if(this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) + item = this.world.getState(this.pointed.block).getBlock().getItem(); + else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null) + item = this.pointed.entity.getItem(); + if(item != null) { + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(40 + 1), 0.0f); + GL11.glScalef(2.0f, 2.0f, 2.0f); + GlState.enableDepth(); + this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), 0, 0); } } @@ -1546,34 +1587,12 @@ public class Client implements IThreadListener { } Item item = null; - if (this.pointed.type == HitPosition.ObjectType.BLOCK) - { - BlockPos blockpos = this.pointed.block; - Block block = this.world.getState(blockpos).getBlock(); - - if (block == Blocks.air) - { - return; - } - - item = block.getItem(); - - if (item == null) - { - return; - } - } - else - { - if (this.pointed.type != HitPosition.ObjectType.ENTITY || this.pointed.entity == null || !this.itemCheat) - { - return; - } + item = this.world.getState(this.pointed.block).getBlock().getItem(); + else if (this.pointed.type == HitPosition.ObjectType.ENTITY && this.pointed.entity != null && this.itemCheat) item = this.pointed.entity.getItem(); - if(item == null) - return; - } + if(item == null) + return; InventoryPlayer inventoryplayer = this.player.inventory; diff --git a/client/src/main/resources/textures/items/iron_pickaxe.png b/client/src/main/resources/textures/items/iron_pickaxe.png index d21440bd1196194a19bf6391dc938ff3ad5f16a9..f381e70861d8266c6ce1ee238365f597ed5029f5 100755 GIT binary patch literal 4781 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 FV1nrWL9qY; diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index 634cb023..6d16815c 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -176,11 +176,12 @@ public class Block { private boolean sumBrightness; private boolean axeHarvest; private boolean shovelHarvest; + private boolean shearsHarvest; + private boolean swordHarvest; private boolean ticked; private int opacity; private int light; private int miningLevel; - private int shearsEfficiency; private int encouragement; private int flammability; private float hardness; @@ -363,7 +364,9 @@ public class Block { public Block(Material material) { this.miningLevel = (material == Material.SOLID || material == Material.HEAVY) ? 0 : -1; this.axeHarvest = material == Material.WOOD || material == Material.PLANT || material == Material.BUSH || material == Material.SOFT; - this.shearsEfficiency = (material == Material.LEAVES || material == Material.FLUFF) ? 3 : -1; + this.shovelHarvest = material == Material.POWDER || material == Material.DIGGABLE; + this.shearsHarvest = material == Material.LEAVES; + this.swordHarvest = material == Material.FLUFF; this.sound = SoundType.STONE; this.slipperiness = 0.6F; this.material = material; @@ -442,8 +445,13 @@ public class Block { return this; } - public final Block setShearsEfficiency(int efficiency) { - this.shearsEfficiency = efficiency; + public final Block setShearsHarvestable() { + this.shearsHarvest = true; + return this; + } + + public final Block setSwordHarvestable() { + this.swordHarvest = true; return this; } @@ -593,8 +601,12 @@ public class Block { return this.shovelHarvest; } - public final int getShearsEfficiency() { - return this.shearsEfficiency; + public final boolean canShearsHarvest() { + return this.shearsHarvest; + } + + public final boolean canSwordHarvest() { + return this.swordHarvest; } public final float getRadiation() { diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index 8c069d92..75b3e9d7 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -2415,7 +2415,7 @@ public abstract class Entity public final String getColoredName(Color reset) { - return Color.DARK_GRAY + "[" + this.getName() + Color.DARK_GRAY + "]" + reset; + return Color.DARK_GRAY + "[" + this.getName() + Color.DARK_GRAY + "]" + (reset == null ? Color.RESET : reset); } // public Text formatComponent(Text comp) { diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index 266486b0..ffc5c1b2 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -351,7 +351,7 @@ public abstract class BlockRegistry { for(BlockTallGrass.EnumType type : BlockTallGrass.EnumType.values()) { - register(type.getName(), (new BlockTallGrass(type)).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay(type.getDisplay()).setShearsEfficiency(0)); + register(type.getName(), (new BlockTallGrass(type)).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay(type.getDisplay()).setShearsHarvestable()); } register("deadbush", (new BlockDeadBush()).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("Toter Busch")); for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) { @@ -363,8 +363,8 @@ public abstract class BlockRegistry { Block cactus = (new BlockCactus()).setHardness(0.4F).setSound(SoundType.CLOTH).setDisplay("Kaktus"); register("cactus", cactus); register("reeds", (new BlockReed()).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("Zuckerrohr").setTab(CheatTab.PLANTS)); - register("vine", (new BlockVine(false)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Ranken").setShearsEfficiency(0)); - register("swamp_vine", (new BlockVine(true)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Sumpfranken").setShearsEfficiency(0)); + register("vine", (new BlockVine(false)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Ranken").setShearsHarvestable()); + register("swamp_vine", (new BlockVine(true)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Sumpfranken").setShearsHarvestable()); register("waterlily", (new BlockLilyPad()).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("Seerosenblatt")); @@ -425,7 +425,7 @@ public abstract class BlockRegistry { for(Color color : Color.values()) { register(color.getName() + "_wool", (new BlockWool(color)).setHardness(0.8F).setSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle") - .setShearsEfficiency(1)); + .setShearsHarvestable()); } for(Color color : Color.values()) { register(color.getName() + "_carpet", (new BlockCarpet(color)).setHardness(0.1F).setSound(SoundType.CLOTH).setDisplay(color.getSubject(1) + " Teppich").setOpacity(0)); @@ -672,7 +672,7 @@ public abstract class BlockRegistry { .setDisplay("Lampe").setTab(CheatTab.TECHNOLOGY)); register("lit_lamp", (new BlockToggleableLight(true)).setHardness(0.3F).setSound(SoundType.GLASS).setDisplay("Lampe")); register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken")); - register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0).setTab(CheatTab.TECHNOLOGY)); + register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setTab(CheatTab.TECHNOLOGY)); register("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setSound(SoundType.STONE).setDisplay("Eisentür")); for(WoodType wood : WoodType.values()) { diff --git a/common/src/main/java/common/init/MetalType.java b/common/src/main/java/common/init/MetalType.java index 4b146a38..4c1cf9c2 100755 --- a/common/src/main/java/common/init/MetalType.java +++ b/common/src/main/java/common/init/MetalType.java @@ -3,7 +3,7 @@ package common.init; import common.util.Color; public enum MetalType { - IRON("iron", 26, "Fe", "Eisen", 0, new ToolMaterial(2, 8.0f, 0.0f, 250, 6.0F, 2, 14, true, 15, 9, 2, 6, 5, 2).setMagnetic()), + IRON("iron", 26, "Fe", "Eisen", 0, new ToolMaterial(2, 8.0f, 0.0f, 250, 6, 2, 14, true, 15, 9, 2, 6, 5, 2).setMagnetic()), COPPER("copper", 29, "Cu", "Kupfer", 0), TIN("tin", 50, "Sn", "Zinn", 0), @@ -30,7 +30,7 @@ public enum MetalType { VANADIUM("vanadium", 23, "V", "Vanadium", 4), CHROME("chrome", 24, "Cr", "Chrom", 4), PLATINUM("platinum", 78, "Pt", "Platin", 4), - GOLD("gold", 79, "Au", "Gold", 4, new ToolMaterial(0, 15.0f, 1.0f, 32, 12.0F, 0, 22, true, 7, 25, 2, 5, 3, 1)), + GOLD("gold", 79, "Au", "Gold", 4, new ToolMaterial(0, 15.0f, 1.0f, 32, 12, 0, 22, true, 7, 25, 2, 5, 3, 1)), MANGANESE("manganese", 25, "Mn", "Mangan", 5), COBALT("cobalt", 27, "Co", "Cobalt", 5), diff --git a/common/src/main/java/common/init/OreType.java b/common/src/main/java/common/init/OreType.java index 764b2882..24d19fff 100755 --- a/common/src/main/java/common/init/OreType.java +++ b/common/src/main/java/common/init/OreType.java @@ -1,11 +1,11 @@ package common.init; public enum OreType { - DIAMOND("diamond", "Diamant", new ToolMaterial(3, 12.0f, 2.0f, 1561, 8.0F, 3, 10, true, 33, 10, 3, 8, 6, 3), "diamond", 3, 1, 0), - THETIUM("thetium", "Thetium", "Thi-Fragment", new ToolMaterial(4, 20.0f, 4.0f, 3451, 11.0F, 7, 12, false, 59, 12, 4, 9, 7, 4), "thi_fragment", 5, 1, 0), - ARDITE("ardite", "Ardit", "Ahrd-Fragment", new ToolMaterial(5, 30.0f, 12.0f, 7320, 11, 12, 86, 12, 6, 12, 9, 5), "ahrd_fragment", 7, 1, 0), - GYRIYN("gyriyn", "Gyriyn", "Ghi-Fragment", new ToolMaterial(5, 7320, 15.0F, 11, 12, false), "ghi_fragment", 7, 1, 0), - NICHUN("nichun", "Nichun", "Nieh-Fragment", new ToolMaterial(6, 50.0f, 40.0f, 21300, 20.0F, 18, 15, false, 172, 15, 12, 23, 14, 11), "nieh_fragment", 10, 1, 0), + DIAMOND("diamond", "Diamant", new ToolMaterial(3, 12.0f, 2.0f, 1561, 8, 3, 10, true, 33, 10, 3, 8, 6, 3), "diamond", 3, 1, 0), + THETIUM("thetium", "Thetium", "Thi-Fragment", new ToolMaterial(4, 20.0f, 4.0f, 3451, 11, 7, 12, false, 59, 12, 4, 9, 7, 4), "thi_fragment", 5, 1, 0), + ARDITE("ardite", "Ardit", "Ahrd-Fragment", new ToolMaterial(5, 30.0f, 12.0f, 7320, 15, 11, 12, 86, 12, 6, 12, 9, 5), "ahrd_fragment", 7, 1, 0), + GYRIYN("gyriyn", "Gyriyn", "Ghi-Fragment", new ToolMaterial(5, 7320, 15, 11, 12, false), "ghi_fragment", 7, 1, 0), + NICHUN("nichun", "Nichun", "Nieh-Fragment", new ToolMaterial(6, 50.0f, 40.0f, 21300, 20, 18, 15, false, 172, 15, 12, 23, 14, 11), "nieh_fragment", 10, 1, 0), RUBY("ruby", "Rubin", new ToolMaterial(3), "ruby", 3, 1, 0), CINNABAR("cinnabar", "Zinnober", new ToolMaterial(2), "cinnabar", 2, 1, 1); diff --git a/common/src/main/java/common/init/ToolMaterial.java b/common/src/main/java/common/init/ToolMaterial.java index 5cf8dd3e..1920e6e4 100755 --- a/common/src/main/java/common/init/ToolMaterial.java +++ b/common/src/main/java/common/init/ToolMaterial.java @@ -13,7 +13,7 @@ public class ToolMaterial { private final int harvestLevel; private final int durability; - private final float efficiency; + private final int efficiency; private final int damage; private final float radiationResistance; private final float magicResistance; @@ -29,7 +29,7 @@ public class ToolMaterial { private boolean magnetic; private int defColor = 0xffffffff; - private ToolMaterial(float rad, float mag, int level, int uses, float efficiency, int damage, int ench, boolean tools, boolean weapons, + private ToolMaterial(float rad, float mag, int level, int uses, int efficiency, int damage, int ench, boolean tools, boolean weapons, boolean extras, int auses, int aench, int r1, int r2, int r3, int r4) { this.harvestLevel = level; this.durability = uses; @@ -47,22 +47,22 @@ public class ToolMaterial { } protected ToolMaterial(int level) { - this(0.0f, 0.0f, level, 0, 0.0f, 0, 0, false, false, false, 0, 0, 0, 0, 0, 0); + this(0.0f, 0.0f, level, 0, 0, 0, 0, false, false, false, 0, 0, 0, 0, 0, 0); } - protected ToolMaterial(int level, int uses, float efficiency, int damage, int ench, boolean weapons) { + protected ToolMaterial(int level, int uses, int efficiency, int damage, int ench, boolean weapons) { this(0.0f, 0.0f, level, uses, efficiency, damage, ench, true, weapons, false, 0, ench, 0, 0, 0, 0); } - protected ToolMaterial(int level, float rad, float mag, int uses, int damage, int ench, int auses, int aench, int r1, int r2, int r3, int r4) { - this(rad, mag, level, uses, 0.0F, damage, ench, false, true, false, auses, aench, r1, r2, r3, r4); + protected ToolMaterial(int level, float rad, float mag, int uses, int efficiency, int damage, int ench, int auses, int aench, int r1, int r2, int r3, int r4) { + this(rad, mag, level, uses, efficiency, damage, ench, false, true, false, auses, aench, r1, r2, r3, r4); } protected ToolMaterial(int level, float rad, float mag, int auses, int aench, int r1, int r2, int r3, int r4) { - this(rad, mag, 0, 0, 0.0F, 0, 0, false, false, false, auses, aench, r1, r2, r3, r4); + this(rad, mag, 0, 0, 0, 0, 0, false, false, false, auses, aench, r1, r2, r3, r4); } - protected ToolMaterial(int level, float rad, float mag, int uses, float efficiency, int damage, int ench, boolean extras, int auses, int aench, + protected ToolMaterial(int level, float rad, float mag, int uses, int efficiency, int damage, int ench, boolean extras, int auses, int aench, int r1, int r2, int r3, int r4) { this(rad, mag, level, uses, efficiency, damage, ench, true, true, extras, auses, aench, r1, r2, r3, r4); } @@ -101,7 +101,7 @@ public class ToolMaterial { return this.durability; } - public float getEfficiency() { + public int getEfficiency() { return this.efficiency; } diff --git a/common/src/main/java/common/init/ToolType.java b/common/src/main/java/common/init/ToolType.java index 893269f2..9c9359cd 100755 --- a/common/src/main/java/common/init/ToolType.java +++ b/common/src/main/java/common/init/ToolType.java @@ -1,8 +1,8 @@ package common.init; public enum ToolType { - WOOD("wood", "Holz", new ToolMaterial(0, 59, 2.0F, 0, 15, true), WoodType.getNames("planks")), - STONE("stone", "Stein", new ToolMaterial(1, 131, 4.0F, 1, 5, true), "cobblestone"), + WOOD("wood", "Holz", new ToolMaterial(0, 59, 2, 0, 15, true), WoodType.getNames("planks")), + STONE("stone", "Stein", new ToolMaterial(1, 131, 4, 1, 5, true), "cobblestone"), LEATHER("leather", "Leder", new ToolMaterial(0, 2.0f, 0.0f, 5, 15, 1, 3, 2, 1).setDyeable(0xa06540), "leather"), CHAIN("chain", "Ketten", new ToolMaterial(0, 0.5f, 0.25f, 15, 12, 2, 5, 4, 1).setMagnetic(), "chain"), CLOTH("cloth", null, new ToolMaterial(0, 0.0f, 0.0f, 10, 0, 0, 0, 0, 0).setDyeable(0xffffff), "string"); diff --git a/common/src/main/java/common/item/tool/ItemAxe.java b/common/src/main/java/common/item/tool/ItemAxe.java index 354f43a8..c5cf1798 100755 --- a/common/src/main/java/common/item/tool/ItemAxe.java +++ b/common/src/main/java/common/item/tool/ItemAxe.java @@ -12,4 +12,8 @@ public class ItemAxe extends ItemTool { public boolean canUseOn(ItemStack stack, Block block) { return block.canAxeHarvest(); } + + public boolean canHarvestBlock(Block block) { + return block.canAxeHarvest(); + } } diff --git a/common/src/main/java/common/item/tool/ItemPickaxe.java b/common/src/main/java/common/item/tool/ItemPickaxe.java index d0b54494..0501cccf 100755 --- a/common/src/main/java/common/item/tool/ItemPickaxe.java +++ b/common/src/main/java/common/item/tool/ItemPickaxe.java @@ -1,8 +1,13 @@ package common.item.tool; +import java.util.List; + import common.block.Block; +import common.entity.npc.EntityNPC; import common.init.ToolMaterial; import common.item.ItemStack; +import common.util.Clientside; +import common.util.Color; public class ItemPickaxe extends ItemTool { public ItemPickaxe(ToolMaterial material) { @@ -16,4 +21,11 @@ public class ItemPickaxe extends ItemTool { public boolean canUseOn(ItemStack stack, Block block) { return block.getMiningLevel() >= 0; } + + @Clientside + public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) + { + tooltip.add(Color.VIOLET + "Level " + (this.getToolMaterial().getHarvestLevel() + 1)); + super.addInformation(stack, playerIn, tooltip); + } } diff --git a/common/src/main/java/common/item/tool/ItemShears.java b/common/src/main/java/common/item/tool/ItemShears.java index 6b576d76..6f77a66f 100755 --- a/common/src/main/java/common/item/tool/ItemShears.java +++ b/common/src/main/java/common/item/tool/ItemShears.java @@ -1,16 +1,18 @@ package common.item.tool; +import java.util.List; + import common.block.Block; -import common.block.Material; -import common.block.tech.BlockWire; +import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; -import common.init.Blocks; import common.init.ToolMaterial; import common.item.CheatTab; import common.item.Item; import common.item.ItemStack; import common.item.WieldType; import common.util.BlockPos; +import common.util.Clientside; +import common.util.Color; import common.world.World; public class ItemShears extends Item @@ -28,31 +30,31 @@ public class ItemShears extends Item public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLiving playerIn) { - if (blockIn.getShearsEfficiency() < 0) // blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool) - { + if (!blockIn.canShearsHarvest()) return super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn); - } - else - { - stack.damage(1, playerIn); - return true; - } + stack.damage(1, playerIn); + return true; } public boolean canHarvestBlock(Block blockIn) { - return blockIn.getMaterial() == Material.FLUFF || blockIn instanceof BlockWire || blockIn == Blocks.string; + return blockIn.canShearsHarvest(); } public float getStrVsBlock(ItemStack stack, Block state) { - return state.getShearsEfficiency() <= 0 ? 1.0F : (((float)state.getShearsEfficiency()) * (this.material.getEfficiency() - 1.0F)); - // state != Blocks.web && state.getMaterial() != Material.leaves ? (state == Blocks.wool ? 5.0F : super.getStrVsBlock(stack, state)) : 15.0F; + return !state.canShearsHarvest() ? 1.0F : (float)this.material.getEfficiency(); + } + + @Clientside + public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) + { + tooltip.add(Color.DARK_GREEN + "+ " + (this.material.getEfficiency() - 1) + " Abbaueffizienz"); } public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { - return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(toRepair, repair); + return this.material.isRepairItem(repair.getItem()); } public WieldType getWieldType() { diff --git a/common/src/main/java/common/item/tool/ItemShovel.java b/common/src/main/java/common/item/tool/ItemShovel.java index ab424953..7b7de0cb 100755 --- a/common/src/main/java/common/item/tool/ItemShovel.java +++ b/common/src/main/java/common/item/tool/ItemShovel.java @@ -1,7 +1,6 @@ package common.item.tool; import common.block.Block; -import common.block.Material; import common.init.ToolMaterial; import common.item.ItemStack; @@ -15,6 +14,6 @@ public class ItemShovel extends ItemTool { } public boolean canHarvestBlock(Block block) { - return block.getMaterial() == Material.POWDER || block.getMaterial() == Material.DIGGABLE; + return block.canShovelHarvest(); } } diff --git a/common/src/main/java/common/item/tool/ItemTool.java b/common/src/main/java/common/item/tool/ItemTool.java index 1470017c..bee2a93c 100755 --- a/common/src/main/java/common/item/tool/ItemTool.java +++ b/common/src/main/java/common/item/tool/ItemTool.java @@ -1,6 +1,9 @@ package common.item.tool; +import java.util.List; + import common.block.Block; +import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.init.ToolMaterial; import common.item.CheatTab; @@ -8,17 +11,17 @@ import common.item.Item; import common.item.ItemStack; import common.item.WieldType; import common.util.BlockPos; +import common.util.Clientside; +import common.util.Color; import common.world.World; public abstract class ItemTool extends Item { - private final float efficiency; private final int damage; private final ToolMaterial material; public ItemTool(int damage, ToolMaterial material) { this.material = material; this.setMaxDamage(material.getDurability()); - this.efficiency = material.getEfficiency(); this.damage = damage + material.getDamage(); this.setTab(CheatTab.TOOLS); if(this.material.isMagnetic()) @@ -28,9 +31,15 @@ public abstract class ItemTool extends Item { public abstract boolean canUseOn(ItemStack stack, Block block); public float getStrVsBlock(ItemStack stack, Block block) { - return !this.canUseOn(stack, block) ? 1.0F : this.efficiency; + return !this.canUseOn(stack, block) ? 1.0F : (float)this.material.getEfficiency(); } + @Clientside + public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) + { + tooltip.add(Color.DARK_GREEN + "+ " + (this.material.getEfficiency() - 1) + " Abbaueffizienz"); + } + public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { stack.damage(2, attacker); return true; diff --git a/common/src/main/java/common/item/weapon/ItemSword.java b/common/src/main/java/common/item/weapon/ItemSword.java index 206de32d..abc4ddc2 100755 --- a/common/src/main/java/common/item/weapon/ItemSword.java +++ b/common/src/main/java/common/item/weapon/ItemSword.java @@ -1,10 +1,10 @@ package common.item.weapon; +import java.util.List; + import common.block.Block; -import common.block.Material; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; -import common.init.Blocks; import common.init.ToolMaterial; import common.item.CheatTab; import common.item.Item; @@ -12,6 +12,8 @@ import common.item.ItemAction; import common.item.ItemStack; import common.item.WieldType; import common.util.BlockPos; +import common.util.Clientside; +import common.util.Color; import common.world.World; public class ItemSword extends Item @@ -44,15 +46,18 @@ public class ItemSword extends Item public float getStrVsBlock(ItemStack stack, Block state) { - if (state == Blocks.web) - { - return 15.0F; - } - else - { - Material material = state.getMaterial(); - return material != Material.PLANT && material != Material.BUSH && material != Material.LEAVES && material != Material.SOFT ? 1.0F : 1.5F; - } + return state.canSwordHarvest() ? (float)this.material.getEfficiency() : 1.0f; + } + + public boolean canHarvestBlock(Block blockIn) + { + return blockIn.canSwordHarvest(); + } + + @Clientside + public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) + { + tooltip.add(Color.DARK_GREEN + "+ " + (this.material.getEfficiency() - 1) + " Abbaueffizienz"); } /** @@ -111,14 +116,6 @@ public class ItemSword extends Item return itemStackIn; } - /** - * Check whether this Item can harvest the given Block - */ - public boolean canHarvestBlock(Block blockIn) - { - return blockIn == Blocks.web; - } - /** * Return the enchantability factor of the item, most of the time is based on material. */ diff --git a/server/src/main/java/server/worldgen/ReplacerMesa.java b/server/src/main/java/server/worldgen/ReplacerMesa.java index 1dad2087..8f6e8054 100644 --- a/server/src/main/java/server/worldgen/ReplacerMesa.java +++ b/server/src/main/java/server/worldgen/ReplacerMesa.java @@ -82,8 +82,8 @@ public class ReplacerMesa extends ReplacerBiome int bx = x & 15; int by = z & 15; - State surface = Blocks.white_clay.getState(); - State top = Blocks.white_clay.getState(); + State surface = Blocks.beige_clay.getState(); + State top = Blocks.beige_clay.getState(); int rng = (int)(noise / 3.0D + 3.0D + rand.doublev() * 0.25D); boolean hard = Math.cos(noise / 3.0D * Math.PI) > 0.0D; int sel = -1; @@ -115,8 +115,8 @@ public class ReplacerMesa extends ReplacerBiome } else if (i1 >= this.seaLevel - 4 && i1 <= this.seaLevel + 1) { - surface = Blocks.white_clay.getState(); - top = Blocks.white_clay.getState(); + surface = Blocks.beige_clay.getState(); + top = Blocks.beige_clay.getState(); } if (i1 < this.seaLevel && (surface == null || surface.getBlock() == Blocks.air)) @@ -132,7 +132,7 @@ public class ReplacerMesa extends ReplacerBiome if (top.getBlock() instanceof BlockColoredClay) { - primer.set(by, i1, bx, Blocks.orange_clay.getState()); + primer.set(by, i1, bx, Blocks.light_brown_clay.getState()); } } else if (soil && i1 > 86 + rng * 2) @@ -168,7 +168,7 @@ public class ReplacerMesa extends ReplacerBiome } else { - iblockstate4 = Blocks.orange_clay.getState(); + iblockstate4 = Blocks.light_brown_clay.getState(); } primer.set(by, i1, bx, iblockstate4); @@ -180,7 +180,7 @@ public class ReplacerMesa extends ReplacerBiome if (base) { - primer.set(by, i1, bx, Blocks.orange_clay.getState()); + primer.set(by, i1, bx, Blocks.light_brown_clay.getState()); } else { @@ -200,7 +200,7 @@ public class ReplacerMesa extends ReplacerBiome if (l1 < 64) { - this.layers[l1] = Blocks.orange_clay.getState(); + this.layers[l1] = Blocks.light_brown_clay.getState(); } } @@ -213,7 +213,7 @@ public class ReplacerMesa extends ReplacerBiome for (int l = 0; k + l < 64 && l < j; ++l) { - this.layers[k + l] = Blocks.yellow_clay.getState(); + this.layers[k + l] = Blocks.white_clay.getState(); } } @@ -226,7 +226,7 @@ public class ReplacerMesa extends ReplacerBiome for (int i1 = 0; l3 + i1 < 64 && i1 < i3; ++i1) { - this.layers[l3 + i1] = Blocks.brown_clay.getState(); + this.layers[l3 + i1] = Blocks.dark_brown_clay.getState(); } } @@ -239,7 +239,7 @@ public class ReplacerMesa extends ReplacerBiome for (int j1 = 0; k4 + j1 < 64 && j1 < i4; ++j1) { - this.layers[k4 + j1] = Blocks.red_clay.getState(); + this.layers[k4 + j1] = Blocks.dark_red_clay.getState(); } } @@ -253,7 +253,7 @@ public class ReplacerMesa extends ReplacerBiome for (int k1 = 0; j4 + k1 < 64 && k1 < i5; ++k1) { - this.layers[j4 + k1] = Blocks.white_clay.getState(); + this.layers[j4 + k1] = Blocks.beige_clay.getState(); if (j4 + k1 > 1 && random.chance()) {