Skip to content

Commit

Permalink
block palette 1.21.30.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Aug 17, 2024
1 parent 38a0de4 commit ca644a6
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockFullNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public interface BlockFullNames {
String WHITE_CONCRETE_POWDER = "minecraft:" + BlockNames.WHITE_CONCRETE_POWDER; //TODO: 1.20.30 flattening
String CONCRETE_POWDER = "minecraft:" + BlockNames.CONCRETE_POWDER; //TODO: 1.18.30 rename
String CONCRETE_POWDER_NEW = "minecraft:" + BlockNames.CONCRETE_POWDER_NEW;
String COMPOUND_CREATOR = "minecraft:" + BlockNames.COMPOUND_CREATOR; //TODO: 1.21.30 flattening
String CHEMISTRY_TABLE = "minecraft:" + BlockNames.CHEMISTRY_TABLE;
String UNDERWATER_TORCH = "minecraft:" + BlockNames.UNDERWATER_TORCH;
String CHORUS_PLANT = "minecraft:" + BlockNames.CHORUS_PLANT;
Expand Down Expand Up @@ -1288,4 +1289,8 @@ public interface BlockFullNames {
String RED_SANDSTONE_WALL = "minecraft:" + BlockNames.RED_SANDSTONE_WALL;
String RED_NETHER_BRICK_WALL = "minecraft:" + BlockNames.RED_NETHER_BRICK_WALL;
String WET_SPONGE = "minecraft:" + BlockNames.WET_SPONGE;
String UNDERWATER_TNT = "minecraft:" + BlockNames.UNDERWATER_TNT;
String MATERIAL_REDUCER = "minecraft:" + BlockNames.MATERIAL_REDUCER;
String ELEMENT_CONSTRUCTOR = "minecraft:" + BlockNames.ELEMENT_CONSTRUCTOR;
String LAB_TABLE = "minecraft:" + BlockNames.LAB_TABLE;
}
7 changes: 6 additions & 1 deletion src/main/java/cn/nukkit/block/BlockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public interface BlockID {
*/
@Deprecated
int CONCRETEPOWDER = 237;
int COMPOUND_CREATOR = 238; //TODO: 1.21.30 flattening
int CHEMISTRY_TABLE = 238;
int UNDERWATER_TORCH = 239;
int CHORUS_PLANT = 240;
Expand Down Expand Up @@ -1329,7 +1330,11 @@ public interface BlockID {
int RED_SANDSTONE_WALL = 1237;
int RED_NETHER_BRICK_WALL = 1238;
int WET_SPONGE = 1239;
int UNDERWATER_TNT = 1240;
int MATERIAL_REDUCER = 1241;
int ELEMENT_CONSTRUCTOR = 1242;
int LAB_TABLE = 1243;


int UNDEFINED = 1240;
int UNDEFINED = 1244;
}
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ public interface BlockNames {
String WHITE_CONCRETE_POWDER = "white_concrete_powder"; //TODO: 1.20.30 flattening
String CONCRETE_POWDER = "concretePowder"; //TODO: 1.18.30 rename
String CONCRETE_POWDER_NEW = "concrete_powder";
String COMPOUND_CREATOR = "compound_creator"; //TODO: 1.21.30 flattening
String CHEMISTRY_TABLE = "chemistry_table";
String UNDERWATER_TORCH = "underwater_torch";
String CHORUS_PLANT = "chorus_plant";
Expand Down Expand Up @@ -1287,4 +1288,8 @@ public interface BlockNames {
String RED_SANDSTONE_WALL = "red_sandstone_wall";
String RED_NETHER_BRICK_WALL = "red_nether_brick_wall";
String WET_SPONGE = "wet_sponge";
String UNDERWATER_TNT = "underwater_tnt";
String MATERIAL_REDUCER = "material_reducer";
String ELEMENT_CONSTRUCTOR = "element_constructor";
String LAB_TABLE = "lab_table";
}
14 changes: 14 additions & 0 deletions src/main/java/cn/nukkit/block/BlockSnowLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@ protected int getFallingBlockDamage() {
return getDamage() & HEIGHT_MASK;
}

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

@Override
public Item getSilkTouchResource() {
int height = getDamage() & HEIGHT_MASK;
if (height == HEIGHT_MASK) {
return Item.get(SNOW);
}
return Item.get(SNOW_LAYER, 0, 1 + height);
}

public boolean isCovered() {
return (getDamage() & COVERED_BIT) != 0;
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/cn/nukkit/block/BlockTNT.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@
* Package cn.nukkit.block in project Nukkit .
*/
public class BlockTNT extends BlockSolidMeta {
public static final int EXPLODE_BIT = 0b1;
public static final int ALLOW_UNDERWATER_BIT = 0b10;

private static final String[] NAMES = {
"TNT",
"Underwater TNT",
};

public BlockTNT() {
this(0);
}

public BlockTNT(int meta) {
// 0b1 allow_underwater_bit
// 0b10 explode_bit
super(meta & 0b11);
super(meta);
}

@Override
public String getName() {
return "TNT";
return NAMES[(getDamage() & 0b11) >> 1];
}

@Override
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/cn/nukkit/block/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,13 @@ private static void registerComplexAliases() {
registerComplexAlias(ItemBlockNames.COLORED_TORCH_BLUE, COLORED_TORCH_BP, BlockTorchColoredBluePurple.BLUE, V1_21_30);
registerComplexAlias(ItemBlockNames.COLORED_TORCH_PURPLE, COLORED_TORCH_BP, BlockTorchColoredBluePurple.PURPLE, V1_21_30);
registerComplexAlias(ItemBlockNames.COMPOUND_CREATOR, CHEMISTRY_TABLE, BlockChemistryTable.TYPE_COMPOUND_CREATOR, V1_21_30);
registerComplexAlias(ItemBlockNames.MATERIAL_REDUCER, CHEMISTRY_TABLE, BlockChemistryTable.TYPE_MATERIAL_REDUCER, V1_21_30);
registerComplexAlias(ItemBlockNames.ELEMENT_CONSTRUCTOR, CHEMISTRY_TABLE, BlockChemistryTable.TYPE_ELEMENT_CONSTRUCTOR, V1_21_30);
registerComplexAlias(ItemBlockNames.LAB_TABLE, CHEMISTRY_TABLE, BlockChemistryTable.TYPE_LAB_TABLE, V1_21_30);
registerComplexAlias(ItemBlockNames.UNDERWATER_TNT, TNT, BlockTNT.ALLOW_UNDERWATER_BIT, V1_21_30);
*/
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/cn/nukkit/block/edu/BlockChemistryTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class BlockChemistryTable extends BlockSolidMeta {
public static final int DIRECTION_MASK = 0b11;
public static final int DIRECTION_BITS = 2;

public static final int COMPOUND_CREATOR = 0;
public static final int MATERIAL_REDUCER = 1 << DIRECTION_BITS;
public static final int ELEMENT_CONSTRUCTOR = 2 << DIRECTION_BITS;
public static final int LAB_TABLE = 3 << DIRECTION_BITS;
public static final int TYPE_COMPOUND_CREATOR = 0;
public static final int TYPE_MATERIAL_REDUCER = 1 << DIRECTION_BITS;
public static final int TYPE_ELEMENT_CONSTRUCTOR = 2 << DIRECTION_BITS;
public static final int TYPE_LAB_TABLE = 3 << DIRECTION_BITS;

private static final String[] NAMES = {
"Compound Creator",
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/item/ItemBlockFullNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ public interface ItemBlockFullNames {
String CONCRETE = "minecraft:" + ItemBlockNames.CONCRETE;
String WHITE_CONCRETE_POWDER = "minecraft:" + ItemBlockNames.WHITE_CONCRETE_POWDER; //TODO: 1.20.30 flattening
String CONCRETE_POWDER = "minecraft:" + ItemBlockNames.CONCRETE_POWDER;
String COMPOUND_CREATOR = "minecraft:" + ItemBlockNames.COMPOUND_CREATOR; //TODO: 1.21.30 flattening
String CHEMISTRY_TABLE = "minecraft:" + ItemBlockNames.CHEMISTRY_TABLE;
String UNDERWATER_TORCH = "minecraft:" + ItemBlockNames.UNDERWATER_TORCH;
String CHORUS_PLANT = "minecraft:" + ItemBlockNames.CHORUS_PLANT;
Expand Down Expand Up @@ -1368,4 +1369,8 @@ public interface ItemBlockFullNames {
String RED_SANDSTONE_WALL = "minecraft:" + ItemBlockNames.RED_SANDSTONE_WALL;
String RED_NETHER_BRICK_WALL = "minecraft:" + ItemBlockNames.RED_NETHER_BRICK_WALL;
String WET_SPONGE = "minecraft:" + ItemBlockNames.WET_SPONGE;
String UNDERWATER_TNT = "minecraft:" + ItemBlockNames.UNDERWATER_TNT;
String MATERIAL_REDUCER = "minecraft:" + ItemBlockNames.MATERIAL_REDUCER;
String ELEMENT_CONSTRUCTOR = "minecraft:" + ItemBlockNames.ELEMENT_CONSTRUCTOR;
String LAB_TABLE = "minecraft:" + ItemBlockNames.LAB_TABLE;
}
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/item/ItemBlockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ public interface ItemBlockID {
*/
@Deprecated
int CONCRETEPOWDER = 237;
int COMPOUND_CREATOR = 238;
int CHEMISTRY_TABLE = 238;
int UNDERWATER_TORCH = 239;
int CHORUS_PLANT = 240;
Expand Down Expand Up @@ -1331,6 +1332,10 @@ public interface ItemBlockID {
int RED_SANDSTONE_WALL = 0xff - BlockID.RED_SANDSTONE_WALL;
int RED_NETHER_BRICK_WALL = 0xff - BlockID.RED_NETHER_BRICK_WALL;
int WET_SPONGE = 0xff - BlockID.WET_SPONGE;
int UNDERWATER_TNT = 0xff - BlockID.UNDERWATER_TNT;
int MATERIAL_REDUCER = 0xff - BlockID.MATERIAL_REDUCER;
int ELEMENT_CONSTRUCTOR = 0xff - BlockID.ELEMENT_CONSTRUCTOR;
int LAB_TABLE = 0xff - BlockID.LAB_TABLE;


int UNDEFINED = 0xff - BlockID.UNDEFINED;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/item/ItemBlockNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public interface ItemBlockNames {
String CONCRETE = "concrete";
String WHITE_CONCRETE_POWDER = "white_concrete_powder"; //TODO: 1.20.30 flattening
String CONCRETE_POWDER = "concrete_powder";
String COMPOUND_CREATOR = "compound_creator"; //TODO: 1.21.30 flattening
String CHEMISTRY_TABLE = "chemistry_table";
String UNDERWATER_TORCH = "underwater_torch";
String CHORUS_PLANT = "chorus_plant";
Expand Down Expand Up @@ -1367,4 +1368,8 @@ public interface ItemBlockNames {
String RED_SANDSTONE_WALL = "red_sandstone_wall";
String RED_NETHER_BRICK_WALL = "red_nether_brick_wall";
String WET_SPONGE = "wet_sponge";
String UNDERWATER_TNT = "underwater_tnt";
String MATERIAL_REDUCER = "material_reducer";
String ELEMENT_CONSTRUCTOR = "element_constructor";
String LAB_TABLE = "lab_table";
}
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/item/ItemFullNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,4 +745,5 @@ public interface ItemFullNames extends ItemBlockNames {
String BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = "minecraft:" + ItemNames.BOLT_ARMOR_TRIM_SMITHING_TEMPLATE;
String FLOW_BANNER_PATTERN = "minecraft:" + ItemNames.FLOW_BANNER_PATTERN;
String GUSTER_BANNER_PATTERN = "minecraft:" + ItemNames.GUSTER_BANNER_PATTERN;
String BUNDLE = "minecraft:" + ItemNames.BUNDLE;
}
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/item/ItemNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,5 @@ public interface ItemNames extends ItemBlockNames {
String BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = "bolt_armor_trim_smithing_template";
String FLOW_BANNER_PATTERN = "flow_banner_pattern";
String GUSTER_BANNER_PATTERN = "guster_banner_pattern";
String BUNDLE = "bundle";
}
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/item/ItemRuntimeID.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public interface ItemRuntimeID {
int SCRAPE_POTTERY_SHERD = BASE_INTERNAL_ID + 56;
int FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = BASE_INTERNAL_ID + 57;
int BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = BASE_INTERNAL_ID + 58;
int BUNDLE = BASE_INTERNAL_ID + 59;

int CUSTOM_ITEM = Mth.smallestEncompassingPowerOfTwo(BASE_INTERNAL_ID + 59); //2048
int CUSTOM_ITEM = Mth.smallestEncompassingPowerOfTwo(BASE_INTERNAL_ID + 60); //2048
}
2 changes: 2 additions & 0 deletions src/main/java/cn/nukkit/item/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ public static void registerVanillaNewItems() {
registerNewItem(ItemNames.FLOW_ARMOR_TRIM_SMITHING_TEMPLATE, FLOW_ARMOR_TRIM_SMITHING_TEMPLATE, ItemSmithingTemplateArmorTrimFlow.class, ItemSmithingTemplateArmorTrimFlow::new, V1_21_0);
registerNewItem(ItemNames.BOLT_ARMOR_TRIM_SMITHING_TEMPLATE, BOLT_ARMOR_TRIM_SMITHING_TEMPLATE, ItemSmithingTemplateArmorTrimBolt.class, ItemSmithingTemplateArmorTrimBolt::new, V1_21_0);

// registerNewItem(ItemNames.BUNDLE, BUNDLE, ItemBundle.class, ItemBundle::new, );

}

@SuppressWarnings("deprecation")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,7 @@ public Item useBreakOn(Vector3 vector, @Nullable BlockFace face, @Nullable Item
Item[] eventDrops;
if (!player.isSurvival()) {
eventDrops = new Item[0];
} else if (isSilkTouch && target.canSilkTouch()) {
} else if (isSilkTouch && target.canSilkTouch() && (target.canHarvestWithHand() || target.isToolCompatible(item))) {
eventDrops = new Item[]{target.getSilkTouchResource()};
} else {
eventDrops = target.getDrops(item, player);
Expand Down Expand Up @@ -2757,7 +2757,7 @@ public Item useBreakOn(Vector3 vector, @Nullable BlockFace face, @Nullable Item
dropExp = ev.getDropExp();
} else if (!target.isBreakable(item)) {
return null;
} else if (isSilkTouch && target.canSilkTouch()) {
} else if (isSilkTouch && target.canSilkTouch() && (target.canHarvestWithHand() || target.isToolCompatible(item))) {
drops = new Item[]{target.getSilkTouchResource()};
} else {
drops = target.getDrops(item);
Expand Down

0 comments on commit ca644a6

Please sign in to comment.