Start changes model loading (early WIP)

This commit is contained in:
Aleksey 2021-05-10 22:21:51 +03:00
parent 807e25c907
commit ce98c5857e
57 changed files with 122 additions and 97 deletions

View file

@ -96,6 +96,10 @@ public class BetterEnd implements ModInitializer {
return String.format("%s:%s", MOD_ID, id);
}
public static boolean isModId(ResourceLocation id) {
return id.getNamespace().equals(MOD_ID);
}
public static boolean isDevEnvironment() {
return FabricLoader.getInstance().isDevelopmentEnvironment();
}

View file

@ -60,7 +60,7 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%glow%", getGlowTexture());

View file

@ -46,7 +46,7 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());

View file

@ -93,7 +93,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}

View file

@ -55,7 +55,7 @@ public class EndPathBlock extends BlockBaseNotFull {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String name = Registry.BLOCK.getKey(this).getPath();
Map<String, String> map = Maps.newHashMap();
map.put("%top%", name + "_top");

View file

@ -17,7 +17,7 @@ public class EndPedestal extends PedestalBlock {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
String name = blockId.getPath();
Map<String, String> textures = new HashMap<String, String>() {

View file

@ -95,7 +95,7 @@ public class EndTerrainBlock extends BlockBase {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String name = Registry.BLOCK.getKey(this).getPath();
Map<String, String> map = Maps.newHashMap();
map.put("%top%", "betterend:block/" + name + "_top");

View file

@ -36,7 +36,7 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String path = "betterend:block/block_petal_colored";
return Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);
}

View file

@ -73,7 +73,7 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
return Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
}

View file

@ -16,7 +16,7 @@ public class PedestalVanilla extends PedestalBlock {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
String name = blockId.getPath().replace("_block", "");
Map<String, String> textures = new HashMap<String, String>() {

View file

@ -74,7 +74,7 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}

View file

@ -12,7 +12,7 @@ public class BarkBlock extends EndPillarBlock {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
}

View file

@ -61,7 +61,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%anvil%", blockId.getPath());

View file

@ -95,7 +95,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
if (block.contains("open")) {
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);

View file

@ -40,7 +40,7 @@ public class EndBookshelfBlock extends BlockBase {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
}

View file

@ -35,7 +35,7 @@ public class EndChainBlock extends ChainBlock implements BlockPatterned, IRender
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());

View file

@ -49,7 +49,7 @@ public class EndChestBlock extends ChestBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String path) {
public String getModelString(String path) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (path.contains("item")) {

View file

@ -32,7 +32,7 @@ public class EndComposterBlock extends ComposterBlock implements BlockPatterned
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String blockName = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);

View file

@ -33,7 +33,7 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String blockName = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {

View file

@ -43,7 +43,7 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String blockId = Registry.BLOCK.getKey(this).getPath();
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, block);

View file

@ -36,7 +36,7 @@ public class EndFenceBlock extends FenceBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -57,7 +57,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%top%", blockId.getPath() + "_top");

View file

@ -36,7 +36,7 @@ public class EndGateBlock extends FenceGateBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("wall")) {

View file

@ -144,7 +144,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());

View file

@ -60,7 +60,7 @@ public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRend
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
}

View file

@ -37,7 +37,7 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockPatterned,
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());

View file

@ -36,7 +36,7 @@ public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements Bl
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("down")) {

View file

@ -78,7 +78,7 @@ public class EndOreBlock extends OreBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}

View file

@ -36,7 +36,7 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture);
}

View file

@ -36,7 +36,7 @@ public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("down")) {

View file

@ -152,7 +152,7 @@ public class EndSignBlock extends SignBlock implements BlockPatterned, ISpetialI
}
@Override
public String getModelPattern(String path) {
public String getModelString(String path) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (path.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, path);

View file

@ -36,7 +36,7 @@ public class EndSlabBlock extends SlabBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());

View file

@ -37,7 +37,7 @@ public class EndStairsBlock extends StairBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("inner")) {

View file

@ -36,7 +36,7 @@ public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatter
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -40,7 +40,7 @@ public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable,
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String name = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {

View file

@ -37,7 +37,7 @@ public class EndWallBlock extends WallBlock implements BlockPatterned {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -36,7 +36,7 @@ public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockPatter
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -104,7 +104,7 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Bo
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
if (block.contains("item")) {
block = block.split("/")[1];
return Patterns.createJson(Patterns.ITEM_BLOCK, block);

View file

@ -341,7 +341,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
String name = blockId.getPath();
Map<String, String> textures = new HashMap<String, String>() {

View file

@ -43,7 +43,7 @@ public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeab
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
}

View file

@ -192,7 +192,7 @@ public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterlogg
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());

View file

@ -68,7 +68,7 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
if (block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);

View file

@ -49,7 +49,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
}
@Override
public String getModelPattern(String block) {
public String getModelString(String block) {
String name = Registry.BLOCK.getKey(this).getPath();
if (block.endsWith("_middle")) {
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");

View file

@ -16,7 +16,7 @@ public class EnchantedPetalItem extends PatternedItem {
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
}
}

View file

@ -12,7 +12,7 @@ public class EndBucketItem extends BucketItem implements Patterned {
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
}
}

View file

@ -11,7 +11,7 @@ public class EndSpawnEggItem extends SpawnEggItem implements Patterned {
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);
}
}

View file

@ -11,7 +11,7 @@ public class PatternedDiscItem extends RecordItem implements Patterned {
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
}
}

View file

@ -10,7 +10,7 @@ public class PatternedItem extends Item implements Patterned {
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createItemGenerated(name);
}
}

View file

