Start changes model loading (early WIP)
This commit is contained in:
parent
807e25c907
commit
ce98c5857e
57 changed files with 122 additions and 97 deletions
|
@ -96,6 +96,10 @@ public class BetterEnd implements ModInitializer {
|
||||||
return String.format("%s:%s", MOD_ID, id);
|
return String.format("%s:%s", MOD_ID, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isModId(ResourceLocation id) {
|
||||||
|
return id.getNamespace().equals(MOD_ID);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isDevEnvironment() {
|
public static boolean isDevEnvironment() {
|
||||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%glow%", getGlowTexture());
|
map.put("%glow%", getGlowTexture());
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class EndPathBlock extends BlockBaseNotFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String name = Registry.BLOCK.getKey(this).getPath();
|
String name = Registry.BLOCK.getKey(this).getPath();
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%top%", name + "_top");
|
map.put("%top%", name + "_top");
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class EndPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
Map<String, String> textures = new HashMap<String, String>() {
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class EndTerrainBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String name = Registry.BLOCK.getKey(this).getPath();
|
String name = Registry.BLOCK.getKey(this).getPath();
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%top%", "betterend:block/" + name + "_top");
|
map.put("%top%", "betterend:block/" + name + "_top");
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String path = "betterend:block/block_petal_colored";
|
String path = "betterend:block/block_petal_colored";
|
||||||
return Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);
|
return Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
|
return Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class PedestalVanilla extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath().replace("_block", "");
|
String name = blockId.getPath().replace("_block", "");
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
Map<String, String> textures = new HashMap<String, String>() {
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class BarkBlock extends EndPillarBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%anvil%", blockId.getPath());
|
map.put("%anvil%", blockId.getPath());
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||||
if (block.contains("open")) {
|
if (block.contains("open")) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class EndBookshelfBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class EndChainBlock extends ChainBlock implements BlockPatterned, IRender
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class EndChestBlock extends ChestBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String path) {
|
public String getModelString(String path) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (path.contains("item")) {
|
if (path.contains("item")) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class EndComposterBlock extends ComposterBlock implements BlockPatterned
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
String blockName = blockId.getPath();
|
String blockName = blockId.getPath();
|
||||||
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);
|
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
String blockName = blockId.getPath();
|
String blockName = blockId.getPath();
|
||||||
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, block);
|
return Patterns.createJson(Patterns.ITEM_GENERATED, block);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndFenceBlock extends FenceBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%top%", blockId.getPath() + "_top");
|
map.put("%top%", blockId.getPath() + "_top");
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndGateBlock extends FenceGateBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("wall")) {
|
if (block.contains("wall")) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRend
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
|
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockPatterned,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements Bl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("down")) {
|
if (block.contains("down")) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class EndOreBlock extends OreBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||||
return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture);
|
return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("down")) {
|
if (block.contains("down")) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class EndSignBlock extends SignBlock implements BlockPatterned, ISpetialI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String path) {
|
public String getModelString(String path) {
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (path.contains("item")) {
|
if (path.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, path);
|
return Patterns.createJson(Patterns.ITEM_GENERATED, path);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndSlabBlock extends SlabBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class EndStairsBlock extends StairBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("inner")) {
|
if (block.contains("inner")) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
|
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class EndWallBlock extends WallBlock implements BlockPatterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockPatter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Bo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
block = block.split("/")[1];
|
block = block.split("/")[1];
|
||||||
return Patterns.createJson(Patterns.ITEM_BLOCK, block);
|
return Patterns.createJson(Patterns.ITEM_BLOCK, block);
|
||||||
|
|
|
@ -341,7 +341,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
Map<String, String> textures = new HashMap<String, String>() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
|
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||||
if (block.contains("ceil")) {
|
if (block.contains("ceil")) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);
|
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelString(String block) {
|
||||||
String name = Registry.BLOCK.getKey(this).getPath();
|
String name = Registry.BLOCK.getKey(this).getPath();
|
||||||
if (block.endsWith("_middle")) {
|
if (block.endsWith("_middle")) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
|
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class EnchantedPetalItem extends PatternedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
|
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class EndBucketItem extends BucketItem implements Patterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
|
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class EndSpawnEggItem extends SpawnEggItem implements Patterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);
|
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class PatternedDiscItem extends RecordItem implements Patterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
|
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class PatternedItem extends Item implements Patterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createItemGenerated(name);
|
return Patterns.createItemGenerated(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class EndHoeItem extends HoeItem implements Patterned {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, P
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class EndSwordItem extends SwordItem implements DynamicAttributeTool, Pat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,68 @@
|
||||||
package ru.betterend.mixin.client;
|
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.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.client.resources.model.ModelBakery;
|
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.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.Resource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
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.BetterEnd;
|
||||||
import ru.betterend.patterns.Patterned;
|
import ru.betterend.patterns.Patterned;
|
||||||
import ru.betterend.world.generator.GeneratorOptions;
|
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)
|
@Mixin(ModelBakery.class)
|
||||||
public class ModelLoaderMixin {
|
public abstract class ModelLoaderMixin {
|
||||||
@Final
|
@Final
|
||||||
@Shadow
|
@Shadow
|
||||||
private ResourceManager resourceManager;
|
private ResourceManager resourceManager;
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
private Map<ResourceLocation, UnbakedModel> unbakedCache;
|
||||||
|
|
||||||
@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
|
@Shadow
|
||||||
public void be_registerModel(ResourceLocation resourceLocation, CallbackInfoReturnable<UnbakedModel> info) {
|
protected abstract void cacheAndQueueDependencies(ResourceLocation resourceLocation, UnbakedModel unbakedModel);
|
||||||
if (resourceLocation.getNamespace().equals(BetterEnd.MOD_ID)) {
|
|
||||||
if (resourceLocation instanceof ModelResourceLocation) {
|
|
||||||
ModelResourceLocation modelId = (ModelResourceLocation) resourceLocation;
|
|
||||||
String variant = modelId.getVariant();
|
|
||||||
if (variant.equals("inventory")) {
|
|
||||||
|
|
||||||
|
@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 {
|
} else {
|
||||||
System.out.println(modelId.getVariant());
|
ResourceLocation blockstateId = new ResourceLocation(resourceLocation.getNamespace(), "blockstates/" + resourceLocation.getPath() + ".json");
|
||||||
|
if (!resourceManager.hasResource(blockstateId)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +70,10 @@ public class ModelLoaderMixin {
|
||||||
|
|
||||||
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
|
||||||
private void be_loadModelPattern(ResourceLocation id, CallbackInfoReturnable<BlockModel> info) {
|
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");
|
ResourceLocation modelId = new ResourceLocation(id.getNamespace(), "models/" + id.getPath() + ".json");
|
||||||
BlockModel model;
|
BlockModel model;
|
||||||
try (Resource resource = this.resourceManager.getResource(modelId)) {
|
try (Resource resource = resourceManager.getResource(modelId)) {
|
||||||
Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8);
|
Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8);
|
||||||
model = BlockModel.fromStream(reader);
|
model = BlockModel.fromStream(reader);
|
||||||
model.name = id.toString();
|
model.name = id.toString();
|
||||||
|
@ -66,14 +86,14 @@ public class ModelLoaderMixin {
|
||||||
if (block.isPresent()) {
|
if (block.isPresent()) {
|
||||||
if (block.get() instanceof Patterned) {
|
if (block.get() instanceof Patterned) {
|
||||||
Patterned patterned = (Patterned) block.get();
|
Patterned patterned = (Patterned) block.get();
|
||||||
model = this.be_getModel(data, id, patterned);
|
model = be_getModel(data, id, patterned);
|
||||||
info.setReturnValue(model);
|
info.setReturnValue(model);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Optional<Item> item = Registry.ITEM.getOptional(itemId);
|
Optional<Item> item = Registry.ITEM.getOptional(itemId);
|
||||||
if (item.isPresent() && item.get() instanceof Patterned) {
|
if (item.isPresent() && item.get() instanceof Patterned) {
|
||||||
Patterned patterned = (Patterned) item.get();
|
Patterned patterned = (Patterned) item.get();
|
||||||
model = this.be_getModel(data, id, patterned);
|
model = be_getModel(data, id, patterned);
|
||||||
info.setReturnValue(model);
|
info.setReturnValue(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,12 +105,12 @@ public class ModelLoaderMixin {
|
||||||
private BlockModel be_getModel(String[] data, ResourceLocation id, Patterned patterned) {
|
private BlockModel be_getModel(String[] data, ResourceLocation id, Patterned patterned) {
|
||||||
String pattern;
|
String pattern;
|
||||||
if (id.getPath().contains("item")) {
|
if (id.getPath().contains("item")) {
|
||||||
pattern = patterned.getModelPattern(id.getPath());
|
pattern = patterned.getModelString(id.getPath());
|
||||||
} else {
|
} else {
|
||||||
if (data.length > 2) {
|
if (data.length > 2) {
|
||||||
pattern = patterned.getModelPattern(data[2]);
|
pattern = patterned.getModelString(data[2]);
|
||||||
} else {
|
} else {
|
||||||
pattern = patterned.getModelPattern(data[1]);
|
pattern = patterned.getModelString(data[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockModel model = BlockModel.fromString(pattern);
|
BlockModel model = BlockModel.fromString(pattern);
|
||||||
|
|
|
@ -2,16 +2,13 @@ package ru.betterend.patterns;
|
||||||
|
|
||||||
import java.io.Reader;
|
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.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface BlockPatterned extends Patterned {
|
public interface BlockPatterned extends Patterned {
|
||||||
//BlockModel getBlockModel(BlockState state);
|
String getStatesPattern(Reader data);
|
||||||
default String getStatesPattern(Reader data) {
|
ResourceLocation statePatternId();
|
||||||
return null;
|
@NotNull UnbakedModel getBlockModel(BlockState blockState);
|
||||||
}
|
|
||||||
default ResourceLocation statePatternId() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
package ru.betterend.patterns;
|
package ru.betterend.patterns;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface Patterned {
|
public interface Patterned {
|
||||||
String getModelPattern(String name);
|
String getModelString(String name);
|
||||||
|
@NotNull BlockModel getItemModel();
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue