Skip to content

Commit

Permalink
chores: add code generating tool
Browse files Browse the repository at this point in the history
* fix: readme
  • Loading branch information
IWareQ committed Aug 23, 2024
1 parent 83c55a9 commit 15775cc
Show file tree
Hide file tree
Showing 30 changed files with 521 additions and 306 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/deploy-release.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/deploy-snapshot.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/deploy.yml

This file was deleted.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ All updaters are auto-generated!
```java
// Update legacy items to new latest items (example for update jungle planks)
NbtMap updatedNbt = ItemStateUpdaters.updateItemState(
NbtMap.builder()
.putString("Id", "5")
.putInt("Damage", 3) // You can use int, short, long and byte
.build(),
ItemStateUpdaters.LATEST_VERSION
NbtMap.builder()
.putString("Id", "5")
.putInt("Damage", 3) // You can use int, short, long and byte
.build(),
ItemStateUpdaters.LATEST_VERSION
);

// or update new items to latest
Expand All @@ -33,11 +33,11 @@ NbtMap updatedNbt = ItemStateUpdaters.updateItemState(
```java
// Update legacy block
NbtMap updatedNbt = BlockStateUpdaters.updateBlockState(
NbtMap.builder()
.putString("name", "minecraft:stone")
.putInt("val", 1) // You can use int, short, long and byte
.build(),
BlockStateUpdaters.LATEST_VERSION
NbtMap.builder()
.putString("name", "minecraft:stone")
.putInt("val", 1) // You can use int, short, long and byte
.build(),
BlockStateUpdaters.LATEST_VERSION
);

// or update block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public void registerUpdaters(BlockUpdaterContext context) {
context.remapValues("minecraft:coral_block", "mapped_type", mapped_type_03);
context.remapValues("minecraft:coral_fan", "mapped_type", mapped_type_03);
context.remapValues("minecraft:coral_fan_dead", "mapped_type", mapped_type_03);

