From 41f769b8b22de1f4473508f997e96ad1ecd45b5a Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 28 May 2021 14:35:55 +0200 Subject: [PATCH] Rename #getBlockId to #getId --- .../server/entity/metadata/other/FallingBlockMeta.java | 2 +- src/main/java/net/minestom/server/instance/Instance.java | 2 +- .../java/net/minestom/server/instance/InstanceContainer.java | 2 +- src/main/java/net/minestom/server/instance/block/Block.java | 4 ++-- .../java/net/minestom/server/instance/block/BlockImpl.java | 2 +- .../java/net/minestom/server/instance/block/BlockManager.java | 4 ++-- .../net/minestom/server/instance/block/BlockRegistry.java | 2 +- .../net/minestom/server/listener/BlockPlacementListener.java | 2 +- .../server/network/packet/server/play/TagsPacket.java | 2 +- src/test/java/testextension/mixins/DynamicChunkMixin.java | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/metadata/other/FallingBlockMeta.java b/src/main/java/net/minestom/server/entity/metadata/other/FallingBlockMeta.java index 94a6e36b3..2d3fad418 100644 --- a/src/main/java/net/minestom/server/entity/metadata/other/FallingBlockMeta.java +++ b/src/main/java/net/minestom/server/entity/metadata/other/FallingBlockMeta.java @@ -42,7 +42,7 @@ public class FallingBlockMeta extends EntityMeta implements ObjectDataProvider { @SuppressWarnings("ConstantConditions") @Override public int getObjectData() { - int id = this.block.getBlockId(); + int id = this.block.getId(); int metadata = 0; // TODO ? return id | (metadata << 12); } diff --git a/src/main/java/net/minestom/server/instance/Instance.java b/src/main/java/net/minestom/server/instance/Instance.java index 0eb58ade5..fddde5f0e 100644 --- a/src/main/java/net/minestom/server/instance/Instance.java +++ b/src/main/java/net/minestom/server/instance/Instance.java @@ -574,7 +574,7 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler, blockActionPacket.blockPosition = blockPosition; blockActionPacket.actionId = actionId; blockActionPacket.actionParam = actionParam; - blockActionPacket.blockId = block.getBlockId(); + blockActionPacket.blockId = block.getId(); final Chunk chunk = getChunkAt(blockPosition); Check.notNull(chunk, "The chunk at " + blockPosition + " is not loaded!"); diff --git a/src/main/java/net/minestom/server/instance/InstanceContainer.java b/src/main/java/net/minestom/server/instance/InstanceContainer.java index 518c80933..c64949973 100644 --- a/src/main/java/net/minestom/server/instance/InstanceContainer.java +++ b/src/main/java/net/minestom/server/instance/InstanceContainer.java @@ -176,7 +176,7 @@ public class InstanceContainer extends Instance { final Block changedBlock = currentlyChangingBlocks.get(blockPosition); if (changedBlock == null) return false; - return changedBlock.getBlockId() == block.getBlockId(); + return changedBlock.getId() == block.getId(); } /** diff --git a/src/main/java/net/minestom/server/instance/block/Block.java b/src/main/java/net/minestom/server/instance/block/Block.java index 946396fb5..54b69bfbc 100644 --- a/src/main/java/net/minestom/server/instance/block/Block.java +++ b/src/main/java/net/minestom/server/instance/block/Block.java @@ -33,7 +33,7 @@ public interface Block extends Keyed, TagReadable, BlockConstants { @NotNull Map createPropertiesMap(); - int getBlockId(); + int getId(); short getStateId(); @@ -88,7 +88,7 @@ public interface Block extends Keyed, TagReadable, BlockConstants { interface Comparator extends BiPredicate { Comparator IDENTITY = (b1, b2) -> b1 == b2; - Comparator ID = (b1, b2) -> b1.getBlockId() == b2.getBlockId(); + Comparator ID = (b1, b2) -> b1.getId() == b2.getId(); Comparator STATE = (b1, b2) -> b1.getStateId() == b2.getStateId(); } diff --git a/src/main/java/net/minestom/server/instance/block/BlockImpl.java b/src/main/java/net/minestom/server/instance/block/BlockImpl.java index f462e487f..70005d8b7 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockImpl.java +++ b/src/main/java/net/minestom/server/instance/block/BlockImpl.java @@ -137,7 +137,7 @@ class BlockImpl implements Block { } @Override - public int getBlockId() { + public int getId() { return blockId; } diff --git a/src/main/java/net/minestom/server/instance/block/BlockManager.java b/src/main/java/net/minestom/server/instance/block/BlockManager.java index 66aa823b9..a726e0910 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockManager.java +++ b/src/main/java/net/minestom/server/instance/block/BlockManager.java @@ -17,7 +17,7 @@ public class BlockManager { * @throws IllegalArgumentException if blockPlacementRule block id is negative */ public synchronized void registerBlockPlacementRule(@NotNull BlockPlacementRule blockPlacementRule) { - final int id = blockPlacementRule.getBlock().getBlockId(); + final int id = blockPlacementRule.getBlock().getId(); Check.argCondition(id < 0, "Block ID must be >= 0, got: " + id); this.placementRules[id] = blockPlacementRule; @@ -31,6 +31,6 @@ public class BlockManager { */ @Nullable public BlockPlacementRule getBlockPlacementRule(@NotNull Block block) { - return this.placementRules[block.getBlockId()]; + return this.placementRules[block.getId()]; } } diff --git a/src/main/java/net/minestom/server/instance/block/BlockRegistry.java b/src/main/java/net/minestom/server/instance/block/BlockRegistry.java index bc8ce4226..c87e307e7 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockRegistry.java +++ b/src/main/java/net/minestom/server/instance/block/BlockRegistry.java @@ -39,6 +39,6 @@ class BlockRegistry { @NotNull IntRange range, @NotNull Block.Supplier blockSupplier) { namespaceMap.put(namespaceID, block); IntStream.range(range.getMinimum(), range.getMaximum() + 1).forEach(value -> stateSet.put((short) value, blockSupplier)); - blockSet.put(block.getBlockId(), block); + blockSet.put(block.getId(), block); } } diff --git a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java index 4145dba80..0e1fdcf09 100644 --- a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java +++ b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java @@ -90,7 +90,7 @@ public class BlockPlacementListener { //after rapid invalid block placements BlockChangePacket blockChangePacket = new BlockChangePacket(); blockChangePacket.blockPosition = blockPosition; - blockChangePacket.blockStateId = Block.AIR.getBlockId(); + blockChangePacket.blockStateId = Block.AIR.getId(); player.getPlayerConnection().sendPacket(blockChangePacket); } return; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java index f5a6ec8e9..55a5d7c1b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java @@ -40,7 +40,7 @@ public class TagsPacket implements ServerPacket { @Override public void write(@NotNull BinaryWriter writer) { - writeTags(writer, blockTags, name -> Block.fromNamespaceId(name).getBlockId()); + writeTags(writer, blockTags, name -> Block.fromNamespaceId(name).getId()); writeTags(writer, itemTags, name -> Registries.getMaterial(name).ordinal()); writeTags(writer, fluidTags, name -> Registries.getFluid(name).ordinal()); writeTags(writer, entityTags, name -> Registries.getEntityType(name).ordinal()); diff --git a/src/test/java/testextension/mixins/DynamicChunkMixin.java b/src/test/java/testextension/mixins/DynamicChunkMixin.java index fd0369c64..c2676c546 100644 --- a/src/test/java/testextension/mixins/DynamicChunkMixin.java +++ b/src/test/java/testextension/mixins/DynamicChunkMixin.java @@ -12,7 +12,7 @@ public class DynamicChunkMixin { @ModifyVariable(method = "UNSAFE_setBlock", at = @At("HEAD"), index = 4, require = 1, argsOnly = true, remap = false) public int oopsAllTnt(short blockStateId) { if(blockStateId != 0) - return Block.TNT.getBlockId(); + return Block.TNT.getId(); return 0; } }