Skip to content

Commit

Permalink
feat: 1.21.60
Browse files Browse the repository at this point in the history
refactor: remove legacy update
  • Loading branch information
IWareQ committed Feb 10, 2025
1 parent 672cd59 commit 94faef3
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 20,011 deletions.
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ All updaters are auto-generated!
#### Update Item

```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
);

// or update new items to latest
NbtMap updatedNbt = ItemStateUpdaters.updateItemState(
NbtMap.builder()
.putString("Name", "minecraft:coal")
Expand All @@ -31,16 +21,6 @@ NbtMap updatedNbt = ItemStateUpdaters.updateItemState(
#### Update Block

```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
);

// or update block
NbtMap updatedNbt = BlockStateUpdaters.updateBlockState(
NbtMap.builder()
.putString("name", "minecraft:anvil")
Expand Down
2 changes: 1 addition & 1 deletion block-updater/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = "org.allaymc.updater.block"
version = "1.21.40"
version = "1.21.60"

dependencies {
api(project(":common"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package org.allaymc.updater.block;

import org.allaymc.updater.block.context.BlockUpdaterContext;
import org.allaymc.updater.block.context.RemapValue;

/**
* @author IWareQ
*/
public class BlockStateUpdater_1_21_60 extends BlockStateUpdater {
public static final BlockStateUpdater INSTANCE = new BlockStateUpdater_1_21_60();

private BlockStateUpdater_1_21_60() {
super(1, 21, 60);
}

@Override
public void registerUpdaters(BlockUpdaterContext context) {
var direction_00 = new RemapValue[]{
new RemapValue(0, "south"),
new RemapValue(1, "west"),
new RemapValue(2, "north"),
new RemapValue(3, "east")
};
context.remapValues("minecraft:acacia_door", "direction", direction_00);
context.remapValues("minecraft:acacia_fence_gate", "direction", direction_00);
context.remapValues("minecraft:bamboo_door", "direction", direction_00);
context.remapValues("minecraft:bamboo_fence_gate", "direction", direction_00);
context.remapValues("minecraft:birch_door", "direction", direction_00);
context.remapValues("minecraft:birch_fence_gate", "direction", direction_00);
context.remapValues("minecraft:cherry_door", "direction", direction_00);
context.remapValues("minecraft:cherry_fence_gate", "direction", direction_00);
context.remapValues("minecraft:copper_door", "direction", direction_00);
context.remapValues("minecraft:crimson_door", "direction", direction_00);
context.remapValues("minecraft:crimson_fence_gate", "direction", direction_00);
context.remapValues("minecraft:dark_oak_door", "direction", direction_00);
context.remapValues("minecraft:dark_oak_fence_gate", "direction", direction_00);
context.remapValues("minecraft:exposed_copper_door", "direction", direction_00);
context.remapValues("minecraft:fence_gate", "direction", direction_00);
context.remapValues("minecraft:iron_door", "direction", direction_00);
context.remapValues("minecraft:jungle_door", "direction", direction_00);
context.remapValues("minecraft:jungle_fence_gate", "direction", direction_00);
context.remapValues("minecraft:mangrove_door", "direction", direction_00);
context.remapValues("minecraft:mangrove_fence_gate", "direction", direction_00);
context.remapValues("minecraft:oxidized_copper_door", "direction", direction_00);
context.remapValues("minecraft:pale_oak_door", "direction", direction_00);
context.remapValues("minecraft:pale_oak_fence_gate", "direction", direction_00);
context.remapValues("minecraft:spruce_door", "direction", direction_00);
context.remapValues("minecraft:spruce_fence_gate", "direction", direction_00);
context.remapValues("minecraft:warped_door", "direction", direction_00);
context.remapValues("minecraft:warped_fence_gate", "direction", direction_00);
context.remapValues("minecraft:waxed_copper_door", "direction", direction_00);
context.remapValues("minecraft:waxed_exposed_copper_door", "direction", direction_00);
context.remapValues("minecraft:waxed_oxidized_copper_door", "direction", direction_00);
context.remapValues("minecraft:waxed_weathered_copper_door", "direction", direction_00);
context.remapValues("minecraft:weathered_copper_door", "direction", direction_00);
context.remapValues("minecraft:wooden_door", "direction", direction_00);
context.remapValues("minecraft:creaking_heart", "active",
new RemapValue((byte) 0, "dormant"),
new RemapValue((byte) 1, "uprooted")
);

context.addUpdater()
.match("name", "minecraft:red_mushroom_block")
.visit("states")
.match("huge_mushroom_bits", "10")
.removeProperty("huge_mushroom_bits")
.popVisit()
.replaceValue("name", "minecraft:mushroom_stem");
context.addUpdater()
.match("name", "minecraft:red_mushroom_block")
.visit("states")
.match("huge_mushroom_bits", "15")
.removeProperty("huge_mushroom_bits")
.popVisit()
.replaceValue("name", "minecraft:mushroom_stem");

context.renameProperty("minecraft:acacia_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:acacia_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:bamboo_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:bamboo_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:birch_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:birch_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:cherry_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:cherry_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:creaking_heart", "active", "creaking_heart_state");
context.renameProperty("minecraft:crimson_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:crimson_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:dark_oak_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:dark_oak_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:exposed_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:iron_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:jungle_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:jungle_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:mangrove_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:mangrove_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:oxidized_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:pale_oak_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:pale_oak_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:spruce_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:spruce_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:warped_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:warped_fence_gate", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:waxed_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:waxed_exposed_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:waxed_oxidized_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:waxed_weathered_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:weathered_copper_door", "direction", "minecraft:cardinal_direction");
context.renameProperty("minecraft:wooden_door", "direction", "minecraft:cardinal_direction");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class BlockStateUpdaters {

static {
List<BlockStateUpdater> updaters = new ArrayList<>();
updaters.add(BlockStateUpdaterBase.INSTANCE);
updaters.add(BlockStateUpdater_1_10_0.INSTANCE);
updaters.add(BlockStateUpdater_1_12_0.INSTANCE);
updaters.add(BlockStateUpdater_1_13_0.INSTANCE);
Expand Down Expand Up @@ -46,6 +45,7 @@ public class BlockStateUpdaters {
updaters.add(BlockStateUpdater_1_21_20.INSTANCE);
updaters.add(BlockStateUpdater_1_21_30.INSTANCE);
updaters.add(BlockStateUpdater_1_21_40.INSTANCE);
updaters.add(BlockStateUpdater_1_21_60.INSTANCE);

var context = new BlockUpdaterContext();
updaters.forEach(updater -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
import org.allaymc.updater.common.context.filter.HasKeyFilter;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Predicate;

/**
* @author IWareQ
*/
public class BlockUpdater extends BaseUpdater<BlockUpdater, BlockUpdater.Builder> {
private static final Predicate<CompoundTagEditHelper> COMPOUND_FILTER = helper -> helper.getTag() instanceof Map;
private static final Predicate<CompoundTagEditHelper> COMPOUND_FILTER = helper -> helper.getCompoundTag() != null;

public BlockUpdater(int version) {
super(version);
Expand Down Expand Up @@ -58,13 +57,13 @@ public Builder addCompound(String key) {

public Builder visit(String key) {
filters.add(helper -> {
var tag = helper.getTag();
if (tag instanceof Map && ((Map<String, Object>) tag).containsKey(key)) {
helper.pushChild(key);
return true;
var compoundTag = helper.getCompoundTag();
if (compoundTag == null || !compoundTag.containsKey(key)) {
return false;
}

return false;
helper.pushChild(key);
return true;
});
updaters.add(helper -> helper.pushChild(key));
return self();
Expand All @@ -86,15 +85,14 @@ public Builder popVisit() {

public Builder tryEdit(String name, Consumer<CompoundTagEditHelper> function) {
updaters.add(helper -> {
var tag = helper.getTag();
if (!(tag instanceof Map)) return;

var compoundTag = (Map<String, Object>) tag;
if (compoundTag.containsKey(name)) {
helper.pushChild(name);
function.accept(helper);
helper.popChild();
var compoundTag = helper.getCompoundTag();
if (compoundTag == null || !compoundTag.containsKey(name)) {
return;
}

helper.pushChild(name);
function.accept(helper);
helper.popChild();
});
return self();
}
Expand Down
Loading

0 comments on commit 94faef3

Please sign in to comment.