mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 11:25:55 +03:00
185 lines
12 KiB
Diff
185 lines
12 KiB
Diff
--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java
|
|
+++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java
|
|
@@ -53,7 +53,7 @@
|
|
{
|
|
protected static final Set<ResourceLocation> LOCATIONS_BUILTIN_TEXTURES = Sets.newHashSet(new ResourceLocation("blocks/water_flow"), new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/lava_flow"), new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/water_overlay"), new ResourceLocation("blocks/destroy_stage_0"), new ResourceLocation("blocks/destroy_stage_1"), new ResourceLocation("blocks/destroy_stage_2"), new ResourceLocation("blocks/destroy_stage_3"), new ResourceLocation("blocks/destroy_stage_4"), new ResourceLocation("blocks/destroy_stage_5"), new ResourceLocation("blocks/destroy_stage_6"), new ResourceLocation("blocks/destroy_stage_7"), new ResourceLocation("blocks/destroy_stage_8"), new ResourceLocation("blocks/destroy_stage_9"), new ResourceLocation("items/empty_armor_slot_helmet"), new ResourceLocation("items/empty_armor_slot_chestplate"), new ResourceLocation("items/empty_armor_slot_leggings"), new ResourceLocation("items/empty_armor_slot_boots"), new ResourceLocation("items/empty_armor_slot_shield"), new ResourceLocation("blocks/shulker_top_white"), new ResourceLocation("blocks/shulker_top_orange"), new ResourceLocation("blocks/shulker_top_magenta"), new ResourceLocation("blocks/shulker_top_light_blue"), new ResourceLocation("blocks/shulker_top_yellow"), new ResourceLocation("blocks/shulker_top_lime"), new ResourceLocation("blocks/shulker_top_pink"), new ResourceLocation("blocks/shulker_top_gray"), new ResourceLocation("blocks/shulker_top_silver"), new ResourceLocation("blocks/shulker_top_cyan"), new ResourceLocation("blocks/shulker_top_purple"), new ResourceLocation("blocks/shulker_top_blue"), new ResourceLocation("blocks/shulker_top_brown"), new ResourceLocation("blocks/shulker_top_green"), new ResourceLocation("blocks/shulker_top_red"), new ResourceLocation("blocks/shulker_top_black"));
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
- public static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation("builtin/missing", "missing");
|
|
+ protected static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation("builtin/missing", "missing");
|
|
private static final String MISSING_MODEL_MESH = "{ 'textures': { 'particle': 'missingno', 'missingno': 'missingno' }, 'elements': [ { 'from': [ 0, 0, 0 ], 'to': [ 16, 16, 16 ], 'faces': { 'down': { 'uv': [ 0, 0, 16, 16 ], 'cullface': 'down', 'texture': '#missingno' }, 'up': { 'uv': [ 0, 0, 16, 16 ], 'cullface': 'up', 'texture': '#missingno' }, 'north': { 'uv': [ 0, 0, 16, 16 ], 'cullface': 'north', 'texture': '#missingno' }, 'south': { 'uv': [ 0, 0, 16, 16 ], 'cullface': 'south', 'texture': '#missingno' }, 'west': { 'uv': [ 0, 0, 16, 16 ], 'cullface': 'west', 'texture': '#missingno' }, 'east': { 'uv': [ 0, 0, 16, 16 ], 'cullface': 'east', 'texture': '#missingno' } } } ]}".replaceAll("'", "\"");
|
|
private static final Map<String, String> BUILT_IN_MODELS = Maps.<String, String>newHashMap();
|
|
private static final Joiner JOINER = Joiner.on(" -> ");
|
|
@@ -103,6 +103,21 @@
|
|
{
|
|
try
|
|
{
|
|
+ loadBlock(blockstatemapper, block, resourcelocation);
|
|
+ }
|
|
+ catch (Exception exception)
|
|
+ {
|
|
+ LOGGER.warn((String)("Unable to load definition " + resourcelocation), (Throwable)exception);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ protected void loadBlock(BlockStateMapper blockstatemapper, Block block, final ResourceLocation resourcelocation)
|
|
+ {
|
|
+ {
|
|
+ {
|
|
+ {
|
|
ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(resourcelocation);
|
|
Map<IBlockState, ModelResourceLocation> map = blockstatemapper.getVariants(block);
|
|
|
|
@@ -115,7 +130,6 @@
|
|
if (collection1 == null)
|
|
{
|
|
collection1 = Lists.<ModelResourceLocation>newArrayList();
|
|
- this.multipartVariantMap.put(modelblockdefinition, collection1);
|
|
}
|
|
|
|
collection1.addAll(Lists.newArrayList(Iterables.filter(collection, new Predicate<ModelResourceLocation>()
|
|
@@ -125,6 +139,7 @@
|
|
return resourcelocation.equals(p_apply_1_);
|
|
}
|
|
})));
|
|
+ registerMultipartVariant(modelblockdefinition, collection1);
|
|
}
|
|
|
|
for (Entry<IBlockState, ModelResourceLocation> entry : map.entrySet())
|
|
@@ -135,22 +150,18 @@
|
|
{
|
|
try
|
|
{
|
|
- this.variants.put(modelresourcelocation, modelblockdefinition.getVariant(modelresourcelocation.getVariant()));
|
|
+ registerVariant(modelblockdefinition, modelresourcelocation);
|
|
}
|
|
catch (RuntimeException var12)
|
|
{
|
|
if (!modelblockdefinition.hasMultipartData())
|
|
{
|
|
- LOGGER.warn("Unable to load variant: {} from {}", modelresourcelocation.getVariant(), modelresourcelocation);
|
|
+ LOGGER.warn("Unable to load variant: " + modelresourcelocation.getVariant() + " from " + modelresourcelocation, var12);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- catch (Exception exception)
|
|
- {
|
|
- LOGGER.warn("Unable to load definition {}", resourcelocation, exception);
|
|
- }
|
|
}
|
|
}
|
|
}
|
|
@@ -228,7 +239,7 @@
|
|
try
|
|
{
|
|
inputstream = resource.getInputStream();
|
|
- lvt_4_1_ = ModelBlockDefinition.parseFromReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8));
|
|
+ lvt_4_1_ = ModelBlockDefinition.parseFromReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8), location);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
@@ -394,6 +405,7 @@
|
|
|
|
protected void registerVariantNames()
|
|
{
|
|
+ this.variantNames.clear(); // FML clear this to prevent double ups.
|
|
this.variantNames.put(Item.getItemFromBlock(Blocks.STONE), Lists.newArrayList("stone", "granite", "granite_smooth", "diorite", "diorite_smooth", "andesite", "andesite_smooth"));
|
|
this.variantNames.put(Item.getItemFromBlock(Blocks.DIRT), Lists.newArrayList("dirt", "coarse_dirt", "podzol"));
|
|
this.variantNames.put(Item.getItemFromBlock(Blocks.PLANKS), Lists.newArrayList("oak_planks", "spruce_planks", "birch_planks", "jungle_planks", "acacia_planks", "dark_oak_planks"));
|
|
@@ -441,6 +453,10 @@
|
|
this.variantNames.put(Items.OAK_DOOR, Lists.newArrayList("oak_door"));
|
|
this.variantNames.put(Items.BOAT, Lists.newArrayList("oak_boat"));
|
|
this.variantNames.put(Items.TOTEM_OF_UNDYING, Lists.newArrayList("totem"));
|
|
+ for (Entry<net.minecraftforge.registries.IRegistryDelegate<Item>, Set<String>> e : customVariantNames.entrySet())
|
|
+ {
|
|
+ this.variantNames.put(e.getKey().get(), Lists.newArrayList(e.getValue().iterator()));
|
|
+ }
|
|
}
|
|
|
|
protected List<String> getVariantNames(Item stack)
|
|
@@ -457,7 +473,7 @@
|
|
|
|
protected ResourceLocation getItemLocation(String location)
|
|
{
|
|
- ResourceLocation resourcelocation = new ResourceLocation(location);
|
|
+ ResourceLocation resourcelocation = new ResourceLocation(location.replaceAll("#.*", ""));
|
|
return new ResourceLocation(resourcelocation.getResourceDomain(), "item/" + resourcelocation.getResourcePath());
|
|
}
|
|
|
|
@@ -565,7 +581,7 @@
|
|
for (Entry<String, ResourceLocation> entry : this.itemLocations.entrySet())
|
|
{
|
|
ResourceLocation resourcelocation = entry.getValue();
|
|
- ModelResourceLocation modelresourcelocation = new ModelResourceLocation(entry.getKey(), "inventory");
|
|
+ ModelResourceLocation modelresourcelocation = net.minecraftforge.client.model.ModelLoader.getInventoryVariant(entry.getKey());
|
|
ModelBlock modelblock = this.models.get(resourcelocation);
|
|
|
|
if (modelblock != null && modelblock.isResolved())
|
|
@@ -653,6 +669,11 @@
|
|
@Nullable
|
|
private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked)
|
|
{
|
|
+ return bakeModel(modelBlockIn, (net.minecraftforge.common.model.ITransformation)modelRotationIn, uvLocked);
|
|
+ }
|
|
+
|
|
+ protected IBakedModel bakeModel(ModelBlock modelBlockIn, net.minecraftforge.common.model.ITransformation modelRotationIn, boolean uvLocked)
|
|
+ {
|
|
TextureAtlasSprite textureatlassprite = this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName("particle")));
|
|
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn, modelBlockIn.createOverrides())).setTexture(textureatlassprite);
|
|
|
|
@@ -669,13 +690,13 @@
|
|
BlockPartFace blockpartface = blockpart.mapFaces.get(enumfacing);
|
|
TextureAtlasSprite textureatlassprite1 = this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName(blockpartface.texture)));
|
|
|
|
- if (blockpartface.cullFace == null)
|
|
+ if (blockpartface.cullFace == null || !net.minecraftforge.common.model.TRSRTransformation.isInteger(modelRotationIn.getMatrix()))
|
|
{
|
|
simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
|
|
}
|
|
else
|
|
{
|
|
- simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotateFace(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
|
|
+ simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotate(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
|
|
}
|
|
}
|
|
}
|
|
@@ -686,6 +707,11 @@
|
|
|
|
private BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_)
|
|
{
|
|
+ return makeBakedQuad(p_177589_1_, p_177589_2_, p_177589_3_, p_177589_4_, (net.minecraftforge.common.model.ITransformation)p_177589_5_, p_177589_6_);
|
|
+ }
|
|
+
|
|
+ protected BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, net.minecraftforge.common.model.ITransformation p_177589_5_, boolean p_177589_6_)
|
|
+ {
|
|
return this.faceBakery.makeBakedQuad(p_177589_1_.positionFrom, p_177589_1_.positionTo, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.partRotation, p_177589_6_, p_177589_1_.shade);
|
|
}
|
|
|
|
@@ -916,4 +942,23 @@
|
|
MODEL_GENERATED.name = "generation marker";
|
|
MODEL_ENTITY.name = "block entity marker";
|
|
}
|
|
+
|
|
+ protected void registerMultipartVariant(ModelBlockDefinition definition, Collection<ModelResourceLocation> locations)
|
|
+ {
|
|
+ this.multipartVariantMap.put(definition, locations);
|
|
+ }
|
|
+
|
|
+ private static Map<net.minecraftforge.registries.IRegistryDelegate<Item>, Set<String>> customVariantNames = Maps.newHashMap();
|
|
+
|
|
+ public static void registerItemVariants(Item item, ResourceLocation... names)
|
|
+ {
|
|
+ if (!customVariantNames.containsKey(item.delegate))
|
|
+ {
|
|
+ customVariantNames.put(item.delegate, Sets.<String>newHashSet());
|
|
+ }
|
|
+ for(ResourceLocation name : names)
|
|
+ {
|
|
+ customVariantNames.get(item.delegate).add(name.toString());
|
|
+ }
|
|
+ }
|
|
}
|