Skip to content

Commit

Permalink
Merge (1.21.40)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 committed Oct 21, 2024
1 parent 4ba1a10 commit 7376835
Show file tree
Hide file tree
Showing 73 changed files with 313 additions and 408 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ repositories {
dependencies {
api(libs.network)
api(libs.epoll)
api(libs.natives)
api(libs.fastutil)
api(libs.bundles.fastutilmaps)
api(libs.guava)
Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ fastutilmaps = "8.5.13-SNAPSHOT"
[libraries]
network = { group = "org.cloudburstmc.netty", name = "netty-transport-raknet", version = "1.0.0.CR3-SNAPSHOT" }
epoll = { group = "io.netty", name = "netty-transport-native-epoll", version = "4.1.101.Final" }
natives = { group = "com.nukkitx", name = "natives", version = "1.0.3" }
fastutil = { group = "com.nukkitx", name = "fastutil-lite", version = "8.1.1" }
fastutil-long-long-maps = { group = "org.cloudburstmc.fastutil.maps", name = "long-long-maps", version.ref = "fastutilmaps" }
fastutil-int-short-maps = { group = "org.cloudburstmc.fastutil.maps", name = "int-short-maps", version.ref = "fastutilmaps" }
Expand All @@ -16,7 +15,7 @@ fastutil-object-object-maps = { group = "org.cloudburstmc.fastutil.maps", name =
guava = { group = "com.google.guava", name = "guava", version = "33.2.1-jre" }
gson = { group = "com.google.code.gson", name = "gson", version = "2.10.1" }
snakeyaml = { group = "org.yaml", name = "snakeyaml", version = "1.33" }
leveldb = { group = "org.iq80.leveldb", name = "leveldb", version = "0.11-SNAPSHOT" }
leveldb = { group = "org.iq80.leveldb", name = "leveldb", version = "0.11.1-SNAPSHOT" }
leveldbjni = { group = "net.daporkchop", name = "leveldb-mcpe-jni", version = "0.0.10-SNAPSHOT" }
snappy = { group = "org.xerial.snappy", name = "snappy-java", version = "1.1.10.7" }
jwt = { group = "com.nimbusds", name = "nimbus-jose-jwt", version = "9.23" }
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3290,6 +3290,16 @@ public void onCompletion(Server server) {
}
}

if (authPacket.getInputData().contains(AuthInputAction.STOP_SPIN_ATTACK)) {
PlayerToggleSpinAttackEvent playerToggleSpinAttackEvent = new PlayerToggleSpinAttackEvent(this, false);
this.server.getPluginManager().callEvent(playerToggleSpinAttackEvent);
if (playerToggleSpinAttackEvent.isCancelled()) {
this.needSendData = true;
} else {
this.setSpinAttack(false);
}
}

if (authPacket.getInputData().contains(AuthInputAction.START_FLYING)) {
if (!server.getAllowFlight() && !this.adventureSettings.get(Type.ALLOW_FLIGHT)) {
this.kick(PlayerKickEvent.Reason.FLYING_DISABLED, MSG_FLYING_NOT_ENABLED, true);
Expand Down Expand Up @@ -3423,15 +3433,6 @@ public void onCompletion(Server server) {
break stopItemHold;
case PlayerActionPacket.ACTION_STOP_SWIMMING:
return;
case PlayerActionPacket.ACTION_STOP_SPIN_ATTACK:
PlayerToggleSpinAttackEvent playerToggleSpinAttackEvent = new PlayerToggleSpinAttackEvent(this, false);
this.server.getPluginManager().callEvent(playerToggleSpinAttackEvent);
if (playerToggleSpinAttackEvent.isCancelled()) {
this.needSendData = true;
} else {
this.setSpinAttack(false);
}
return;
}

this.setUsingItem(false);
Expand Down Expand Up @@ -4832,7 +4833,7 @@ private void onBlockBreakStart(BlockVector3 blockPos, BlockFace face) {
break;
}

int bid = this.level.getBlockIdAt(blockPos.x + face.getXOffset(), blockPos.y + face.getYOffset(), blockPos.z + face.getZOffset());
int bid = this.level.getBlockIdAt(this.chunk, blockPos.x + face.getXOffset(), blockPos.y + face.getYOffset(), blockPos.z + face.getZOffset());
if (bid == Block.FIRE || bid == Block.SOUL_FIRE) {
Vector3 block = this.temporalVector.setComponents(blockPos.x + face.getXOffset(), blockPos.y + face.getYOffset(), blockPos.z + face.getZOffset());
this.level.setBlock(block, Block.get(BlockID.AIR), true);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/block/BlockComposter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class BlockComposter extends BlockTransparentMeta implements ItemID {
registerItems(100, CAKE, PUMPKIN_PIE);
registerBlocks(30, BLOCK_KELP, LEAVES, LEAVES2, SAPLINGS, SEAGRASS, SWEET_BERRY_BUSH);
registerBlocks(50, GRASS, CACTUS, DRIED_KELP_BLOCK, VINES, NETHER_SPROUTS_BLOCK);
registerBlocks(65, DANDELION, RED_FLOWER, DOUBLE_PLANT, WITHER_ROSE, LILY_PAD, MELON_BLOCK, PUMPKIN, CARVED_PUMPKIN, SEA_PICKLE, BROWN_MUSHROOM, RED_MUSHROOM, SHROOMLIGHT, CRIMSON_FUNGUS, WARPED_FUNGUS);
registerBlocks(85, HAY_BALE, BROWN_MUSHROOM_BLOCK, RED_MUSHROOM_BLOCK, MUSHROOM_STEW, BLOCK_NETHER_WART_BLOCK, WARPED_WART_BLOCK);
registerBlocks(65, DANDELION, RED_FLOWER, DOUBLE_PLANT, WITHER_ROSE, LILY_PAD, MELON_BLOCK, PUMPKIN, CARVED_PUMPKIN, SEA_PICKLE, BROWN_MUSHROOM, RED_MUSHROOM, SHROOMLIGHT, CRIMSON_FUNGUS, WARPED_FUNGUS, MUSHROOM_STEW);
registerBlocks(85, HAY_BALE, BROWN_MUSHROOM_BLOCK, RED_MUSHROOM_BLOCK, BLOCK_NETHER_WART_BLOCK, WARPED_WART_BLOCK);
registerBlocks(100, CAKE_BLOCK);
registerBlock(50, TALL_GRASS, 0);
registerBlock(50, TALL_GRASS, 1);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cn/nukkit/block/BlockCoral.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public boolean place(Item item, Block block, Block target, BlockFace face, doubl
if (this.down().isTransparent()) {
return false;
}
if (!(block instanceof BlockWater || block.level.isBlockWaterloggedAt(block.getChunk(), (int) block.x, (int) block.y, (int) block.z))) {
this.setDamage(8 + this.getDamage()); // Dead
}
if (this.getLevel().setBlock(this, this, true, true)) {
if (block instanceof BlockWater) {
this.getLevel().setBlock((int) this.x, (int) this.y, (int) this.z, Block.LAYER_WATERLOGGED, Block.get(Block.STILL_WATER), true, true);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/block/BlockCoralBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public int onUpdate(int type) {
}

BlockFadeEvent event = new BlockFadeEvent(this, Block.get(CORAL_BLOCK, this.getDamage() | 0x8));
level.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setDead(true);
this.getLevel().setBlock(this, event.getNewState(), true, true);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/block/BlockCoralFan.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public int onUpdate(int type) {

if (!this.isDead() && !(this.getLevelBlock(BlockLayer.WATERLOGGED) instanceof BlockWater) && !(this.getLevelBlock(BlockLayer.WATERLOGGED) instanceof BlockIceFrosted)) {
BlockFadeEvent event = new BlockFadeEvent(this, Block.get(CORAL_FAN_DEAD, this.getDamage()));
level.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.getLevel().setBlock(this, event.getNewState(), true, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public interface BlockID {
int MANGROVE_PRESSURE_PLATE = 745;
int MANGROVE_FENCE = 746;
int MANGROVE_FENCE_GATE = 747;
//
int MANGROVE_DOOR = 748;
int MANGROVE_STANDING_SIGN = 749;
int MANGROVE_WALL_SIGN = 750;
int MANGROVE_TRAPDOOR = 751;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockMushroom.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public int onUpdate(int type) {

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
if (block instanceof BlockWater) {
if (block instanceof BlockWater || block.level.isBlockWaterloggedAt(block.getChunk(), (int) block.x, (int) block.y, (int) block.z)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockRedstoneWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public int getId() {

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
if (block instanceof BlockWater) {
if (block instanceof BlockWater || block.level.isBlockWaterloggedAt(block.getChunk(), (int) block.x, (int) block.y, (int) block.z)) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/block/BlockSeaPickle.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public int onUpdate(int type) {
}
} else if (!this.isDead()) {
BlockFadeEvent event = new BlockFadeEvent(this, Block.get(SEA_PICKLE, this.getDamage() ^ 0x4));
level.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.getLevel().setBlock(this, event.getNewState(), true, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockTorch.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public int onUpdate(int type) {

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
if (block instanceof BlockWater) {
if (block instanceof BlockWater || block.level.isBlockWaterloggedAt(block.getChunk(), (int) block.x, (int) block.y, (int) block.z)) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/block/BlockTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ public class BlockTypes {
public static final BlockType MANGROVE_PRESSURE_PLATE = register("minecraft:mangrove_pressure_plate", BlockID.MANGROVE_PRESSURE_PLATE);
public static final BlockType MANGROVE_FENCE = register("minecraft:mangrove_fence", BlockID.MANGROVE_FENCE);
public static final BlockType MANGROVE_FENCE_GATE = register("minecraft:mangrove_fence_gate", BlockID.MANGROVE_FENCE_GATE);
public static final BlockType MANGROVE_DOOR = register("minecraft:mangrove_door", BlockID.MANGROVE_DOOR);
public static final BlockType MANGROVE_STANDING_SIGN = register("minecraft:mangrove_standing_sign", BlockID.MANGROVE_STANDING_SIGN);
public static final BlockType MANGROVE_WALL_SIGN = register("minecraft:mangrove_wall_sign", BlockID.MANGROVE_WALL_SIGN);
public static final BlockType MANGROVE_TRAPDOOR = register("minecraft:mangrove_trapdoor", BlockID.MANGROVE_TRAPDOOR);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/block/BlockVinesNether.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ && findVineAge(true).orElse(maxVineAge) < maxVineAge) {
*/
public boolean grow() {
Block pos = getSide(getGrowthDirection());
if (pos.getId() != AIR || pos.y < 0 || 255 < pos.y) {
if (pos.getId() != AIR || pos.y < level.getMinBlockY() || pos.y > level.getMaxBlockY()) {
return false;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public int growMultiple() {
int grew = 0;
for (int distance = 1; distance <= blocksToGrow; distance++) {
Block pos = getSide(growthDirection, distance);
if (pos.getId() != AIR || pos.y < 0 || 255 < pos.y) {
if (pos.getId() != AIR || pos.y < level.getMinBlockY() || pos.y > level.getMaxBlockY()) {
break;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/cn/nukkit/blockentity/BlockEntityBell.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public void saveNBT() {

@Override
public boolean onUpdate() {
if (this.closed) {
return false;
}

if (ringing) {
if (ticks == 0) {
this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BLOCK_BELL_HIT);
Expand All @@ -79,10 +83,6 @@ public boolean onUpdate() {
}

private void spawnToAllWithExceptions() {
if (this.closed) {
return;
}

for (Player player : this.getLevel().getChunkPlayers(this.chunk.getX(), this.chunk.getZ()).values()) {
if (player.spawned && !spawnExceptions.contains(player.getId())) {
this.spawnTo(player);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/cn/nukkit/command/SimpleCommandMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void setDefaultCommands() {
this.register("nukkit", new KickCommand("kick"));
this.register("nukkit", new OpCommand("op"));
this.register("nukkit", new DeopCommand("deop"));
this.register("nukkit", new SaveCommand("save-all"));
this.register("nukkit", new SaveCommand("save"));
this.register("nukkit", new GiveCommand("give"));
this.register("nukkit", new ClearCommand("clear"));
this.register("nukkit", new EffectCommand("effect"));
Expand All @@ -64,8 +64,6 @@ private void setDefaultCommands() {
this.register("nukkit", new DefaultGamemodeCommand("defaultgamemode"));
this.register("nukkit", new SayCommand("say"));
this.register("nukkit", new MeCommand("me"));
this.register("nukkit", new SaveOnCommand("save-on"));
this.register("nukkit", new SaveOffCommand("save-off"));
this.register("nukkit", new DifficultyCommand("difficulty"));
this.register("nukkit", new ParticleCommand("particle"));
this.register("nukkit", new SpawnpointCommand("spawnpoint"));
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/cn/nukkit/command/defaults/SaveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SaveCommand extends VanillaCommand {
public SaveCommand(String name) {
super(name, "%nukkit.command.save.description", "%commands.save.usage");
this.setPermission("nukkit.command.save.perform");
this.setAliases(new String[]{"save-all"});
this.commandParameters.clear();
}

Expand All @@ -24,6 +25,30 @@ public boolean execute(CommandSender sender, String commandLabel, String[] args)
return true;
}

if (args.length > 0) {
switch (args[0].toLowerCase()) {
case "on":
sender.getServer().setAutoSave(true);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.enabled"));
return true;
case "off":
sender.getServer().setAutoSave(false);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.disabled"));
return true;
case "hold":
sender.getServer().holdWorldSave = true;
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.hold-on"));
return true;
case "resume":
sender.getServer().holdWorldSave = false;
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.hold-off"));
return true;
default:
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
}

Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.start"));

for (Player player : sender.getServer().getOnlinePlayers().values()) {
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/cn/nukkit/command/defaults/SaveOffCommand.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/cn/nukkit/command/defaults/SaveOnCommand.java

This file was deleted.

17 changes: 10 additions & 7 deletions src/main/java/cn/nukkit/entity/data/EntityMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
*/
public class EntityMetadata {

private Int2ObjectMap<EntityData> map = new Int2ObjectOpenHashMap<>();
private final Int2ObjectMap<EntityData> map;

public EntityMetadata() {
this.map = new Int2ObjectOpenHashMap<>();
}

private EntityMetadata(Int2ObjectMap<EntityData> map) {
this.map = map;
}

public EntityData get(int id) {
return this.getOrDefault(id, null);
Expand Down Expand Up @@ -123,12 +131,7 @@ public Map<Integer, EntityData> getMap() {
return new TreeMap<>(this.map); // Ordered
}

private EntityMetadata replace(Int2ObjectMap<EntityData> map) {
this.map = map;
return this;
}

public EntityMetadata clone() {
return new EntityMetadata().replace(new Int2ObjectOpenHashMap<>(this.map));
return new EntityMetadata(new Int2ObjectOpenHashMap<>(this.map));
}
}
Loading

0 comments on commit 7376835

Please sign in to comment.