@ -26,7 +26,7 @@ public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Pattern
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -135,7 +135,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -11,7 +11,7 @@ public class EndHoeItem extends HoeItem implements Patterned {
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -38,7 +38,7 @@ public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool,
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -34,7 +34,7 @@ public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, P
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -12,7 +12,7 @@ public class EndSwordItem extends SwordItem implements DynamicAttributeTool, Pat
}
@Override
public String getModelPattern(String name) {
public String getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -1,48 +1,68 @@
package ru.betterend.mixin.client;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.betterend.BetterEnd;
import ru.betterend.patterns.Patterned;
import ru.betterend.world.generator.GeneratorOptions;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@Mixin(ModelBakery.class)
public class ModelLoaderMixin {
public abstract class ModelLoaderMixin {
@Final
@Shadow
private ResourceManager resourceManager;
@Final
@Shadow
private Map<ResourceLocation, UnbakedModel> unbakedCache;
@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
public void be_registerModel(ResourceLocation resourceLocation, CallbackInfoReturnable<UnbakedModel> info) {
if (resourceLocation.getNamespace().equals(BetterEnd.MOD_ID)) {
if (resourceLocation instanceof ModelResourceLocation) {
ModelResourceLocation modelId = (ModelResourceLocation) resourceLocation;
String variant = modelId.getVariant();
if (variant.equals("inventory")) {
@Shadow
protected abstract void cacheAndQueueDependencies(ResourceLocation resourceLocation, UnbakedModel unbakedModel);
@Inject(method = "loadModel", at = @At("HEAD"), cancellable = true)
private void be_loadModels(ResourceLocation resourceLocation, CallbackInfo info) {
if (BetterEnd.isModId(resourceLocation) && resourceLocation instanceof ModelResourceLocation) {
ResourceLocation clearLoc = new ResourceLocation(resourceLocation.getNamespace(), resourceLocation.getPath());
ModelResourceLocation modelLoc = (ModelResourceLocation) resourceLocation;
if (Objects.equals(modelLoc.getVariant(), "inventory")) {
ResourceLocation itemModelLoc = new ResourceLocation(resourceLocation.getNamespace(), "models/" + resourceLocation.getPath() + ".json");
if (!resourceManager.hasResource(itemModelLoc)) {
Item item = Registry.ITEM.get(clearLoc);
if (item instanceof Patterned) {
BlockModel model = ((Patterned) item).getItemModel();
ResourceLocation itemLoc = new ResourceLocation(resourceLocation.getNamespace(), "item/" + resourceLocation.getPath());
model.name = itemLoc.toString();
cacheAndQueueDependencies(modelLoc, model);
unbakedCache.put(modelLoc, model);
info.cancel();
}
}
} else {
ResourceLocation blockstateId = new ResourceLocation(resourceLocation.getNamespace(), "blockstates/" + resourceLocation.getPath() + ".json");
if (!resourceManager.hasResource(blockstateId)) {
} else {
System.out.println(modelId.getVariant());
}
}
}
@ -50,10 +70,10 @@ public class ModelLoaderMixin {
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
private void be_loadModelPattern(ResourceLocation id, CallbackInfoReturnable<BlockModel> info) {
if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
if (BetterEnd.isModId(id)) {
ResourceLocation modelId = new ResourceLocation(id.getNamespace(), "models/" + id.getPath() + ".json");
BlockModel model;
try (Resource resource = this.resourceManager.getResource(modelId)) {
try (Resource resource = resourceManager.getResource(modelId)) {
Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8);
model = BlockModel.fromStream(reader);
model.name = id.toString();
@ -66,14 +86,14 @@ public class ModelLoaderMixin {
if (block.isPresent()) {
if (block.get() instanceof Patterned) {
Patterned patterned = (Patterned) block.get();
model = this.be_getModel(data, id, patterned);
model = be_getModel(data, id, patterned);
info.setReturnValue(model);
}
} else {
Optional<Item> item = Registry.ITEM.getOptional(itemId);
if (item.isPresent() && item.get() instanceof Patterned) {
Patterned patterned = (Patterned) item.get();
model = this.be_getModel(data, id, patterned);
model = be_getModel(data, id, patterned);
info.setReturnValue(model);
}
}
@ -85,12 +105,12 @@ public class ModelLoaderMixin {
private BlockModel be_getModel(String[] data, ResourceLocation id, Patterned patterned) {
String pattern;
if (id.getPath().contains("item")) {
pattern = patterned.getModelPattern(id.getPath());
pattern = patterned.getModelString(id.getPath());
} else {
if (data.length > 2) {
pattern = patterned.getModelPattern(data[2]);
pattern = patterned.getModelString(data[2]);
} else {
pattern = patterned.getModelPattern(data[1]);
pattern = patterned.getModelString(data[1]);
}
}
BlockModel model = BlockModel.fromString(pattern);

View file

@ -2,16 +2,13 @@ package ru.betterend.patterns;
import java.io.Reader;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
public interface BlockPatterned extends Patterned {
//BlockModel getBlockModel(BlockState state);
default String getStatesPattern(Reader data) {
return null;
}
default ResourceLocation statePatternId() {
return null;
}
String getStatesPattern(Reader data);
ResourceLocation statePatternId();
@NotNull UnbakedModel getBlockModel(BlockState blockState);
}

View file

@ -1,5 +1,9 @@
package ru.betterend.patterns;
import net.minecraft.client.renderer.block.model.BlockModel;
import org.jetbrains.annotations.NotNull;
public interface Patterned {
String getModelPattern(String name);
String getModelString(String name);
@NotNull BlockModel getItemModel();
}