mirror of
https://github.com/TeamMidnightDust/ThisRocks.git
synced 2025-12-15 10:45:10 +01:00
Fix polymer support in 1.21.4
You can now enjoy This Rocks on vanilla clients again :)
This commit is contained in:
@@ -23,9 +23,9 @@ public class ItemDisplayStickModel extends ConditionalBlockModel {
|
||||
public static void initModels() {
|
||||
for (StickType type : StickType.values()) {
|
||||
var stacks = new ItemStack[3];
|
||||
stacks[0] = ItemDisplayElementUtil.getModel(RocksMain.id("block/small_"+type.name()+"_stick"));
|
||||
stacks[1] = ItemDisplayElementUtil.getModel(RocksMain.id("block/medium_"+type.name()+"_stick"));
|
||||
stacks[2] = ItemDisplayElementUtil.getModel(RocksMain.id("block/large_"+type.name()+"_stick"));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
stacks[i] = ItemDisplayElementUtil.getModel(RocksMain.id("block/"+type.getVariations()[i].getPath()));
|
||||
}
|
||||
models.put(type, stacks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class StarfishItemPolymer extends BlockItem implements PolymerItem {
|
||||
var state = itemStack.getComponents().get(DataComponentTypes.BLOCK_STATE);
|
||||
if (state != null && !state.isEmpty()) {
|
||||
StarfishVariation variation = state.getValue(RocksMain.STARFISH_VARIATION);
|
||||
if (variation != null) return ResourcePackExtras.bridgeModel(polymerId(variation + "_starfish"));
|
||||
if (variation != null) return ResourcePackExtras.bridgeModel(polymerId("item/"+variation + "_starfish"));
|
||||
}
|
||||
return itemStack.get(DataComponentTypes.ITEM_MODEL);
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ public enum RockType {
|
||||
|
||||
public Identifier[] getVariations() {
|
||||
var variations = new Identifier[4];
|
||||
variations[0] = id("tiny_"+name);
|
||||
variations[1] = id("small_"+name);
|
||||
variations[2] = id("medium_"+name);
|
||||
variations[3] = id("large_"+name);
|
||||
variations[0] = id(name+"_tiny");
|
||||
variations[1] = id(name+"_small");
|
||||
variations[2] = id(name+"_medium");
|
||||
variations[3] = id(name+"_large");
|
||||
return variations;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.motschen.rocks.RocksMain.id;
|
||||
|
||||
@@ -32,18 +33,15 @@ public enum StickType {
|
||||
|
||||
public Identifier[] getVariations() {
|
||||
var variations = new Identifier[3];
|
||||
variations[0] = id("small_"+name);
|
||||
variations[1] = id("medium_"+name);
|
||||
variations[2] = id("large_"+name);
|
||||
variations[0] = id(name+"_stick_small");
|
||||
variations[1] = id(name+"_stick_medium");
|
||||
variations[2] = id(name+"_stick_large");
|
||||
return variations;
|
||||
}
|
||||
|
||||
public static StickType fromBlockName(String name) {
|
||||
return Arrays.stream(values()).filter(type -> name
|
||||
.replace("block.rocks.", "")
|
||||
.replace("small_", "")
|
||||
.replace("medium_", "")
|
||||
.replace("large_", "")
|
||||
.equals(type.getName())).findFirst().orElse(StickType.OAK);
|
||||
return Arrays.stream(StickType.values()).filter(woodType -> Objects.equals(woodType.getName(), name
|
||||
.replace("block.rocks.", "").replace("_stick", "")
|
||||
)).findFirst().orElse(StickType.OAK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import eu.pb4.polymer.core.api.item.PolymerItemGroupUtils;
|
||||
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
|
||||
import eu.pb4.polymer.core.api.utils.PolymerSyncUtils;
|
||||
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
||||
import eu.pb4.polymer.resourcepack.extras.api.ResourcePackExtras;
|
||||
import eu.pb4.polymer.virtualentity.api.ElementHolder;
|
||||
import eu.pb4.polymer.virtualentity.api.attachment.BlockBoundAttachment;
|
||||
import eu.pb4.polymer.virtualentity.impl.HolderHolder;
|
||||
@@ -51,6 +52,9 @@ public class PolyUtil {
|
||||
if (PASSABLE_WATERLOGGED_BLOCK == null) SMALL_BLOCK = Blocks.BARRIER.getDefaultState().with(WATERLOGGED, true);
|
||||
|
||||
PolymerResourcePackUtils.addModAssets(MOD_ID);
|
||||
ResourcePackExtras.forDefault().addBridgedModelsFolder(id("block"), id("rocks"));
|
||||
ResourcePackExtras.forDefault().addBridgedModelsFolder(polymerId("block"), polymerId("polymer-rocks"));
|
||||
ResourcePackExtras.forDefault().addBridgedModelsFolder(polymerId("item"), polymerId("polymer-rocks"));
|
||||
|
||||
ItemDisplayNetherGeyserModel.initModels();
|
||||
ItemDisplayOverworldGeyserModel.initModels();
|
||||
|
||||
Reference in New Issue
Block a user