Skip to content

Commit

Permalink
Bedrock 1.20.40
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Oct 26, 2023
1 parent 8e7f690 commit b2bff5c
Show file tree
Hide file tree
Showing 59 changed files with 1,027 additions and 53 deletions.
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/GameVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum GameVersion {
V1_20_0(589, "1.20.0", "1.20"),
V1_20_10(594, "1.20.10"),
V1_20_30(618, "1.20.30"),
V1_20_40(622, "1.20.40"),
;

private static GameVersion FEATURE_VERSION = ENABLE_BLOCK_STATE_PERSISTENCE ? GameVersion.V1_18_0 : GameVersion.V1_12_0;
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -4197,9 +4197,7 @@ public void close(TextContainer message, String reason) {
public void close(TextContainer message, String reason, boolean notify) {
if (this.connected && !this.closed) {
if (notify && !reason.isEmpty()) {
DisconnectPacket pk = new DisconnectPacket();
pk.message = reason;
this.dataPacket(pk);
sendDisconnectScreen(reason);
}

this.connected = false;
Expand Down Expand Up @@ -6267,4 +6265,19 @@ protected void setFreezeEffectStrength(float freezeEffectStrength) {

movementSpeedAttribute.replaceModifier(AttributeModifiers.freezeEffect(freezeEffectStrength));
}

public void sendDisconnectScreen(@Nullable String message) {
sendDisconnectScreen(DisconnectPacket.REASON_UNKNOWN, message);
}

public void sendDisconnectScreen(int reason, @Nullable String message) {
DisconnectPacket packet = new DisconnectPacket();
packet.reason = reason;
if (message != null) {
packet.message = message;
} else {
packet.hideDisconnectionScreen = true;
}
dataPacket(packet);
}
}
73 changes: 71 additions & 2 deletions src/main/java/cn/nukkit/block/BlockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface BlockID {
int GRASS = 2;
int DIRT = 3;
int COBBLESTONE = 4;
int OAK_PLANKS = 5; //TODO: 1.20.50: flattening
int PLANKS = 5;
int SAPLING = 6;
int BEDROCK = 7;
Expand Down Expand Up @@ -612,6 +613,8 @@ public interface BlockID {
int POINTED_DRIPSTONE = 563;
int COPPER_ORE = 566;
int LIGHTNING_ROD = 567;
int CRAFTER = 568;

int DRIPSTONE_BLOCK = 572;
int DIRT_WITH_ROOTS = 573;
int HANGING_ROOTS = 574;
Expand Down Expand Up @@ -877,7 +880,12 @@ public interface BlockID {
int DEAD_BUBBLE_CORAL = 842;
int DEAD_FIRE_CORAL = 843;
int DEAD_HORN_CORAL = 844;

int GRANITE = 845;
int POLISHED_GRANITE = 846;
int DIORITE = 847;
int POLISHED_DIORITE = 848;
int ANDESITE = 849;
int POLISHED_ANDESITE = 850;
int SNIFFER_EGG = 851;
int ORANGE_CARPET = 852;
int MAGENTA_CARPET = 853;
Expand Down Expand Up @@ -987,7 +995,68 @@ public interface BlockID {
int GREEN_TERRACOTTA = 991;
int RED_TERRACOTTA = 992;
int BLACK_TERRACOTTA = 993;
int SPRUCE_PLANKS = 994;
int BIRCH_PLANKS = 995;
int JUNGLE_PLANKS = 996;
int ACACIA_PLANKS = 997;
int DARK_OAK_PLANKS = 998;
int TUFF_SLAB = 999;
int TUFF_DOUBLE_SLAB = 1000;
int TUFF_STAIRS = 1001;
int TUFF_WALL = 1002;
int POLISHED_TUFF = 1003;
int POLISHED_TUFF_SLAB = 1004;
int POLISHED_TUFF_DOUBLE_SLAB = 1005;
int POLISHED_TUFF_STAIRS = 1006;
int POLISHED_TUFF_WALL = 1007;
int CHISELED_TUFF = 1008;
int TUFF_BRICKS = 1009;
int TUFF_BRICK_SLAB = 1010;
int TUFF_BRICK_DOUBLE_SLAB = 1011;
int TUFF_BRICK_STAIRS = 1012;
int TUFF_BRICK_WALL = 1013;
int CHISELED_TUFF_BRICKS = 1014;
int CHISELED_COPPER = 1015;
int EXPOSED_CHISELED_COPPER = 1016;
int WEATHERED_CHISELED_COPPER = 1017;
int OXIDIZED_CHISELED_COPPER = 1018;
int WAXED_CHISELED_COPPER = 1019;
int WAXED_EXPOSED_CHISELED_COPPER = 1020;
int WAXED_OXIDIZED_CHISELED_COPPER = 1021;
int WAXED_WEATHERED_CHISELED_COPPER = 1022;
int COPPER_GRATE = 1023;
int EXPOSED_COPPER_GRATE = 1024;
int WEATHERED_COPPER_GRATE = 1025;
int OXIDIZED_COPPER_GRATE = 1026;
int WAXED_COPPER_GRATE = 1027;
int WAXED_EXPOSED_COPPER_GRATE = 1028;
int WAXED_WEATHERED_COPPER_GRATE = 1029;
int WAXED_OXIDIZED_COPPER_GRATE = 1030;
int COPPER_BULB = 1031;
int EXPOSED_COPPER_BULB = 1032;
int WEATHERED_COPPER_BULB = 1033;
int OXIDIZED_COPPER_BULB = 1034;
int WAXED_COPPER_BULB = 1035;
int WAXED_EXPOSED_COPPER_BULB = 1036;
int WAXED_WEATHERED_COPPER_BULB = 1037;
int WAXED_OXIDIZED_COPPER_BULB = 1038;
int COPPER_DOOR = 1039;
int EXPOSED_COPPER_DOOR = 1040;
int WEATHERED_COPPER_DOOR = 1041;
int OXIDIZED_COPPER_DOOR = 1042;
int WAXED_COPPER_DOOR = 1043;
int WAXED_EXPOSED_COPPER_DOOR = 1044;
int WAXED_WEATHERED_COPPER_DOOR = 1045;
int WAXED_OXIDIZED_COPPER_DOOR = 1046;
int COPPER_TRAPDOOR = 1047;
int EXPOSED_COPPER_TRAPDOOR = 1048;
int WEATHERED_COPPER_TRAPDOOR = 1049;
int OXIDIZED_COPPER_TRAPDOOR = 1050;
int WAXED_COPPER_TRAPDOOR = 1051;
int WAXED_EXPOSED_COPPER_TRAPDOOR = 1052;
int WAXED_WEATHERED_COPPER_TRAPDOOR = 1053;
int WAXED_OXIDIZED_COPPER_TRAPDOOR = 1054;


int UNDEFINED = 994;
int UNDEFINED = 1055;
}
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/block/BlockIceFrosted.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void slightlyMelt(boolean propagate) {
if (!propagate) {
return;
}
for (BlockFace face : BlockFace.values()) {
for (BlockFace face : BlockFace.getValues()) {
Block block = getSide(face);
if (block instanceof BlockIceFrosted) {
((BlockIceFrosted) block).slightlyMelt(false);
Expand All @@ -127,7 +127,7 @@ private void slightlyMelt(boolean propagate) {

private int countNeighbors() {
int result = 0;
for (BlockFace face : BlockFace.values()) {
for (BlockFace face : BlockFace.getValues()) {
if (getSide(face).getId() == FROSTED_ICE && ++result >= 4) {
return result;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/cn/nukkit/block/BlockSnowLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ public boolean onActivate(Item item, BlockFace face, Player player) {
return false;
}

@Override
public boolean canPassThrough() {
if (V1_20_30.isAvailable()) {
return (this.getDamage() & HEIGHT_MASK) == 0;
}
return (this.getDamage() & HEIGHT_MASK) < 3;
}

@Override
public boolean breaksWhenMoved() {
return true;
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/cn/nukkit/entity/data/EntityFlagID.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,19 @@ public interface EntityFlagID {
* @since 1.20.10
*/
int DATA_FLAG_CRAWLING = 114;

int DATA_FLAG_UNDEFINED = 115;
/**
* @since 1.20.40
*/
int DATA_FLAG_TIMER_FLAG_1 = 115;
/**
* @since 1.20.40
*/
int DATA_FLAG_TIMER_FLAG_2 = 116;
/**
* @since 1.20.40
*/
int DATA_FLAG_TIMER_FLAG_3 = 117;
int DATA_FLAG_UNDEFINED = 118;


long NUKKIT_FLAG_VARIANT_BLOCK = 1L << 1;
Expand Down
71 changes: 70 additions & 1 deletion src/main/java/cn/nukkit/item/ItemBlockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface ItemBlockID {
int GRASS = 2;
int DIRT = 3;
int COBBLESTONE = 4;
int OAK_PLANKS = 5;
int PLANKS = 5;
int SAPLING = 6;
int BEDROCK = 7;
Expand Down Expand Up @@ -614,6 +615,8 @@ public interface ItemBlockID {
int POINTED_DRIPSTONE = 0xff - BlockID.POINTED_DRIPSTONE;
int COPPER_ORE = 0xff - BlockID.COPPER_ORE;
int LIGHTNING_ROD = 0xff - BlockID.LIGHTNING_ROD;
int CRAFTER = 0xff - BlockID.CRAFTER;

int DRIPSTONE_BLOCK = 0xff - BlockID.DRIPSTONE_BLOCK;
int DIRT_WITH_ROOTS = 0xff - BlockID.DIRT_WITH_ROOTS;
int HANGING_ROOTS = 0xff - BlockID.HANGING_ROOTS;
Expand Down Expand Up @@ -879,7 +882,12 @@ public interface ItemBlockID {
int DEAD_BUBBLE_CORAL = 0xff - BlockID.DEAD_BUBBLE_CORAL;
int DEAD_FIRE_CORAL = 0xff - BlockID.DEAD_FIRE_CORAL;
int DEAD_HORN_CORAL = 0xff - BlockID.DEAD_HORN_CORAL;

int GRANITE = 0xff - BlockID.GRANITE;
int POLISHED_GRANITE = 0xff - BlockID.POLISHED_GRANITE;
int DIORITE = 0xff - BlockID.DIORITE;
int POLISHED_DIORITE = 0xff - BlockID.POLISHED_DIORITE;
int ANDESITE = 0xff - BlockID.ANDESITE;
int POLISHED_ANDESITE = 0xff - BlockID.POLISHED_ANDESITE;
int SNIFFER_EGG = 0xff - BlockID.SNIFFER_EGG;
int ORANGE_CARPET = 0xff - BlockID.ORANGE_CARPET;
int MAGENTA_CARPET = 0xff - BlockID.MAGENTA_CARPET;
Expand Down Expand Up @@ -989,6 +997,67 @@ public interface ItemBlockID {
int GREEN_TERRACOTTA = 0xff - BlockID.GREEN_TERRACOTTA;
int RED_TERRACOTTA = 0xff - BlockID.RED_TERRACOTTA;
int BLACK_TERRACOTTA = 0xff - BlockID.BLACK_TERRACOTTA;
int SPRUCE_PLANKS = 0xff - BlockID.SPRUCE_PLANKS;
int BIRCH_PLANKS = 0xff - BlockID.BIRCH_PLANKS;
int JUNGLE_PLANKS = 0xff - BlockID.JUNGLE_PLANKS;
int ACACIA_PLANKS = 0xff - BlockID.ACACIA_PLANKS;
int DARK_OAK_PLANKS = 0xff - BlockID.DARK_OAK_PLANKS;
int TUFF_SLAB = 0xff - BlockID.TUFF_SLAB;
int TUFF_DOUBLE_SLAB = 0xff - BlockID.TUFF_DOUBLE_SLAB;
int TUFF_STAIRS = 0xff - BlockID.TUFF_STAIRS;
int TUFF_WALL = 0xff - BlockID.TUFF_WALL;
int POLISHED_TUFF = 0xff - BlockID.POLISHED_TUFF;
int POLISHED_TUFF_SLAB = 0xff - BlockID.POLISHED_TUFF_SLAB;
int POLISHED_TUFF_DOUBLE_SLAB = 0xff - BlockID.POLISHED_TUFF_DOUBLE_SLAB;
int POLISHED_TUFF_STAIRS = 0xff - BlockID.POLISHED_TUFF_STAIRS;
int POLISHED_TUFF_WALL = 0xff - BlockID.POLISHED_TUFF_WALL;
int CHISELED_TUFF = 0xff - BlockID.CHISELED_TUFF;
int TUFF_BRICKS = 0xff - BlockID.TUFF_BRICKS;
int TUFF_BRICK_SLAB = 0xff - BlockID.TUFF_BRICK_SLAB;
int TUFF_BRICK_DOUBLE_SLAB = 0xff - BlockID.TUFF_BRICK_DOUBLE_SLAB;
int TUFF_BRICK_STAIRS = 0xff - BlockID.TUFF_BRICK_STAIRS;
int TUFF_BRICK_WALL = 0xff - BlockID.TUFF_BRICK_WALL;
int CHISELED_TUFF_BRICKS = 0xff - BlockID.CHISELED_TUFF_BRICKS;
int CHISELED_COPPER = 0xff - BlockID.CHISELED_COPPER;
int EXPOSED_CHISELED_COPPER = 0xff - BlockID.EXPOSED_CHISELED_COPPER;
int WEATHERED_CHISELED_COPPER = 0xff - BlockID.WEATHERED_CHISELED_COPPER;
int OXIDIZED_CHISELED_COPPER = 0xff - BlockID.OXIDIZED_CHISELED_COPPER;
int WAXED_CHISELED_COPPER = 0xff - BlockID.WAXED_CHISELED_COPPER;
int WAXED_EXPOSED_CHISELED_COPPER = 0xff - BlockID.WAXED_EXPOSED_CHISELED_COPPER;
int WAXED_OXIDIZED_CHISELED_COPPER = 0xff - BlockID.WAXED_OXIDIZED_CHISELED_COPPER;
int WAXED_WEATHERED_CHISELED_COPPER = 0xff - BlockID.WAXED_WEATHERED_CHISELED_COPPER;
int COPPER_GRATE = 0xff - BlockID.COPPER_GRATE;
int EXPOSED_COPPER_GRATE = 0xff - BlockID.EXPOSED_COPPER_GRATE;
int WEATHERED_COPPER_GRATE = 0xff - BlockID.WEATHERED_COPPER_GRATE;
int OXIDIZED_COPPER_GRATE = 0xff - BlockID.OXIDIZED_COPPER_GRATE;
int WAXED_COPPER_GRATE = 0xff - BlockID.WAXED_COPPER_GRATE;
int WAXED_EXPOSED_COPPER_GRATE = 0xff - BlockID.WAXED_EXPOSED_COPPER_GRATE;
int WAXED_WEATHERED_COPPER_GRATE = 0xff - BlockID.WAXED_WEATHERED_COPPER_GRATE;
int WAXED_OXIDIZED_COPPER_GRATE = 0xff - BlockID.WAXED_OXIDIZED_COPPER_GRATE;
int COPPER_BULB = 0xff - BlockID.COPPER_BULB;
int EXPOSED_COPPER_BULB = 0xff - BlockID.EXPOSED_COPPER_BULB;
int WEATHERED_COPPER_BULB = 0xff - BlockID.WEATHERED_COPPER_BULB;
int OXIDIZED_COPPER_BULB = 0xff - BlockID.OXIDIZED_COPPER_BULB;
int WAXED_COPPER_BULB = 0xff - BlockID.WAXED_COPPER_BULB;
int WAXED_EXPOSED_COPPER_BULB = 0xff - BlockID.WAXED_EXPOSED_COPPER_BULB;
int WAXED_WEATHERED_COPPER_BULB = 0xff - BlockID.WAXED_WEATHERED_COPPER_BULB;
int WAXED_OXIDIZED_COPPER_BULB = 0xff - BlockID.WAXED_OXIDIZED_COPPER_BULB;
int COPPER_DOOR = 0xff - BlockID.COPPER_DOOR;
int EXPOSED_COPPER_DOOR = 0xff - BlockID.EXPOSED_COPPER_DOOR;
int WEATHERED_COPPER_DOOR = 0xff - BlockID.WEATHERED_COPPER_DOOR;
int OXIDIZED_COPPER_DOOR = 0xff - BlockID.OXIDIZED_COPPER_DOOR;
int WAXED_COPPER_DOOR = 0xff - BlockID.WAXED_COPPER_DOOR;
int WAXED_EXPOSED_COPPER_DOOR = 0xff - BlockID.WAXED_EXPOSED_COPPER_DOOR;
int WAXED_WEATHERED_COPPER_DOOR = 0xff - BlockID.WAXED_WEATHERED_COPPER_DOOR;
int WAXED_OXIDIZED_COPPER_DOOR = 0xff - BlockID.WAXED_OXIDIZED_COPPER_DOOR;
int COPPER_TRAPDOOR = 0xff - BlockID.COPPER_TRAPDOOR;
int EXPOSED_COPPER_TRAPDOOR = 0xff - BlockID.EXPOSED_COPPER_TRAPDOOR;
int WEATHERED_COPPER_TRAPDOOR = 0xff - BlockID.WEATHERED_COPPER_TRAPDOOR;
int OXIDIZED_COPPER_TRAPDOOR = 0xff - BlockID.OXIDIZED_COPPER_TRAPDOOR;
int WAXED_COPPER_TRAPDOOR = 0xff - BlockID.WAXED_COPPER_TRAPDOOR;
int WAXED_EXPOSED_COPPER_TRAPDOOR = 0xff - BlockID.WAXED_EXPOSED_COPPER_TRAPDOOR;
int WAXED_WEATHERED_COPPER_TRAPDOOR = 0xff - BlockID.WAXED_WEATHERED_COPPER_TRAPDOOR;
int WAXED_OXIDIZED_COPPER_TRAPDOOR = 0xff - BlockID.WAXED_OXIDIZED_COPPER_TRAPDOOR;


int UNDEFINED = 0xff - BlockID.UNDEFINED;
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/cn/nukkit/item/ItemBrush.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cn.nukkit.item;

public class ItemBrush extends ItemTool {
public ItemBrush() {
this(0, 1);
}

public ItemBrush(Integer meta) {
this(meta, 1);
}

public ItemBrush(Integer meta, int count) {
super(BRUSH, meta, count, "Brush");
}

@Override
public int getMaxDurability() {
return ItemTool.DURABILITY_BRUSH;
}

@Override
public boolean noDamageOnAttack() {
return true;
}

@Override
public boolean noDamageOnBreak() {
return true;
}
}
12 changes: 6 additions & 6 deletions src/main/java/cn/nukkit/item/ItemBucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,30 +311,30 @@ public boolean onActivate(Level level, Player player, Block block, Block target,

switch (meta) {
case COD_BUCKET:
Entity cod = new EntityCod(block.getChunk(), Entity.getDefaultNBT(block));
Entity cod = new EntityCod(block.getChunk(), Entity.getDefaultNBT(block.add(0.5, 0, 0.5)));
cod.spawnToAll();
break;
case SALMON_BUCKET:
Entity salmon = new EntitySalmon(block.getChunk(), Entity.getDefaultNBT(block));
Entity salmon = new EntitySalmon(block.getChunk(), Entity.getDefaultNBT(block.add(0.5, 0, 0.5)));
salmon.spawnToAll();
break;
case TROPICAL_FISH_BUCKET:
Entity tropicalFish = new EntityTropicalFish(block.getChunk(), Entity.getDefaultNBT(block));
Entity tropicalFish = new EntityTropicalFish(block.getChunk(), Entity.getDefaultNBT(block.add(0.5, 0, 0.5)));
tropicalFish.spawnToAll();
break;
case PUFFERFISH_BUCKET:
Entity pufferfish = new EntityPufferfish(block.getChunk(), Entity.getDefaultNBT(block));
Entity pufferfish = new EntityPufferfish(block.getChunk(), Entity.getDefaultNBT(block.add(0.5, 0, 0.5)));
pufferfish.spawnToAll();
break;
case AXOLOTL_BUCKET:
Entity axolotl = new EntityAxolotl(block.getChunk(), Entity.getDefaultNBT(block));
Entity axolotl = new EntityAxolotl(block.getChunk(), Entity.getDefaultNBT(block.add(0.5, 0, 0.5)));
axolotl.spawnToAll();
break;
case TADPOLE_BUCKET:
if (!V1_19_0.isAvailable()) {
break;
}
Entity tadpole = new EntityTadpole(block.getChunk(), Entity.getDefaultNBT(block));
Entity tadpole = new EntityTadpole(block.getChunk(), Entity.getDefaultNBT(block.add(0.5, 0, 0.5)));
tadpole.spawnToAll();
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cn/nukkit/item/ItemFirework.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ public enum ExplosionType {
CREEPER_SHAPED,
BURST;

private static final ExplosionType[] $VALUES0 = values();
private static final ExplosionType[] VALUES = values();

public static ExplosionType[] values0() {
return $VALUES0;
public static ExplosionType[] getValues() {
return VALUES;
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/cn/nukkit/item/ItemPotterySherdAngler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cn.nukkit.item;

public class ItemPotterySherdAngler extends Item {
public ItemPotterySherdAngler() {
this(0, 1);
}

public ItemPotterySherdAngler(Integer meta) {
this(meta, 1);
}

public ItemPotterySherdAngler(Integer meta, int count) {
super(ANGLER_POTTERY_SHERD, meta, count, "Angler Pottery Sherd");
}
}
Loading

0 comments on commit b2bff5c

Please sign in to comment.