var mapped_type_04 = new RemapValue[]{
new RemapValue(0, (byte) 0),
new RemapValue(1, (byte) 1)
};
context.remapValues("minecraft:coral_fan_hang", "mapped_type", mapped_type_04);
context.remapValues("minecraft:coral_fan_hang2", "mapped_type", mapped_type_04);
context.remapValues("minecraft:coral_fan_hang3", "mapped_type", mapped_type_04);
context.remapValues("minecraft:dirt", "mapped_type",
new RemapValue(0, "normal"),
new RemapValue(1, "coarse")
Expand All @@ -98,6 +106,91 @@ public void registerUpdaters(BlockUpdaterContext context) {
new RemapValue(6, "sunflower"),
new RemapValue(7, "sunflower")
);

var mapped_type_07 = new RemapValue[]{
new RemapValue(0, "smooth_stone"),
new RemapValue(1, "sandstone"),
new RemapValue(2, "wood"),
new RemapValue(3, "cobblestone"),
new RemapValue(4, "brick"),
new RemapValue(5, "stone_brick"),
new RemapValue(6, "quartz"),
new RemapValue(7, "nether_brick")
};
context.remapValues("minecraft:double_stone_slab", "mapped_type", mapped_type_07);
context.remapValues("minecraft:stone_slab", "mapped_type", mapped_type_07);

var mapped_type_08 = new RemapValue[]{
new RemapValue(0, "red_sandstone"),
new RemapValue(1, "purpur"),
new RemapValue(2, "prismarine_rough"),
new RemapValue(3, "prismarine_dark"),
new RemapValue(4, "prismarine_brick"),
new RemapValue(5, "mossy_cobblestone"),
new RemapValue(6, "smooth_sandstone"),
new RemapValue(7, "red_nether_brick")
};
context.remapValues("minecraft:double_stone_slab2", "mapped_type", mapped_type_08);
context.remapValues("minecraft:stone_slab2", "mapped_type", mapped_type_08);

var mapped_type_09 = new RemapValue[]{
new RemapValue(0, "end_stone_brick"),
new RemapValue(1, "smooth_red_sandstone"),
new RemapValue(2, "polished_andesite"),
new RemapValue(3, "andesite"),
new RemapValue(4, "diorite"),
new RemapValue(5, "polished_diorite"),
new RemapValue(6, "granite"),
new RemapValue(7, "polished_granite")
};
context.remapValues("minecraft:double_stone_slab3", "mapped_type", mapped_type_09);
context.remapValues("minecraft:stone_slab3", "mapped_type", mapped_type_09);

var mapped_type_10 = new RemapValue[]{
new RemapValue(0, "mossy_stone_brick"),
new RemapValue(1, "smooth_quartz"),
new RemapValue(2, "stone"),
new RemapValue(3, "cut_sandstone"),
new RemapValue(4, "cut_red_sandstone"),
new RemapValue(5, "mossy_stone_brick"),
new RemapValue(6, "mossy_stone_brick"),
new RemapValue(7, "mossy_stone_brick")
};
context.remapValues("minecraft:double_stone_slab4", "mapped_type", mapped_type_10);
context.remapValues("minecraft:stone_slab4", "mapped_type", mapped_type_10);

var mapped_type_11 = new RemapValue[]{
new RemapValue(0, "oak"),
new RemapValue(1, "spruce"),
new RemapValue(2, "birch"),
new RemapValue(3, "jungle"),
new RemapValue(4, "acacia"),
new RemapValue(5, "dark_oak"),
new RemapValue(6, "oak"),
new RemapValue(7, "oak")
};
context.remapValues("minecraft:double_wooden_slab", "mapped_type", mapped_type_11);
context.remapValues("minecraft:fence", "mapped_type", mapped_type_11);
context.remapValues("minecraft:planks", "mapped_type", mapped_type_11);
context.remapValues("minecraft:wooden_slab", "mapped_type", mapped_type_11);

var mapped_type_12 = new RemapValue[]{
new RemapValue(0, "oak"),
new RemapValue(1, "spruce"),
new RemapValue(2, "birch"),
new RemapValue(3, "jungle")
};
context.remapValues("minecraft:leaves", "mapped_type", mapped_type_12);
context.remapValues("minecraft:log", "mapped_type", mapped_type_12);

var mapped_type_13 = new RemapValue[]{
new RemapValue(0, "acacia"),
new RemapValue(1, "dark_oak"),
new RemapValue(2, "acacia"),
new RemapValue(3, "acacia")
};
context.remapValues("minecraft:leaves2", "mapped_type", mapped_type_13);
context.remapValues("minecraft:log2", "mapped_type", mapped_type_13);
context.remapValues("minecraft:monster_egg", "mapped_type",
new RemapValue(0, "stone"),
new RemapValue(1, "cobblestone"),
Expand All @@ -114,6 +207,15 @@ public void registerUpdaters(BlockUpdaterContext context) {
new RemapValue(2, "bricks"),
new RemapValue(3, "default")
);

var mapped_type_16 = new RemapValue[]{
new RemapValue(0, "default"),
new RemapValue(1, "chiseled"),
new RemapValue(2, "lines"),
new RemapValue(3, "smooth")
};
context.remapValues("minecraft:purpur_block", "mapped_type", mapped_type_16);
context.remapValues("minecraft:quartz_block", "mapped_type", mapped_type_16);
context.remapValues("minecraft:red_flower", "mapped_type",
new RemapValue(0, "poppy"),
new RemapValue(1, "orchid"),
Expand All @@ -132,6 +234,15 @@ public void registerUpdaters(BlockUpdaterContext context) {
new RemapValue(14, "poppy"),
new RemapValue(15, "poppy")
);

var mapped_type_18 = new RemapValue[]{
new RemapValue(0, "default"),
new RemapValue(1, "heiroglyphs"),
new RemapValue(2, "cut"),
new RemapValue(3, "smooth")
};
context.remapValues("minecraft:red_sandstone", "mapped_type", mapped_type_18);
context.remapValues("minecraft:sandstone", "mapped_type", mapped_type_18);
context.remapValues("minecraft:sand", "mapped_type",
new RemapValue(0, "normal"),
new RemapValue(1, "red")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,25 @@ public void registerUpdaters(BlockUpdaterContext context) {
.visit("states")
.match("direction", "0")
.addProperty("pillar_axis", "y")
.removeProperty("direction");
.removeProperty("direction")
.popVisit()
.replaceValue("name", "minecraft:log");
context.addUpdater()
.match("name", "minecraft:log")
.visit("states")
.match("direction", "1")
.addProperty("pillar_axis", "x")
.removeProperty("direction");
.removeProperty("direction")
.popVisit()
.replaceValue("name", "minecraft:log");
context.addUpdater()
.match("name", "minecraft:log")
.visit("states")
.match("direction", "2")
.addProperty("pillar_axis", "z")
.removeProperty("direction");
.removeProperty("direction")
.popVisit()
.replaceValue("name", "minecraft:log");

context.addUpdater()
.match("name", "minecraft:log2")
Expand Down Expand Up @@ -263,19 +269,26 @@ public void registerUpdaters(BlockUpdaterContext context) {
.visit("states")
.match("direction", "0")
.addProperty("pillar_axis", "y")
.removeProperty("direction");
.removeProperty("direction")
.popVisit()
.replaceValue("name", "minecraft:log2");
context.addUpdater()
.match("name", "minecraft:log2")
.visit("states")
.match("direction", "1")
.addProperty("pillar_axis", "x")
.removeProperty("direction");
.removeProperty("direction")
.popVisit()
.replaceValue("name", "minecraft:log2");
context.addUpdater()
.match("name", "minecraft:log2")
.visit("states")
.match("direction", "2")
.addProperty("pillar_axis", "z")
.removeProperty("direction");
.removeProperty("direction")
.popVisit()
.replaceValue("name", "minecraft:log2");


context.addProperty("minecraft:coral", "dead_bit", (byte) 0);
context.addProperty("minecraft:wood", "pillar_axis", "y");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@ private BlockStateUpdater_1_21_0() {

@Override
public void registerUpdaters(BlockUpdaterContext context) {
context.remapState("minecraft:coral_block", oldState -> oldState.match("dead_bit", "0"), "minecraft:", "coral_color", "_coral_block",
new RemapValue("blue", "tube"),
new RemapValue("pink", "brain"),
new RemapValue("purple", "bubble"),
new RemapValue("red", "fire"),
new RemapValue("yellow", "horn")
);
context.remapState("minecraft:coral_block", oldState -> oldState.match("dead_bit", "1"), "minecraft:dead_", "coral_color", "_coral_block",
new RemapValue("blue", "tube"),
new RemapValue("pink", "brain"),
new RemapValue("purple", "bubble"),
new RemapValue("red", "fire"),
new RemapValue("yellow", "horn")
);
context.remapState("minecraft:double_plant", "minecraft:", "double_plant_type", "",
new RemapValue("fern", "large_fern"),
new RemapValue("grass", "tall_grass"),
new RemapValue("paeonia", "peony"),
new RemapValue("rose", "rose_bush"),
new RemapValue("syringa", "lilac")
);
context.remapState("minecraft:stone_block_slab", "minecraft:", "stone_slab_type", "_slab",
new RemapValue("wood", "petrified_oak")
);

context.addUpdater()
.match("name", "minecraft:tallgrass")
.visit("states")
Expand Down Expand Up @@ -46,31 +71,6 @@ public void registerUpdaters(BlockUpdaterContext context) {
.popVisit()
.replaceValue("name", "minecraft:short_grass");

context.remapState("minecraft:coral_block", oldState -> oldState.match("dead_bit", "0"), "minecraft:", "coral_color", "_coral_block",
new RemapValue("blue", "tube"),
new RemapValue("pink", "brain"),
new RemapValue("purple", "bubble"),
new RemapValue("red", "fire"),
new RemapValue("yellow", "horn")
);
context.remapState("minecraft:coral_block", oldState -> oldState.match("dead_bit", "1"), "minecraft:dead_", "coral_color", "_coral_block",
new RemapValue("blue", "tube"),
new RemapValue("pink", "brain"),
new RemapValue("purple", "bubble"),
new RemapValue("red", "fire"),
new RemapValue("yellow", "horn")
);
context.remapState("minecraft:double_plant", "minecraft:", "double_plant_type", "",
new RemapValue("fern", "large_fern"),
new RemapValue("grass", "tall_grass"),
new RemapValue("paeonia", "peony"),
new RemapValue("rose", "rose_bush"),
new RemapValue("syringa", "lilac")
);
context.remapState("minecraft:stone_block_slab", "minecraft:", "stone_slab_type", "_slab",
new RemapValue("wood", "petrified_oak")
);

context.addProperty("minecraft:trial_spawner", "ominous", (byte) 0);
context.addProperty("minecraft:vault", "ominous", (byte) 0);
}
Expand Down
Loading

0 comments on commit 15775cc

Please sign in to comment.