-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdater_1_20_70.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.cloudburstmc.blockstateupdater; | ||
|
||
import org.cloudburstmc.blockstateupdater.util.tagupdater.CompoundTagUpdaterContext; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
public class BlockStateUpdater_1_20_70 implements BlockStateUpdater { | ||
|
||
public static final BlockStateUpdater INSTANCE = new BlockStateUpdater_1_20_70(); | ||
|
||
@Override | ||
public void registerUpdaters(CompoundTagUpdaterContext ctx) { | ||
this.addTypeUpdater(ctx, "minecraft:double_wooden_slab", "wood_type", type -> "minecraft:" + type + "_double_slab"); | ||
this.addTypeUpdater(ctx, "minecraft:leaves", "old_leaf_type", type -> "minecraft:" + type + "_leaves"); | ||
this.addTypeUpdater(ctx, "minecraft:leaves2", "new_leaf_type", type -> "minecraft:" + type + "_leaves"); | ||
this.addTypeUpdater(ctx, "minecraft:wooden_slab", "wood_type", type -> "minecraft:" + type + "_slab"); | ||
|
||
ctx.addUpdater(1, 20, 70) | ||
.match("name", "minecraft:wood") | ||
.edit("states", helper -> { | ||
Map<String, Object> states = helper.getCompoundTag(); | ||
Object bit = states.remove("stripped_bit"); | ||
boolean toggles = bit instanceof Byte && (byte) bit == 1 || bit instanceof Boolean && (boolean) bit; | ||
|
||
String type = (String) states.remove("wood_type"); | ||
helper.getRootTag().put("name", toggles ? "minecraft:stripped_" + type + "_wood" : "minecraft:" + type + "_wood"); | ||
}); | ||
|
||
// Vanilla does not use updater for this block for some reason | ||
ctx.addUpdater(1, 20, 70, false, false) | ||
.match("name", "minecraft:grass") | ||
.edit("name", helper -> helper.replaceWith("name", "minecraft:grass_block")); | ||
} | ||
|
||
private void addTypeUpdater(CompoundTagUpdaterContext context, String identifier, String typeState, Function<String, String> rename) { | ||
context.addUpdater(1, 20, 70) | ||
.match("name", identifier) | ||
.visit("states") | ||
.edit(typeState, helper -> helper.getRootTag().put("name", rename.apply((String) helper.getTag()))) | ||
.remove(typeState); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters