mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Remove get
prefixes for protocol objects to be more record-friendly
This commit is contained in:
parent
123f0bec04
commit
106125319a
@ -607,7 +607,7 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
final Block block = chunk.getBlock(x, y, z);
|
final Block block = chunk.getBlock(x, y, z);
|
||||||
final BlockHandler handler = block.getHandler();
|
final BlockHandler handler = block.handler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
tmpPosition.setX(x);
|
tmpPosition.setX(x);
|
||||||
tmpPosition.setY(y);
|
tmpPosition.setY(y);
|
||||||
|
@ -49,8 +49,8 @@ public class EatBlockGoal extends GoalSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final BlockPosition blockPosition = entityCreature.getPosition().toBlockPosition();
|
final BlockPosition blockPosition = entityCreature.getPosition().toBlockPosition();
|
||||||
final short blockStateIdIn = instance.getBlock(blockPosition.clone().subtract(0, 1, 0)).getStateId();
|
final short blockStateIdIn = instance.getBlock(blockPosition.clone().subtract(0, 1, 0)).stateId();
|
||||||
final short blockStateIdBelow = instance.getBlock(blockPosition.clone().subtract(0, 2, 0)).getStateId();
|
final short blockStateIdBelow = instance.getBlock(blockPosition.clone().subtract(0, 2, 0)).stateId();
|
||||||
|
|
||||||
return eatInMap.containsKey(blockStateIdIn) || eatBelowMap.containsKey(blockStateIdBelow);
|
return eatInMap.containsKey(blockStateIdIn) || eatBelowMap.containsKey(blockStateIdBelow);
|
||||||
}
|
}
|
||||||
@ -73,8 +73,8 @@ public class EatBlockGoal extends GoalSelector {
|
|||||||
final BlockPosition currentPosition = entityCreature.getPosition().toBlockPosition().clone().subtract(0, 1, 0);
|
final BlockPosition currentPosition = entityCreature.getPosition().toBlockPosition().clone().subtract(0, 1, 0);
|
||||||
final BlockPosition belowPosition = currentPosition.clone().subtract(0, 1, 0);
|
final BlockPosition belowPosition = currentPosition.clone().subtract(0, 1, 0);
|
||||||
|
|
||||||
final short blockStateIdIn = instance.getBlock(currentPosition).getStateId();
|
final short blockStateIdIn = instance.getBlock(currentPosition).stateId();
|
||||||
final short blockStateIdBelow = instance.getBlock(belowPosition).getStateId();
|
final short blockStateIdBelow = instance.getBlock(belowPosition).stateId();
|
||||||
if (eatInMap.containsKey(blockStateIdIn)) {
|
if (eatInMap.containsKey(blockStateIdIn)) {
|
||||||
instance.setBlock(currentPosition, Block.fromStateId(eatInMap.get(blockStateIdIn)));
|
instance.setBlock(currentPosition, Block.fromStateId(eatInMap.get(blockStateIdIn)));
|
||||||
} else if (eatBelowMap.containsKey(blockStateIdBelow)) {
|
} else if (eatBelowMap.containsKey(blockStateIdBelow)) {
|
||||||
|
@ -44,7 +44,7 @@ public class FallingBlockMeta extends EntityMeta implements ObjectDataProvider {
|
|||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Override
|
@Override
|
||||||
public int getObjectData() {
|
public int getObjectData() {
|
||||||
int id = this.block.getId();
|
int id = this.block.id();
|
||||||
int metadata = 0; // TODO ?
|
int metadata = 0; // TODO ?
|
||||||
return id | (metadata << 12);
|
return id | (metadata << 12);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class PFBlockDescription implements IBlockDescription {
|
|||||||
* @return the {@link PFBlockDescription} linked to {@code blockStateId}
|
* @return the {@link PFBlockDescription} linked to {@code blockStateId}
|
||||||
*/
|
*/
|
||||||
public static PFBlockDescription getBlockDescription(Block block) {
|
public static PFBlockDescription getBlockDescription(Block block) {
|
||||||
final short blockStateId = block.getStateId();
|
final short blockStateId = block.stateId();
|
||||||
if (!BLOCK_DESCRIPTION_MAP.containsKey(blockStateId)) {
|
if (!BLOCK_DESCRIPTION_MAP.containsKey(blockStateId)) {
|
||||||
synchronized (BLOCK_DESCRIPTION_MAP) {
|
synchronized (BLOCK_DESCRIPTION_MAP) {
|
||||||
final PFBlockDescription blockDescription = new PFBlockDescription(block);
|
final PFBlockDescription blockDescription = new PFBlockDescription(block);
|
||||||
@ -41,26 +41,26 @@ public class PFBlockDescription implements IBlockDescription {
|
|||||||
// TODO: Use Hitbox
|
// TODO: Use Hitbox
|
||||||
// Return fences, fencegates and walls.
|
// Return fences, fencegates and walls.
|
||||||
// It just so happens that their namespace IDs contain "fence".
|
// It just so happens that their namespace IDs contain "fence".
|
||||||
if (block.getNamespaceId().asString().contains("fence")) {
|
if (block.namespace().asString().contains("fence")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Return all walls
|
// Return all walls
|
||||||
// It just so happens that their namespace IDs all end with "door".
|
// It just so happens that their namespace IDs all end with "door".
|
||||||
return block.getNamespaceId().asString().endsWith("wall");
|
return block.namespace().asString().endsWith("wall");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClimbable() {
|
public boolean isClimbable() {
|
||||||
// Return ladders and vines (including weeping and twisting vines)
|
// Return ladders and vines (including weeping and twisting vines)
|
||||||
// Note that no other Namespace IDs contain "vine" except vines.
|
// Note that no other Namespace IDs contain "vine" except vines.
|
||||||
return block.compare(Block.LADDER) || block.getNamespaceId().asString().contains("vine");
|
return block.compare(Block.LADDER) || block.namespace().asString().contains("vine");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDoor() {
|
public boolean isDoor() {
|
||||||
// Return all normal doors and trap doors.
|
// Return all normal doors and trap doors.
|
||||||
// It just so happens that their namespace IDs all end with "door".
|
// It just so happens that their namespace IDs all end with "door".
|
||||||
return block.getNamespaceId().asString().endsWith("door");
|
return block.namespace().asString().endsWith("door");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,29 +85,29 @@ public class PFBlockDescription implements IBlockDescription {
|
|||||||
if (isDoor()) {
|
if (isDoor()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (block.getName().startsWith("potted")) {
|
if (block.name().startsWith("potted")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Skulls & Heads
|
// Skulls & Heads
|
||||||
if (block.getName().contains("skull") || block.getName().contains("head")) {
|
if (block.name().contains("skull") || block.name().contains("head")) {
|
||||||
// NOTE: blocks.getName().contains("head") also matches Piston_Head
|
// NOTE: blocks.getName().contains("head") also matches Piston_Head
|
||||||
// I could not find out by documentation if piston_head is fully bounded, I would presume it is NOT.
|
// I could not find out by documentation if piston_head is fully bounded, I would presume it is NOT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Carpets
|
// Carpets
|
||||||
if (block.getName().endsWith("carpet")) {
|
if (block.name().endsWith("carpet")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Slabs
|
// Slabs
|
||||||
if (block.getName().contains("slab")) {
|
if (block.name().contains("slab")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Beds
|
// Beds
|
||||||
if (block.getName().endsWith("bed")) {
|
if (block.name().endsWith("bed")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Glass Panes
|
// Glass Panes
|
||||||
if (block.getName().endsWith("pane")) {
|
if (block.name().endsWith("pane")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class PFBlockObject implements IBlockObject {
|
|||||||
* @return the {@link PFBlockObject} linked to {@code blockStateId}
|
* @return the {@link PFBlockObject} linked to {@code blockStateId}
|
||||||
*/
|
*/
|
||||||
public static PFBlockObject getBlockObject(Block block) {
|
public static PFBlockObject getBlockObject(Block block) {
|
||||||
final short blockStateId = block.getStateId();
|
final short blockStateId = block.stateId();
|
||||||
if (!BLOCK_OBJECT_MAP.containsKey(blockStateId)) {
|
if (!BLOCK_OBJECT_MAP.containsKey(blockStateId)) {
|
||||||
synchronized (BLOCK_OBJECT_MAP) {
|
synchronized (BLOCK_OBJECT_MAP) {
|
||||||
final PFBlockObject blockObject = new PFBlockObject(block);
|
final PFBlockObject blockObject = new PFBlockObject(block);
|
||||||
@ -50,26 +50,26 @@ public class PFBlockObject implements IBlockObject {
|
|||||||
// TODO: Use Hitbox
|
// TODO: Use Hitbox
|
||||||
// Return fences, fencegates and walls.
|
// Return fences, fencegates and walls.
|
||||||
// It just so happens that their namespace IDs contain "fence".
|
// It just so happens that their namespace IDs contain "fence".
|
||||||
if (block.getNamespaceId().asString().contains("fence")) {
|
if (block.namespace().asString().contains("fence")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Return all walls
|
// Return all walls
|
||||||
// It just so happens that their namespace IDs all end with "door".
|
// It just so happens that their namespace IDs all end with "door".
|
||||||
return block.getNamespaceId().asString().endsWith("wall");
|
return block.namespace().asString().endsWith("wall");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClimbable() {
|
public boolean isClimbable() {
|
||||||
// Return ladders and vines (including weeping and twisting vines)
|
// Return ladders and vines (including weeping and twisting vines)
|
||||||
// Note that no other Namespace IDs contain "vine" except vines.
|
// Note that no other Namespace IDs contain "vine" except vines.
|
||||||
return block.compare(Block.LADDER) || block.getNamespaceId().asString().contains("vine");
|
return block.compare(Block.LADDER) || block.namespace().asString().contains("vine");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDoor() {
|
public boolean isDoor() {
|
||||||
// Return all normal doors and trap doors.
|
// Return all normal doors and trap doors.
|
||||||
// It just so happens that their namespace IDs all end with "door".
|
// It just so happens that their namespace IDs all end with "door".
|
||||||
return block.getNamespaceId().asString().endsWith("door");
|
return block.namespace().asString().endsWith("door");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,29 +94,29 @@ public class PFBlockObject implements IBlockObject {
|
|||||||
if (isDoor()) {
|
if (isDoor()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (block.getName().startsWith("potted")) {
|
if (block.name().startsWith("potted")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Skulls & Heads
|
// Skulls & Heads
|
||||||
if (block.getName().contains("skull") || block.getName().contains("head")) {
|
if (block.name().contains("skull") || block.name().contains("head")) {
|
||||||
// NOTE: blocks.getName().contains("head") also matches Piston_Head
|
// NOTE: blocks.getName().contains("head") also matches Piston_Head
|
||||||
// I could not find out by documentation if piston_head is fully bounded, I would presume it is NOT.
|
// I could not find out by documentation if piston_head is fully bounded, I would presume it is NOT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Carpets
|
// Carpets
|
||||||
if (block.getName().endsWith("carpet")) {
|
if (block.name().endsWith("carpet")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Slabs
|
// Slabs
|
||||||
if (block.getName().contains("slab")) {
|
if (block.name().contains("slab")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Beds
|
// Beds
|
||||||
if (block.getName().endsWith("bed")) {
|
if (block.name().endsWith("bed")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Glass Panes
|
// Glass Panes
|
||||||
if (block.getName().endsWith("pane")) {
|
if (block.name().endsWith("pane")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,18 +68,18 @@ public class DynamicChunk extends Chunk {
|
|||||||
columnarOcclusionFieldList.onBlockChanged(x, y, z, blockDescription, 0);
|
columnarOcclusionFieldList.onBlockChanged(x, y, z, blockDescription, 0);
|
||||||
}
|
}
|
||||||
Section section = retrieveSection(y);
|
Section section = retrieveSection(y);
|
||||||
section.setBlockAt(x, y, z, block.getStateId());
|
section.setBlockAt(x, y, z, block.stateId());
|
||||||
|
|
||||||
final int index = getBlockIndex(x, y, z);
|
final int index = getBlockIndex(x, y, z);
|
||||||
// Handler
|
// Handler
|
||||||
final BlockHandler handler = block.getHandler();
|
final BlockHandler handler = block.handler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
this.handlerMap.put(index, handler);
|
this.handlerMap.put(index, handler);
|
||||||
} else {
|
} else {
|
||||||
this.handlerMap.remove(index);
|
this.handlerMap.remove(index);
|
||||||
}
|
}
|
||||||
// Nbt
|
// Nbt
|
||||||
final NBTCompound nbt = block.getNbt();
|
final NBTCompound nbt = block.nbt();
|
||||||
if (nbt != null) {
|
if (nbt != null) {
|
||||||
this.nbtMap.put(index, nbt);
|
this.nbtMap.put(index, nbt);
|
||||||
} else {
|
} else {
|
||||||
|
@ -572,7 +572,7 @@ public abstract class Instance implements BlockGetter, BlockSetter, Tickable, Ev
|
|||||||
blockActionPacket.blockPosition = blockPosition;
|
blockActionPacket.blockPosition = blockPosition;
|
||||||
blockActionPacket.actionId = actionId;
|
blockActionPacket.actionId = actionId;
|
||||||
blockActionPacket.actionParam = actionParam;
|
blockActionPacket.actionParam = actionParam;
|
||||||
blockActionPacket.blockId = block.getId();
|
blockActionPacket.blockId = block.id();
|
||||||
|
|
||||||
final Chunk chunk = getChunkAt(blockPosition);
|
final Chunk chunk = getChunkAt(blockPosition);
|
||||||
Check.notNull(chunk, "The chunk at " + blockPosition + " is not loaded!");
|
Check.notNull(chunk, "The chunk at " + blockPosition + " is not loaded!");
|
||||||
|
@ -149,7 +149,7 @@ public class InstanceContainer extends Instance {
|
|||||||
setAlreadyChanged(blockPosition, block);
|
setAlreadyChanged(blockPosition, block);
|
||||||
|
|
||||||
final Block previousBlock = chunk.getBlock(blockPosition);
|
final Block previousBlock = chunk.getBlock(blockPosition);
|
||||||
final BlockHandler previousHandler = previousBlock.getHandler();
|
final BlockHandler previousHandler = previousBlock.handler();
|
||||||
|
|
||||||
// Change id based on neighbors
|
// Change id based on neighbors
|
||||||
block = executeBlockPlacementRule(block, blockPosition);
|
block = executeBlockPlacementRule(block, blockPosition);
|
||||||
@ -167,7 +167,7 @@ public class InstanceContainer extends Instance {
|
|||||||
// Previous destroy
|
// Previous destroy
|
||||||
previousHandler.onDestroy(BlockHandler.Destroy.from(previousBlock, this, blockPosition));
|
previousHandler.onDestroy(BlockHandler.Destroy.from(previousBlock, this, blockPosition));
|
||||||
}
|
}
|
||||||
final BlockHandler handler = block.getHandler();
|
final BlockHandler handler = block.handler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
// New placement
|
// New placement
|
||||||
handler.onPlace(BlockHandler.Placement.from(block, this, blockPosition));
|
handler.onPlace(BlockHandler.Placement.from(block, this, blockPosition));
|
||||||
@ -191,7 +191,7 @@ public class InstanceContainer extends Instance {
|
|||||||
final Block changedBlock = currentlyChangingBlocks.get(blockPosition);
|
final Block changedBlock = currentlyChangingBlocks.get(blockPosition);
|
||||||
if (changedBlock == null)
|
if (changedBlock == null)
|
||||||
return false;
|
return false;
|
||||||
return changedBlock.getId() == block.getId();
|
return changedBlock.id() == block.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -285,7 +285,7 @@ public class InstanceContainer extends Instance {
|
|||||||
EffectPacket effectPacket = new EffectPacket();
|
EffectPacket effectPacket = new EffectPacket();
|
||||||
effectPacket.effectId = 2001; // Block break + block break sound
|
effectPacket.effectId = 2001; // Block break + block break sound
|
||||||
effectPacket.position = blockPosition;
|
effectPacket.position = blockPosition;
|
||||||
effectPacket.data = resultBlock.getStateId();
|
effectPacket.data = resultBlock.stateId();
|
||||||
effectPacket.disableRelativeVolume = false;
|
effectPacket.disableRelativeVolume = false;
|
||||||
|
|
||||||
PacketUtils.sendGroupedPacket(chunk.getViewers(), effectPacket,
|
PacketUtils.sendGroupedPacket(chunk.getViewers(), effectPacket,
|
||||||
@ -639,7 +639,7 @@ public class InstanceContainer extends Instance {
|
|||||||
private void sendBlockChange(@NotNull Chunk chunk, @NotNull BlockPosition blockPosition, @NotNull Block block) {
|
private void sendBlockChange(@NotNull Chunk chunk, @NotNull BlockPosition blockPosition, @NotNull Block block) {
|
||||||
BlockChangePacket blockChangePacket = new BlockChangePacket();
|
BlockChangePacket blockChangePacket = new BlockChangePacket();
|
||||||
blockChangePacket.blockPosition = blockPosition;
|
blockChangePacket.blockPosition = blockPosition;
|
||||||
blockChangePacket.blockStateId = block.getStateId();
|
blockChangePacket.blockStateId = block.stateId();
|
||||||
chunk.sendPacketToViewers(blockChangePacket);
|
chunk.sendPacketToViewers(blockChangePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public interface Block extends ProtocolObject, TagReadable, BlockConstants {
|
|||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
default <T> @NotNull Block withTag(@NotNull Tag<T> tag, @Nullable T value) {
|
default <T> @NotNull Block withTag(@NotNull Tag<T> tag, @Nullable T value) {
|
||||||
var compound = Objects.requireNonNullElseGet(getNbt(), NBTCompound::new);
|
var compound = Objects.requireNonNullElseGet(nbt(), NBTCompound::new);
|
||||||
tag.write(compound, value);
|
tag.write(compound, value);
|
||||||
return withNbt(compound);
|
return withNbt(compound);
|
||||||
}
|
}
|
||||||
@ -45,38 +45,38 @@ public interface Block extends ProtocolObject, TagReadable, BlockConstants {
|
|||||||
@NotNull Block withHandler(@Nullable BlockHandler handler);
|
@NotNull Block withHandler(@Nullable BlockHandler handler);
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
@Nullable NBTCompound getNbt();
|
@Nullable NBTCompound nbt();
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
@Nullable BlockHandler getHandler();
|
@Nullable BlockHandler handler();
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
@NotNull Map<String, String> getProperties();
|
@NotNull Map<String, String> properties();
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
default @NotNull String getProperty(@NotNull String property) {
|
default @NotNull String property(@NotNull String property) {
|
||||||
return getProperties().get(property);
|
return properties().get(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
default <T> @NotNull String getProperty(@NotNull BlockProperty<T> property) {
|
default <T> @NotNull String property(@NotNull BlockProperty<T> property) {
|
||||||
return getProperty(property.getName());
|
return property(property.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
@NotNull Registry.BlockEntry registry();
|
@NotNull Registry.BlockEntry registry();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default @NotNull NamespaceID getNamespaceId() {
|
default @NotNull NamespaceID namespace() {
|
||||||
return NamespaceID.from(registry().namespace());
|
return NamespaceID.from(registry().namespace());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default int getId() {
|
default int id() {
|
||||||
return registry().id();
|
return registry().id();
|
||||||
}
|
}
|
||||||
|
|
||||||
default short getStateId() {
|
default short stateId() {
|
||||||
return (short) registry().stateId();
|
return (short) registry().stateId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,8 +120,8 @@ public interface Block extends ProtocolObject, TagReadable, BlockConstants {
|
|||||||
interface Comparator extends BiPredicate<Block, Block> {
|
interface Comparator extends BiPredicate<Block, Block> {
|
||||||
Comparator IDENTITY = (b1, b2) -> b1 == b2;
|
Comparator IDENTITY = (b1, b2) -> b1 == b2;
|
||||||
|
|
||||||
Comparator ID = (b1, b2) -> b1.getId() == b2.getId();
|
Comparator ID = (b1, b2) -> b1.id() == b2.id();
|
||||||
|
|
||||||
Comparator STATE = (b1, b2) -> b1.getStateId() == b2.getStateId();
|
Comparator STATE = (b1, b2) -> b1.stateId() == b2.stateId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class BlockManager {
|
|||||||
* @throws IllegalArgumentException if <code>blockPlacementRule</code> block id is negative
|
* @throws IllegalArgumentException if <code>blockPlacementRule</code> block id is negative
|
||||||
*/
|
*/
|
||||||
public synchronized void registerBlockPlacementRule(@NotNull BlockPlacementRule blockPlacementRule) {
|
public synchronized void registerBlockPlacementRule(@NotNull BlockPlacementRule blockPlacementRule) {
|
||||||
final int id = blockPlacementRule.getBlock().getId();
|
final int id = blockPlacementRule.getBlock().id();
|
||||||
Check.argCondition(id < 0, "Block ID must be >= 0, got: " + id);
|
Check.argCondition(id < 0, "Block ID must be >= 0, got: " + id);
|
||||||
|
|
||||||
this.placementRules[id] = blockPlacementRule;
|
this.placementRules[id] = blockPlacementRule;
|
||||||
@ -31,6 +31,6 @@ public class BlockManager {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockPlacementRule getBlockPlacementRule(@NotNull Block block) {
|
public BlockPlacementRule getBlockPlacementRule(@NotNull Block block) {
|
||||||
return this.placementRules[block.getId()];
|
return this.placementRules[block.id()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class BlockRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static @Nullable Block getProperties(Block block, Map<String, String> properties) {
|
static @Nullable Block getProperties(Block block, Map<String, String> properties) {
|
||||||
return getProperties(block.getNamespaceId().asString(), properties);
|
return getProperties(block.namespace().asString(), properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -52,17 +52,17 @@ class BlockTest implements Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable NBTCompound getNbt() {
|
public @Nullable NBTCompound nbt() {
|
||||||
return compound != null ? compound.deepClone() : null;
|
return compound != null ? compound.deepClone() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable BlockHandler getHandler() {
|
public @Nullable BlockHandler handler() {
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Map<String, String> getProperties() {
|
public @NotNull Map<String, String> properties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package net.minestom.server.item;
|
|||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.minestom.server.adventure.AdventureSerializer;
|
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.item.attribute.ItemAttribute;
|
import net.minestom.server.item.attribute.ItemAttribute;
|
||||||
import net.minestom.server.tag.Tag;
|
import net.minestom.server.tag.Tag;
|
||||||
@ -156,7 +155,7 @@ public abstract class ItemMetaBuilder implements TagWritable {
|
|||||||
this.canPlaceOn = blocks;
|
this.canPlaceOn = blocks;
|
||||||
handleCollection(canPlaceOn, "CanPlaceOn", nbt, () -> {
|
handleCollection(canPlaceOn, "CanPlaceOn", nbt, () -> {
|
||||||
NBTList<NBTString> list = new NBTList<>(NBTTypes.TAG_String);
|
NBTList<NBTString> list = new NBTList<>(NBTTypes.TAG_String);
|
||||||
canPlaceOn.forEach(block -> list.add(new NBTString(block.getName())));
|
canPlaceOn.forEach(block -> list.add(new NBTString(block.name())));
|
||||||
nbt.set("CanPlaceOn", list);
|
nbt.set("CanPlaceOn", list);
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
@ -173,7 +172,7 @@ public abstract class ItemMetaBuilder implements TagWritable {
|
|||||||
this.canDestroy = blocks;
|
this.canDestroy = blocks;
|
||||||
handleCollection(canDestroy, "CanDestroy", nbt, () -> {
|
handleCollection(canDestroy, "CanDestroy", nbt, () -> {
|
||||||
NBTList<NBTString> list = new NBTList<>(NBTTypes.TAG_String);
|
NBTList<NBTString> list = new NBTList<>(NBTTypes.TAG_String);
|
||||||
canDestroy.forEach(block -> list.add(new NBTString(block.getName())));
|
canDestroy.forEach(block -> list.add(new NBTString(block.name())));
|
||||||
nbt.set("CanDestroy", list);
|
nbt.set("CanDestroy", list);
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
|
@ -91,7 +91,7 @@ public class BlockPlacementListener {
|
|||||||
//after rapid invalid block placements
|
//after rapid invalid block placements
|
||||||
BlockChangePacket blockChangePacket = new BlockChangePacket();
|
BlockChangePacket blockChangePacket = new BlockChangePacket();
|
||||||
blockChangePacket.blockPosition = blockPosition;
|
blockChangePacket.blockPosition = blockPosition;
|
||||||
blockChangePacket.blockStateId = Block.AIR.getStateId();
|
blockChangePacket.blockStateId = Block.AIR.stateId();
|
||||||
player.getPlayerConnection().sendPacket(blockChangePacket);
|
player.getPlayerConnection().sendPacket(blockChangePacket);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -181,7 +181,7 @@ public class PlayerDiggingListener {
|
|||||||
@NotNull ClientPlayerDiggingPacket.Status status, boolean success) {
|
@NotNull ClientPlayerDiggingPacket.Status status, boolean success) {
|
||||||
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();
|
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();
|
||||||
acknowledgePlayerDiggingPacket.blockPosition = blockPosition;
|
acknowledgePlayerDiggingPacket.blockPosition = blockPosition;
|
||||||
acknowledgePlayerDiggingPacket.blockStateId = block.getStateId();
|
acknowledgePlayerDiggingPacket.blockStateId = block.stateId();
|
||||||
acknowledgePlayerDiggingPacket.status = status;
|
acknowledgePlayerDiggingPacket.status = status;
|
||||||
acknowledgePlayerDiggingPacket.successful = success;
|
acknowledgePlayerDiggingPacket.successful = success;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class TagsPacket implements ServerPacket {
|
|||||||
writer.writeVarInt(-1);
|
writer.writeVarInt(-1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
writer.writeVarInt(b.getId());
|
writer.writeVarInt(b.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -7,16 +7,16 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public interface ProtocolObject extends Keyed {
|
public interface ProtocolObject extends Keyed {
|
||||||
|
|
||||||
@NotNull NamespaceID getNamespaceId();
|
@NotNull NamespaceID namespace();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default @NotNull Key key() {
|
default @NotNull Key key() {
|
||||||
return getNamespaceId();
|
return namespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
default @NotNull String getName() {
|
default @NotNull String name() {
|
||||||
return getNamespaceId().asString();
|
return namespace().asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getId();
|
int id();
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ public class BiomeParticles {
|
|||||||
public NBTCompound toNbt() {
|
public NBTCompound toNbt() {
|
||||||
NBTCompound nbtCompound = new NBTCompound();
|
NBTCompound nbtCompound = new NBTCompound();
|
||||||
nbtCompound.setString("type", type);
|
nbtCompound.setString("type", type);
|
||||||
nbtCompound.setString("Name", block.getName());
|
nbtCompound.setString("Name", block.name());
|
||||||
Map<String, String> propertiesMap = block.getProperties();
|
Map<String, String> propertiesMap = block.properties();
|
||||||
if (propertiesMap.size() != 0) {
|
if (propertiesMap.size() != 0) {
|
||||||
NBTCompound properties = new NBTCompound();
|
NBTCompound properties = new NBTCompound();
|
||||||
propertiesMap.forEach(properties::setString);
|
propertiesMap.forEach(properties::setString);
|
||||||
|
@ -9,10 +9,10 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|||||||
@Mixin(DynamicChunk.class)
|
@Mixin(DynamicChunk.class)
|
||||||
public class DynamicChunkMixin {
|
public class DynamicChunkMixin {
|
||||||
|
|
||||||
@ModifyVariable(method = "UNSAFE_setBlock", at = @At("HEAD"), index = 4, require = 1, argsOnly = true, remap = false)
|
@ModifyVariable(method = "setBlock", at = @At("HEAD"), index = 4, require = 1, argsOnly = true, remap = false)
|
||||||
public int oopsAllTnt(short blockStateId) {
|
public int oopsAllTnt(short blockStateId) {
|
||||||
if(blockStateId != 0)
|
if(blockStateId != 0)
|
||||||
return Block.TNT.getId();
|
return Block.TNT.id();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user