Skip to content

Commit

Permalink
feat: 1.21.40 support almost finished
Browse files Browse the repository at this point in the history
  • Loading branch information
C0R0X committed Oct 11, 2024
1 parent 13156e4 commit c4530eb
Show file tree
Hide file tree
Showing 84 changed files with 34,709 additions and 14,225 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<p align="center">
<img alt="Version" src="https://img.shields.io/badge/version-2.0.0-blue.svg?cacheSeconds=2592000" />
<a href="https://feedback.minecraft.net/hc/en-us/articles/26247797084173--Minecraft-1-21-1-Bedrock">
<img alt="Minecraft" src="https://img.shields.io/badge/minecraft-v1.21.30%20(Bedrock)-56383E" />
<img alt="Minecraft" src="https://img.shields.io/badge/minecraft-v1.21.40%20(Bedrock)-56383E" />
</a>
<a href="https://github.com/Mojang/bedrock-protocol-docs">
<img alt="Minecraft" src="https://img.shields.io/badge/protocol-729-blue" />
<img alt="Minecraft" src="https://img.shields.io/badge/protocol-748-blue" />
</a>
<a href="https://github.com/PowerNukkitX/PowerNukkitX/actions?query=branch%3Amaster+is%3Asuccess" target="_blank">
<img alt="Action" src="https://github.com/PowerNukkitX/PowerNukkitX/actions/workflows/pnx.yml/badge.svg?branch=master" />
Expand Down
4 changes: 2 additions & 2 deletions README_FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<p align="center">
<img alt="Version" src="https://img.shields.io/badge/version-2.0.0-blue.svg?cacheSeconds=2592000" />
<a href="https://feedback.minecraft.net/hc/en-us/articles/26247797084173--Minecraft-1-21-1-Bedrock">
<img alt="Minecraft" src="https://img.shields.io/badge/minecraft-v1.21.30%20(Bedrock)-56383E" />
<img alt="Minecraft" src="https://img.shields.io/badge/minecraft-v1.21.40%20(Bedrock)-56383E" />
</a>
<a href="https://github.com/Mojang/bedrock-protocol-docs">
<img alt="Minecraft" src="https://img.shields.io/badge/protocol-729-blue" />
<img alt="Minecraft" src="https://img.shields.io/badge/protocol-748-blue" />
</a>
<a href="https://github.com/PowerNukkitX/PowerNukkitX/actions?query=branch%3Amaster+is%3Asuccess" target="_blank">
<img alt="Action" src="https://github.com/PowerNukkitX/PowerNukkitX/actions/workflows/pnx.yml/badge.svg?branch=master" />
Expand Down
4 changes: 2 additions & 2 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<p align="center">
<img alt="Version" src="https://img.shields.io/badge/version-2.0.0-blue.svg?cacheSeconds=2592000" />
<a href="https://feedback.minecraft.net/hc/en-us/articles/26247797084173--Minecraft-1-21-1-Bedrock">
<img alt="Minecraft" src="https://img.shields.io/badge/minecraft-v1.21.30%20(Bedrock)-56383E" />
<img alt="Minecraft" src="https://img.shields.io/badge/minecraft-v1.21.40%20(Bedrock)-56383E" />
</a>
<a href="https://github.com/Mojang/bedrock-protocol-docs">
<img alt="Minecraft" src="https://img.shields.io/badge/protocol-729-blue" />
<img alt="Minecraft" src="https://img.shields.io/badge/protocol-748-blue" />
</a>
<a href="https://github.com/PowerNukkitX/PowerNukkitX/actions?query=branch%3Amaster+is%3Asuccess" target="_blank">
<img alt="Action" src="https://github.com/PowerNukkitX/PowerNukkitX/actions/workflows/pnx.yml/badge.svg?branch=master" />
Expand Down
26 changes: 4 additions & 22 deletions src/main/java/cn/nukkit/block/BlockBrownMushroomBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import cn.nukkit.utils.random.NukkitRandom;
import org.jetbrains.annotations.NotNull;

