From 2d476cbf8a6a7baebb095bfd7e17281f94c71bc4 Mon Sep 17 00:00:00 2001 From: Sen Date: Sat, 13 Sep 2025 11:05:32 +0200 Subject: [PATCH] change block destruction logic --- client/src/main/java/client/Client.java | 157 +++++++---------- .../java/client/renderer/EffectRenderer.java | 57 +------ .../java/client/renderer/ItemRenderer.java | 25 --- .../java/client/util/PlayerController.java | 103 +----------- .../java/common/ai/EntityAIDoorInteract.java | 2 +- common/src/main/java/common/block/Block.java | 13 +- .../src/main/java/common/block/Material.java | 41 ++--- .../block/artificial/BlockBookshelf.java | 2 +- .../common/block/artificial/BlockDoor.java | 2 +- .../common/block/artificial/BlockFence.java | 2 +- .../block/artificial/BlockFenceGate.java | 2 +- .../common/block/artificial/BlockSlab.java | 2 +- .../block/artificial/BlockTrapDoor.java | 2 +- .../block/foliage/BlockHugeMushroom.java | 2 +- .../java/common/block/foliage/BlockLog.java | 4 +- .../java/common/block/tech/BlockAnvil.java | 2 +- .../java/common/block/tech/BlockChest.java | 2 +- .../common/block/tech/BlockPistonBase.java | 2 +- .../common/block/tech/BlockPistonHead.java | 2 +- .../java/common/block/tech/BlockSign.java | 2 +- .../common/block/tech/BlockWorkbench.java | 2 +- .../src/main/java/common/effect/Effect.java | 7 +- .../java/common/enchantment/Enchantment.java | 16 -- .../common/enchantment/EnchantmentHelper.java | 32 ---- .../java/common/entity/npc/EntityNPC.java | 83 +-------- .../main/java/common/init/BlockRegistry.java | 12 +- common/src/main/java/common/init/Items.java | 3 - .../main/java/common/init/ToolMaterial.java | 8 +- .../src/main/java/common/item/ItemAction.java | 2 +- .../java/common/item/consumable/ItemFood.java | 44 +---- .../item/consumable/ItemMilkBottle.java | 20 +-- .../common/item/consumable/ItemPotion.java | 91 ++++------ .../main/java/common/item/tool/ItemTool.java | 5 - .../main/java/common/packet/CPacketBreak.java | 2 - .../common/pathfinding/WalkNodeProcessor.java | 4 +- .../src/main/java/common/village/Village.java | 2 +- .../server/command/commands/CommandGod.java | 2 +- .../src/main/java/server/network/Player.java | 158 +----------------- .../server/village/VillageCollection.java | 2 +- 39 files changed, 175 insertions(+), 746 deletions(-) diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 271392bc..f34008c6 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1078,7 +1078,8 @@ public class Client implements IThreadListener { this.secondary(); } - this.sendClickBlockToController(this.open == null && Bind.PRIMARY.isDown() && this.viewEntity == this.player); + if(this.open != null || !Bind.PRIMARY.isDown() || this.viewEntity != this.player) + this.leftClickCounter = 0; } this.primary = this.secondary = this.tertiary = this.quarternary = false; @@ -1335,11 +1336,11 @@ public class Client implements IThreadListener { if(this.pointedLiquid != null ? block.getMaterial().isLiquid() : block != Blocks.air) { desc = block.getDisplay(); line1 = block.getInfo(this.world, pos, state, this.player); - boolean toolReq = block.getMaterial().isToolRequired(); + boolean toolReq = !this.player.hasEffect(Effect.PUNCHING); boolean harvestable = this.player.canHarvestBlock(block); line2 = Color.BLUE + "Werkzeug" + Color.DARK_GRAY + ": " + (block.getMiningTool() != null ? (toolReq ? (harvestable ? Color.GREEN : Color.RED) : Color.LIGHT_GRAY) + block.getMiningTool().getDisplay() + (block.getMiningTool().isLevelled() ? (toolReq ? (harvestable ? Color.ORK : Color.CRIMSON) : Color.DARK_GRAY) + " Level " + (toolReq ? (harvestable ? Color.DARK_GREEN : Color.DARK_RED) : Color.GRAY) + (block.getMiningLevel() + 1) : "") : Color.GRAY + "Keins"); - if(this.controller.isHittingBlock()) { - bar = 1.0f - this.controller.getDamage(pos); + if(block.getMiningTool() != null && block.getMiningTool().isLevelled()) { + bar = (float)(block.getMiningLevel() + 1) / 20.0f; color = (int)(bar * 255.0f) << 8 | (int)((1.0f - bar) * 255.0f) << 16; } } @@ -1646,33 +1647,6 @@ public class Client implements IThreadListener { } } - private void sendClickBlockToController(boolean leftClick) - { - if (!leftClick) - { - this.leftClickCounter = 0; - this.controller.resetInteraction(); - } - - if (this.leftClickCounter <= 0 && !this.player.isUsingItem()) - { - if (leftClick && this.pointed != null && this.pointed.type == HitPosition.ObjectType.BLOCK) - { - LocalPos blockpos = this.pointed.block; - - if (this.world.getState(blockpos).getBlock() != Blocks.air && this.controller.damageBlock(blockpos, this.pointed.side)) - { - this.effectRenderer.damageBlock(blockpos, this.pointed.side); - this.player.swingItem(); - } - } - else - { - this.controller.resetProgress(); - } - } - } - private void primary() { if (this.leftClickCounter <= 0) @@ -1723,80 +1697,77 @@ public class Client implements IThreadListener { private void secondary() { - if (!this.controller.isHittingBlock()) - { - this.rightClickTimer = 4; - boolean flag = true; - ItemStack itemstack = this.player.getHeldItem(); + this.rightClickTimer = 4; + boolean flag = true; + ItemStack itemstack = this.player.getHeldItem(); - if (itemstack != null && itemstack.getItem() == Items.camera && !this.saving) + if (itemstack != null && itemstack.getItem() == Items.camera && !this.saving) + { + this.screenshot = this.cameraUsed = true; + } + + if (this.pointed == null) + { + Log.TICK.warn("Null zurückgegeben als 'hitResult', das sollte niemals passieren!"); + } + else + { + if ((this.pointed.type != ObjectType.BLOCK || this.world.getState(this.pointed.block).getBlock() == Blocks.air) && itemstack != null && itemstack.getItem().onAction(itemstack, this.player, this.world, ItemControl.SECONDARY, null)) { - this.screenshot = this.cameraUsed = true; + this.player.swingItem(); + this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.SECONDARY.ordinal())); + if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty()) + this.player.clearHeldItem(); + return; } - - if (this.pointed == null) + + switch (this.pointed.type) { - Log.TICK.warn("Null zurückgegeben als 'hitResult', das sollte niemals passieren!"); - } - else - { - if ((this.pointed.type != ObjectType.BLOCK || this.world.getState(this.pointed.block).getBlock() == Blocks.air) && itemstack != null && itemstack.getItem().onAction(itemstack, this.player, this.world, ItemControl.SECONDARY, null)) - { - this.player.swingItem(); - this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.SECONDARY.ordinal())); - if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty()) - this.player.clearHeldItem(); - return; - } - - switch (this.pointed.type) - { - case ENTITY: - if (this.controller.interact(this.player, this.pointed.entity)) + case ENTITY: + if (this.controller.interact(this.player, this.pointed.entity)) + { + flag = false; + } + + break; + + case BLOCK: + LocalPos blockpos = this.pointed.block; + + if (this.world.getState(blockpos).getBlock() != Blocks.air) + { + int i = itemstack != null ? itemstack.getSize() : 0; + + if (this.controller.clickRight(this.player, this.world, itemstack, blockpos, this.pointed.side, this.pointed.vec)) { flag = false; + this.player.swingItem(); } - break; - - case BLOCK: - LocalPos blockpos = this.pointed.block; - - if (this.world.getState(blockpos).getBlock() != Blocks.air) + if (itemstack == null) { - int i = itemstack != null ? itemstack.getSize() : 0; - - if (this.controller.clickRight(this.player, this.world, itemstack, blockpos, this.pointed.side, this.pointed.vec)) - { - flag = false; - this.player.swingItem(); - } - - if (itemstack == null) - { - return; - } - - if (itemstack.isEmpty()) - { - this.player.clearHeldItem(); - } - else if (itemstack.getSize() != i) - { - this.itemRenderer.resetProgress(); - } + return; } - } - } - if (flag) + if (itemstack.isEmpty()) + { + this.player.clearHeldItem(); + } + else if (itemstack.getSize() != i) + { + this.itemRenderer.resetProgress(); + } + } + } + } + + if (flag) + { + ItemStack itemstack1 = this.player.getHeldItem(); + + if (itemstack1 != null && this.controller.sendUseItem(this.player, this.world, itemstack1)) { - ItemStack itemstack1 = this.player.getHeldItem(); - - if (itemstack1 != null && this.controller.sendUseItem(this.player, this.world, itemstack1)) - { - this.itemRenderer.resetProgress(); - } + this.itemRenderer.resetProgress(); } } } diff --git a/client/src/main/java/client/renderer/EffectRenderer.java b/client/src/main/java/client/renderer/EffectRenderer.java index 35bb579e..955fbcb6 100755 --- a/client/src/main/java/client/renderer/EffectRenderer.java +++ b/client/src/main/java/client/renderer/EffectRenderer.java @@ -708,15 +708,10 @@ public class EffectRenderer { this.offsetY = rng.floatv() * 3.0F; } - protected Icon(double x, double y, double z, State state, boolean hit) { - this(x, y, z, hit ? 0.6f : 1.0f, Client.CLIENT.renderer.getModelManager().getTexture(state)); + protected Icon(double x, double y, double z, State state) { + this(x, y, z, 1.0f, Client.CLIENT.renderer.getModelManager().getTexture(state)); this.gravity = 1.0F; this.red = this.green = this.blue = 0.6F; - if(hit) { - this.motionX *= 0.2; - this.motionY = (this.motionY - 0.1) * 0.2 + 0.1; - this.motionZ *= 0.2; - } } protected Icon(double x, double y, double z, Item item) { @@ -964,7 +959,7 @@ public class EffectRenderer { }); this.register(ParticleType.BLOCK_CRACK, (x, y, z, id) -> { State state = BlockRegistry.byId(id); - return state == null ? null : new Icon(x, y, z, state, false); + return state == null ? null : new Icon(x, y, z, state); }); this.register(ParticleType.EXPLOSION_HUGE, (x, y, z, u) -> new ExplosionSpawner(x, y, z)); this.register(ParticleType.EXPLOSION_LARGE, @@ -1089,57 +1084,13 @@ public class EffectRenderer { double d0 = (double)pos.getX() + ((double)j + 0.5D) / (double)i; double d1 = (double)pos.getY() + ((double)k + 0.5D) / (double)i; double d2 = (double)pos.getZ() + ((double)l + 0.5D) / (double)i; - this.add(new Icon(d0, d1, d2, state, false)); + this.add(new Icon(d0, d1, d2, state)); } } } } } - public void damageBlock(LocalPos pos, Facing side) { - State iblockstate = this.world.getState(pos); - Block block = iblockstate.getBlock(); - - if(block != Blocks.air) { - int i = pos.getX(); - int j = pos.getY(); - int k = pos.getZ(); - float f = 0.1F; - double d0 = (double)i + this.rng.doublev() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (double)(f * 2.0F)) + (double)f - + block.getBlockBoundsMinX(); - double d1 = (double)j + this.rng.doublev() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (double)(f * 2.0F)) + (double)f - + block.getBlockBoundsMinY(); - double d2 = (double)k + this.rng.doublev() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (double)(f * 2.0F)) + (double)f - + block.getBlockBoundsMinZ(); - - if(side == Facing.DOWN) { - d1 = (double)j + block.getBlockBoundsMinY() - (double)f; - } - - if(side == Facing.UP) { - d1 = (double)j + block.getBlockBoundsMaxY() + (double)f; - } - - if(side == Facing.NORTH) { - d2 = (double)k + block.getBlockBoundsMinZ() - (double)f; - } - - if(side == Facing.SOUTH) { - d2 = (double)k + block.getBlockBoundsMaxZ() + (double)f; - } - - if(side == Facing.WEST) { - d0 = (double)i + block.getBlockBoundsMinX() - (double)f; - } - - if(side == Facing.EAST) { - d0 = (double)i + block.getBlockBoundsMaxX() + (double)f; - } - - this.add(new Icon(d0, d1, d2, iblockstate, true)); - } - } - public void spawnCritParticles(Entity entity) { this.add(new HitSpawner(entity)); } diff --git a/client/src/main/java/client/renderer/ItemRenderer.java b/client/src/main/java/client/renderer/ItemRenderer.java index 59d4f019..f0b7b69a 100755 --- a/client/src/main/java/client/renderer/ItemRenderer.java +++ b/client/src/main/java/client/renderer/ItemRenderer.java @@ -262,25 +262,6 @@ public class ItemRenderer GL15.glTranslatef(f, f1, f2); } - private void performDrinking(EntityNPC clientPlayer, float partialTicks) - { - float f = (float)clientPlayer.getItemInUseCount() - partialTicks + 1.0F; - float f1 = f / (float)this.itemToRender.getMaxItemUseDuration(); - float f2 = ExtMath.absf(ExtMath.cos(f / 4.0F * (float)Math.PI) * 0.1F); - - if (f1 >= 0.8F) - { - f2 = 0.0F; - } - - GL15.glTranslatef(0.0F, f2, 0.0F); - float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D); - GL15.glTranslatef(f3 * 0.6F, f3 * -0.5F, f3 * 0.0F); - GL15.glRotatef(f3 * 90.0F, 0.0F, 1.0F, 0.0F); - GL15.glRotatef(f3 * 10.0F, 1.0F, 0.0F, 0.0F); - GL15.glRotatef(f3 * 30.0F, 0.0F, 0.0F, 1.0F); - } - private void transformFirstPersonItem(float equipProgress, float swingProgress) { GL15.glTranslatef(0.56F, -0.52F, -0.71999997F); @@ -354,12 +335,6 @@ public class ItemRenderer this.transformFirstPersonItem(f, 0.0F); break; - case EAT: - case DRINK: - this.performDrinking(clientplayer, partialTicks); - this.transformFirstPersonItem(f, 0.0F); - break; - case BLOCK: this.transformFirstPersonItem(f, 0.0F); this.doBlockTransformations(); diff --git a/client/src/main/java/client/util/PlayerController.java b/client/src/main/java/client/util/PlayerController.java index 96598078..fd2321b0 100755 --- a/client/src/main/java/client/util/PlayerController.java +++ b/client/src/main/java/client/util/PlayerController.java @@ -24,13 +24,7 @@ public class PlayerController { private final Client gm; private final ClientPlayer handler; - private LocalPos position = new LocalPos(-1, -World.MAX_SIZE_Y - 1, -1); - private ItemStack stack; - private float damage; - private int delay; - private boolean hitting; private int lastSelected; - private boolean interacting; private int itemUseCooldown; private int itemUseCooldownMax; @@ -55,8 +49,6 @@ public class PlayerController { block.onBroken(world, pos, state); } - this.position = new LocalPos(this.position.getX(), -1, this.position.getZ()); - ItemStack stack = this.gm.player.getHeldItem(); if(stack != null) { @@ -78,84 +70,19 @@ public class PlayerController { else { ItemStack stack = this.gm.player.getHeldItem(); if(stack != null && stack.getItem().onAction(stack, this.gm.player, this.gm.world, ItemControl.PRIMARY, pos)) { - this.interacting = true; this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face)); if(this.gm.player.getHeldItem() != null && this.gm.player.getHeldItem().isEmpty()) this.gm.player.clearHeldItem(); return true; } - if(!this.hitting || !this.isHitting(pos)) { - if(this.hitting) { - this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, face)); - } - - this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face)); - Block block = this.gm.world.getState(pos).getBlock(); - boolean flag = block != Blocks.air; - - if(flag && this.damage == 0.0F) { - block.onStartBreak(this.gm.world, pos, this.gm.player); - } - - if(flag && block.getHardness(this.gm.player, this.gm.player.worldObj, pos) >= 1.0F) { - this.destroyBlock(pos, face); - this.delay = 3; - } - else { - this.hitting = true; - this.position = pos; - this.stack = this.gm.player.getHeldItem(); - this.damage = 0.0F; - } - } - - return true; - } - } - - public void resetProgress() { - if(this.hitting) { - this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN)); - this.hitting = false; - this.damage = 0.0F; - } - } - - public void resetInteraction() { - this.interacting = false; - } - - public boolean damageBlock(LocalPos pos, Facing face) { - if(this.interacting) - return false; - this.syncItem(); - - if(this.delay > 0) { - --this.delay; - return true; - } - else if(this.isHitting(pos)) { + this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face)); Block block = this.gm.world.getState(pos).getBlock(); - - if(block == Blocks.air) { - this.hitting = false; - return false; - } - else { - this.damage += block.getHardness(this.gm.player, this.gm.player.worldObj, pos); - - if(this.damage >= 1.0F) { - this.hitting = false; - this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.STOP_DESTROY_BLOCK, pos, face)); + if(block != Blocks.air) { + block.onStartBreak(this.gm.world, pos, this.gm.player); + if(this.gm.player.canHarvestBlock(block)) this.destroyBlock(pos, face); - this.damage = 0.0F; - this.delay = 5; - } - return true; } - } - else { - return this.clickBlock(pos, face); + return true; } } @@ -172,18 +99,6 @@ public class PlayerController { } } - private boolean isHitting(LocalPos pos) { - ItemStack stack = this.gm.player.getHeldItem(); - boolean flag = this.stack == null && stack == null; - - if(this.stack != null && stack != null) { - flag = stack.getItem() == this.stack.getItem() - && ItemStack.dataEquals(stack, this.stack); - } - - return pos.equals(this.position) && flag; - } - private void syncItem() { int slot = this.gm.player.getSelectedIndex(); @@ -294,10 +209,6 @@ public class PlayerController { player.stopUsingItem(); } - public boolean isHittingBlock() { - return this.hitting; - } - public int getUseCooldown() { return this.itemUseCooldown; } @@ -309,8 +220,4 @@ public class PlayerController { public void resetUseCooldown() { this.itemUseCooldown = 0; } - - public float getDamage(LocalPos pos) { - return this.hitting && pos.equals(this.position) ? this.damage : 0.0f; - } } diff --git a/common/src/main/java/common/ai/EntityAIDoorInteract.java b/common/src/main/java/common/ai/EntityAIDoorInteract.java index 4fea34a1..2775b273 100755 --- a/common/src/main/java/common/ai/EntityAIDoorInteract.java +++ b/common/src/main/java/common/ai/EntityAIDoorInteract.java @@ -113,6 +113,6 @@ public abstract class EntityAIDoorInteract extends EntityAIBase private BlockDoor getBlockDoor(LocalPos pos) { Block block = this.theEntity.worldObj.getState(pos).getBlock(); - return block instanceof BlockDoor && block.getMaterial() == Material.WOOD ? (BlockDoor)block : null; + return block instanceof BlockDoor && block.getMaterial() == Material.BURNABLE ? (BlockDoor)block : null; } } diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index aeaa4716..8b2d6d47 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -560,13 +560,6 @@ public class Block { return this.maxZ; } - public final float getHardness(EntityNPC player, World world, LocalPos pos) { - float f = (float)this.hardness; - return f < 0.0F ? 0.0F - : (!player.canHarvestBlock(this) ? player.getToolDigEfficiency(this) / f / 100.0F - : player.getToolDigEfficiency(this) / f / 30.0F); - } - public final State getState() { return this.defaultState; } @@ -1013,7 +1006,7 @@ public class Block { } public int getFuelAmount() { - return this.material == Material.WOOD ? 300 : 0; + return this.material == Material.BURNABLE ? 300 : 0; } public void getModifiers(Map map) { @@ -1084,7 +1077,9 @@ public class Block { if(this.light != 0) tooltip.add(Color.BLUE + "Licht" + Color.DARK_GRAY + ": " + Color.NEON + String.format("%06x", this.light)); if(this.hardness != 0) - tooltip.add(Color.BLUE + "Härte" + Color.DARK_GRAY + ": " + Color.NEON + this.hardness); + tooltip.add(Color.LIGHT_GRAY + "Härte" + Color.GRAY + ": " + Color.BEIGE + this.hardness); + if(this.miningTool != null && this.miningTool.isLevelled()) + tooltip.add(Color.VIOLET + "Level" + Color.DARK_VIOLET + ": " + Color.DARK_MAGENTA + (this.miningLevel + 1)); } @Clientside diff --git a/common/src/main/java/common/block/Material.java b/common/src/main/java/common/block/Material.java index 887d353c..2fbec48c 100755 --- a/common/src/main/java/common/block/Material.java +++ b/common/src/main/java/common/block/Material.java @@ -9,31 +9,25 @@ public enum Material { LOOSE {{ ; }}, - WOOD {{ - this.setBurning().setTool(Equipment.AXE); + BURNABLE {{ // is fuel + this.setBurning(); }}, SOLID {{ - this.setRequiredTool(Equipment.PICKAXE); + this.setTool(Equipment.PICKAXE); }}, TRANSLUCENT {{ this.setTranslucent(); }}, - BURNABLE {{ - this.setBurning(); - }}, - SOFT {{ // can break faster with sword, can't connect to fences+walls + SOFT {{ // can't connect to fences+walls this.setNoPushMobility(); }}, - PISTON {{ + IMMOVABLE {{ this.setImmovableMobility(); }}, - HEAVY {{ - this.setRequiredTool(Equipment.PICKAXE).setImmovableMobility(); - }}, - PLANT {{ // can break faster with sword + PLANT {{ this.setNonSolid().setNoPushMobility(); }}, - SMALL {{ // can be placed more easily + SMALL {{ // can be replaced by anvil this.setNonSolid().setNoPushMobility(); }}, FLEECE {{ @@ -60,20 +54,20 @@ public enum Material { HOT {{ this.setLiquid(true).setReplaceable().setNoPushMobility(); }}, - LEAVES {{ // can break faster with sword, precipitation block, special treatment in some worldgen + LEAVES {{ // precipitation block, special treatment in some worldgen this.setBurning().setTranslucent().setNoPushMobility(); }}, - BUSH {{ // can break faster with sword, can be replaced by small tree leaves + BUSH {{ // can be replaced by small tree leaves this.setNonSolid().setBurning().setNoPushMobility().setReplaceable(); }}, FIRE {{ this.setNonSolid().setReplaceable().setNoPushMobility(); }}, - POWDER {{ // can harvest with shovel, precipitation block + POWDER {{ // precipitation block this.setNonSolid().setReplaceable().setNoPushMobility(); }}, - FLUFF {{ // can harvest with shears - this.setPassable().setRequiredTool(Equipment.SWORD).setNoPushMobility(); + FLUFF {{ + this.setPassable().setTool(Equipment.SWORD).setNoPushMobility(); }}; private boolean solid = true; @@ -85,7 +79,6 @@ public enum Material { private boolean hot; private boolean burnable; private boolean replaceable; - private boolean requiresTool; // 0 - normal; 1 - can't push other blocks; 2 - can't be pushed private int mobility; private Equipment tool; @@ -121,12 +114,6 @@ public enum Material { return this; } - protected Material setRequiredTool(Equipment tool) { - this.requiresTool = true; - this.tool = tool; - return this; - } - protected Material setTool(Equipment tool) { this.tool = tool; return this; @@ -188,10 +175,6 @@ public enum Material { return this.opaque; } - public boolean isToolRequired() { - return this.requiresTool; - } - public int getMobility() { return this.mobility; } diff --git a/common/src/main/java/common/block/artificial/BlockBookshelf.java b/common/src/main/java/common/block/artificial/BlockBookshelf.java index 3e5196f9..2f757e04 100755 --- a/common/src/main/java/common/block/artificial/BlockBookshelf.java +++ b/common/src/main/java/common/block/artificial/BlockBookshelf.java @@ -14,7 +14,7 @@ public class BlockBookshelf extends Block { public BlockBookshelf() { - super(Material.WOOD); + super(Material.BURNABLE); this.setTab(CheatTab.DECORATION); this.setFlammable(30, 20); } diff --git a/common/src/main/java/common/block/artificial/BlockDoor.java b/common/src/main/java/common/block/artificial/BlockDoor.java index 7ac65a8c..f669ab2a 100755 --- a/common/src/main/java/common/block/artificial/BlockDoor.java +++ b/common/src/main/java/common/block/artificial/BlockDoor.java @@ -70,7 +70,7 @@ public class BlockDoor extends Block implements Rotatable { super(material); this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(OPEN, false) .withProperty(HINGE, EnumHingePosition.LEFT).withProperty(HALF, EnumDoorHalf.LOWER)); - this.setTab(material == Material.WOOD ? CheatTab.WOOD : CheatTab.TECHNOLOGY); + this.setTab(material == Material.BURNABLE ? CheatTab.WOOD : CheatTab.TECHNOLOGY); DOORS.add(this); } diff --git a/common/src/main/java/common/block/artificial/BlockFence.java b/common/src/main/java/common/block/artificial/BlockFence.java index edbe23a5..d2bd2137 100755 --- a/common/src/main/java/common/block/artificial/BlockFence.java +++ b/common/src/main/java/common/block/artificial/BlockFence.java @@ -44,7 +44,7 @@ public class BlockFence extends Block { super(p_i46395_1_); this.setDefaultState(this.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false))); - this.setTab(p_i46395_1_ == Material.WOOD ? CheatTab.WOOD : CheatTab.BLOCKS); + this.setTab(p_i46395_1_ == Material.BURNABLE ? CheatTab.WOOD : CheatTab.BLOCKS); this.texture = texture; FENCES.add(this); } diff --git a/common/src/main/java/common/block/artificial/BlockFenceGate.java b/common/src/main/java/common/block/artificial/BlockFenceGate.java index fd0eb81f..f8c49270 100755 --- a/common/src/main/java/common/block/artificial/BlockFenceGate.java +++ b/common/src/main/java/common/block/artificial/BlockFenceGate.java @@ -30,7 +30,7 @@ public class BlockFenceGate extends Block implements Rotatable public BlockFenceGate(WoodType type) { - super(Material.WOOD); + super(Material.BURNABLE); this.setDefaultState(this.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false))); this.setTab(CheatTab.WOOD); this.texture = type.getName() + "_planks"; diff --git a/common/src/main/java/common/block/artificial/BlockSlab.java b/common/src/main/java/common/block/artificial/BlockSlab.java index 8ffc4f04..ea6ce0cf 100755 --- a/common/src/main/java/common/block/artificial/BlockSlab.java +++ b/common/src/main/java/common/block/artificial/BlockSlab.java @@ -202,6 +202,6 @@ public class BlockSlab extends Block implements Directional { } public int getFuelAmount() { - return this.material == Material.WOOD ? 150 : 0; + return this.material == Material.BURNABLE ? 150 : 0; } } diff --git a/common/src/main/java/common/block/artificial/BlockTrapDoor.java b/common/src/main/java/common/block/artificial/BlockTrapDoor.java index eda667d7..30905aed 100755 --- a/common/src/main/java/common/block/artificial/BlockTrapDoor.java +++ b/common/src/main/java/common/block/artificial/BlockTrapDoor.java @@ -38,7 +38,7 @@ public class BlockTrapDoor extends Block implements Rotatable float f = 0.5F; float f1 = 1.0F; this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - this.setTab(materialIn == Material.WOOD ? CheatTab.WOOD : CheatTab.TECHNOLOGY); + this.setTab(materialIn == Material.BURNABLE ? CheatTab.WOOD : CheatTab.TECHNOLOGY); } public void setKeyItem(ItemKey key) { diff --git a/common/src/main/java/common/block/foliage/BlockHugeMushroom.java b/common/src/main/java/common/block/foliage/BlockHugeMushroom.java index 09eba3cb..a25158e0 100755 --- a/common/src/main/java/common/block/foliage/BlockHugeMushroom.java +++ b/common/src/main/java/common/block/foliage/BlockHugeMushroom.java @@ -48,7 +48,7 @@ public class BlockHugeMushroom extends Block { private final Block smallBlock; public BlockHugeMushroom(Block smallBlock) { - super(Material.WOOD); + super(Material.BURNABLE); this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockHugeMushroom.EnumType.ALL_OUTSIDE)); this.smallBlock = smallBlock; } diff --git a/common/src/main/java/common/block/foliage/BlockLog.java b/common/src/main/java/common/block/foliage/BlockLog.java index d70d2baa..36914d81 100755 --- a/common/src/main/java/common/block/foliage/BlockLog.java +++ b/common/src/main/java/common/block/foliage/BlockLog.java @@ -9,6 +9,7 @@ import common.model.Model.ModelProvider; import common.model.ModelRotation; import common.properties.Property; import common.util.LocalPos; +import common.util.Equipment; import common.util.Facing; import common.world.State; import common.world.World; @@ -18,11 +19,12 @@ public class BlockLog extends BlockRotatedPillar { public BlockLog() { - super(Material.WOOD); + super(Material.BURNABLE); this.setDefaultState(this.getBaseState().withProperty(AXIS, Facing.Axis.Y)); this.setTab(CheatTab.WOOD); this.setHardness(2.0F); this.setFlammable(5, 5); + this.setMiningTool(Equipment.AXE); } public void onRemoved(AWorldServer worldIn, LocalPos pos, State state) diff --git a/common/src/main/java/common/block/tech/BlockAnvil.java b/common/src/main/java/common/block/tech/BlockAnvil.java index 468d965c..f4bcdaae 100755 --- a/common/src/main/java/common/block/tech/BlockAnvil.java +++ b/common/src/main/java/common/block/tech/BlockAnvil.java @@ -33,7 +33,7 @@ public class BlockAnvil extends BlockFalling implements Rotatable public BlockAnvil(int damage) { - super(Material.HEAVY); + super(Material.IMMOVABLE); this.damage = damage; this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH)); this.setOpacity(0); diff --git a/common/src/main/java/common/block/tech/BlockChest.java b/common/src/main/java/common/block/tech/BlockChest.java index fdd4b1d3..5e98ce63 100755 --- a/common/src/main/java/common/block/tech/BlockChest.java +++ b/common/src/main/java/common/block/tech/BlockChest.java @@ -50,7 +50,7 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable public BlockChest(int capacity) { - super(capacity <= 30 ? Material.WOOD : Material.SOLID); + super(capacity <= 30 ? Material.BURNABLE : Material.SOLID); this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(OPEN, false)); this.capacity = capacity; this.setTab(CheatTab.TECHNOLOGY); diff --git a/common/src/main/java/common/block/tech/BlockPistonBase.java b/common/src/main/java/common/block/tech/BlockPistonBase.java index 1104f51e..eab080c9 100755 --- a/common/src/main/java/common/block/tech/BlockPistonBase.java +++ b/common/src/main/java/common/block/tech/BlockPistonBase.java @@ -250,7 +250,7 @@ public class BlockPistonBase extends Block implements Directional public BlockPistonBase(boolean isSticky) { - super(Material.PISTON); + super(Material.IMMOVABLE); this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(EXTENDED, Boolean.valueOf(false))); this.isSticky = isSticky; this.setHardness(0.5F); diff --git a/common/src/main/java/common/block/tech/BlockPistonHead.java b/common/src/main/java/common/block/tech/BlockPistonHead.java index 8e6eacde..76879798 100755 --- a/common/src/main/java/common/block/tech/BlockPistonHead.java +++ b/common/src/main/java/common/block/tech/BlockPistonHead.java @@ -28,7 +28,7 @@ public class BlockPistonHead extends Block implements Directional public BlockPistonHead(boolean sticky) { - super(Material.PISTON); + super(Material.IMMOVABLE); this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH)); this.setHardness(0.5F); this.sticky = sticky; diff --git a/common/src/main/java/common/block/tech/BlockSign.java b/common/src/main/java/common/block/tech/BlockSign.java index da0ec545..3e2f23ff 100755 --- a/common/src/main/java/common/block/tech/BlockSign.java +++ b/common/src/main/java/common/block/tech/BlockSign.java @@ -23,7 +23,7 @@ public class BlockSign extends Block implements ITileEntityProvider, Rotatable { public BlockSign() { - super(Material.WOOD); + super(Material.BURNABLE); float f = 0.25F; float f1 = 1.0F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); diff --git a/common/src/main/java/common/block/tech/BlockWorkbench.java b/common/src/main/java/common/block/tech/BlockWorkbench.java index 25712193..b158e8f4 100755 --- a/common/src/main/java/common/block/tech/BlockWorkbench.java +++ b/common/src/main/java/common/block/tech/BlockWorkbench.java @@ -19,7 +19,7 @@ public class BlockWorkbench extends Block public BlockWorkbench(int tier) { - super(Material.WOOD); + super(Material.BURNABLE); this.setTab(CheatTab.TECHNOLOGY); this.tier = tier; } diff --git a/common/src/main/java/common/effect/Effect.java b/common/src/main/java/common/effect/Effect.java index a7979e4e..1de39b76 100755 --- a/common/src/main/java/common/effect/Effect.java +++ b/common/src/main/java/common/effect/Effect.java @@ -21,12 +21,7 @@ public enum Effect { return String.format(Color.RED + "-%d%% Geschwindigkeit", 15 * (amp + 1)); } }, - HASTE("haste", "Eile", "Trank der Eile", false, 14270531) { - public double getEffectiveness() { - return 1.5; - } - }, - FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583), + PUNCHING("punching", "Schlagkraft", "Trank der Schlagkraft", false, 0xffff00), STRENGTH("strength", 2, 180, "Stärke", "Trank der Stärke", false, 9643043) { public String getTooltip(int amp) { return String.format(Color.BLUE + "+%d%% Angriffsschaden", 50 * (amp + 1)); diff --git a/common/src/main/java/common/enchantment/Enchantment.java b/common/src/main/java/common/enchantment/Enchantment.java index cfe84d9c..44c1cea7 100755 --- a/common/src/main/java/common/enchantment/Enchantment.java +++ b/common/src/main/java/common/enchantment/Enchantment.java @@ -299,22 +299,6 @@ public enum Enchantment implements Displayable, Identifyable return 3; } }, - EFFICIENCY("efficiency", 10, EnchantmentType.DIGGER, "Effizienz") { - public int getMinEnchantability(int enchantmentLevel) - { - return 1 + 10 * (enchantmentLevel - 1); - } - - public int getMaxEnchantability(int enchantmentLevel) - { - return super.getMinEnchantability(enchantmentLevel) + 50; - } - - public int getMaxLevel() - { - return 5; - } - }, SILK_TOUCH("silk_touch", 1, EnchantmentType.DIGGER, "Behutsamkeit") { public int getMinEnchantability(int enchantmentLevel) { diff --git a/common/src/main/java/common/enchantment/EnchantmentHelper.java b/common/src/main/java/common/enchantment/EnchantmentHelper.java index 8ca3aa43..54e61d51 100755 --- a/common/src/main/java/common/enchantment/EnchantmentHelper.java +++ b/common/src/main/java/common/enchantment/EnchantmentHelper.java @@ -213,30 +213,6 @@ public class EnchantmentHelper return getEnchantmentLevel(Enchantment.FIRE_ASPECT, player instanceof EntityNPC npc ? npc.getHeldItem() : null); } -// /** -// * Returns the 'Water Breathing' modifier of enchantments on player equipped armors. -// */ -// public static int getRespiration(Entity player) -// { -// return getMaxEnchantmentLevel(Enchantment.respiration.effectId, player.getInventory()); -// } - -// /** -// * Returns the level of the Depth Strider enchantment. -// */ -// public static int getDepthStriderModifier(Entity player) -// { -// return getMaxEnchantmentLevel(Enchantment.depthStrider.effectId, player.getInventory()); -// } - - /** - * Return the extra efficiency of tools based on enchantments on equipped player item. - */ - public static int getEfficiencyModifier(EntityLiving player) - { - return getEnchantmentLevel(Enchantment.EFFICIENCY, player instanceof EntityNPC npc ? npc.getHeldItem() : null); - } - /** * Returns the silk touch status of enchantments on current equipped item of player. */ @@ -277,14 +253,6 @@ public class EnchantmentHelper return getEnchantmentLevel(Enchantment.LOOTING, player instanceof EntityNPC npc ? npc.getHeldItem() : null); } -// /** -// * Returns the aqua affinity status of enchantments on current equipped item of player. -// */ -// public static boolean getAquaAffinityModifier(EntityLivingBase player) -// { -// return getMaxEnchantmentLevel(Enchantment.aquaAffinity.effectId, player.getInventory()) > 0; -// } - public static ItemStack getEnchantedArmor(Enchantment ench, EntityLiving entity) { if(entity instanceof EntityNPC npc) { diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index a6502e34..654ccc99 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -1640,11 +1640,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory if (itemstack == this.itemInUse) { - if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) - { - this.updateItemUse(itemstack, 5); - } - if (--this.itemInUseCount == 0 && !this.worldObj.client) { this.onItemUseFinish(); @@ -2883,7 +2878,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory // super.onItemUseFinish(); if (this.itemInUse != null) { - this.updateItemUse(this.itemInUse, 16); int i = this.itemInUse.getSize(); ItemStack itemstack = this.itemInUse.getItem().onItemUseFinish(this.itemInUse, this.worldObj, this); @@ -3034,22 +3028,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory return this.isUsingItem() && this.itemInUse.getItem().getItemUseAction() == ItemAction.BLOCK; } - /** - * Plays sounds and makes particles for item in use state - */ - protected void updateItemUse(ItemStack itemStackIn, int p_71010_2_) - { - if (itemStackIn.getItemUseAction() == ItemAction.DRINK) - { - this.playSound(SoundEvent.DRINK, 0.5F); - } - - if (itemStackIn.getItemUseAction() == ItemAction.EAT) - { - this.playSound(SoundEvent.EAT, 0.5F + 0.5F * (float)this.rand.zrange(2)); - } - } - @Clientside public void handleStatusUpdate(byte id) { @@ -3228,64 +3206,9 @@ public abstract class EntityNPC extends EntityLiving implements IInventory return entityitem; } - /** - * Block hardness will be further counted in game/block/Block.getPlayerRelativeBlockHardness - */ - public float getToolDigEfficiency(Block block) - { - float f = this.getHeldItem() != null && this.getHeldItem().getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() ? tool.getToolEfficiency() : 1.0f; - - if (f > 1.0F) - { - int i = EnchantmentHelper.getEfficiencyModifier(this); - ItemStack itemstack = this.getHeldItem(); - - if (i > 0 && itemstack != null) - { - f += (float)(i * i + 1); - } - } - - if (this.hasEffect(Effect.HASTE)) - { - int speed = this.getEffect(Effect.HASTE).getAmplifier(); - if(speed >= 255) - return 1000000.0f; - f *= 1.0F + (float)(speed + 1) * 0.2F; - } - - if (this.hasEffect(Effect.FATIGUE)) - { - float f1 = 1.0F; - - switch (this.getEffect(Effect.FATIGUE).getAmplifier()) - { - case 0: - f1 = 0.3F; - break; - - case 1: - f1 = 0.09F; - break; - - case 2: - f1 = 0.0027F; - break; - - case 3: - default: - f1 = 8.1E-4F; - } - - f *= f1; - } - - return f; - } - public boolean canHarvestBlock(Block block) { - if(!block.getMaterial().isToolRequired()) + if(block.getMiningTool() == null || this.hasEffect(Effect.PUNCHING)) return true; return this.getHeldItem() != null && this.getHeldItem().getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() && (!tool.getToolType().isLevelled() || tool.getToolLevel() >= block.getMiningLevel()); } @@ -4481,7 +4404,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory public void setGodMode(boolean god) { this.fallDistance = 0.0F; if(!god) { - this.removeEffect(Effect.HASTE); + this.removeEffect(Effect.PUNCHING); this.removeEffect(Effect.RESISTANCE); this.removeEffect(Effect.FIRE_RESISTANCE); this.removeEffect(Effect.FLYING); @@ -4492,7 +4415,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory this.setHealth(this.getMaxHealth()); this.setManaPoints(this.getMaxMana()); this.clearEffects(false); - this.addEffect(new StatusEffect(Effect.HASTE, Integer.MAX_VALUE, 255)); + this.addEffect(new StatusEffect(Effect.PUNCHING, Integer.MAX_VALUE, 255)); this.addEffect(new StatusEffect(Effect.RESISTANCE, Integer.MAX_VALUE, 255)); this.addEffect(new StatusEffect(Effect.FIRE_RESISTANCE, Integer.MAX_VALUE, 0)); this.addEffect(new StatusEffect(Effect.FLYING, Integer.MAX_VALUE, 1)); diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index d161d359..16b17212 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -290,17 +290,17 @@ public abstract class BlockRegistry { register(wood.getName() + "_sapling", (new BlockSapling(wood)).setHardness(0.0F) .setDisplay(wood.getDisplay() + "setzling")); register(wood.getName() + "_trunk", (new BlockSlab(log, wood.getName() + "_log_top", wood.getName() + "_log_top")).setDisplay(wood.getDisplay() + "holzscheibe")); - Block planks = (new Block(Material.WOOD)).setHardness(2.0F) + Block planks = (new Block(Material.BURNABLE)).setHardness(2.0F) .setDisplay(wood.getDisplay() + "holzbretter").setTab(CheatTab.WOOD).setFlammable(5, 20); register(wood.getName() + "_planks", planks); register(wood.getName() + "_stairs", (new BlockStairs(planks)) .setDisplay(wood.getDisplay() + "holztreppe").setFlammable(5, 20)); register(wood.getName() + "_slab", (new BlockSlab(planks)).setDisplay(wood.getDisplay() + "holzstufe").setFlammable(5, 20)); - register(wood.getName() + "_fence", (new BlockFence(Material.WOOD, wood.getName() + "_planks")) + register(wood.getName() + "_fence", (new BlockFence(Material.BURNABLE, wood.getName() + "_planks")) .setHardness(2.0F).setDisplay(wood.getDisplay() + "holzzaun").setFlammable(5, 20)); register(wood.getName() + "_fence_gate", (new BlockFenceGate(wood)).setHardness(2.0F) .setDisplay(wood.getDisplay() + "holzzauntor").setFlammable(5, 20)); - register(wood.getName() + "_door", (new BlockDoor(Material.WOOD)).setHardness(3.0F) + register(wood.getName() + "_door", (new BlockDoor(Material.BURNABLE)).setHardness(3.0F) .setDisplay(wood.getDisplay() + "holztür").setFlammable(5, 20)); } @@ -333,7 +333,7 @@ public abstract class BlockRegistry { register(color.getName() + "_bed", (new BlockBed(color)).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett")); } - register("ladder", (new BlockLadder()).setHardness(0.4F).setDisplay("Leiter").setMiningTool(Equipment.AXE)); + register("ladder", (new BlockLadder()).setHardness(0.4F).setDisplay("Leiter")); register("bookshelf", (new BlockBookshelf()).setHardness(1.5F).setDisplay("Bücherregal")); register("cake", (new BlockCake()).setHardness(0.5F).setDisplay("Kuchen").setTab(CheatTab.DECORATION)); register("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F) @@ -538,7 +538,7 @@ public abstract class BlockRegistry { } register("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setDisplay("Eisentür")); - register("trapdoor", (new BlockTrapDoor(Material.WOOD)).setHardness(3.0F).setDisplay("Holzfalltür").setFlammable(5, 20)); + register("trapdoor", (new BlockTrapDoor(Material.BURNABLE)).setHardness(3.0F).setDisplay("Holzfalltür").setFlammable(5, 20)); register("iron_trapdoor", (new BlockTrapDoor(Material.SOLID)).setHardness(5.0F).setDisplay("Eisenfalltür")); register("core", new BlockCore().setHardness(1.5F).setDisplay("Chunk-Lade-Kern")); @@ -606,7 +606,7 @@ public abstract class BlockRegistry { register("stone_pressure_plate", (new BlockPressurePlate(Material.SOLID, BlockPressurePlate.Sensitivity.MOBS)).setHardness(0.5F) .setDisplay("Steindruckplatte")); - register("wooden_pressure_plate", (new BlockPressurePlate(Material.WOOD, BlockPressurePlate.Sensitivity.EVERYTHING)) + register("wooden_pressure_plate", (new BlockPressurePlate(Material.BURNABLE, BlockPressurePlate.Sensitivity.EVERYTHING)) .setHardness(0.5F).setDisplay("Holzdruckplatte")); register("light_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.SOLID, 15)).setHardness(0.5F) .setDisplay("Wägeplatte (niedrige Gewichte)")); diff --git a/common/src/main/java/common/init/Items.java b/common/src/main/java/common/init/Items.java index 217a0b82..27405fd2 100755 --- a/common/src/main/java/common/init/Items.java +++ b/common/src/main/java/common/init/Items.java @@ -825,9 +825,6 @@ public abstract class Items { public static final ItemEnchantedBook enchanted_book_draining_5 = get("enchanted_book_draining_5"); public static final ItemEnchantedBook enchanted_book_draining_7 = get("enchanted_book_draining_7"); public static final ItemEnchantedBook enchanted_book_draining_9 = get("enchanted_book_draining_9"); - public static final ItemEnchantedBook enchanted_book_efficiency = get("enchanted_book_efficiency"); - public static final ItemEnchantedBook enchanted_book_efficiency_3 = get("enchanted_book_efficiency_3"); - public static final ItemEnchantedBook enchanted_book_efficiency_5 = get("enchanted_book_efficiency_5"); public static final ItemEnchantedBook enchanted_book_feather_falling = get("enchanted_book_feather_falling"); public static final ItemEnchantedBook enchanted_book_feather_falling_4 = get("enchanted_book_feather_falling_4"); public static final ItemEnchantedBook enchanted_book_fire_aspect = get("enchanted_book_fire_aspect"); diff --git a/common/src/main/java/common/init/ToolMaterial.java b/common/src/main/java/common/init/ToolMaterial.java index 34fc8b6a..e4945ac2 100755 --- a/common/src/main/java/common/init/ToolMaterial.java +++ b/common/src/main/java/common/init/ToolMaterial.java @@ -9,7 +9,6 @@ import common.util.Equipment; public class ToolMaterial { private final int harvestLevel; private final int durability; - private final int efficiency; private final int damage; private final float radiationResistance; private final float magicResistance; @@ -22,10 +21,9 @@ public class ToolMaterial { private boolean magnetic; private int defColor = 0xffffffff; - 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) { + protected ToolMaterial(int level, float rad, float mag, int uses, int d, int damage, int ench, int auses, int aench, int r1, int r2, int r3, int r4) { this.harvestLevel = level; this.durability = uses; - this.efficiency = efficiency; this.damage = damage; this.enchantability = ench; this.maxDamageFactor = auses; @@ -53,10 +51,6 @@ public class ToolMaterial { return this.durability; } - public int getEfficiency() { - return this.efficiency; - } - public int getDamage() { return this.damage; } diff --git a/common/src/main/java/common/item/ItemAction.java b/common/src/main/java/common/item/ItemAction.java index faf64d23..6d4350ba 100755 --- a/common/src/main/java/common/item/ItemAction.java +++ b/common/src/main/java/common/item/ItemAction.java @@ -1,5 +1,5 @@ package common.item; public enum ItemAction { - NONE, EAT, DRINK, BLOCK, AIM; + NONE, BLOCK, AIM; } diff --git a/common/src/main/java/common/item/consumable/ItemFood.java b/common/src/main/java/common/item/consumable/ItemFood.java index f8071fbe..23d1c680 100755 --- a/common/src/main/java/common/item/consumable/ItemFood.java +++ b/common/src/main/java/common/item/consumable/ItemFood.java @@ -6,7 +6,6 @@ import common.entity.npc.EntityNPC; import common.init.SoundEvent; import common.item.CheatTab; import common.item.Item; -import common.item.ItemAction; import common.item.ItemStack; import common.item.ItemCategory; import common.world.World; @@ -33,21 +32,6 @@ public class ItemFood extends Item return ItemCategory.CONSUMABLE; } - /** - * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using - * the Item before the action is complete. - */ - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) - { -// if(!playerIn.creative) - stack.decrSize(); - worldIn.playSoundAtEntity(playerIn, SoundEvent.EAT, 0.5F); - playerIn.heal((int)((float)this.getHealAmount(stack) * 0.5f * (1.0f + worldIn.rand.floatv()))); - this.onFoodEaten(stack, worldIn, playerIn); -// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); - return stack; - } - protected void onFoodEaten(ItemStack stack, World worldIn, EntityNPC player) { if (!worldIn.client && this.potionId != null && worldIn.rand.floatv() < this.potionEffectProbability) @@ -56,29 +40,19 @@ public class ItemFood extends Item } } - /** - * How long it takes to use or consume an item - */ - public int getMaxItemUseDuration(ItemStack stack) - { - return 32; - } - - /** - * returns the action that specifies what animation to play when the items is being used - */ - public ItemAction getItemUseAction() - { - return ItemAction.EAT; - } - /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) + public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityNPC playerIn) { - playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); - return itemStackIn; + playerIn.playSound(SoundEvent.EAT, 0.5F + 0.5F * (float)playerIn.getRNG().zrange(2)); +// if(!playerIn.creative) + stack.decrSize(); +// worldIn.playSoundAtEntity(playerIn, SoundEvent.EAT, 0.5F); + playerIn.heal((int)((float)this.getHealAmount(stack) * 0.5f * (1.0f + worldIn.rand.floatv()))); + this.onFoodEaten(stack, worldIn, playerIn); +// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); + return stack; } public int getHealAmount(ItemStack stack) diff --git a/common/src/main/java/common/item/consumable/ItemMilkBottle.java b/common/src/main/java/common/item/consumable/ItemMilkBottle.java index 4086a502..cd670048 100755 --- a/common/src/main/java/common/item/consumable/ItemMilkBottle.java +++ b/common/src/main/java/common/item/consumable/ItemMilkBottle.java @@ -4,9 +4,9 @@ import java.util.Map; import common.entity.npc.Attribute; import common.entity.npc.EntityNPC; +import common.init.SoundEvent; import common.item.CheatTab; import common.item.Item; -import common.item.ItemAction; import common.item.ItemStack; import common.item.ItemCategory; import common.util.Clientside; @@ -23,23 +23,11 @@ public class ItemMilkBottle extends Item { return ItemCategory.CONSUMABLE; } - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) { - stack.decrSize(); + public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { + playerIn.playSound(SoundEvent.DRINK, 0.5F); + itemStackIn.decrSize(); if(!worldIn.client) playerIn.clearEffects(false); - return stack; - } - - public int getMaxItemUseDuration(ItemStack stack) { - return 32; - } - - public ItemAction getItemUseAction() { - return ItemAction.DRINK; - } - - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { - playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); return itemStackIn; } diff --git a/common/src/main/java/common/item/consumable/ItemPotion.java b/common/src/main/java/common/item/consumable/ItemPotion.java index 14886d1e..61368d58 100755 --- a/common/src/main/java/common/item/consumable/ItemPotion.java +++ b/common/src/main/java/common/item/consumable/ItemPotion.java @@ -94,61 +94,6 @@ public class ItemPotion extends Item { return this.type; } - - /** - * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using - * the Item before the action is complete. - */ - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) - { -// if (!playerIn.creative) -// { - stack.decrSize(); -// } - - if (!worldIn.client) - { - if (this.effect != null) - { - if(this.effect.getPotion().isInstant()) - this.effect.getPotion().onImpact(null, null, playerIn, this.effect.getAmplifier(), 1.0); - else - playerIn.addEffect(new StatusEffect(this.effect.getPotion(), this.effect.getDuration(), this.effect.getAmplifier())); - } - } - -// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); - -// if (!playerIn.creative) -// { - if (stack.isEmpty()) - { - return new ItemStack(Items.bottle); - } - - if (!playerIn.addItemStackToInventory(new ItemStack(Items.bottle))) { - playerIn.dropItem(new ItemStack(Items.bottle), false); - } -// } - - return stack; - } - - /** - * How long it takes to use or consume an item - */ - public int getMaxItemUseDuration(ItemStack stack) - { - return 32; - } - - /** - * returns the action that specifies what animation to play when the items is being used - */ - public ItemAction getItemUseAction() - { - return ItemAction.DRINK; - } public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, LocalPos block) { if(control == ItemControl.TERTIARY || control == ItemControl.QUARTERNARY) { @@ -164,10 +109,40 @@ public class ItemPotion extends Item /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) + public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityNPC playerIn) { - playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); - return itemStackIn; +// if (!playerIn.creative) +// { + playerIn.playSound(SoundEvent.DRINK, 0.5F); + stack.decrSize(); +// } + + if (!worldIn.client) + { + if (this.effect != null) + { + if(this.effect.getPotion().isInstant()) + this.effect.getPotion().onImpact(null, null, playerIn, this.effect.getAmplifier(), 1.0); + else + playerIn.addEffect(new StatusEffect(this.effect.getPotion(), this.effect.getDuration(), this.effect.getAmplifier())); + } + } + +// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); + +// if (!playerIn.creative) +// { + if (stack.isEmpty()) + { + return new ItemStack(Items.bottle); + } + + if (!playerIn.addItemStackToInventory(new ItemStack(Items.bottle))) { + playerIn.dropItem(new ItemStack(Items.bottle), false); + } +// } + + return stack; } @Clientside diff --git a/common/src/main/java/common/item/tool/ItemTool.java b/common/src/main/java/common/item/tool/ItemTool.java index 75c0fde8..3c9dc212 100755 --- a/common/src/main/java/common/item/tool/ItemTool.java +++ b/common/src/main/java/common/item/tool/ItemTool.java @@ -44,7 +44,6 @@ public class ItemTool extends Item { { if(this.type.isLevelled()) tooltip.add(Color.VIOLET + "Level " + (this.material.getHarvestLevel() + 1)); - tooltip.add(Color.DARK_GREEN + "+" + (this.material.getEfficiency() - 1) + " Abbaueffizienz"); int damage = this.getAttackDamageBonus(stack); if(damage > 0) tooltip.add(Color.BLUE + "+" + damage + " Angriffsschaden"); @@ -73,10 +72,6 @@ public class ItemTool extends Item { return this.material.getHarvestLevel(); } - public int getToolEfficiency() { - return this.material.getEfficiency(); - } - public int getItemEnchantability() { return this.material.getEnchantability(); } diff --git a/common/src/main/java/common/packet/CPacketBreak.java b/common/src/main/java/common/packet/CPacketBreak.java index f94f135f..0dff102b 100755 --- a/common/src/main/java/common/packet/CPacketBreak.java +++ b/common/src/main/java/common/packet/CPacketBreak.java @@ -62,8 +62,6 @@ public class CPacketBreak implements Packet public static enum Action { START_DESTROY_BLOCK, - ABORT_DESTROY_BLOCK, - STOP_DESTROY_BLOCK, DROP_ALL_ITEMS, DROP_ITEM, RELEASE_USE_ITEM; diff --git a/common/src/main/java/common/pathfinding/WalkNodeProcessor.java b/common/src/main/java/common/pathfinding/WalkNodeProcessor.java index 4a85a548..4c4f9af3 100755 --- a/common/src/main/java/common/pathfinding/WalkNodeProcessor.java +++ b/common/src/main/java/common/pathfinding/WalkNodeProcessor.java @@ -212,7 +212,7 @@ public class WalkNodeProcessor extends NodeProcessor { if (!block.getMaterial().isColdLiquid()) { - if (!enterDoors && block instanceof BlockDoor && block.getMaterial() == Material.WOOD) + if (!enterDoors && block instanceof BlockDoor && block.getMaterial() == Material.BURNABLE) { return 0; } @@ -239,7 +239,7 @@ public class WalkNodeProcessor extends NodeProcessor return -3; } } - else if (!block.isPassable(world, mpos) && (!breakDoors || !(block instanceof BlockDoor) || block.getMaterial() != Material.WOOD)) + else if (!block.isPassable(world, mpos) && (!breakDoors || !(block instanceof BlockDoor) || block.getMaterial() != Material.BURNABLE)) { if (block instanceof BlockFence || block instanceof BlockFenceGate || block instanceof BlockWall) { diff --git a/common/src/main/java/common/village/Village.java b/common/src/main/java/common/village/Village.java index 312455f7..26054991 100755 --- a/common/src/main/java/common/village/Village.java +++ b/common/src/main/java/common/village/Village.java @@ -182,7 +182,7 @@ public class Village private boolean isWoodDoor(AWorldServer world, LocalPos pos) { Block block = world.getState(pos).getBlock(); - return block instanceof BlockDoor ? block.getMaterial() == Material.WOOD : false; + return block instanceof BlockDoor ? block.getMaterial() == Material.BURNABLE : false; } private void updatePosition() diff --git a/server/src/main/java/server/command/commands/CommandGod.java b/server/src/main/java/server/command/commands/CommandGod.java index 6f70493c..4cff3383 100644 --- a/server/src/main/java/server/command/commands/CommandGod.java +++ b/server/src/main/java/server/command/commands/CommandGod.java @@ -21,7 +21,7 @@ public class CommandGod extends Command { } public void exec(CommandEnvironment env, Executor exec, List players, boolean remove, boolean quiet) { - remove = !remove && exec.isPlayer() && players.size() == 1 && players.get(0).connection == exec ? players.get(0).hasEffect(Effect.HASTE) && players.get(0).getEffect(Effect.HASTE).getAmplifier() == 255 : remove; + remove = !remove && exec.isPlayer() && players.size() == 1 && players.get(0).connection == exec ? players.get(0).hasEffect(Effect.PUNCHING) && players.get(0).getEffect(Effect.PUNCHING).getAmplifier() == 255 : remove; for(EntityNPC player : players) { player.setGodMode(!remove); if(!quiet) diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 9066d071..f77c1945 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -186,15 +186,6 @@ public class Player extends User implements Executor, IPlayer private Vec3i selOffset; private EditAction edit = EditAction.SELECT; - private LocalPos startPos = LocalPos.ORIGIN; - private LocalPos removingPos = LocalPos.ORIGIN; - private boolean isDestroyingBlock; - private boolean receivedFinishDiggingPacket; - private int initialDamage; - private int curblockDamage; - private int initialBlockDamage; - private int durabilityRemainingOnBlock = -1; - private boolean isChangingQuantityOnly; private int respawnTimer; @@ -234,12 +225,6 @@ public class Player extends User implements Executor, IPlayer if(this.entity == null) this.entity = new EntityHuman(world); this.entity.setServerPlayer(this); - this.isDestroyingBlock = false; - this.receivedFinishDiggingPacket = false; - this.initialDamage = 0; - this.curblockDamage = 0; - this.initialBlockDamage = 0; - this.durabilityRemainingOnBlock = -1; this.managedPosX = 0.0; this.managedPosZ = 0.0; this.combinedHealth = Float.MIN_VALUE; @@ -1048,61 +1033,6 @@ public class Player extends User implements Executor, IPlayer } } } - - - - - - - ++this.curblockDamage; - - if (this.receivedFinishDiggingPacket) - { - int i = this.curblockDamage - this.initialBlockDamage; - Block block = this.entity.worldObj.getState(this.removingPos).getBlock(); - - if (block == Blocks.air) - { - this.receivedFinishDiggingPacket = false; - } - else - { - float f = block.getHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(i + 1); - int j = (int)(f * 10.0F); - - if (j != this.durabilityRemainingOnBlock) - { - this.durabilityRemainingOnBlock = j; - } - - if (f >= 1.0F) - { - this.receivedFinishDiggingPacket = false; - this.tryHarvestBlock(this.removingPos); - } - } - } - else if (this.isDestroyingBlock) - { - Block block1 = this.entity.worldObj.getState(this.startPos).getBlock(); - - if (block1 == Blocks.air) - { - this.durabilityRemainingOnBlock = -1; - this.isDestroyingBlock = false; - } - else - { - int k = this.curblockDamage - this.initialDamage; - float f1 = block1.getHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(k + 1); - int l = (int)(f1 * 10.0F); - - if (l != this.durabilityRemainingOnBlock) - { - this.durabilityRemainingOnBlock = l; - } - } - } } public void onBlockClicked(LocalPos pos, Facing side) @@ -1115,71 +1045,16 @@ public class Player extends User implements Executor, IPlayer return; } -// if (this.creative) -// { -// if (!this.worldObj.extinguishFire(null, pos, side)) -// { -// this.tryHarvestBlock(pos); -// } -// } -// else -// { Block block = this.entity.worldObj.getState(pos).getBlock(); this.entity.worldObj.extinguishFire(null, pos, side); - this.initialDamage = this.curblockDamage; - float f = 1.0F; if (block != Blocks.air) { block.onStartBreak(this.entity.worldObj, pos, this.entity); - f = block.getHardness(this.entity, this.entity.worldObj, pos); + if(this.entity.canHarvestBlock(block)) + this.tryHarvestBlock(pos); } - - if (block != Blocks.air && f >= 1.0F) - { - this.tryHarvestBlock(pos); - } - else - { - this.isDestroyingBlock = true; - this.startPos = pos; - int i = (int)(f * 10.0F); - this.durabilityRemainingOnBlock = i; - } -// } - } - - public void blockRemoving(LocalPos pos) - { - if (pos.equals(this.startPos)) - { - int i = this.curblockDamage - this.initialDamage; - Block block = this.entity.worldObj.getState(pos).getBlock(); - - if (block != Blocks.air) - { - float f = block.getHardness(this.entity, this.entity.worldObj, pos) * (float)(i + 1); - - if (f >= 0.7F) - { - this.isDestroyingBlock = false; - this.tryHarvestBlock(pos); - } - else if (!this.receivedFinishDiggingPacket) - { - this.isDestroyingBlock = false; - this.receivedFinishDiggingPacket = true; - this.removingPos = pos; - this.initialBlockDamage = this.initialDamage; - } - } - } - } - - public void cancelDestroyingBlock() - { - this.isDestroyingBlock = false; } private boolean removeBlock(LocalPos pos) @@ -2282,8 +2157,6 @@ public class Player extends User implements Executor, IPlayer return; case START_DESTROY_BLOCK: - case ABORT_DESTROY_BLOCK: - case STOP_DESTROY_BLOCK: double d0 = this.entity.posX - ((double)blockpos.getX() + 0.5D); double d1 = this.entity.posY - ((double)blockpos.getY() + 0.5D) + 1.5D; double d2 = this.entity.posZ - ((double)blockpos.getZ() + 0.5D); @@ -2301,32 +2174,13 @@ public class Player extends User implements Executor, IPlayer } else { - if (packetIn.getStatus() == CPacketBreak.Action.START_DESTROY_BLOCK) + if (World.isValidXZ(blockpos)) { - if (World.isValidXZ(blockpos)) - { - this.onBlockClicked(blockpos, packetIn.getFacing()); - } - else - { - this.sendPacket(new SPacketBlockChange(worldserver, blockpos)); - } + this.onBlockClicked(blockpos, packetIn.getFacing()); } else { - if (packetIn.getStatus() == CPacketBreak.Action.STOP_DESTROY_BLOCK) - { - this.blockRemoving(blockpos); - } - else if (packetIn.getStatus() == CPacketBreak.Action.ABORT_DESTROY_BLOCK) - { - this.cancelDestroyingBlock(); - } - - if (worldserver.getState(blockpos).getBlock() != Blocks.air) - { - this.sendPacket(new SPacketBlockChange(worldserver, blockpos)); - } + this.sendPacket(new SPacketBlockChange(worldserver, blockpos)); } return; @@ -2672,7 +2526,7 @@ public class Player extends User implements Executor, IPlayer case GOD: if(this.isAdmin()) { - boolean god = !this.entity.hasEffect(Effect.HASTE) || this.entity.getEffect(Effect.HASTE).getAmplifier() != 255; + boolean god = !this.entity.hasEffect(Effect.PUNCHING) || this.entity.getEffect(Effect.PUNCHING).getAmplifier() != 255; this.entity.setGodMode(god); this.addFeed(god ? (Color.GREEN + "Statuseffekte wurden hinzugefügt") : (Color.RED + "Statuseffekte wurden entfernt")); } diff --git a/server/src/main/java/server/village/VillageCollection.java b/server/src/main/java/server/village/VillageCollection.java index 7c7930f0..17a2d46e 100755 --- a/server/src/main/java/server/village/VillageCollection.java +++ b/server/src/main/java/server/village/VillageCollection.java @@ -244,7 +244,7 @@ public class VillageCollection private boolean isWoodDoor(WorldServer world, LocalPos doorPos) { Block block = world.getState(doorPos).getBlock(); - return block instanceof BlockDoor ? block.getMaterial() == Material.WOOD : false; + return block instanceof BlockDoor ? block.getMaterial() == Material.BURNABLE : false; } public TagObject toTags()