public class BlockBrownMushroomBlock extends BlockSolid {
import java.util.concurrent.ThreadLocalRandom;

public class BlockBrownMushroomBlock extends BlockMushroomBlock {
public static final BlockProperties PROPERTIES = new BlockProperties(BROWN_MUSHROOM_BLOCK, CommonBlockProperties.HUGE_MUSHROOM_BITS);

@Override
Expand All @@ -22,34 +24,14 @@ public BlockBrownMushroomBlock(BlockState blockstate) {
super(blockstate);
}

@Override
public int getToolType() {
return ItemTool.TYPE_AXE;
}

@Override
public double getHardness() {
return 0.2;
}

@Override
public double getResistance() {
return 0.2;
}

@Override
public Item[] getDrops(Item item) {
if (new NukkitRandom().nextInt(1, 20) == 1) {
if (ThreadLocalRandom.current().nextInt(1, 20) == 1) {
return new Item[]{
Item.get(BROWN_MUSHROOM_BLOCK)
};
} else {
return Item.EMPTY_ARRAY;
}
}

@Override
public boolean canSilkTouch() {
return true;
}
}
17 changes: 2 additions & 15 deletions src/main/java/cn/nukkit/block/BlockCherryWood.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static cn.nukkit.block.property.CommonBlockProperties.PILLAR_AXIS;

public class BlockCherryWood extends BlockWood {
public static final BlockProperties PROPERTIES = new BlockProperties(CHERRY_WOOD, CommonBlockProperties.PILLAR_AXIS, CommonBlockProperties.STRIPPED_BIT);
public static final BlockProperties PROPERTIES = new BlockProperties(CHERRY_WOOD, CommonBlockProperties.PILLAR_AXIS);

@Override
@NotNull public BlockProperties getProperties() {
Expand All @@ -25,24 +25,11 @@ public BlockCherryWood(BlockState blockstate) {

@Override
public String getName() {
return (isStripped() ? "Stripped " : "") + "Cherry Wood";
}

public boolean isStripped() {
return getPropertyValue(CommonBlockProperties.STRIPPED_BIT);
}

public void setStripped(boolean stripped) {
setPropertyValue(CommonBlockProperties.STRIPPED_BIT, stripped);
return "Cherry Wood";
}

@Override
public WoodType getWoodType() {
throw new UnsupportedOperationException();
}

@Override
public BlockState getStrippedState() {
return Registries.BLOCK.getBlockProperties(STRIPPED_CHERRY_WOOD).getBlockState(PILLAR_AXIS, getPillarAxis());
}
}
38 changes: 38 additions & 0 deletions src/main/java/cn/nukkit/block/BlockCreeperHead.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cn.nukkit.block;

import cn.nukkit.block.property.CommonBlockProperties;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemCreeperHead;
import cn.nukkit.item.ItemPlayerHead;
import org.jetbrains.annotations.NotNull;

public class BlockCreeperHead extends BlockHead {

public static final BlockProperties PROPERTIES = new BlockProperties(CREEPER_HEAD, CommonBlockProperties.FACING_DIRECTION);

public BlockCreeperHead(BlockState blockState) {
super(blockState);
}

@Override
public @NotNull BlockProperties getProperties() {
return PROPERTIES;
}

@Override
public String getName() {
return "Creeper Head";
}

@Override
public Item[] getDrops(Item item) {
return new Item[]{
this.toItem()
};
}

@Override
public Item toItem() {
return new ItemCreeperHead();
}
}
38 changes: 38 additions & 0 deletions src/main/java/cn/nukkit/block/BlockDragonHead.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cn.nukkit.block;

import cn.nukkit.block.property.CommonBlockProperties;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemDragonHead;
import cn.nukkit.item.ItemZombieHead;
import org.jetbrains.annotations.NotNull;

public class BlockDragonHead extends BlockHead {

public static final BlockProperties PROPERTIES = new BlockProperties(DRAGON_HEAD, CommonBlockProperties.FACING_DIRECTION);

public BlockDragonHead(BlockState blockState) {
super(blockState);
}

@Override
public @NotNull BlockProperties getProperties() {
return PROPERTIES;
}

@Override
public String getName() {
return "Dragon Head";
}

@Override
public Item[] getDrops(Item item) {
return new Item[]{
this.toItem()
};
}

@Override
public Item toItem() {
return new ItemDragonHead();
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package cn.nukkit.block;

/**
* @author Justin
*/

import cn.nukkit.Player;
import cn.nukkit.block.property.CommonBlockProperties;
import cn.nukkit.blockentity.BlockEntity;
import cn.nukkit.blockentity.BlockEntitySkull;
import cn.nukkit.event.redstone.RedstoneUpdateEvent;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemSkull;
import cn.nukkit.item.ItemTool;
import cn.nukkit.level.Level;
import cn.nukkit.math.AxisAlignedBB;
Expand All @@ -23,21 +18,10 @@

import javax.annotation.Nullable;

public class BlockSkull extends BlockTransparent implements RedstoneComponent, BlockEntityHolder<BlockEntitySkull>, Faceable {
public static final BlockProperties PROPERTIES = new BlockProperties(SKULL, CommonBlockProperties.FACING_DIRECTION);

@Override
@NotNull
public BlockProperties getProperties() {
return PROPERTIES;
}

public BlockSkull() {
this(PROPERTIES.getDefaultState());
}
public abstract class BlockHead extends BlockTransparent implements RedstoneComponent, BlockEntityHolder<BlockEntitySkull>, Faceable {

public BlockSkull(BlockState blockstate) {
super(blockstate);
public BlockHead(BlockState blockState) {
super(blockState);
}

@Override
Expand Down Expand Up @@ -82,25 +66,15 @@ public boolean canBeFlowedInto() {
return true;
}

@Override
public String getName() {
int itemMeta = 0;

if (this.level != null) {
BlockEntitySkull blockEntity = getBlockEntity();
if (blockEntity != null) {
itemMeta = blockEntity.namedTag.getByte("SkullType");
}
}

return ItemSkull.getItemSkullName(itemMeta);
}

@Override
public boolean place(@NotNull Item item, @NotNull Block block, @NotNull Block target, @NotNull BlockFace face, double fx, double fy, double fz, @Nullable Player player) {
if (face == BlockFace.DOWN) {
return false;
}

if (player == null)
return false;

setBlockFace(face);
CompoundTag nbt = new CompoundTag()
.putByte("SkullType", item.getDamage())
Expand Down Expand Up @@ -135,30 +109,6 @@ public int onUpdate(int type) {
return Level.BLOCK_UPDATE_REDSTONE;
}

@Override
public Item[] getDrops(Item item) {
BlockEntitySkull entitySkull = getBlockEntity();
int dropMeta = 0;
if (entitySkull != null) {
dropMeta = entitySkull.namedTag.getByte("SkullType");
}
return new Item[]{
new ItemSkull(dropMeta)
};
}

@Override
public Item toItem() {
if (getLevel() != null) {
BlockEntitySkull blockEntity = getBlockEntity();
int itemMeta = 0;
if (blockEntity != null) {
itemMeta = blockEntity.namedTag.getByte("SkullType");
}
return new ItemSkull(itemMeta);
} else return new ItemSkull();
}

@Override
public int getToolType() {
return ItemTool.TYPE_PICKAXE;
Expand Down Expand Up @@ -195,4 +145,6 @@ protected AxisAlignedBB recalculateBoundingBox() {
default -> bb;
};
}


}
16 changes: 16 additions & 0 deletions src/main/java/cn/nukkit/block/BlockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ public interface BlockID {

String CRAFTING_TABLE = "minecraft:crafting_table";

String CREEPER_HEAD = "minecraft:creeper_head";

String CRIMSON_BUTTON = "minecraft:crimson_button";

String CRIMSON_DOOR = "minecraft:crimson_door";
Expand Down Expand Up @@ -714,6 +716,8 @@ public interface BlockID {

String DRAGON_EGG = "minecraft:dragon_egg";

String DRAGON_HEAD = "minecraft:dragon_head";

String DRIED_KELP_BLOCK = "minecraft:dried_kelp_block";

String DRIPSTONE_BLOCK = "minecraft:dripstone_block";
Expand Down Expand Up @@ -1536,6 +1540,8 @@ public interface BlockID {

String MUDDY_MANGROVE_ROOTS = "minecraft:muddy_mangrove_roots";

String MUSHROOM_STEM = "minecraft:mushroom_stem";

String MYCELIUM = "minecraft:mycelium";

String NETHER_BRICK = "minecraft:nether_brick";
Expand Down Expand Up @@ -1656,6 +1662,8 @@ public interface BlockID {

String PETRIFIED_OAK_SLAB = "minecraft:petrified_oak_slab";

String PIGLIN_HEAD = "minecraft:piglin_head";

String PINK_CANDLE = "minecraft:pink_candle";

String PINK_CANDLE_CAKE = "minecraft:pink_candle_cake";
Expand Down Expand Up @@ -1690,6 +1698,8 @@ public interface BlockID {

String PITCHER_PLANT = "minecraft:pitcher_plant";

String PLAYER_HEAD = "minecraft:player_head";

String PODZOL = "minecraft:podzol";

String POINTED_DRIPSTONE = "minecraft:pointed_dripstone";
Expand Down Expand Up @@ -1960,6 +1970,8 @@ public interface BlockID {

String SILVER_GLAZED_TERRACOTTA = "minecraft:silver_glazed_terracotta";

String SKELETON_SKULL = "minecraft:skeleton_skull";

String SKULL = "minecraft:skull";

String SLIME = "minecraft:slime";
Expand Down Expand Up @@ -2404,6 +2416,8 @@ public interface BlockID {

String WITHER_ROSE = "minecraft:wither_rose";

String WITHER_SKELETON_SKULL = "minecraft:wither_skeleton_skull";

String WOODEN_BUTTON = "minecraft:wooden_button";

String WOODEN_DOOR = "minecraft:wooden_door";
Expand Down Expand Up @@ -2431,4 +2445,6 @@ public interface BlockID {
String YELLOW_TERRACOTTA = "minecraft:yellow_terracotta";

String YELLOW_WOOL = "minecraft:yellow_wool";

String ZOMBIE_HEAD = "minecraft:zombie_head";
}
Loading

0 comments on commit c4530eb

Please sign in to comment.