Porting Forge rendering code to 1.13 (#5132)
This commit is contained in:
parent
eac693e785
commit
dde7dccef1
57 changed files with 1186 additions and 775 deletions
|
@ -0,0 +1,58 @@
|
|||
--- a/net/minecraft/client/renderer/BufferBuilder.java
|
||||
+++ b/net/minecraft/client/renderer/BufferBuilder.java
|
||||
@@ -107,7 +107,8 @@
|
||||
|
||||
bitset.set(i1);
|
||||
}
|
||||
-
|
||||
+ this.rawIntBuffer.limit(this.rawIntBuffer.capacity());
|
||||
+ this.rawIntBuffer.position(this.getBufferSize());
|
||||
}
|
||||
|
||||
public BufferBuilder.State getVertexState() {
|
||||
@@ -438,15 +439,15 @@
|
||||
break;
|
||||
case USHORT:
|
||||
case SHORT:
|
||||
- this.byteBuffer.putShort(i, (short)((int)x * 32767 & '\uffff'));
|
||||
- this.byteBuffer.putShort(i + 2, (short)((int)y * 32767 & '\uffff'));
|
||||
- this.byteBuffer.putShort(i + 4, (short)((int)z * 32767 & '\uffff'));
|
||||
+ this.byteBuffer.putShort(i, (short)((int)(x * Short.MAX_VALUE) & 0xFFFF));
|
||||
+ this.byteBuffer.putShort(i + 2, (short)((int)(y * Short.MAX_VALUE) & 0xFFFF));
|
||||
+ this.byteBuffer.putShort(i + 4, (short)((int)(z * Short.MAX_VALUE) & 0xFFFF));
|
||||
break;
|
||||
case UBYTE:
|
||||
case BYTE:
|
||||
- this.byteBuffer.put(i, (byte)((int)x * 127 & 255));
|
||||
- this.byteBuffer.put(i + 1, (byte)((int)y * 127 & 255));
|
||||
- this.byteBuffer.put(i + 2, (byte)((int)z * 127 & 255));
|
||||
+ this.byteBuffer.put(i, (byte)((int)(x * Byte.MAX_VALUE) & 0xFF));
|
||||
+ this.byteBuffer.put(i + 1, (byte)((int)(y * Byte.MAX_VALUE) & 0xFF));
|
||||
+ this.byteBuffer.put(i + 2, (byte)((int)(z * Byte.MAX_VALUE) & 0xFF));
|
||||
}
|
||||
|
||||
this.nextVertexFormatIndex();
|
||||
@@ -521,4 +522,23 @@
|
||||
return this.stateVertexFormat;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ //For some unknown reason Mojang changed the vanilla function to hardcode alpha as 255.... So lets re-add the parameter -.-
|
||||
+ public void putColorRGBA(int index, int red, int green, int blue, int alpha) {
|
||||
+ if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
|
||||
+ this.rawIntBuffer.put(index, alpha << 24 | blue << 16 | green << 8 | red);
|
||||
+ else
|
||||
+ this.rawIntBuffer.put(index, red << 24 | green << 16 | blue << 8 | alpha);
|
||||
}
|
||||
+
|
||||
+ public boolean isColorDisabled() {
|
||||
+ return noColor;
|
||||
+ }
|
||||
+
|
||||
+ public void putBulkData(ByteBuffer buffer) {
|
||||
+ growBuffer(buffer.limit() + this.vertexFormat.getSize());
|
||||
+ this.byteBuffer.position(this.vertexCount * this.vertexFormat.getSize());
|
||||
+ this.byteBuffer.put(buffer);
|
||||
+ this.vertexCount += buffer.limit() / this.vertexFormat.getSize();
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,11 @@
|
|||
--- a/net/minecraft/client/renderer/ItemRenderer.java
|
||||
+++ b/net/minecraft/client/renderer/ItemRenderer.java
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
public ItemRenderer(TextureManager p_i46552_1_, ModelManager p_i46552_2_, ItemColors p_i46552_3_) {
|
||||
this.textureManager = p_i46552_1_;
|
||||
- this.itemModelMesher = new ItemModelMesher(p_i46552_2_);
|
||||
+ this.itemModelMesher = new net.minecraftforge.client.ItemModelMesherForge(p_i46552_2_);
|
||||
|
||||
for(Item item : Item.REGISTRY) {
|
||||
if (!field_195411_c.contains(item)) {
|
|
@ -0,0 +1,48 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/BakedQuad.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/BakedQuad.java
|
||||
@@ -6,13 +6,23 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class BakedQuad {
|
||||
+public class BakedQuad implements net.minecraftforge.client.model.pipeline.IVertexProducer {
|
||||
protected final int[] vertexData;
|
||||
protected final int tintIndex;
|
||||
protected final EnumFacing face;
|
||||
protected final TextureAtlasSprite sprite;
|
||||
|
||||
+ /**
|
||||
+ * @deprecated Use constructor with the format argument.
|
||||
+ */
|
||||
+ @Deprecated
|
||||
public BakedQuad(int[] vertexDataIn, int tintIndexIn, EnumFacing faceIn, TextureAtlasSprite spriteIn) {
|
||||
+ this(vertexDataIn, tintIndexIn, faceIn, spriteIn, true, net.minecraft.client.renderer.vertex.DefaultVertexFormats.BLOCK);
|
||||
+ }
|
||||
+
|
||||
+ public BakedQuad(int[] vertexDataIn, int tintIndexIn, EnumFacing faceIn, TextureAtlasSprite spriteIn, boolean applyDiffuseLighting, net.minecraft.client.renderer.vertex.VertexFormat format) {
|
||||
+ this.format = format;
|
||||
+ this.applyDiffuseLighting = applyDiffuseLighting;
|
||||
this.vertexData = vertexDataIn;
|
||||
this.tintIndex = tintIndexIn;
|
||||
this.face = faceIn;
|
||||
@@ -38,4 +48,20 @@
|
||||
public EnumFacing getFace() {
|
||||
return this.face;
|
||||
}
|
||||
+
|
||||
+ protected final net.minecraft.client.renderer.vertex.VertexFormat format;
|
||||
+ protected final boolean applyDiffuseLighting;
|
||||
+
|
||||
+ @Override
|
||||
+ public void pipe(net.minecraftforge.client.model.pipeline.IVertexConsumer consumer) {
|
||||
+ net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this);
|
||||
}
|
||||
+
|
||||
+ public net.minecraft.client.renderer.vertex.VertexFormat getFormat() {
|
||||
+ return format;
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldApplyDiffuseLighting() {
|
||||
+ return applyDiffuseLighting;
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,88 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/FaceBakery.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/FaceBakery.java
|
||||
@@ -39,18 +39,23 @@
|
||||
};
|
||||
|
||||
public BakedQuad func_199332_a(Vector3f p_199332_1_, Vector3f p_199332_2_, BlockPartFace p_199332_3_, TextureAtlasSprite p_199332_4_, EnumFacing p_199332_5_, ModelRotation p_199332_6_, @Nullable BlockPartRotation p_199332_7_, boolean p_199332_8_, boolean p_199332_9_) {
|
||||
+ return makeBakedQuad(p_199332_1_, p_199332_2_, p_199332_3_, p_199332_4_, p_199332_5_, (net.minecraftforge.common.model.ITransformation)p_199332_6_, p_199332_7_, p_199332_8_, p_199332_9_);
|
||||
+ }
|
||||
+
|
||||
+ public BakedQuad makeBakedQuad(Vector3f p_199332_1_, Vector3f p_199332_2_, BlockPartFace p_199332_3_, TextureAtlasSprite p_199332_4_, EnumFacing p_199332_5_, net.minecraftforge.common.model.ITransformation p_199332_6_, BlockPartRotation p_199332_7_, boolean p_199332_8_, boolean p_199332_9_) {
|
||||
BlockFaceUV blockfaceuv = p_199332_3_.blockFaceUV;
|
||||
if (p_199332_8_) {
|
||||
- blockfaceuv = this.applyUVLock(p_199332_3_.blockFaceUV, p_199332_5_, p_199332_6_);
|
||||
+ blockfaceuv = net.minecraftforge.client.ForgeHooksClient.applyUVLock(p_199332_3_.blockFaceUV, p_199332_5_, p_199332_6_);
|
||||
}
|
||||
|
||||
- int[] aint = this.makeQuadVertexData(blockfaceuv, p_199332_4_, p_199332_5_, this.func_199337_a(p_199332_1_, p_199332_2_), p_199332_6_, p_199332_7_, p_199332_9_);
|
||||
+ int[] aint = this.makeQuadVertexData(blockfaceuv, p_199332_4_, p_199332_5_, this.func_199337_a(p_199332_1_, p_199332_2_), p_199332_6_, p_199332_7_, false);
|
||||
EnumFacing enumfacing = getFacingFromVertexData(aint);
|
||||
if (p_199332_7_ == null) {
|
||||
this.applyFacing(aint, enumfacing);
|
||||
}
|
||||
|
||||
- return new BakedQuad(aint, p_199332_3_.tintIndex, enumfacing, p_199332_4_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, enumfacing);
|
||||
+ return new BakedQuad(aint, p_199332_3_.tintIndex, enumfacing, p_199332_4_, p_199332_9_, net.minecraft.client.renderer.vertex.DefaultVertexFormats.BLOCK);
|
||||
}
|
||||
|
||||
private BlockFaceUV applyUVLock(BlockFaceUV p_188010_1_, EnumFacing p_188010_2_, ModelRotation p_188010_3_) {
|
||||
@@ -58,6 +63,10 @@
|
||||
}
|
||||
|
||||
private int[] makeQuadVertexData(BlockFaceUV uvs, TextureAtlasSprite sprite, EnumFacing orientation, float[] p_188012_4_, ModelRotation rotationIn, @Nullable BlockPartRotation partRotation, boolean shade) {
|
||||
+ return makeQuadVertexData(uvs, sprite, orientation, p_188012_4_, (net.minecraftforge.common.model.ITransformation)rotationIn, partRotation, shade);
|
||||
+ }
|
||||
+
|
||||
+ private int[] makeQuadVertexData(BlockFaceUV uvs, TextureAtlasSprite sprite, EnumFacing orientation, float[] p_188012_4_, net.minecraftforge.common.model.ITransformation rotationIn, BlockPartRotation partRotation, boolean shade) {
|
||||
int[] aint = new int[28];
|
||||
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
@@ -102,12 +111,16 @@
|
||||
}
|
||||
|
||||
private void fillVertexData(int[] p_188015_1_, int p_188015_2_, EnumFacing p_188015_3_, BlockFaceUV p_188015_4_, float[] p_188015_5_, TextureAtlasSprite p_188015_6_, ModelRotation p_188015_7_, @Nullable BlockPartRotation p_188015_8_, boolean p_188015_9_) {
|
||||
- EnumFacing enumfacing = p_188015_7_.rotateFace(p_188015_3_);
|
||||
+ fillVertexData(p_188015_1_, p_188015_2_, p_188015_3_, p_188015_4_, p_188015_5_, p_188015_6_, (net.minecraftforge.common.model.ITransformation)p_188015_7_, p_188015_8_, p_188015_9_);
|
||||
+ }
|
||||
+
|
||||
+ private void fillVertexData(int[] p_188015_1_, int p_188015_2_, EnumFacing p_188015_3_, BlockFaceUV p_188015_4_, float[] p_188015_5_, TextureAtlasSprite p_188015_6_, net.minecraftforge.common.model.ITransformation p_188015_7_, BlockPartRotation p_188015_8_, boolean p_188015_9_) {
|
||||
+ EnumFacing enumfacing = p_188015_7_.rotate(p_188015_3_);
|
||||
int i = p_188015_9_ ? this.getFaceShadeColor(enumfacing) : -1;
|
||||
EnumFaceDirection.VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.getFacing(p_188015_3_).getVertexInformation(p_188015_2_);
|
||||
Vector3f vector3f = new Vector3f(p_188015_5_[enumfacedirection$vertexinformation.xIndex], p_188015_5_[enumfacedirection$vertexinformation.yIndex], p_188015_5_[enumfacedirection$vertexinformation.zIndex]);
|
||||
this.func_199336_a(vector3f, p_188015_8_);
|
||||
- int j = this.func_199335_a(vector3f, p_188015_3_, p_188015_2_, p_188015_7_);
|
||||
+ int j = this.rotateVertex(vector3f, p_188015_3_, p_188015_2_, p_188015_7_);
|
||||
this.func_199333_a(p_188015_1_, j, p_188015_2_, vector3f, i, p_188015_6_, p_188015_4_);
|
||||
}
|
||||
|
||||
@@ -117,8 +130,8 @@
|
||||
p_199333_1_[i + 1] = Float.floatToRawIntBits(p_199333_4_.func_195900_b());
|
||||
p_199333_1_[i + 2] = Float.floatToRawIntBits(p_199333_4_.func_195902_c());
|
||||
p_199333_1_[i + 3] = p_199333_5_;
|
||||
- p_199333_1_[i + 4] = Float.floatToRawIntBits(p_199333_6_.getInterpolatedU((double)p_199333_7_.getVertexU(p_199333_3_)));
|
||||
- p_199333_1_[i + 4 + 1] = Float.floatToRawIntBits(p_199333_6_.getInterpolatedV((double)p_199333_7_.getVertexV(p_199333_3_)));
|
||||
+ p_199333_1_[i + 4] = Float.floatToRawIntBits(p_199333_6_.getInterpolatedU((double)p_199333_7_.getVertexU(p_199333_3_) * .999 + p_199333_7_.getVertexU((p_199333_3_ + 2) % 4) * .001));
|
||||
+ p_199333_1_[i + 4 + 1] = Float.floatToRawIntBits(p_199333_6_.getInterpolatedV((double)p_199333_7_.getVertexV(p_199333_3_) * .999 + p_199333_7_.getVertexV((p_199333_3_ + 2) % 4) * .001));
|
||||
}
|
||||
|
||||
private void func_199336_a(Vector3f p_199336_1_, @Nullable BlockPartRotation p_199336_2_) {
|
||||
@@ -160,11 +173,15 @@
|
||||
}
|
||||
|
||||
public int func_199335_a(Vector3f p_199335_1_, EnumFacing p_199335_2_, int p_199335_3_, ModelRotation p_199335_4_) {
|
||||
+ return rotateVertex(p_199335_1_, p_199335_2_, p_199335_3_, (net.minecraftforge.common.model.ITransformation)p_199335_4_);
|
||||
+ }
|
||||
+
|
||||
+ public int rotateVertex(Vector3f p_199335_1_, EnumFacing p_199335_2_, int p_199335_3_, net.minecraftforge.common.model.ITransformation p_199335_4_) {
|
||||
if (p_199335_4_ == ModelRotation.X0_Y0) {
|
||||
return p_199335_3_;
|
||||
} else {
|
||||
- this.func_199334_a(p_199335_1_, new Vector3f(0.5F, 0.5F, 0.5F), p_199335_4_.func_195820_a(), new Vector3f(1.0F, 1.0F, 1.0F));
|
||||
- return p_199335_4_.rotateVertex(p_199335_2_, p_199335_3_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.transform(p_199335_1_, p_199335_4_.getMatrix());
|
||||
+ return p_199335_4_.rotate(p_199335_2_, p_199335_3_);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/IBakedModel.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/IBakedModel.java
|
||||
@@ -21,7 +21,18 @@
|
||||
|
||||
TextureAtlasSprite getParticleTexture();
|
||||
|
||||
- ItemCameraTransforms getItemCameraTransforms();
|
||||
+ @Deprecated
|
||||
+ default ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
|
||||
|
||||
ItemOverrideList getOverrides();
|
||||
+
|
||||
+ default boolean isAmbientOcclusion(IBlockState state) { return isAmbientOcclusion(); }
|
||||
+
|
||||
+ /*
|
||||
+ * Returns the pair of the model for the given perspective, and the matrix
|
||||
+ * that should be applied to the GL state before rendering it (matrix may be null).
|
||||
+ */
|
||||
+ default org.apache.commons.lang3.tuple.Pair<? extends IBakedModel, javax.vecmath.Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
+ return net.minecraftforge.client.ForgeHooksClient.handlePerspective(this, cameraTransformType);
|
||||
}
|
||||
+}
|
|
@ -0,0 +1,26 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/IUnbakedModel.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/IUnbakedModel.java
|
||||
@@ -8,13 +8,21 @@
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
+import net.minecraftforge.client.model.IModel;
|
||||
+import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public interface IUnbakedModel {
|
||||
+public interface IUnbakedModel extends IModel<IUnbakedModel> {
|
||||
Collection<ResourceLocation> getOverrideLocations();
|
||||
|
||||
Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_);
|
||||
|
||||
+ /**
|
||||
+ * @deprecated Use {@link #bake(Function, Function, IModelState, boolean)}.
|
||||
+ */
|
||||
@Nullable
|
||||
- IBakedModel func_209558_a(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, ModelRotation p_209558_3_, boolean p_209558_4_);
|
||||
+ @Deprecated
|
||||
+ default IBakedModel func_209558_a(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, ModelRotation p_209558_3_, boolean p_209558_4_) {
|
||||
+ return bake(p_209558_1_, p_209558_2_, p_209558_3_, p_209558_4_, net.minecraft.client.renderer.vertex.DefaultVertexFormats.BLOCK);
|
||||
}
|
||||
+}
|
|
@ -0,0 +1,46 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java
|
||||
@@ -12,6 +12,10 @@
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
+/**
|
||||
+ * @deprecated use {@link net.minecraft.client.renderer.block.model.IBakedModel#handlePerspective(TransformType)} instead
|
||||
+ */
|
||||
+@Deprecated
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ItemCameraTransforms {
|
||||
public static final ItemCameraTransforms DEFAULT = new ItemCameraTransforms();
|
||||
@@ -37,6 +41,7 @@
|
||||
this(ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT);
|
||||
}
|
||||
|
||||
+ @Deprecated
|
||||
public ItemCameraTransforms(ItemCameraTransforms transforms) {
|
||||
this.thirdperson_left = transforms.thirdperson_left;
|
||||
this.thirdperson_right = transforms.thirdperson_right;
|
||||
@@ -48,6 +53,7 @@
|
||||
this.fixed = transforms.fixed;
|
||||
}
|
||||
|
||||
+ @Deprecated
|
||||
public ItemCameraTransforms(ItemTransformVec3f thirdperson_leftIn, ItemTransformVec3f thirdperson_rightIn, ItemTransformVec3f firstperson_leftIn, ItemTransformVec3f firstperson_rightIn, ItemTransformVec3f headIn, ItemTransformVec3f guiIn, ItemTransformVec3f groundIn, ItemTransformVec3f fixedIn) {
|
||||
this.thirdperson_left = thirdperson_leftIn;
|
||||
this.thirdperson_right = thirdperson_rightIn;
|
||||
@@ -80,6 +86,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ @Deprecated
|
||||
public ItemTransformVec3f getTransform(ItemCameraTransforms.TransformType type) {
|
||||
switch(type) {
|
||||
case THIRD_PERSON_LEFT_HAND:
|
||||
@@ -136,7 +143,7 @@
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
- public static enum TransformType {
|
||||
+ public static enum TransformType implements net.minecraftforge.common.model.IModelPart {
|
||||
NONE,
|
||||
THIRD_PERSON_LEFT_HAND,
|
||||
THIRD_PERSON_RIGHT_HAND,
|
|
@ -0,0 +1,21 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/ItemOverrideList.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/ItemOverrideList.java
|
||||
@@ -25,7 +25,8 @@
|
||||
this.field_209582_c = Collections.<IBakedModel>emptyList();
|
||||
}
|
||||
|
||||
- public ItemOverrideList(ModelBlock p_i49525_1_, Function<ResourceLocation, IUnbakedModel> p_i49525_2_, Function<ResourceLocation, TextureAtlasSprite> p_i49525_3_, List<ItemOverride> p_i49525_4_) {
|
||||
+ // FORGE: No reason for first param to be limited to ModelBlock
|
||||
+ public ItemOverrideList(IUnbakedModel p_i49525_1_, Function<ResourceLocation, IUnbakedModel> p_i49525_2_, Function<ResourceLocation, TextureAtlasSprite> p_i49525_3_, List<ItemOverride> p_i49525_4_) {
|
||||
this.field_209582_c = (List)p_i49525_4_.stream().<IBakedModel>map((p_209580_3_) -> {
|
||||
IUnbakedModel iunbakedmodel = p_i49525_2_.apply(p_209580_3_.getLocation());
|
||||
return Objects.equals(iunbakedmodel, p_i49525_1_) ? null : iunbakedmodel.func_209558_a(p_i49525_2_, p_i49525_3_, ModelRotation.X0_Y0, false);
|
||||
@@ -56,4 +57,8 @@
|
||||
|
||||
return p_209581_1_;
|
||||
}
|
||||
+
|
||||
+ public com.google.common.collect.ImmutableList<ItemOverride> getOverrides() {
|
||||
+ return com.google.common.collect.ImmutableList.copyOf(overrides);
|
||||
}
|
||||
+}
|
|
@ -0,0 +1,17 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java
|
||||
@@ -12,8 +12,13 @@
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
+/**
|
||||
+ * @deprecated use {@link net.minecraftforge.client.model.IModelState} and {@link net.minecraftforge.client.model.TRSRTransformation}
|
||||
+ */
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class ItemTransformVec3f {
|
||||
+@Deprecated
|
||||
+public class ItemTransformVec3f implements net.minecraftforge.common.model.IModelState {
|
||||
+ public java.util.Optional<net.minecraftforge.common.model.TRSRTransformation> apply(java.util.Optional<? extends net.minecraftforge.common.model.IModelPart> part) { return net.minecraftforge.client.ForgeHooksClient.applyTransform(this, part); }
|
||||
public static final ItemTransformVec3f DEFAULT = new ItemTransformVec3f(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F));
|
||||
public final Vector3f rotation;
|
||||
public final Vector3f translation;
|
|
@ -0,0 +1,85 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/ModelBlock.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/ModelBlock.java
|
||||
@@ -18,6 +18,7 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
+import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
@@ -25,11 +26,13 @@
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
+import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
+
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -79,6 +82,9 @@
|
||||
return this.parent != null;
|
||||
}
|
||||
|
||||
+ @Nullable
|
||||
+ public ResourceLocation getParentLocation() { return parentLocation; }
|
||||
+
|
||||
public boolean isAmbientOcclusion() {
|
||||
return this.hasParent() ? this.parent.isAmbientOcclusion() : this.ambientOcclusion;
|
||||
}
|
||||
@@ -178,14 +184,18 @@
|
||||
return set1;
|
||||
}
|
||||
|
||||
- public IBakedModel func_209558_a(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, ModelRotation p_209558_3_, boolean p_209558_4_) {
|
||||
- return this.func_209565_a(this, p_209558_1_, p_209558_2_, p_209558_3_, p_209558_4_);
|
||||
+ @Override
|
||||
+ public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, net.minecraftforge.common.model.IModelState state, boolean uvlock, VertexFormat format) {
|
||||
+ if (!net.minecraftforge.client.model.Attributes.moreSpecific(format, net.minecraftforge.client.model.Attributes.DEFAULT_BAKED_FORMAT)) {
|
||||
+ throw new IllegalArgumentException("Cannot bake vanilla model to format other than BLOCK");
|
||||
}
|
||||
+ return func_209565_a(this, p_209558_1_, p_209558_2_, state, uvlock);
|
||||
+ }
|
||||
|
||||
- private IBakedModel func_209565_a(ModelBlock p_209565_1_, Function<ResourceLocation, IUnbakedModel> p_209565_2_, Function<ResourceLocation, TextureAtlasSprite> p_209565_3_, ModelRotation p_209565_4_, boolean p_209565_5_) {
|
||||
+ private IBakedModel func_209565_a(ModelBlock p_209565_1_, Function<ResourceLocation, IUnbakedModel> p_209565_2_, Function<ResourceLocation, TextureAtlasSprite> p_209565_3_, net.minecraftforge.common.model.IModelState state, boolean uvlock) {
|
||||
ModelBlock modelblock = this.getRootModel();
|
||||
if (modelblock == ModelBakery.MODEL_GENERATED) {
|
||||
- return field_209571_g.func_209579_a(p_209565_3_, this).func_209565_a(p_209565_1_, p_209565_2_, p_209565_3_, p_209565_4_, p_209565_5_);
|
||||
+ return field_209571_g.func_209579_a(p_209565_3_, this).func_209565_a(p_209565_1_, p_209565_2_, p_209565_3_, state, uvlock);
|
||||
} else if (modelblock == ModelBakery.MODEL_ENTITY) {
|
||||
return new BuiltInModel(this.getAllTransforms(), this.func_209568_a(p_209565_1_, p_209565_2_, p_209565_3_));
|
||||
} else {
|
||||
@@ -197,9 +207,10 @@
|
||||
BlockPartFace blockpartface = blockpart.mapFaces.get(enumfacing);
|
||||
TextureAtlasSprite textureatlassprite1 = p_209565_3_.apply(new ResourceLocation(this.resolveTextureName(blockpartface.texture)));
|
||||
if (blockpartface.cullFace == null) {
|
||||
- simplebakedmodel$builder.addGeneralQuad(func_209567_a(blockpart, blockpartface, textureatlassprite1, enumfacing, p_209565_4_, p_209565_5_));
|
||||
+ simplebakedmodel$builder.addGeneralQuad(makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, state, uvlock));
|
||||
} else {
|
||||
- simplebakedmodel$builder.addFaceQuad(p_209565_4_.rotateFace(blockpartface.cullFace), func_209567_a(blockpart, blockpartface, textureatlassprite1, enumfacing, p_209565_4_, p_209565_5_));
|
||||
+
|
||||
+ simplebakedmodel$builder.addFaceQuad(state.apply(Optional.empty()).map(trsr -> trsr.rotate(enumfacing)).orElse(enumfacing), makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, state, uvlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,9 +220,13 @@
|
||||
}
|
||||
|
||||
private static BakedQuad func_209567_a(BlockPart p_209567_0_, BlockPartFace p_209567_1_, TextureAtlasSprite p_209567_2_, EnumFacing p_209567_3_, ModelRotation p_209567_4_, boolean p_209567_5_) {
|
||||
- return field_209572_h.func_199332_a(p_209567_0_.positionFrom, p_209567_0_.positionTo, p_209567_1_, p_209567_2_, p_209567_3_, p_209567_4_, p_209567_0_.partRotation, p_209567_5_, p_209567_0_.shade);
|
||||
+ return makeBakedQuad(p_209567_0_, p_209567_1_, p_209567_2_, p_209567_3_, (net.minecraftforge.common.model.IModelState) p_209567_4_, p_209567_5_);
|
||||
}
|
||||
|
||||
+ public static BakedQuad makeBakedQuad(BlockPart p_209567_0_, BlockPartFace p_209567_1_, TextureAtlasSprite p_209567_2_, EnumFacing p_209567_3_, net.minecraftforge.common.model.IModelState p_209567_4_, boolean p_209567_5_) {
|
||||
+ return field_209572_h.makeBakedQuad(p_209567_0_.positionFrom, p_209567_0_.positionTo, p_209567_1_, p_209567_2_, p_209567_3_, p_209567_4_.apply(Optional.empty()).orElse(net.minecraftforge.common.model.TRSRTransformation.identity()), p_209567_0_.partRotation, p_209567_5_, p_209567_0_.shade);
|
||||
+ }
|
||||
+
|
||||
public boolean isTexturePresent(String textureName) {
|
||||
return !MissingTextureSprite.func_195677_a().func_195668_m().toString().equals(this.resolveTextureName(textureName));
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/ModelRotation.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/ModelRotation.java
|
||||
@@ -10,9 +10,10 @@
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
+import net.minecraftforge.client.model.IModel;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public enum ModelRotation {
|
||||
+public enum ModelRotation implements net.minecraftforge.common.model.IModelState, net.minecraftforge.common.model.ITransformation {
|
||||
X0_Y0(0, 0),
|
||||
X0_Y90(0, 90),
|
||||
X0_Y180(0, 180),
|
||||
@@ -97,4 +98,9 @@
|
||||
public static ModelRotation getModelRotation(int x, int y) {
|
||||
return MAP_ROTATIONS.get(combineXY(MathHelper.normalizeAngle(x, 360), MathHelper.normalizeAngle(y, 360)));
|
||||
}
|
||||
+
|
||||
+ public java.util.Optional<net.minecraftforge.common.model.TRSRTransformation> apply(java.util.Optional<? extends net.minecraftforge.common.model.IModelPart> part) { return net.minecraftforge.client.ForgeHooksClient.applyTransform(this, part); }
|
||||
+ public javax.vecmath.Matrix4f getMatrix() { return net.minecraftforge.common.model.TRSRTransformation.from(this).getMatrix(); }
|
||||
+ public EnumFacing rotate(EnumFacing facing) { return rotateFace(facing); }
|
||||
+ public int rotate(EnumFacing facing, int vertexIndex) { return rotateVertex(facing, vertexIndex); }
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/Variant.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/Variant.java
|
||||
@@ -12,7 +12,7 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class Variant {
|
||||
+public class Variant implements net.minecraftforge.client.model.ISmartVariant {
|
||||
private final ResourceLocation modelLocation;
|
||||
private final ModelRotation rotation;
|
||||
private final boolean uvLock;
|
||||
@@ -29,10 +29,15 @@
|
||||
return this.modelLocation;
|
||||
}
|
||||
|
||||
+ @Deprecated
|
||||
public ModelRotation getRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
+ public net.minecraftforge.common.model.IModelState getState() {
|
||||
+ return this.rotation;
|
||||
+ }
|
||||
+
|
||||
public boolean isUvLock() {
|
||||
return this.uvLock;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/VariantList.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/VariantList.java
|
||||
@@ -56,14 +56,15 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- public IBakedModel func_209558_a(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, ModelRotation p_209558_3_, boolean p_209558_4_) {
|
||||
+ @Override
|
||||
+ public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, net.minecraftforge.common.model.IModelState p_209558_3_, boolean p_209558_4_, net.minecraft.client.renderer.vertex.VertexFormat format) {
|
||||
if (this.getVariantList().isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder();
|
||||
|
||||
for(Variant variant : this.getVariantList()) {
|
||||
- IBakedModel ibakedmodel = (p_209558_1_.apply(variant.getModelLocation())).func_209558_a(p_209558_1_, p_209558_2_, variant.getRotation(), variant.isUvLock());
|
||||
+ IBakedModel ibakedmodel = (p_209558_1_.apply(variant.getModelLocation())).bake(p_209558_1_, p_209558_2_, variant.getState(), variant.isUvLock(), format);
|
||||
weightedbakedmodel$builder.add(ibakedmodel, variant.getWeight());
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
--- a/net/minecraft/client/renderer/block/model/multipart/Multipart.java
|
||||
+++ b/net/minecraft/client/renderer/block/model/multipart/Multipart.java
|
||||
@@ -81,11 +81,12 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- public IBakedModel func_209558_a(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, ModelRotation p_209558_3_, boolean p_209558_4_) {
|
||||
+ @Override
|
||||
+ public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, net.minecraftforge.common.model.IModelState p_209558_3_, boolean p_209558_4_, net.minecraft.client.renderer.vertex.VertexFormat format) {
|
||||
MultipartBakedModel.Builder multipartbakedmodel$builder = new MultipartBakedModel.Builder();
|
||||
|
||||
for(Selector selector : this.getSelectors()) {
|
||||
- IBakedModel ibakedmodel = selector.getVariantList().func_209558_a(p_209558_1_, p_209558_2_, p_209558_3_, p_209558_4_);
|
||||
+ IBakedModel ibakedmodel = selector.getVariantList().bake(p_209558_1_, p_209558_2_, p_209558_3_, p_209558_4_, format);
|
||||
if (ibakedmodel != null) {
|
||||
multipartbakedmodel$builder.putModel(selector.getPredicate(this.stateContainer), ibakedmodel);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java
|
||||
+++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java
|
||||
@@ -439,4 +439,10 @@
|
||||
public void func_195663_q() {
|
||||
this.func_195659_d(0);
|
||||
}
|
||||
+
|
||||
+ // Forge Start
|
||||
+
|
||||
+ public int getPixelRGBA(int frameIndex, int x, int y) {
|
||||
+ return this.field_195670_c[frameIndex].func_195709_a(x + this.field_195671_d[frameIndex] * this.width, y + this.field_195672_e[frameIndex] * this.height);
|
||||
}
|
||||
+}
|
|
@ -0,0 +1,11 @@
|
|||
--- a/net/minecraft/client/renderer/tileentity/TileEntityRenderer.java
|
||||
+++ b/net/minecraft/client/renderer/tileentity/TileEntityRenderer.java
|
||||
@@ -63,6 +63,8 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, net.minecraft.client.renderer.BufferBuilder buffer) {}
|
||||
+
|
||||
protected void drawNameplate(T te, String str, double x, double y, double z, int maxDistance) {
|
||||
Entity entity = this.rendererDispatcher.entity;
|
||||
double d0 = te.getDistanceSq(entity.posX, entity.posY, entity.posZ);
|
|
@ -39,12 +39,12 @@ import net.minecraft.client.renderer.texture.DynamicTexture;
|
|||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexBuffer;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
|||
public CloudRenderer()
|
||||
{
|
||||
// Resource manager should always be reloadable.
|
||||
((IReloadableResourceManager) mc.getResourceManager()).registerReloadListener(this);
|
||||
((IReloadableResourceManager) mc.func_195551_G()).func_199006_a(this);
|
||||
}
|
||||
|
||||
private int getScale()
|
||||
|
@ -345,24 +345,14 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
|||
float g = (float) color.y;
|
||||
float b = (float) color.z;
|
||||
|
||||
if (mc.gameSettings.anaglyph)
|
||||
{
|
||||
float tempR = r * 0.3F + g * 0.59F + b * 0.11F;
|
||||
float tempG = r * 0.3F + g * 0.7F;
|
||||
float tempB = r * 0.3F + b * 0.7F;
|
||||
r = tempR;
|
||||
g = tempG;
|
||||
b = tempB;
|
||||
}
|
||||
|
||||
if (COLOR_TEX == null)
|
||||
COLOR_TEX = new DynamicTexture(1, 1);
|
||||
COLOR_TEX = new DynamicTexture(1, 1, false);
|
||||
|
||||
// Apply a color multiplier through a texture upload if shaders aren't supported.
|
||||
COLOR_TEX.getTextureData()[0] = 255 << 24
|
||||
COLOR_TEX.func_195414_e().func_195700_a(0, 0, 255 << 24
|
||||
| ((int) (r * 255)) << 16
|
||||
| ((int) (g * 255)) << 8
|
||||
| (int) (b * 255);
|
||||
| (int) (b * 255));
|
||||
COLOR_TEX.updateDynamicTexture();
|
||||
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
|
@ -404,22 +394,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
|||
GlStateManager.callList(displayList);
|
||||
|
||||
// Full render.
|
||||
if (!mc.gameSettings.anaglyph)
|
||||
{
|
||||
GlStateManager.colorMask(true, true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (EntityRenderer.anaglyphField)
|
||||
{
|
||||
case 0:
|
||||
GlStateManager.colorMask(false, true, true, true);
|
||||
break;
|
||||
case 1:
|
||||
GlStateManager.colorMask(true, false, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Wireframe for debug.
|
||||
if (WIREFRAME)
|
||||
|
|
|
@ -67,6 +67,7 @@ import net.minecraft.client.renderer.block.model.ModelRotation;
|
|||
import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
@ -97,6 +98,7 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
|
@ -146,7 +148,7 @@ public class ForgeHooksClient
|
|||
//Optifine Helper Functions u.u, these are here specifically for Optifine
|
||||
//Note: When using Optifine, these methods are invoked using reflection, which
|
||||
//incurs a major performance penalty.
|
||||
public static void orientBedCamera(IBlockAccess world, BlockPos pos, IBlockState state, Entity entity)
|
||||
public static void orientBedCamera(IWorldReader world, BlockPos pos, IBlockState state, Entity entity)
|
||||
{
|
||||
Block block = state.getBlock();
|
||||
|
||||
|
@ -519,17 +521,17 @@ public class ForgeHooksClient
|
|||
}
|
||||
}
|
||||
|
||||
public static void transform(org.lwjgl.util.vector.Vector3f vec, Matrix4f m)
|
||||
public static void transform(net.minecraft.client.renderer.Vector3f vec, Matrix4f m)
|
||||
{
|
||||
Vector4f tmp = new Vector4f(vec.x, vec.y, vec.z, 1f);
|
||||
Vector4f tmp = new Vector4f(vec.func_195899_a(), vec.func_195900_b(), vec.func_195902_c(), 1f);
|
||||
m.transform(tmp);
|
||||
if(Math.abs(tmp.w - 1f) > 1e-5) tmp.scale(1f / tmp.w);
|
||||
vec.set(tmp.x, tmp.y, tmp.z);
|
||||
vec.func_195905_a(tmp.x, tmp.y, tmp.z);
|
||||
}
|
||||
|
||||
public static Matrix4f getMatrix(ModelRotation modelRotation)
|
||||
{
|
||||
Matrix4f ret = new Matrix4f(TRSRTransformation.toVecmath(modelRotation.getMatrix4d())), tmp = new Matrix4f();
|
||||
Matrix4f ret = new Matrix4f(TRSRTransformation.toVecmath(modelRotation.func_195820_a()), new Vector3f(), 1), tmp = new Matrix4f();
|
||||
tmp.setIdentity();
|
||||
tmp.m03 = tmp.m13 = tmp.m23 = .5f;
|
||||
ret.mul(tmp, ret);
|
||||
|
|
|
@ -21,12 +21,11 @@ package net.minecraftforge.client;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
|
@ -36,16 +35,13 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Wrapper around ItemModeMesher that cleans up the internal maps to respect ID remapping.
|
||||
*/
|
||||
public class ItemModelMesherForge extends ItemModelMesher
|
||||
{
|
||||
final Map<IRegistryDelegate<Item>, Int2ObjectMap<ModelResourceLocation>> locations = Maps.newHashMap();
|
||||
final Map<IRegistryDelegate<Item>, Int2ObjectMap<IBakedModel>> models = Maps.newHashMap();
|
||||
final Map<IRegistryDelegate<Item>, ModelResourceLocation> locations = Maps.newHashMap();
|
||||
final Map<IRegistryDelegate<Item>, IBakedModel> models = Maps.newHashMap();
|
||||
|
||||
public ItemModelMesherForge(ModelManager manager)
|
||||
{
|
||||
|
@ -54,74 +50,32 @@ public class ItemModelMesherForge extends ItemModelMesher
|
|||
|
||||
@Override
|
||||
@Nullable
|
||||
protected IBakedModel getItemModel(Item item, int meta)
|
||||
public IBakedModel func_199312_b(Item item)
|
||||
{
|
||||
Int2ObjectMap<IBakedModel> map = models.get(item.delegate);
|
||||
return map == null ? null : map.get(meta);
|
||||
return models.get(item.delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Item item, int meta, ModelResourceLocation location)
|
||||
public void func_199311_a(Item item, ModelResourceLocation location)
|
||||
{
|
||||
IRegistryDelegate<Item> key = item.delegate;
|
||||
Int2ObjectMap<ModelResourceLocation> locs = locations.get(key);
|
||||
Int2ObjectMap<IBakedModel> mods = models.get(key);
|
||||
if (locs == null)
|
||||
{
|
||||
locs = new Int2ObjectOpenHashMap<>();
|
||||
locations.put(key, locs);
|
||||
}
|
||||
if (mods == null)
|
||||
{
|
||||
mods = new Int2ObjectOpenHashMap<>();
|
||||
models.put(key, mods);
|
||||
}
|
||||
locs.put(meta, location);
|
||||
mods.put(meta, getModelManager().getModel(location));
|
||||
locations.put(key, location);
|
||||
models.put(key, getModelManager().getModel(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebuildCache()
|
||||
{
|
||||
final ModelManager manager = this.getModelManager();
|
||||
for (Map.Entry<IRegistryDelegate<Item>, Int2ObjectMap<ModelResourceLocation>> e : locations.entrySet())
|
||||
for (Map.Entry<IRegistryDelegate<Item>, ModelResourceLocation> e : locations.entrySet())
|
||||
{
|
||||
Int2ObjectMap<IBakedModel> mods = models.get(e.getKey());
|
||||
if (mods != null)
|
||||
{
|
||||
mods.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
mods = new Int2ObjectOpenHashMap<>();
|
||||
models.put(e.getKey(), mods);
|
||||
}
|
||||
final Int2ObjectMap<IBakedModel> map = mods;
|
||||
e.getValue().int2ObjectEntrySet().forEach(entry ->
|
||||
map.put(entry.getIntKey(), manager.getModel(entry.getValue()))
|
||||
);
|
||||
models.put(e.getKey(), manager.getModel(e.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public ModelResourceLocation getLocation(@Nonnull ItemStack stack)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
ModelResourceLocation location = null;
|
||||
|
||||
Int2ObjectMap<ModelResourceLocation> map = locations.get(item.delegate);
|
||||
if (map != null)
|
||||
{
|
||||
location = map.get(getMetadata(stack));
|
||||
}
|
||||
|
||||
if (location == null)
|
||||
{
|
||||
ItemMeshDefinition definition = shapers.get(item);
|
||||
if (definition != null)
|
||||
{
|
||||
location = definition.getModelLocation(stack);
|
||||
}
|
||||
}
|
||||
ModelResourceLocation location = locations.get(stack.getItem().delegate);
|
||||
|
||||
if (location == null)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.annotation.Nullable;
|
|||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -66,7 +67,7 @@ public class BakedItemModel implements IBakedModel
|
|||
@Override public ItemOverrideList getOverrides() { return overrides; }
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
if (side == null)
|
||||
{
|
||||
|
@ -104,7 +105,7 @@ public class BakedItemModel implements IBakedModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a (@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
if(side == null)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ package net.minecraftforge.client.model;
|
|||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
@ -42,9 +43,9 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
return originalModel.getQuads(state, side, rand);
|
||||
return originalModel.func_200117_a(state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
|
@ -37,9 +38,10 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -56,6 +58,9 @@ public class BlockStateLoader
|
|||
.registerTypeAdapter(ForgeBlockStateV1.Variant.class, ForgeBlockStateV1.Variant.Deserializer.INSTANCE)
|
||||
.registerTypeAdapter(TRSRTransformation.class, ForgeBlockStateV1.TRSRDeserializer.INSTANCE)
|
||||
.create();
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Loads a BlockStates json file.
|
||||
* Will attempt to parse it as a Forge Enhanced version if possible.
|
||||
|
@ -172,13 +177,12 @@ public class BlockStateLoader
|
|||
this.gui3d = gui3d;
|
||||
}
|
||||
|
||||
private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, boolean uvlock, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
|
||||
private IUnbakedModel runModelHooks(IUnbakedModel base, boolean smooth, boolean gui3d, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
|
||||
{
|
||||
base = base.process(customData);
|
||||
base = base.retexture(textureMap);
|
||||
base = base.smoothLighting(smooth);
|
||||
base = base.gui3d(gui3d);
|
||||
base = base.uvlock(uvlock);
|
||||
return base;
|
||||
}
|
||||
|
||||
|
@ -186,7 +190,7 @@ public class BlockStateLoader
|
|||
* Used to replace the base model with a re-textured model containing sub-models.
|
||||
*/
|
||||
@Override
|
||||
public IModel process(IModel base)
|
||||
public IUnbakedModel process(IUnbakedModel base)
|
||||
{
|
||||
int size = parts.size();
|
||||
// FIXME: should missing base be handled this way?
|
||||
|
@ -194,22 +198,22 @@ public class BlockStateLoader
|
|||
|
||||
if (hasBase)
|
||||
{
|
||||
base = runModelHooks(base, smooth, gui3d, this.isUvLock(), textures, customData);
|
||||
base = runModelHooks(base, smooth, gui3d, textures, customData);
|
||||
|
||||
if (size <= 0)
|
||||
return base;
|
||||
}
|
||||
|
||||
ImmutableMap.Builder<String, Pair<IModel, IModelState>> models = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<String, Pair<IUnbakedModel, IModelState>> models = ImmutableMap.builder();
|
||||
for (Entry<String, SubModel> entry : parts.entrySet())
|
||||
{
|
||||
SubModel part = entry.getValue();
|
||||
|
||||
final ResourceLocation modelLocation = part.getModelLocation();
|
||||
final IModel model;
|
||||
final IUnbakedModel model;
|
||||
if (modelLocation == null)
|
||||
{
|
||||
FMLLog.log.error("model not found for variant {} for blockstate {}", entry.getKey(), blockstateLocation);
|
||||
LOGGER.error("model not found for variant {} for blockstate {}", entry.getKey(), blockstateLocation);
|
||||
model = ModelLoaderRegistry.getMissingModel(blockstateLocation, new Throwable());
|
||||
}
|
||||
else
|
||||
|
@ -217,7 +221,7 @@ public class BlockStateLoader
|
|||
model = ModelLoaderRegistry.getModelOrLogError(modelLocation, "Unable to load block sub-model: \'" + modelLocation);
|
||||
}
|
||||
|
||||
models.put(entry.getKey(), Pair.of(runModelHooks(model, part.smooth, part.gui3d, part.uvLock, part.getTextures(), part.getCustomData()), part.getState()));
|
||||
models.put(entry.getKey(), Pair.of(runModelHooks(model, part.smooth, part.gui3d, part.getTextures(), part.getCustomData()), part.getState()));
|
||||
}
|
||||
|
||||
return new MultiModel(getModelLocation(), hasBase ? base : null, models.build());
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -46,9 +47,12 @@ import javax.vecmath.Matrix4f;
|
|||
import javax.vecmath.Quat4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
final class FancyMissingModel implements IModel
|
||||
final class FancyMissingModel implements IUnbakedModel
|
||||
{
|
||||
private static final ResourceLocation font = new ResourceLocation("minecraft", "textures/font/ascii.png");
|
||||
private static final ResourceLocation font2 = new ResourceLocation("minecraft", "font/ascii");
|
||||
|
@ -70,37 +74,43 @@ final class FancyMissingModel implements IModel
|
|||
false,
|
||||
m,
|
||||
format
|
||||
) {
|
||||
) {/* TODO Implement once SimpleModelFontRenderer is fixed
|
||||
@Override
|
||||
protected float renderUnicodeChar(char c, boolean italic)
|
||||
{
|
||||
return super.renderDefaultChar(126, italic);
|
||||
}
|
||||
};
|
||||
*/};
|
||||
}
|
||||
});
|
||||
|
||||
private final IModel missingModel;
|
||||
private final IUnbakedModel missingModel;
|
||||
private final String message;
|
||||
|
||||
public FancyMissingModel(IModel missingModel, String message)
|
||||
public FancyMissingModel(IUnbakedModel missingModel, String message)
|
||||
{
|
||||
this.missingModel = missingModel;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
return ImmutableList.of(font2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
IBakedModel bigMissing = missingModel.bake(state, format, bakedTextureGetter);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
IBakedModel bigMissing = missingModel.bake(modelGetter, bakedTextureGetter, state, uvlock, format);
|
||||
IModelState smallState = new ModelStateComposition(state, smallTransformation);
|
||||
IBakedModel smallMissing = missingModel.bake(smallState, format, bakedTextureGetter);
|
||||
IBakedModel smallMissing = missingModel.bake(modelGetter, bakedTextureGetter, smallState, uvlock, format);
|
||||
return new BakedModel(bigMissing, smallMissing, fontCache.getUnchecked(format), message, bakedTextureGetter.apply(font2));
|
||||
}
|
||||
|
||||
|
@ -135,7 +145,7 @@ final class FancyMissingModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
if (side == null)
|
||||
{
|
||||
|
@ -151,16 +161,16 @@ final class FancyMissingModel implements IModel
|
|||
}
|
||||
for (int y = 0; y < splitLines.size(); y++)
|
||||
{
|
||||
fontRenderer.drawString(splitLines.get(y), 0, (int)((y - splitLines.size() / 2f) * fontRenderer.FONT_HEIGHT) + 0x40, 0xFF00FFFF);
|
||||
fontRenderer.func_211126_b(splitLines.get(y), 0, ((y - splitLines.size() / 2f) * fontRenderer.FONT_HEIGHT) + 0x40, 0xFF00FFFF);
|
||||
}
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
builder.addAll(missingModel.getQuads(state, side, rand));
|
||||
builder.addAll(missingModel.func_200117_a (state, side, rand));
|
||||
builder.addAll(fontRenderer.build());
|
||||
quads = builder.build();
|
||||
}
|
||||
return quads;
|
||||
}
|
||||
return missingModel.getQuads(state, side, rand);
|
||||
return missingModel.func_200117_a (state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.function.Predicate;
|
|||
import net.minecraftforge.client.resource.IResourceType;
|
||||
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.client.resource.VanillaResourceType;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
@ -50,5 +51,5 @@ public interface ICustomModelLoader extends ISelectiveResourceReloadListener
|
|||
/*
|
||||
* loads (or reloads) specified model
|
||||
*/
|
||||
IModel loadModel(ResourceLocation modelLocation) throws Exception;
|
||||
IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception;
|
||||
}
|
||||
|
|
|
@ -19,18 +19,19 @@
|
|||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
import java.util.function.Function;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.model.animation.IClip;
|
||||
|
||||
|
@ -38,35 +39,11 @@ import net.minecraftforge.common.model.animation.IClip;
|
|||
* Interface for models that can be baked
|
||||
* (possibly to different vertex formats and with different state).
|
||||
*/
|
||||
public interface IModel
|
||||
@SuppressWarnings("unchecked")
|
||||
public interface IModel<T extends IModel<T>>
|
||||
{
|
||||
/*
|
||||
* Returns all model locations that this model depends on.
|
||||
* Assume that returned collection is immutable.
|
||||
* See ModelLoaderRegistry.getModel for dependency loading.
|
||||
*/
|
||||
default Collection<ResourceLocation> getDependencies() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns all texture locations that this model depends on.
|
||||
* Assume that returned collection is immutable.
|
||||
*/
|
||||
default Collection<ResourceLocation> getTextures() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/*
|
||||
* All model texture coordinates should be resolved at this method.
|
||||
* Returned model should be in the simplest form possible, for performance
|
||||
* reasons (if it's not ISmartBlock/ItemModel - then it should be
|
||||
* represented by List<BakedQuad> internally).
|
||||
* Returned model's getFormat() can me less specific than the passed
|
||||
* format argument (some attributes can be replaced with padding),
|
||||
* if there's no such info in this model.
|
||||
*/
|
||||
IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter);
|
||||
@Nullable
|
||||
IBakedModel bake(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> p_209558_2_, IModelState state, boolean uvlock, VertexFormat format);
|
||||
|
||||
/*
|
||||
* Default state this model will be baked with.
|
||||
|
@ -85,20 +62,16 @@ public interface IModel
|
|||
* If unknown data is encountered it should be skipped.
|
||||
* @return a new model, with data applied.
|
||||
*/
|
||||
default IModel process(ImmutableMap<String, String> customData) {
|
||||
return this;
|
||||
default T process(ImmutableMap<String, String> customData) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
default IModel smoothLighting(boolean value) {
|
||||
return this;
|
||||
default T smoothLighting(boolean value) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
default IModel gui3d(boolean value) {
|
||||
return this;
|
||||
}
|
||||
|
||||
default IModel uvlock(boolean value) {
|
||||
return this;
|
||||
default T gui3d(boolean value) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +91,7 @@ public interface IModel
|
|||
* @param textures New
|
||||
* @return Model with textures applied.
|
||||
*/
|
||||
default IModel retexture(ImmutableMap<String, String> textures) {
|
||||
return this;
|
||||
default T retexture(ImmutableMap<String, String> textures) {
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,11 @@
|
|||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
|
||||
public interface ISmartVariant
|
||||
{
|
||||
IModel process(IModel base);
|
||||
default IUnbakedModel process(IUnbakedModel base) {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,12 @@ import net.minecraftforge.common.ForgeVersion;
|
|||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
|
@ -40,14 +43,16 @@ import net.minecraftforge.common.model.TRSRTransformation;
|
|||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public final class ItemLayerModel implements IModel
|
||||
public final class ItemLayerModel implements IUnbakedModel
|
||||
{
|
||||
public static final ItemLayerModel INSTANCE = new ItemLayerModel(ImmutableList.of());
|
||||
|
||||
|
@ -70,7 +75,7 @@ public final class ItemLayerModel implements IModel
|
|||
|
||||
public ItemLayerModel(ModelBlock model)
|
||||
{
|
||||
this(getTextures(model), model.createOverrides());
|
||||
this(getTextures(model), model.func_209568_a(model, ModelLoader.defaultModelGetter(), ModelLoader.defaultTextureGetter()));
|
||||
}
|
||||
|
||||
private static ImmutableList<ResourceLocation> getTextures(ModelBlock model)
|
||||
|
@ -83,11 +88,19 @@ public final class ItemLayerModel implements IModel
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
@Override
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
return textures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLayerModel retexture(ImmutableMap<String, String> textures)
|
||||
{
|
||||
ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
|
||||
|
@ -106,8 +119,7 @@ public final class ItemLayerModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, final VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
{
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> p_209558_1_, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean p_209558_4_, VertexFormat format) {
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
Optional<TRSRTransformation> transform = state.apply(Optional.empty());
|
||||
for(int i = 0; i < textures.size(); i++)
|
||||
|
@ -132,7 +144,6 @@ public final class ItemLayerModel implements IModel
|
|||
|
||||
for(int f = 0; f < sprite.getFrameCount(); f++)
|
||||
{
|
||||
int[] pixels = sprite.getFrameTextureData(f)[0];
|
||||
boolean ptu;
|
||||
boolean[] ptv = new boolean[uMax];
|
||||
Arrays.fill(ptv, true);
|
||||
|
@ -141,7 +152,7 @@ public final class ItemLayerModel implements IModel
|
|||
ptu = true;
|
||||
for(int u = 0; u < uMax; u++)
|
||||
{
|
||||
int alpha = getAlpha(pixels, uMax, vMax, u, v);
|
||||
int alpha = sprite.getPixelRGBA(f, u, v) >> 24 & 0xFF;
|
||||
boolean t = alpha / 255f <= 0.1f;
|
||||
|
||||
if (!t && alpha < 255)
|
||||
|
@ -328,11 +339,6 @@ public final class ItemLayerModel implements IModel
|
|||
}
|
||||
}
|
||||
|
||||
private static int getAlpha(int[] pixels, int uMax, int vMax, int u, int v)
|
||||
{
|
||||
return pixels[u + (vMax - 1 - v) * uMax] >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
private static BakedQuad buildSideQuad(VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, int tint, TextureAtlasSprite sprite, int u, int v, int size)
|
||||
{
|
||||
final float eps = 1e-2f;
|
||||
|
@ -435,7 +441,7 @@ public final class ItemLayerModel implements IModel
|
|||
break;
|
||||
}
|
||||
case NORMAL:
|
||||
builder.put(e, (float)side.getFrontOffsetX(), (float)side.getFrontOffsetY(), (float)side.getFrontOffsetZ(), 0f);
|
||||
builder.put(e, (float)side.getXOffset(), (float)side.getYOffset(), (float)side.getZOffset(), 0f);
|
||||
break;
|
||||
default:
|
||||
builder.put(e);
|
||||
|
@ -461,7 +467,7 @@ public final class ItemLayerModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation)
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation)
|
||||
{
|
||||
return ItemLayerModel.INSTANCE;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package net.minecraftforge.client.model;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -83,7 +84,6 @@ public final class ItemTextureQuadConverter
|
|||
int h = template.getIconHeight();
|
||||
float wScale = 16f / (float)w;
|
||||
float hScale = 16f / (float)h;
|
||||
int[] data = template.getFrameTextureData(0)[0];
|
||||
List<UnpackedBakedQuad> quads = Lists.newArrayList();
|
||||
|
||||
// the upper left x-position of the current quad
|
||||
|
@ -93,15 +93,15 @@ public final class ItemTextureQuadConverter
|
|||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
// current pixel
|
||||
int pixel = data[y * w + x];
|
||||
boolean isVisible = !template.func_195662_a(0, x, y);
|
||||
|
||||
// no current quad but found a new one
|
||||
if (start < 0 && isVisible(pixel))
|
||||
if (start < 0 && isVisible)
|
||||
{
|
||||
start = x;
|
||||
}
|
||||
// got a current quad, but it ends here
|
||||
if (start >= 0 && !isVisible(pixel))
|
||||
if (start >= 0 && !isVisible)
|
||||
{
|
||||
// we now check if the visibility of the next row matches the one fo the current row
|
||||
// if they are, we can extend the quad downwards
|
||||
|
@ -111,9 +111,7 @@ public final class ItemTextureQuadConverter
|
|||
{
|
||||
for (int i = 0; i < w; i++)
|
||||
{
|
||||
int px1 = data[y * w + i];
|
||||
int px2 = data[endY * w + i];
|
||||
if (isVisible(px1) != isVisible(px2))
|
||||
if (template.func_195662_a(0, i, y) != template.func_195662_a(0, i, endY))
|
||||
{
|
||||
sameRow = false;
|
||||
break;
|
||||
|
@ -164,7 +162,6 @@ public final class ItemTextureQuadConverter
|
|||
int h = template.getIconHeight();
|
||||
float wScale = 16f / (float)w;
|
||||
float hScale = 16f / (float)h;
|
||||
int[] data = template.getFrameTextureData(0)[0];
|
||||
List<UnpackedBakedQuad> quads = Lists.newArrayList();
|
||||
|
||||
// the upper left y-position of the current quad
|
||||
|
@ -174,15 +171,15 @@ public final class ItemTextureQuadConverter
|
|||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
// current pixel
|
||||
int pixel = data[y * w + x];
|
||||
boolean isVisible = !sprite.func_195662_a(0, x, y);
|
||||
|
||||
// no current quad but found a new one
|
||||
if (start < 0 && isVisible(pixel))
|
||||
if (start < 0 && isVisible)
|
||||
{
|
||||
start = y;
|
||||
}
|
||||
// got a current quad, but it ends here
|
||||
if (start >= 0 && !isVisible(pixel))
|
||||
if (start >= 0 && !isVisible)
|
||||
{
|
||||
// we now check if the visibility of the next column matches the one fo the current row
|
||||
// if they are, we can extend the quad downwards
|
||||
|
@ -192,9 +189,7 @@ public final class ItemTextureQuadConverter
|
|||
{
|
||||
for (int i = 0; i < h; i++)
|
||||
{
|
||||
int px1 = data[i * w + x];
|
||||
int px2 = data[i * w + endX];
|
||||
if (isVisible(px1) != isVisible(px2))
|
||||
if (sprite.func_195662_a(0, x, i) != sprite.func_195662_a(0, endX, i))
|
||||
{
|
||||
sameColumn = false;
|
||||
break;
|
||||
|
@ -328,7 +323,7 @@ public final class ItemTextureQuadConverter
|
|||
break;
|
||||
}
|
||||
case NORMAL:
|
||||
builder.put(e, (float) side.getFrontOffsetX(), (float) side.getFrontOffsetY(), (float) side.getFrontOffsetZ(), 0f);
|
||||
builder.put(e, (float) side.getXOffset(), (float) side.getYOffset(), (float) side.getZOffset(), 0f);
|
||||
break;
|
||||
default:
|
||||
builder.put(e);
|
||||
|
|
|
@ -21,6 +21,7 @@ package net.minecraftforge.client.model;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -30,12 +31,16 @@ import javax.vecmath.Quat4f;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.PngSizeInfo;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.data.AnimationMetadataSection;
|
||||
import net.minecraft.client.resources.data.AnimationMetadataSectionSerializer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResource;
|
||||
|
@ -54,8 +59,8 @@ import net.minecraftforge.fluids.FluidUtil;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.minecraftforge.client.model.ModelDynBucket.LoaderDynBucket.getResource;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -65,7 +70,7 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class ModelDynBucket implements IModel
|
||||
public final class ModelDynBucket implements IUnbakedModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final ModelResourceLocation LOCATION = new ModelResourceLocation(new ResourceLocation(ForgeVersion.MOD_ID, "dynbucket"), "inventory");
|
||||
|
@ -76,7 +81,7 @@ public final class ModelDynBucket implements IModel
|
|||
private static final float NORTH_Z_FLUID = 7.498f / 16f;
|
||||
private static final float SOUTH_Z_FLUID = 8.502f / 16f;
|
||||
|
||||
public static final IModel MODEL = new ModelDynBucket();
|
||||
public static final IUnbakedModel MODEL = new ModelDynBucket();
|
||||
|
||||
@Nullable
|
||||
private final ResourceLocation baseLocation;
|
||||
|
@ -106,7 +111,7 @@ public final class ModelDynBucket implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
ImmutableSet.Builder<ResourceLocation> builder = ImmutableSet.builder();
|
||||
|
||||
|
@ -123,8 +128,13 @@ public final class ModelDynBucket implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format,
|
||||
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
|
||||
ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
|
||||
|
@ -144,11 +154,13 @@ public final class ModelDynBucket implements IModel
|
|||
fluidSprite = bakedTextureGetter.apply(fluid.getStill());
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
if (baseLocation != null)
|
||||
{
|
||||
// build base (insidest)
|
||||
IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter);
|
||||
builder.addAll(model.getQuads(null, null, 0));
|
||||
IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(modelGetter, bakedTextureGetter, state, uvlock, format);
|
||||
random.setSeed(42);
|
||||
builder.addAll(model.func_200117_a(null, null, random));
|
||||
particleSprite = model.getParticleTexture();
|
||||
}
|
||||
if (liquidLocation != null && fluidSprite != null)
|
||||
|
@ -243,6 +255,32 @@ public final class ModelDynBucket implements IModel
|
|||
return new ModelDynBucket(base, liquid, cover, fluid, flipGas, tint);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static IResource getResource(ResourceLocation resourceLocation)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Minecraft.getMinecraft().func_195551_G().func_199002_a(resourceLocation);
|
||||
}
|
||||
catch (IOException ignored)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static PngSizeInfo getSizeInfo(IResource resource)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PngSizeInfo(resource);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public enum LoaderDynBucket implements ICustomModelLoader
|
||||
{
|
||||
INSTANCE;
|
||||
|
@ -254,7 +292,7 @@ public final class ModelDynBucket implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation)
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation)
|
||||
{
|
||||
return MODEL;
|
||||
}
|
||||
|
@ -269,31 +307,19 @@ public final class ModelDynBucket implements IModel
|
|||
{
|
||||
// only create these textures if they are not added by a resource pack
|
||||
|
||||
IResource res;
|
||||
if (getResource(new ResourceLocation(ForgeVersion.MOD_ID, "textures/items/bucket_cover.png")) == null)
|
||||
{
|
||||
ResourceLocation bucketCover = new ResourceLocation(ForgeVersion.MOD_ID, "items/bucket_cover");
|
||||
BucketCoverSprite bucketCoverSprite = new BucketCoverSprite(bucketCover);
|
||||
map.setTextureEntry(bucketCoverSprite);
|
||||
BucketCoverSprite bucketCoverSprite = new BucketCoverSprite(getResource(bucketCover));
|
||||
// map.setTextureEntry(bucketCoverSprite);
|
||||
}
|
||||
|
||||
if (getResource(new ResourceLocation(ForgeVersion.MOD_ID, "textures/items/bucket_base.png")) == null)
|
||||
{
|
||||
ResourceLocation bucketBase = new ResourceLocation(ForgeVersion.MOD_ID, "items/bucket_base");
|
||||
BucketBaseSprite bucketBaseSprite = new BucketBaseSprite(bucketBase);
|
||||
map.setTextureEntry(bucketBaseSprite);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static IResource getResource(ResourceLocation resourceLocation)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
||||
}
|
||||
catch (IOException ignored)
|
||||
{
|
||||
return null;
|
||||
BucketBaseSprite bucketBaseSprite = new BucketBaseSprite(getResource(bucketBase));
|
||||
// map.setTextureEntry(bucketBaseSprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,11 +329,12 @@ public final class ModelDynBucket implements IModel
|
|||
private final ResourceLocation bucket = new ResourceLocation("items/bucket_empty");
|
||||
private final ImmutableList<ResourceLocation> dependencies = ImmutableList.of(bucket);
|
||||
|
||||
private BucketBaseSprite(ResourceLocation resourceLocation)
|
||||
private BucketBaseSprite(IResource resource)
|
||||
{
|
||||
super(resourceLocation.toString());
|
||||
super(resource.func_199029_a(), getSizeInfo(resource), resource.func_199028_a(AnimationMetadataSection.field_195817_a));
|
||||
}
|
||||
|
||||
/* TODO Custom TAS
|
||||
@Override
|
||||
public boolean hasCustomLoader(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location)
|
||||
{
|
||||
|
@ -324,13 +351,15 @@ public final class ModelDynBucket implements IModel
|
|||
public boolean load(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location, @Nonnull Function<ResourceLocation, TextureAtlasSprite> textureGetter)
|
||||
{
|
||||
final TextureAtlasSprite sprite = textureGetter.apply(bucket);
|
||||
// TODO custom sprites are gonna be a PITA, these are final
|
||||
width = sprite.getIconWidth();
|
||||
height = sprite.getIconHeight();
|
||||
// TODO No easy way to dump pixels of one sprite into another without n^2 for loop, investigate patch?
|
||||
final int[][] pixels = sprite.getFrameTextureData(0);
|
||||
this.clearFramesTextureData();
|
||||
this.framesTextureData.add(pixels);
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,11 +371,12 @@ public final class ModelDynBucket implements IModel
|
|||
private final ResourceLocation bucketCoverMask = new ResourceLocation(ForgeVersion.MOD_ID, "items/vanilla_bucket_cover_mask");
|
||||
private final ImmutableList<ResourceLocation> dependencies = ImmutableList.of(bucket, bucketCoverMask);
|
||||
|
||||
private BucketCoverSprite(ResourceLocation resourceLocation)
|
||||
private BucketCoverSprite(IResource resource)
|
||||
{
|
||||
super(resourceLocation.toString());
|
||||
super(resource.func_199029_a(), getSizeInfo(resource), resource.func_199028_a(AnimationMetadataSection.field_195817_a));
|
||||
}
|
||||
|
||||
/* TODO Custom TAS
|
||||
@Override
|
||||
public boolean hasCustomLoader(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location)
|
||||
{
|
||||
|
@ -374,7 +404,7 @@ public final class ModelDynBucket implements IModel
|
|||
IResource mask = getResource(new ResourceLocation(ForgeVersion.MOD_ID, "textures/items/vanilla_bucket_cover_mask.png"))
|
||||
) {
|
||||
// use the alpha mask if it fits, otherwise leave the cover texture blank
|
||||
if (empty != null && mask != null && Objects.equals(empty.getResourcePackName(), mask.getResourcePackName()) &&
|
||||
if (empty != null && mask != null && Objects.equals(empty.func_199026_d(), mask.func_199026_d()) &&
|
||||
alphaMask.getIconWidth() == width && alphaMask.getIconHeight() == height)
|
||||
{
|
||||
final int[][] oldPixels = sprite.getFrameTextureData(0);
|
||||
|
@ -398,19 +428,16 @@ public final class ModelDynBucket implements IModel
|
|||
this.clearFramesTextureData();
|
||||
this.framesTextureData.add(pixels);
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private static final class BakedDynBucketOverrideHandler extends ItemOverrideList
|
||||
{
|
||||
public static final BakedDynBucketOverrideHandler INSTANCE = new BakedDynBucketOverrideHandler();
|
||||
private BakedDynBucketOverrideHandler()
|
||||
{
|
||||
super(ImmutableList.of());
|
||||
}
|
||||
private BakedDynBucketOverrideHandler() {}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
public IBakedModel func_209581_a(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
FluidStack fluidStack = FluidUtil.getFluidContained(stack);
|
||||
|
||||
|
@ -428,11 +455,11 @@ public final class ModelDynBucket implements IModel
|
|||
|
||||
if (!model.cache.containsKey(name))
|
||||
{
|
||||
IModel parent = model.parent.process(ImmutableMap.of("fluid", name));
|
||||
IUnbakedModel parent = model.parent.process(ImmutableMap.of("fluid", name));
|
||||
Function<ResourceLocation, TextureAtlasSprite> textureGetter;
|
||||
textureGetter = location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
|
||||
|
||||
IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter);
|
||||
IBakedModel bakedModel = parent.bake(ModelLoader.defaultModelGetter(), textureGetter, new SimpleModelState(model.transforms), false, model.format);
|
||||
model.cache.put(name, bakedModel);
|
||||
return bakedModel;
|
||||
}
|
||||
|
|
|
@ -21,9 +21,12 @@ package net.minecraftforge.client.model;
|
|||
|
||||
import java.util.function.Function;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
@ -32,6 +35,7 @@ import javax.vecmath.Vector4f;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -62,7 +66,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
public final class ModelFluid implements IModel
|
||||
public final class ModelFluid implements IUnbakedModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final ModelFluid WATER = new ModelFluid(FluidRegistry.WATER);
|
||||
|
@ -76,7 +80,7 @@ public final class ModelFluid implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<String> p_209559_2_)
|
||||
{
|
||||
return fluid.getOverlay() != null
|
||||
? ImmutableSet.of(fluid.getStill(), fluid.getFlowing(), fluid.getOverlay())
|
||||
|
@ -84,7 +88,12 @@ public final class ModelFluid implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public Collection<ResourceLocation> getOverrideLocations() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
return new CachingBakedFluid(
|
||||
state.apply(Optional.empty()),
|
||||
|
@ -116,7 +125,7 @@ public final class ModelFluid implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation)
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation)
|
||||
{
|
||||
return WATER;
|
||||
}
|
||||
|
@ -221,7 +230,7 @@ public final class ModelFluid implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
if (side != null && state instanceof IExtendedBlockState)
|
||||
{
|
||||
|
@ -247,10 +256,10 @@ public final class ModelFluid implements IModel
|
|||
key <<= 1;
|
||||
key |= 1;
|
||||
|
||||
return modelCache.getUnchecked(key).getQuads(state, side, rand);
|
||||
return modelCache.getUnchecked(key).func_200117_a(state, side, rand);
|
||||
}
|
||||
|
||||
return super.getQuads(state, side, rand);
|
||||
return super.func_200117_a(state, side, rand);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +451,7 @@ public final class ModelFluid implements IModel
|
|||
break;
|
||||
}
|
||||
case NORMAL:
|
||||
builder.put(e, (float)side.getFrontOffsetX(), (float)side.getFrontOffsetY(), (float)side.getFrontOffsetZ(), 0f);
|
||||
builder.put(e, (float)side.getXOffset(), (float)side.getYOffset(), (float)side.getZOffset(), 0f);
|
||||
break;
|
||||
default:
|
||||
builder.put(e);
|
||||
|
@ -476,7 +485,7 @@ public final class ModelFluid implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
return side == null ? ImmutableList.of() : faceQuads.get(side);
|
||||
}
|
||||
|
|
|
@ -22,12 +22,17 @@ package net.minecraftforge.client.model;
|
|||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -42,7 +47,9 @@ import net.minecraft.client.renderer.block.model.BlockPart;
|
|||
import net.minecraft.client.renderer.block.model.BlockPartFace;
|
||||
import net.minecraft.client.renderer.block.model.BlockPartRotation;
|
||||
import net.minecraft.client.renderer.block.model.BuiltInModel;
|
||||
import net.minecraft.client.renderer.block.model.FaceBakery;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
|
||||
|
@ -50,7 +57,9 @@ import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
|||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition.ContainerHolder;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.block.model.MultipartBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
|
@ -58,12 +67,14 @@ import net.minecraft.client.renderer.block.model.VariantList;
|
|||
import net.minecraft.client.renderer.block.model.WeightedBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Multipart;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Selector;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
|
@ -90,6 +101,7 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
|
@ -115,13 +127,13 @@ import static net.minecraftforge.fml.Logging.MODELLOADING;
|
|||
public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final Map<ModelResourceLocation, IModel> stateModels = Maps.newHashMap();
|
||||
private final Map<ModelResourceLocation, IUnbakedModel> stateModels = Maps.newHashMap();
|
||||
private final Map<ModelResourceLocation, ModelBlockDefinition> multipartDefinitions = Maps.newHashMap();
|
||||
private final Map<ModelBlockDefinition, IModel> multipartModels = Maps.newHashMap();
|
||||
private final Map<ModelBlockDefinition, IUnbakedModel> multipartModels = Maps.newHashMap();
|
||||
// TODO: nothing adds to missingVariants, remove it?
|
||||
private final Set<ModelResourceLocation> missingVariants = Sets.newHashSet();
|
||||
private final Map<ResourceLocation, Exception> loadingExceptions = Maps.newHashMap();
|
||||
private IModel missingModel = null;
|
||||
private IUnbakedModel missingModel = null;
|
||||
|
||||
private boolean isLoading = false;
|
||||
public boolean isLoading()
|
||||
|
@ -129,41 +141,74 @@ public final class ModelLoader extends ModelBakery
|
|||
return isLoading;
|
||||
}
|
||||
|
||||
public ModelLoader(IResourceManager manager, TextureMap map, BlockModelShapes shapes)
|
||||
public ModelLoader(IResourceManager manager, TextureMap map)
|
||||
{
|
||||
super(manager, map, shapes);
|
||||
super(manager, map);
|
||||
VanillaLoader.INSTANCE.setLoader(this);
|
||||
VariantLoader.INSTANCE.setLoader(this);
|
||||
ModelLoaderRegistry.clearModelCache(manager);
|
||||
}
|
||||
|
||||
// TODO lots of commented code here - we need to reevaluate what exactly this class needs to do in the new system, which is difficult with no mappings. So let's get everything compiling first.
|
||||
// This code has mostly been ported to 1.13
|
||||
/*
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry()
|
||||
{
|
||||
Map<ModelResourceLocation, IUnbakedModel> map = Maps.<ModelResourceLocation, IUnbakedModel>newHashMap();
|
||||
|
||||
if (ClientModLoader.isErrored()) // skip loading models if we're just going to show a fatal error screen
|
||||
return bakedRegistry;
|
||||
|
||||
isLoading = true;
|
||||
loadBlocks();
|
||||
loadVariantItemModels();
|
||||
|
||||
missingModel = ModelLoaderRegistry.getMissingModel();
|
||||
stateModels.put(MODEL_MISSING, missingModel);
|
||||
|
||||
final Set<ResourceLocation> textures = Sets.newHashSet(ModelLoaderRegistry.getTextures());
|
||||
textures.remove(TextureMap.LOCATION_MISSING_TEXTURE);
|
||||
textures.remove(MissingTextureSprite.func_195675_b());
|
||||
textures.addAll(LOCATIONS_BUILTIN_TEXTURES);
|
||||
|
||||
textureMap.loadSprites(resourceManager, map -> textures.forEach(map::registerSprite));
|
||||
textureMap.func_195426_a(resourceManager, textures);
|
||||
|
||||
IBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE);
|
||||
Map<IModel, IBakedModel> bakedModels = Maps.newHashMap();
|
||||
HashMultimap<IModel, ModelResourceLocation> models = HashMultimap.create();
|
||||
field_209607_C.forEach((p_209602_2_, p_209602_3_) -> {
|
||||
p_209602_3_.getValidStates().forEach((p_209601_3_) -> {
|
||||
this.func_209594_a(map, BlockModelShapes.func_209553_a(p_209602_2_, p_209601_3_));
|
||||
});
|
||||
});
|
||||
|
||||
for(ResourceLocation resourcelocation : Item.REGISTRY.getKeys()) {
|
||||
this.func_209594_a(map, new ModelResourceLocation(resourcelocation, "inventory"));
|
||||
}
|
||||
|
||||
this.func_209594_a(map, new ModelResourceLocation("minecraft:trident_in_hand#inventory"));
|
||||
Set<String> set = Sets.<String>newLinkedHashSet();
|
||||
Set<ResourceLocation> set1 = (Set)map.values().stream().<ResourceLocation>flatMap((p_209595_2_) -> {
|
||||
return p_209595_2_.func_209559_a(this::func_209597_a, set).stream();
|
||||
}).collect(Collectors.toSet());
|
||||
set1.addAll(LOCATIONS_BUILTIN_TEXTURES);
|
||||
set.forEach((p_209588_0_) -> {
|
||||
LOGGER.warn("Unable to resolve texture reference: {}", (Object)p_209588_0_);
|
||||
});
|
||||
this.textureMap.func_195426_a(this.resourceManager, set1);
|
||||
map.forEach((p_209599_1_, p_209599_2_) -> {
|
||||
IBakedModel ibakedmodel = p_209599_2_.func_209558_a(this::func_209597_a, this.textureMap::func_195424_a, ModelRotation.X0_Y0, false);
|
||||
if (ibakedmodel != null) {
|
||||
this.bakedRegistry.putObject(p_209599_1_, ibakedmodel);
|
||||
}
|
||||
|
||||
});
|
||||
return this.bakedRegistry;
|
||||
|
||||
IBakedModel missingBaked = missingModel.bake(defaultModelGetter(), defaultTextureGetter(), missingModel.getDefaultState(), false, DefaultVertexFormats.ITEM);
|
||||
Map<IUnbakedModel, IBakedModel> bakedModels = Maps.newHashMap();
|
||||
HashMultimap<IUnbakedModel, ModelResourceLocation> models = HashMultimap.create();
|
||||
Multimaps.invertFrom(Multimaps.forMap(stateModels), models);
|
||||
|
||||
ProgressBar bakeBar = ProgressManager.push("ModelLoader: baking", models.keySet().size());
|
||||
|
||||
for(IModel model : models.keySet())
|
||||
for(IUnbakedModel model : models.keySet())
|
||||
{
|
||||
String modelLocations = "[" + Joiner.on(", ").join(models.get(model)) + "]";
|
||||
bakeBar.step(modelLocations);
|
||||
|
@ -175,11 +220,11 @@ public final class ModelLoader extends ModelBakery
|
|||
{
|
||||
try
|
||||
{
|
||||
bakedModels.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE));
|
||||
bakedModels.put(model, model.bake(defaultModelGetter(), defaultTextureGetter(), model.getDefaultState(), false, DefaultVertexFormats.ITEM));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGEr.error("Exception baking model for location(s) {}:", modelLocations, e);
|
||||
LOGGER.error("Exception baking model for location(s) {}:", modelLocations, e);
|
||||
bakedModels.put(model, missingBaked);
|
||||
}
|
||||
}
|
||||
|
@ -187,22 +232,13 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
ProgressManager.pop(bakeBar);
|
||||
|
||||
for (Entry<ModelResourceLocation, IModel> e : stateModels.entrySet())
|
||||
for (Entry<ModelResourceLocation, IUnbakedModel> e : stateModels.entrySet())
|
||||
{
|
||||
bakedRegistry.putObject(e.getKey(), bakedModels.get(e.getValue()));
|
||||
}
|
||||
return bakedRegistry;
|
||||
}
|
||||
|
||||
// NOOP, replaced by dependency resolution
|
||||
@Override
|
||||
protected void loadVariantModels() {}
|
||||
|
||||
// NOOP, replaced by dependency resolution
|
||||
@Override
|
||||
protected void loadMultipartVariantModels() {}
|
||||
|
||||
@Override
|
||||
protected void loadBlocks()
|
||||
{
|
||||
List<Block> blocks = StreamSupport.stream(Block.REGISTRY.spliterator(), false)
|
||||
|
@ -211,8 +247,6 @@ public final class ModelLoader extends ModelBakery
|
|||
.collect(Collectors.toList());
|
||||
ProgressBar blockBar = ProgressManager.push("ModelLoader: blocks", blocks.size());
|
||||
|
||||
BlockStateMapper mapper = this.blockModelShapes.getBlockStateMapper();
|
||||
|
||||
for(Block block : blocks)
|
||||
{
|
||||
blockBar.step(block.getRegistryName().toString());
|
||||
|
@ -227,7 +261,7 @@ public final class ModelLoader extends ModelBakery
|
|||
@Override
|
||||
protected void registerVariant(@Nullable ModelBlockDefinition definition, ModelResourceLocation location)
|
||||
{
|
||||
IModel model;
|
||||
IUnbakedModel model;
|
||||
try
|
||||
{
|
||||
model = ModelLoaderRegistry.getModel(location);
|
||||
|
@ -255,19 +289,6 @@ public final class ModelLoader extends ModelBakery
|
|||
loadingExceptions.put(location, exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelBlockDefinition getModelBlockDefinition(ResourceLocation location)
|
||||
{
|
||||
try
|
||||
{
|
||||
return super.getModelBlockDefinition(location);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
storeException(location, new Exception("Could not load model definition for variant " + location, exception));
|
||||
}
|
||||
return new ModelBlockDefinition(new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadItemModels()
|
||||
|
@ -287,7 +308,7 @@ public final class ModelLoader extends ModelBakery
|
|||
{
|
||||
ResourceLocation file = getItemLocation(s);
|
||||
ModelResourceLocation memory = getInventoryVariant(s);
|
||||
IModel model = ModelLoaderRegistry.getMissingModel();
|
||||
IUnbakedModel model = ModelLoaderRegistry.getMissingModel();
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
|
@ -315,7 +336,7 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
ProgressManager.pop(itemBar);
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Hooked from ModelBakery, allows using MRLs that don't end with "inventory" for items.
|
||||
*/
|
||||
|
@ -328,14 +349,15 @@ public final class ModelLoader extends ModelBakery
|
|||
return new ModelResourceLocation(s, "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getModelLocation(ResourceLocation model)
|
||||
{
|
||||
return new ResourceLocation(model.getNamespace(), model.getPath() + ".json");
|
||||
}
|
||||
|
||||
private final class VanillaModelWrapper implements IModel
|
||||
private final class VanillaModelWrapper implements IUnbakedModel
|
||||
{
|
||||
private final FaceBakery faceBakery = new FaceBakery();
|
||||
|
||||
private final ResourceLocation location;
|
||||
private final ModelBlock model;
|
||||
private final boolean uvlock;
|
||||
|
@ -350,7 +372,7 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
Set<ResourceLocation> set = Sets.newHashSet();
|
||||
for(ResourceLocation dep : model.getOverrideLocations())
|
||||
|
@ -362,7 +384,7 @@ public final class ModelLoader extends ModelBakery
|
|||
stateModels.put(getInventoryVariant(dep.toString()), ModelLoaderRegistry.getModelOrLogError(dep, "Could not load override model " + dep + " for model " + location));
|
||||
}
|
||||
}
|
||||
if(model.getParentLocation() != null && !model.getParentLocation().getResourcePath().startsWith("builtin/"))
|
||||
if(model.getParentLocation() != null && !model.getParentLocation().getPath().startsWith("builtin/"))
|
||||
{
|
||||
set.add(model.getParentLocation());
|
||||
}
|
||||
|
@ -370,18 +392,18 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
// setting parent here to make textures resolve properly
|
||||
if(model.getParentLocation() != null)
|
||||
{
|
||||
if(model.getParentLocation().getResourcePath().equals("builtin/generated"))
|
||||
if(model.getParentLocation().getPath().equals("builtin/generated"))
|
||||
{
|
||||
model.parent = MODEL_GENERATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
IModel parent = ModelLoaderRegistry.getModelOrLogError(model.getParentLocation(), "Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model);
|
||||
IUnbakedModel parent = ModelLoaderRegistry.getModelOrLogError(model.getParentLocation(), "Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model);
|
||||
if(parent instanceof VanillaModelWrapper)
|
||||
{
|
||||
model.parent = ((VanillaModelWrapper) parent).model;
|
||||
|
@ -395,7 +417,7 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
ImmutableSet.Builder<ResourceLocation> builder = ImmutableSet.builder();
|
||||
|
||||
if(hasItemModel(model))
|
||||
if(model == ModelBakery.MODEL_GENERATED)
|
||||
{
|
||||
for(String s : ItemModelGenerator.LAYERS)
|
||||
{
|
||||
|
@ -418,19 +440,19 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
return VanillaLoader.INSTANCE.modelCache.getUnchecked(new BakedModelCacheKey(this, state, format, bakedTextureGetter));
|
||||
return VanillaLoader.INSTANCE.modelCache.getUnchecked(new BakedModelCacheKey(this, modelGetter, bakedTextureGetter, state, uvlock, format));
|
||||
}
|
||||
|
||||
public IBakedModel bakeImpl(IModelState state, final VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public IBakedModel bakeImpl(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT))
|
||||
{
|
||||
throw new IllegalArgumentException("can't bake vanilla models to the format that doesn't fit into the default one: " + format);
|
||||
}
|
||||
ModelBlock model = this.model;
|
||||
if(model == null) return getMissingModel().bake(getMissingModel().getDefaultState(), format, bakedTextureGetter);
|
||||
if(model == null) return getMissingModel().bake(modelGetter, bakedTextureGetter, getMissingModel().getDefaultState(), uvlock, format);
|
||||
|
||||
List<TRSRTransformation> newTransforms = Lists.newArrayList();
|
||||
for(int i = 0; i < model.getElements().size(); i++)
|
||||
|
@ -445,19 +467,19 @@ public final class ModelLoader extends ModelBakery
|
|||
tMap.putAll(PerspectiveMapWrapper.getTransforms(state));
|
||||
IModelState perState = new SimpleModelState(ImmutableMap.copyOf(tMap));
|
||||
|
||||
if(hasItemModel(model))
|
||||
if(model == ModelBakery.MODEL_GENERATED)
|
||||
{
|
||||
return new ItemLayerModel(model).bake(perState, format, bakedTextureGetter);
|
||||
return new ItemLayerModel(model).bake(modelGetter, bakedTextureGetter, perState, uvlock, format);
|
||||
}
|
||||
if(isCustomRenderer(model)) return new BuiltInModel(transforms, model.createOverrides());
|
||||
return bakeNormal(model, perState, state, newTransforms, format, bakedTextureGetter, uvlock);
|
||||
if(model == ModelBakery.MODEL_ENTITY) return new BuiltInModel(transforms, model.func_209568_a(model, modelGetter, bakedTextureGetter));
|
||||
return bakeNormal(model, perState, state, newTransforms, format, modelGetter, bakedTextureGetter, uvlock);
|
||||
}
|
||||
|
||||
private IBakedModel bakeNormal(ModelBlock model, IModelState perState, final IModelState modelState, List<TRSRTransformation> newTransforms, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, boolean uvLocked)
|
||||
private IBakedModel bakeNormal(ModelBlock model, IModelState perState, final IModelState modelState, List<TRSRTransformation> newTransforms, final VertexFormat format, final Function<ResourceLocation, IUnbakedModel> modelGetter, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, boolean uvLocked)
|
||||
{
|
||||
final TRSRTransformation baseState = modelState.apply(Optional.empty()).orElse(TRSRTransformation.identity());
|
||||
TextureAtlasSprite particle = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName("particle")));
|
||||
SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(model, model.createOverrides())).setTexture(particle);
|
||||
SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(model, model.func_209568_a(model, modelGetter, bakedTextureGetter))).setTexture(particle);
|
||||
for(int i = 0; i < model.getElements().size(); i++)
|
||||
{
|
||||
if(modelState.apply(Optional.of(Models.getHiddenModelPart(ImmutableList.of(Integer.toString(i))))).isPresent())
|
||||
|
@ -479,11 +501,11 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
if (e.getValue().cullFace == null || !TRSRTransformation.isInteger(transformation.getMatrix()))
|
||||
{
|
||||
builder.addGeneralQuad(makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked));
|
||||
builder.addGeneralQuad(ModelBlock.makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.addFaceQuad(baseState.rotate(e.getValue().cullFace), makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked));
|
||||
builder.addFaceQuad(baseState.rotate(e.getValue().cullFace), ModelBlock.makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +515,7 @@ public final class ModelLoader extends ModelBakery
|
|||
private final ItemOverrideList overrides = new AnimationItemOverrideList(VanillaModelWrapper.this, modelState, format, bakedTextureGetter, super.getOverrides());
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
if(state instanceof IExtendedBlockState)
|
||||
{
|
||||
|
@ -504,11 +526,11 @@ public final class ModelLoader extends ModelBakery
|
|||
IExtendedBlockState newExState = exState.withProperty(Properties.AnimationProperty, null);
|
||||
if(newState != null)
|
||||
{
|
||||
return VanillaModelWrapper.this.bake(new ModelStateComposition(modelState, newState), format, bakedTextureGetter).getQuads(newExState, side, rand);
|
||||
return VanillaModelWrapper.this.bake(modelGetter, bakedTextureGetter, new ModelStateComposition(modelState, newState), uvlock, format).func_200117_a(newExState, side, rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getQuads(state, side, rand);
|
||||
return super.func_200117_a(state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -609,24 +631,14 @@ public final class ModelLoader extends ModelBakery
|
|||
newModel.name = model.name;
|
||||
return new VanillaModelWrapper(location, newModel, uvlock, animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel uvlock(boolean value)
|
||||
{
|
||||
if(uvlock == value)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
return new VanillaModelWrapper(location, model, value, animation);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class WeightedRandomModel implements IModel
|
||||
private static final class WeightedRandomModel implements IUnbakedModel
|
||||
{
|
||||
private final List<Variant> variants;
|
||||
private final List<ResourceLocation> locations;
|
||||
private final Set<ResourceLocation> textures;
|
||||
private final List<IModel> models;
|
||||
private final List<IUnbakedModel> models;
|
||||
private final IModelState defaultState;
|
||||
|
||||
public WeightedRandomModel(ResourceLocation parent, VariantList variants) throws Exception
|
||||
|
@ -635,7 +647,7 @@ public final class ModelLoader extends ModelBakery
|
|||
this.locations = new ArrayList<>();
|
||||
this.textures = Sets.newHashSet();
|
||||
this.models = new ArrayList<>();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<Pair<IUnbakedModel, IModelState>> builder = ImmutableList.builder();
|
||||
for (Variant v : this.variants)
|
||||
{
|
||||
ResourceLocation loc = v.getModelLocation();
|
||||
|
@ -645,7 +657,7 @@ public final class ModelLoader extends ModelBakery
|
|||
* Vanilla eats this, which makes it only show variants that have models.
|
||||
* But that doesn't help debugging, so throw the exception
|
||||
*/
|
||||
IModel model;
|
||||
IUnbakedModel model;
|
||||
if(loc.equals(MODEL_MISSING))
|
||||
{
|
||||
// explicit missing location, happens if blockstate has "model"=null
|
||||
|
@ -658,12 +670,12 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
// FIXME: is this the place? messes up dependency and texture resolution
|
||||
model = v.process(model);
|
||||
for(ResourceLocation location : model.getDependencies())
|
||||
for(ResourceLocation location : model.getOverrideLocations())
|
||||
{
|
||||
ModelLoaderRegistry.getModelOrMissing(location);
|
||||
}
|
||||
//FMLLog.getLogger().error("Exception resolving indirect dependencies for model" + loc, e);
|
||||
textures.addAll(model.getTextures()); // Kick this, just in case.
|
||||
textures.addAll(model.func_209559_a(ModelLoader.defaultModelGetter(), new HashSet<>())); // Kick this, just in case.
|
||||
|
||||
models.add(model);
|
||||
|
||||
|
@ -675,7 +687,7 @@ public final class ModelLoader extends ModelBakery
|
|||
if (models.size() == 0) //If all variants are missing, add one with the missing model and default rotation.
|
||||
{
|
||||
// FIXME: log this?
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
IUnbakedModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
models.add(missing);
|
||||
builder.add(Pair.of(missing, TRSRTransformation.identity()));
|
||||
}
|
||||
|
@ -683,7 +695,7 @@ public final class ModelLoader extends ModelBakery
|
|||
defaultState = new MultiModelState(builder.build());
|
||||
}
|
||||
|
||||
private WeightedRandomModel(List<Variant> variants, List<ResourceLocation> locations, Set<ResourceLocation> textures, List<IModel> models, IModelState defaultState)
|
||||
private WeightedRandomModel(List<Variant> variants, List<ResourceLocation> locations, Set<ResourceLocation> textures, List<IUnbakedModel> models, IModelState defaultState)
|
||||
{
|
||||
this.variants = variants;
|
||||
this.locations = locations;
|
||||
|
@ -693,19 +705,19 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
return ImmutableList.copyOf(locations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
return ImmutableSet.copyOf(textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT))
|
||||
{
|
||||
|
@ -713,16 +725,16 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
if(variants.size() == 1)
|
||||
{
|
||||
IModel model = models.get(0);
|
||||
return model.bake(MultiModelState.getPartState(state, model, 0), format, bakedTextureGetter);
|
||||
IUnbakedModel model = models.get(0);
|
||||
return model.bake(modelGetter, bakedTextureGetter, MultiModelState.getPartState(state, model, 0), uvlock, format);
|
||||
}
|
||||
WeightedBakedModel.Builder builder = new WeightedBakedModel.Builder();
|
||||
for(int i = 0; i < variants.size(); i++)
|
||||
{
|
||||
IModel model = models.get(i);
|
||||
builder.add(model.bake(MultiModelState.getPartState(state, model, i), format, bakedTextureGetter), variants.get(i).getWeight());
|
||||
IUnbakedModel model = models.get(i);
|
||||
builder.add(model.bake(modelGetter, bakedTextureGetter, MultiModelState.getPartState(state, model, i), uvlock, format), variants.get(i).getWeight());
|
||||
}
|
||||
return builder.build();
|
||||
return builder.func_209614_a();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -740,12 +752,12 @@ public final class ModelLoader extends ModelBakery
|
|||
// rebuild the texture list taking into account new textures
|
||||
Set<ResourceLocation> modelTextures = Sets.newHashSet();
|
||||
// also recreate the MultiModelState so IModelState data is properly applied to the retextured model
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
List<IModel> retexturedModels = Lists.newArrayList();
|
||||
ImmutableList.Builder<Pair<IUnbakedModel, IModelState>> builder = ImmutableList.builder();
|
||||
List<IUnbakedModel> retexturedModels = Lists.newArrayList();
|
||||
for(int i = 0; i < this.variants.size(); i++)
|
||||
{
|
||||
IModel retextured = this.models.get(i).retexture(textures);
|
||||
modelTextures.addAll(retextured.getTextures());
|
||||
IUnbakedModel retextured = this.models.get(i).retexture(textures);
|
||||
modelTextures.addAll(retextured.func_209559_a(ModelLoader.defaultModelGetter(), new HashSet<>()));
|
||||
retexturedModels.add(retextured);
|
||||
builder.add(Pair.of(retextured, this.variants.get(i).getState()));
|
||||
}
|
||||
|
@ -754,7 +766,7 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
}
|
||||
|
||||
protected IModel getMissingModel()
|
||||
protected IUnbakedModel getMissingModel()
|
||||
{
|
||||
if (missingModel == null)
|
||||
{
|
||||
|
@ -773,16 +785,20 @@ public final class ModelLoader extends ModelBakery
|
|||
protected final class BakedModelCacheKey
|
||||
{
|
||||
private final VanillaModelWrapper model;
|
||||
private final IModelState state;
|
||||
private final VertexFormat format;
|
||||
private final Function<ResourceLocation, IUnbakedModel> modelGetter;
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter;
|
||||
private final IModelState state;
|
||||
private final boolean uvlock;
|
||||
private final VertexFormat format;
|
||||
|
||||
public BakedModelCacheKey(VanillaModelWrapper model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public BakedModelCacheKey(VanillaModelWrapper model, Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
this.model = model;
|
||||
this.state = state;
|
||||
this.format = format;
|
||||
this.modelGetter = modelGetter;
|
||||
this.bakedTextureGetter = bakedTextureGetter;
|
||||
this.state = state;
|
||||
this.uvlock = uvlock;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -797,7 +813,7 @@ public final class ModelLoader extends ModelBakery
|
|||
return false;
|
||||
}
|
||||
BakedModelCacheKey that = (BakedModelCacheKey) o;
|
||||
return Objects.equal(model, that.model) && Objects.equal(state, that.state) && Objects.equal(format, that.format) && Objects.equal(bakedTextureGetter, that.bakedTextureGetter);
|
||||
return Objects.equal(model, that.model) && Objects.equal(modelGetter, that.modelGetter) && Objects.equal(bakedTextureGetter, that.bakedTextureGetter) && Objects.equal(state, that.state) && uvlock == that.uvlock && Objects.equal(format, that.format);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -817,7 +833,7 @@ public final class ModelLoader extends ModelBakery
|
|||
@Override
|
||||
public IBakedModel load(BakedModelCacheKey key) throws Exception
|
||||
{
|
||||
return key.model.bakeImpl(key.state, key.format, key.bakedTextureGetter);
|
||||
return key.model.bakeImpl(key.modelGetter, key.bakedTextureGetter, key.state, key.uvlock, key.format);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -843,7 +859,7 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
if(modelLocation.equals(MODEL_MISSING) && loader.missingModel != null)
|
||||
{
|
||||
|
@ -857,7 +873,7 @@ public final class ModelLoader extends ModelBakery
|
|||
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json");
|
||||
ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(loader.resourceManager, armatureLocation);
|
||||
ModelBlock model = loader.loadModel(modelLocation);
|
||||
IModel iModel = loader.new VanillaModelWrapper(modelLocation, model, false, animation);
|
||||
IUnbakedModel iModel = loader.new VanillaModelWrapper(modelLocation, model, false, animation);
|
||||
if(loader.missingModel == null && modelLocation.equals(MODEL_MISSING))
|
||||
{
|
||||
loader.missingModel = iModel;
|
||||
|
@ -872,9 +888,16 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
}
|
||||
|
||||
// Temporary to compile things
|
||||
public static final class White {
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation("white");
|
||||
public static final TextureAtlasSprite INSTANCE = MissingTextureSprite.func_195677_a();
|
||||
}
|
||||
|
||||
/**
|
||||
* 16x16 pure white sprite.
|
||||
*/
|
||||
/*/ TODO Custom TAS
|
||||
public static final class White extends TextureAtlasSprite
|
||||
{
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation("white");
|
||||
|
@ -912,7 +935,7 @@ public final class ModelLoader extends ModelBakery
|
|||
map.setTextureEntry(White.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static class ItemLoadingException extends ModelLoaderRegistry.LoaderException
|
||||
{
|
||||
|
@ -938,7 +961,7 @@ public final class ModelLoader extends ModelBakery
|
|||
// ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation
|
||||
if(entry.getKey() instanceof ModelResourceLocation)
|
||||
{
|
||||
LOGGER.debug(MODELLOADING, ()-> new ModelLoaderErrorMessage((ModelResourceLocation)entry.getKey(), entry.getValue(), modelRegistry, this.blockModelShapes, this::getVariantNames));
|
||||
LOGGER.debug(MODELLOADING, ()-> new ModelLoaderErrorMessage((ModelResourceLocation)entry.getKey(), entry.getValue()));
|
||||
final ModelResourceLocation location = (ModelResourceLocation)entry.getKey();
|
||||
final IBakedModel model = modelRegistry.getObject(location);
|
||||
if(model == null)
|
||||
|
@ -952,7 +975,7 @@ public final class ModelLoader extends ModelBakery
|
|||
IBakedModel model = modelRegistry.getObject(missing);
|
||||
if(model == null || model == missingModel)
|
||||
{
|
||||
LOGGER.debug(MODELLOADING, ()-> new ModelLoaderErrorMessage(missing, null, modelRegistry, this.blockModelShapes, this::getVariantNames));
|
||||
LOGGER.debug(MODELLOADING, ()-> new ModelLoaderErrorMessage(missing, null));
|
||||
}
|
||||
if(model == null)
|
||||
{
|
||||
|
@ -964,11 +987,13 @@ public final class ModelLoader extends ModelBakery
|
|||
isLoading = false;
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO replace these if necessary, IStateMapper and ItemMeshDefinition are gone
|
||||
private static final Map<IRegistryDelegate<Block>, IStateMapper> customStateMappers = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* Adds a custom IBlockState -> model variant logic.
|
||||
*/
|
||||
*//*
|
||||
public static void setCustomStateMapper(Block block, IStateMapper mapper)
|
||||
{
|
||||
customStateMappers.put(block.delegate, mapper);
|
||||
|
@ -976,7 +1001,7 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
/**
|
||||
* Internal, do not use.
|
||||
*/
|
||||
*//*
|
||||
public static void onRegisterAllBlocks(BlockModelShapes shapes)
|
||||
{
|
||||
for (Entry<IRegistryDelegate<Block>, IStateMapper> e : customStateMappers.entrySet())
|
||||
|
@ -991,7 +1016,7 @@ public final class ModelLoader extends ModelBakery
|
|||
/**
|
||||
* Adds a simple mapping from Item + metadata to the model variant.
|
||||
* Registers the variant with the ModelBakery too.
|
||||
*/
|
||||
*//*
|
||||
public static void setCustomModelResourceLocation(Item item, int metadata, ModelResourceLocation model)
|
||||
{
|
||||
customModels.put(Pair.of(item.delegate, metadata), model);
|
||||
|
@ -1001,7 +1026,7 @@ public final class ModelLoader extends ModelBakery
|
|||
/**
|
||||
* Adds generic ItemStack -> model variant logic.
|
||||
* You still need to manually call ModelBakery.registerItemVariants with all values that meshDefinition can return.
|
||||
*/
|
||||
*//*
|
||||
public static void setCustomMeshDefinition(Item item, ItemMeshDefinition meshDefinition)
|
||||
{
|
||||
customMeshDefinitions.put(item.delegate, meshDefinition);
|
||||
|
@ -1009,7 +1034,7 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
/**
|
||||
* Helper method for registering all itemstacks for given item to map to universal bucket model.
|
||||
*/
|
||||
*//*
|
||||
public static void setBucketModelDefinition(Item item) {
|
||||
ModelLoader.setCustomMeshDefinition(item, stack -> ModelDynBucket.LOCATION);
|
||||
ModelBakery.registerItemVariants(item, ModelDynBucket.LOCATION);
|
||||
|
@ -1017,19 +1042,15 @@ public final class ModelLoader extends ModelBakery
|
|||
|
||||
/**
|
||||
* Internal, do not use.
|
||||
*/
|
||||
*//*
|
||||
public static void onRegisterItems(ItemModelMesher mesher)
|
||||
{
|
||||
for (Map.Entry<IRegistryDelegate<Item>, ItemMeshDefinition> e : customMeshDefinitions.entrySet())
|
||||
{
|
||||
mesher.register(e.getKey().get(), e.getValue());
|
||||
}
|
||||
for (Entry<Pair<IRegistryDelegate<Item>, Integer>, ModelResourceLocation> e : customModels.entrySet())
|
||||
{
|
||||
mesher.register(e.getKey().getLeft().get(), e.getKey().getRight(), e.getValue());
|
||||
mesher.func_199311_a(e.getKey().getLeft().get(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
private static enum DefaultTextureGetter implements Function<ResourceLocation, TextureAtlasSprite>
|
||||
{
|
||||
INSTANCE;
|
||||
|
@ -1041,6 +1062,8 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
}
|
||||
|
||||
private static final Function<ResourceLocation, IUnbakedModel> DEFAULT_MODEL_GETTER = ModelLoaderRegistry::getModelOrMissing;
|
||||
|
||||
/**
|
||||
* Get the default texture getter the models will be baked with.
|
||||
*/
|
||||
|
@ -1049,6 +1072,11 @@ public final class ModelLoader extends ModelBakery
|
|||
return DefaultTextureGetter.INSTANCE;
|
||||
}
|
||||
|
||||
public static Function<ResourceLocation, IUnbakedModel> defaultModelGetter()
|
||||
{
|
||||
return DEFAULT_MODEL_GETTER;
|
||||
}
|
||||
|
||||
protected static enum VariantLoader implements ICustomModelLoader
|
||||
{
|
||||
INSTANCE;
|
||||
|
@ -1071,30 +1099,9 @@ public final class ModelLoader extends ModelBakery
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
ModelResourceLocation variant = (ModelResourceLocation) modelLocation;
|
||||
ModelBlockDefinition definition = loader.getModelBlockDefinition(variant);
|
||||
|
||||
try
|
||||
{
|
||||
VariantList variants = definition.getVariant(variant.getVariant());
|
||||
return new WeightedRandomModel(variant, variants);
|
||||
}
|
||||
catch (MissingVariantException e)
|
||||
{
|
||||
if (definition.equals(loader.multipartDefinitions.get(variant)))
|
||||
{
|
||||
IModel model = loader.multipartModels.get(definition);
|
||||
if (model == null)
|
||||
{
|
||||
model = new MultipartModel(new ResourceLocation(variant.getNamespace(), variant.getPath()), definition.getMultipartData());
|
||||
loader.multipartModels.put(definition, model);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return loader.func_209597_a(modelLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1103,61 +1110,4 @@ public final class ModelLoader extends ModelBakery
|
|||
return "VariantLoader.INSTANCE";
|
||||
}
|
||||
}
|
||||
|
||||
private static class MultipartModel implements IModel
|
||||
{
|
||||
private final ResourceLocation location;
|
||||
private final Multipart multipart;
|
||||
private final ImmutableMap<Selector, IModel> partModels;
|
||||
|
||||
public MultipartModel(ResourceLocation location, Multipart multipart) throws Exception
|
||||
{
|
||||
this.location = location;
|
||||
this.multipart = multipart;
|
||||
ImmutableMap.Builder<Selector, IModel> builder = ImmutableMap.builder();
|
||||
for (Selector selector : multipart.getSelectors())
|
||||
{
|
||||
builder.put(selector, new WeightedRandomModel(location, selector.getVariantList()));
|
||||
}
|
||||
partModels = builder.build();
|
||||
}
|
||||
|
||||
private MultipartModel(ResourceLocation location, Multipart multipart, ImmutableMap<Selector, IModel> partModels)
|
||||
{
|
||||
this.location = location;
|
||||
this.multipart = multipart;
|
||||
this.partModels = partModels;
|
||||
}
|
||||
|
||||
// FIXME: represent selectors as dependencies?
|
||||
// FIXME
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
{
|
||||
MultipartBakedModel.Builder builder = new MultipartBakedModel.Builder();
|
||||
|
||||
for (Selector selector : multipart.getSelectors())
|
||||
{
|
||||
builder.putModel(selector.getPredicate(multipart.getStateContainer()), partModels.get(selector).bake(partModels.get(selector).getDefaultState(), format, bakedTextureGetter));
|
||||
}
|
||||
|
||||
IBakedModel bakedModel = builder.makeMultipartModel();
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel retexture(ImmutableMap<String, String> textures)
|
||||
{
|
||||
if (textures.isEmpty())
|
||||
return this;
|
||||
|
||||
ImmutableMap.Builder<Selector, IModel> builder = ImmutableMap.builder();
|
||||
for (Entry<Selector, IModel> partModel : this.partModels.entrySet())
|
||||
{
|
||||
builder.put(partModel.getKey(), partModel.getValue().retexture(textures));
|
||||
}
|
||||
|
||||
return new MultipartModel(location, multipart, builder.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,24 @@
|
|||
package net.minecraftforge.client.model;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader.VanillaLoader;
|
||||
import net.minecraftforge.client.model.ModelLoader.VariantLoader;
|
||||
|
@ -35,21 +46,16 @@ import net.minecraftforge.client.model.obj.OBJLoader;
|
|||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
import net.minecraftforge.common.model.animation.AnimationStateMachine;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/*
|
||||
* Central hub for custom model loaders.
|
||||
*/
|
||||
public class ModelLoaderRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final Set<ICustomModelLoader> loaders = Sets.newHashSet();
|
||||
private static final Map<ResourceLocation, IModel> cache = Maps.newHashMap();
|
||||
private static final Map<ResourceLocation, IUnbakedModel> cache = Maps.newHashMap();
|
||||
private static final Deque<ResourceLocation> loadingModels = Queues.newArrayDeque();
|
||||
private static final Set<ResourceLocation> textures = Sets.newHashSet();
|
||||
private static final Map<ResourceLocation, ResourceLocation> aliases = Maps.newHashMap();
|
||||
|
@ -73,7 +79,7 @@ public class ModelLoaderRegistry
|
|||
public static void registerLoader(ICustomModelLoader loader)
|
||||
{
|
||||
loaders.add(loader);
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(loader);
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().func_195551_G()).func_199006_a(loader);
|
||||
}
|
||||
|
||||
public static boolean loaded(ResourceLocation location)
|
||||
|
@ -85,8 +91,8 @@ public class ModelLoaderRegistry
|
|||
public static ResourceLocation getActualLocation(ResourceLocation location)
|
||||
{
|
||||
if(location instanceof ModelResourceLocation) return location;
|
||||
if(location.getResourcePath().startsWith("builtin/")) return location;
|
||||
return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath());
|
||||
if(location.getPath().startsWith("builtin/")) return location;
|
||||
return new ResourceLocation(location.getNamespace(), "models/" + location.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,11 +100,11 @@ public class ModelLoaderRegistry
|
|||
* ResourceLocation argument will be passed directly to the custom model loaders,
|
||||
* ModelResourceLocation argument will be loaded through the blockstate system.
|
||||
*/
|
||||
public static IModel getModel(ResourceLocation location) throws Exception
|
||||
public static IUnbakedModel getModel(ResourceLocation location) throws Exception
|
||||
{
|
||||
IModel model;
|
||||
IUnbakedModel model;
|
||||
|
||||
IModel cached = cache.get(location);
|
||||
IUnbakedModel cached = cache.get(location);
|
||||
if (cached != null) return cached;
|
||||
|
||||
for(ResourceLocation loading : loadingModels)
|
||||
|
@ -168,7 +174,7 @@ public class ModelLoaderRegistry
|
|||
{
|
||||
throw new LoaderException(String.format("Loader %s returned null while loading model %s", accepted, location));
|
||||
}
|
||||
textures.addAll(model.getTextures());
|
||||
textures.addAll(model.func_209559_a(ModelLoader.defaultModelGetter(), new HashSet<>()));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -179,7 +185,7 @@ public class ModelLoaderRegistry
|
|||
}
|
||||
}
|
||||
cache.put(location, model);
|
||||
for (ResourceLocation dep : model.getDependencies())
|
||||
for (ResourceLocation dep : model.getOverrideLocations())
|
||||
{
|
||||
getModelOrMissing(dep);
|
||||
}
|
||||
|
@ -189,7 +195,7 @@ public class ModelLoaderRegistry
|
|||
/**
|
||||
* Use this if you don't care about the exception and want some model anyway.
|
||||
*/
|
||||
public static IModel getModelOrMissing(ResourceLocation location)
|
||||
public static IUnbakedModel getModelOrMissing(ResourceLocation location)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -204,7 +210,7 @@ public class ModelLoaderRegistry
|
|||
/**
|
||||
* Use this if you want the model, but need to log the error.
|
||||
*/
|
||||
public static IModel getModelOrLogError(ResourceLocation location, String error)
|
||||
public static IUnbakedModel getModelOrLogError(ResourceLocation location, String error)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -212,12 +218,12 @@ public class ModelLoaderRegistry
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
FMLLog.log.error(error, e);
|
||||
LOGGER.error(error, e);
|
||||
return getMissingModel(location, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static IModel getMissingModel()
|
||||
public static IUnbakedModel getMissingModel()
|
||||
{
|
||||
final ModelLoader loader = VanillaLoader.INSTANCE.getLoader();
|
||||
if(loader == null)
|
||||
|
@ -227,11 +233,11 @@ public class ModelLoaderRegistry
|
|||
return loader.getMissingModel();
|
||||
}
|
||||
|
||||
static IModel getMissingModel(ResourceLocation location, Throwable cause)
|
||||
static IUnbakedModel getMissingModel(ResourceLocation location, Throwable cause)
|
||||
{
|
||||
//IModel model = new FancyMissingModel(ExceptionUtils.getStackTrace(cause).replaceAll("\\t", " "));
|
||||
IModel model = new FancyMissingModel(getMissingModel(), location.toString());
|
||||
textures.addAll(model.getTextures());
|
||||
IUnbakedModel model = new FancyMissingModel(getMissingModel(), location.toString());
|
||||
textures.addAll(model.func_209559_a(null, null));
|
||||
return model;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package net.minecraftforge.client.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -28,6 +29,7 @@ import javax.vecmath.Matrix4f;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
@ -48,12 +50,15 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
import java.util.function.Function;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
public final class MultiLayerModel implements IModel
|
||||
public final class MultiLayerModel implements IUnbakedModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final MultiLayerModel INSTANCE = new MultiLayerModel(ImmutableMap.of());
|
||||
|
@ -66,29 +71,35 @@ public final class MultiLayerModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
return ImmutableList.copyOf(models.values());
|
||||
}
|
||||
|
||||
private static ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
@Override
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, IModelState state, boolean uvlock, VertexFormat format, Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
{
|
||||
ImmutableMap.Builder<Optional<BlockRenderLayer>, IBakedModel> builder = ImmutableMap.builder();
|
||||
for(Optional<BlockRenderLayer> key : models.keySet())
|
||||
{
|
||||
IModel model = ModelLoaderRegistry.getModelOrLogError(models.get(key), "Couldn't load MultiLayerModel dependency: " + models.get(key));
|
||||
builder.put(key, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter));
|
||||
IUnbakedModel model = ModelLoaderRegistry.getModelOrLogError(models.get(key), "Couldn't load MultiLayerModel dependency: " + models.get(key));
|
||||
builder.put(key, model.bake(modelGetter, bakedTextureGetter, new ModelStateComposition(state, model.getDefaultState()), uvlock, format));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
IUnbakedModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
return new MultiLayerBakedModel(
|
||||
buildModels(models, state, format, bakedTextureGetter),
|
||||
missing.bake(missing.getDefaultState(), format, bakedTextureGetter),
|
||||
buildModels(models, state, uvlock, format, modelGetter, bakedTextureGetter),
|
||||
missing.bake(modelGetter, bakedTextureGetter, missing.getDefaultState(), uvlock, format),
|
||||
PerspectiveMapWrapper.getTransforms(state)
|
||||
);
|
||||
}
|
||||
|
@ -143,7 +154,7 @@ public final class MultiLayerModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
|
||||
if (layer == null)
|
||||
|
@ -151,12 +162,12 @@ public final class MultiLayerModel implements IModel
|
|||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
for (IBakedModel model : models.values())
|
||||
{
|
||||
builder.addAll(model.getQuads(state, side, rand));
|
||||
builder.addAll(model.func_200117_a(state, side, rand));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
// assumes that child model will handle this state properly. FIXME?
|
||||
return models.getOrDefault(Optional.of(layer), missing).getQuads(state, side, rand);
|
||||
return models.getOrDefault(Optional.of(layer), missing).func_200117_a(state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,7 +230,7 @@ public final class MultiLayerModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation)
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation)
|
||||
{
|
||||
return MultiLayerModel.INSTANCE;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.EnumMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -33,6 +34,7 @@ import javax.vecmath.Matrix4f;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
|
@ -45,9 +47,10 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -57,8 +60,10 @@ import com.google.common.collect.Sets;
|
|||
|
||||
// TODO: Switch to vanilla class, or to something similar
|
||||
@Deprecated
|
||||
public final class MultiModel implements IModel
|
||||
public final class MultiModel implements IUnbakedModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final class Baked implements IBakedModel
|
||||
{
|
||||
private final ResourceLocation location;
|
||||
|
@ -68,10 +73,10 @@ public final class MultiModel implements IModel
|
|||
|
||||
private final IBakedModel internalBase;
|
||||
private final ImmutableMap<TransformType, Pair<Baked, TRSRTransformation>> transforms;
|
||||
private final ItemOverrideList overrides = new ItemOverrideList(Lists.newArrayList())
|
||||
private final ItemOverrideList overrides = new ItemOverrideList()
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
public IBakedModel func_209581_a(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
if(originalModel != Baked.this)
|
||||
{
|
||||
|
@ -82,7 +87,7 @@ public final class MultiModel implements IModel
|
|||
|
||||
if(base != null)
|
||||
{
|
||||
newBase = base.getOverrides().handleItemState(base, stack, world, entity);
|
||||
newBase = base.getOverrides().func_209581_a(base, stack, world, entity);
|
||||
if(base != newBase)
|
||||
{
|
||||
dirty = true;
|
||||
|
@ -91,7 +96,7 @@ public final class MultiModel implements IModel
|
|||
ImmutableMap.Builder<String, IBakedModel> builder = ImmutableMap.builder();
|
||||
for(Map.Entry<String, IBakedModel> entry : parts.entrySet())
|
||||
{
|
||||
IBakedModel newPart = entry.getValue().getOverrides().handleItemState(entry.getValue(), stack, world, entity);
|
||||
IBakedModel newPart = entry.getValue().getOverrides().func_209581_a(entry.getValue(), stack, world, entity);
|
||||
builder.put(entry.getKey(), newPart);
|
||||
if(entry.getValue() != newPart)
|
||||
{
|
||||
|
@ -183,16 +188,16 @@ public final class MultiModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
|
||||
if (base != null)
|
||||
{
|
||||
quads.addAll(base.getQuads(state, side, rand));
|
||||
quads.addAll(base.func_200117_a(state, side, rand));
|
||||
}
|
||||
for (IBakedModel bakedPart : parts.values())
|
||||
{
|
||||
quads.addAll(bakedPart.getQuads(state, side, rand));
|
||||
quads.addAll(bakedPart.func_200117_a(state, side, rand));
|
||||
}
|
||||
return quads.build();
|
||||
}
|
||||
|
@ -214,17 +219,17 @@ public final class MultiModel implements IModel
|
|||
|
||||
private final ResourceLocation location;
|
||||
@Nullable
|
||||
private final IModel base;
|
||||
private final Map<String, Pair<IModel, IModelState>> parts;
|
||||
private final IUnbakedModel base;
|
||||
private final Map<String, Pair<IUnbakedModel, IModelState>> parts;
|
||||
|
||||
// TODO 1.13 remove, kept for binary compatibility
|
||||
@Deprecated
|
||||
public MultiModel(ResourceLocation location, @Nullable IModel base, IModelState baseState, ImmutableMap<String, Pair<IModel, IModelState>> parts)
|
||||
public MultiModel(ResourceLocation location, @Nullable IUnbakedModel base, IModelState baseState, ImmutableMap<String, Pair<IUnbakedModel, IModelState>> parts)
|
||||
{
|
||||
this(location, base, parts);
|
||||
}
|
||||
|
||||
public MultiModel(ResourceLocation location, @Nullable IModel base, ImmutableMap<String, Pair<IModel, IModelState>> parts)
|
||||
public MultiModel(ResourceLocation location, @Nullable IUnbakedModel base, ImmutableMap<String, Pair<IUnbakedModel, IModelState>> parts)
|
||||
{
|
||||
this.location = location;
|
||||
this.base = base;
|
||||
|
@ -233,65 +238,65 @@ public final class MultiModel implements IModel
|
|||
|
||||
// TODO 1.13 remove, kept for binary compatibility
|
||||
@Deprecated
|
||||
public MultiModel(ResourceLocation location, IModel base, IModelState baseState, Map<String, Pair<IModel, IModelState>> parts)
|
||||
public MultiModel(ResourceLocation location, IUnbakedModel base, IModelState baseState, Map<String, Pair<IUnbakedModel, IModelState>> parts)
|
||||
{
|
||||
this(location, base, parts);
|
||||
}
|
||||
|
||||
public MultiModel(ResourceLocation location, IModel base, Map<String, Pair<IModel, IModelState>> parts)
|
||||
public MultiModel(ResourceLocation location, IUnbakedModel base, Map<String, Pair<IUnbakedModel, IModelState>> parts)
|
||||
{
|
||||
this(location, base, ImmutableMap.copyOf(parts));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
Set<ResourceLocation> deps = Sets.newHashSet();
|
||||
|
||||
if (base != null)
|
||||
deps.addAll(base.getDependencies());
|
||||
deps.addAll(base.getOverrideLocations());
|
||||
|
||||
for (Pair<IModel, IModelState> pair : parts.values())
|
||||
deps.addAll(pair.getLeft().getDependencies());
|
||||
for (Pair<IUnbakedModel, IModelState> pair : parts.values())
|
||||
deps.addAll(pair.getLeft().getOverrideLocations());
|
||||
|
||||
return deps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<String> missingTextures)
|
||||
{
|
||||
Set<ResourceLocation> deps = Sets.newHashSet();
|
||||
|
||||
if (base != null)
|
||||
deps.addAll(base.getTextures());
|
||||
deps.addAll(base.func_209559_a(modelGetter, missingTextures));
|
||||
|
||||
for (Pair<IModel, IModelState> pair : parts.values())
|
||||
deps.addAll(pair.getLeft().getTextures());
|
||||
for (Pair<IUnbakedModel, IModelState> pair : parts.values())
|
||||
deps.addAll(pair.getLeft().func_209559_a(modelGetter, missingTextures));
|
||||
|
||||
return deps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
IBakedModel bakedBase = null;
|
||||
|
||||
if (base != null)
|
||||
bakedBase = base.bake(state, format, bakedTextureGetter);
|
||||
bakedBase = base.bake(modelGetter, bakedTextureGetter, state, uvlock, format);
|
||||
|
||||
ImmutableMap.Builder<String, IBakedModel> mapBuilder = ImmutableMap.builder();
|
||||
|
||||
for (Entry<String, Pair<IModel, IModelState>> entry : parts.entrySet())
|
||||
for (Entry<String, Pair<IUnbakedModel, IModelState>> entry : parts.entrySet())
|
||||
{
|
||||
Pair<IModel, IModelState> pair = entry.getValue();
|
||||
mapBuilder.put(entry.getKey(), pair.getLeft().bake(new ModelStateComposition(state, pair.getRight()), format, bakedTextureGetter));
|
||||
Pair<IUnbakedModel, IModelState> pair = entry.getValue();
|
||||
mapBuilder.put(entry.getKey(), pair.getLeft().bake(modelGetter, bakedTextureGetter, new ModelStateComposition(state, pair.getRight()), uvlock, format));
|
||||
}
|
||||
|
||||
if(bakedBase == null && parts.isEmpty())
|
||||
{
|
||||
FMLLog.log.error("MultiModel {} is empty (no base model or parts were provided/resolved)", location);
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
return missing.bake(missing.getDefaultState(), format, bakedTextureGetter);
|
||||
LOGGER.error("MultiModel {} is empty (no base model or parts were provided/resolved)", location);
|
||||
IUnbakedModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
return missing.bake(modelGetter, bakedTextureGetter, missing.getDefaultState(), uvlock, format);
|
||||
}
|
||||
return new Baked(location, true, bakedBase, mapBuilder.build());
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ package net.minecraftforge.client.model;
|
|||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
@ -108,7 +110,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
@Override public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
|
||||
@Override public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { return parent.getQuads(state, side, rand); }
|
||||
@Override public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) { return parent.func_200117_a(state, side, rand); }
|
||||
@Override public ItemOverrideList getOverrides() { return parent.getOverrides(); }
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,8 @@ public abstract class SimpleModelFontRenderer extends FontRenderer {
|
|||
|
||||
public SimpleModelFontRenderer(GameSettings settings, ResourceLocation font, TextureManager manager, boolean isUnicode, Matrix4f matrix, VertexFormat format)
|
||||
{
|
||||
super(settings, font, manager, isUnicode);
|
||||
super(manager, null);
|
||||
// super(settings, font, manager, isUnicode);
|
||||
this.matrix = new Matrix4f(matrix);
|
||||
Matrix3f nm = new Matrix3f();
|
||||
this.matrix.getRotationScale(nm);
|
||||
|
@ -67,7 +68,6 @@ public abstract class SimpleModelFontRenderer extends FontRenderer {
|
|||
public void setSprite(TextureAtlasSprite sprite)
|
||||
{
|
||||
this.sprite = sprite;
|
||||
super.onResourceManagerReload(null);
|
||||
}
|
||||
|
||||
public void setFillBlanks(boolean fillBlanks)
|
||||
|
@ -75,54 +75,6 @@ public abstract class SimpleModelFontRenderer extends FontRenderer {
|
|||
this.fillBlanks = fillBlanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float renderDefaultChar(int pos, boolean italic)
|
||||
{
|
||||
float x = (pos % 16) / 16f;
|
||||
float y = (pos / 16) / 16f;
|
||||
float sh = italic ? 1f : 0f;
|
||||
float w = charWidth[pos] - 1.01f;
|
||||
float h = FONT_HEIGHT - 1.01f;
|
||||
float wt = w / 128f;
|
||||
float ht = h / 128f;
|
||||
|
||||
UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format);
|
||||
quadBuilder.setTexture(sprite);
|
||||
quadBuilder.setQuadOrientation(orientation);
|
||||
|
||||
addVertex(quadBuilder, posX + sh, posY, x, y);
|
||||
addVertex(quadBuilder, posX - sh, posY + h, x, y + ht);
|
||||
addVertex(quadBuilder, posX + w + sh, posY + h, x + wt, y + ht);
|
||||
addVertex(quadBuilder, posX + w - sh, posY, x + wt, y);
|
||||
builder.add(quadBuilder.build());
|
||||
|
||||
if(fillBlanks)
|
||||
{
|
||||
float cuv = 15f / 16f;
|
||||
|
||||
quadBuilder = new UnpackedBakedQuad.Builder(format);
|
||||
quadBuilder.setTexture(sprite);
|
||||
quadBuilder.setQuadOrientation(orientation);
|
||||
|
||||
addVertex(quadBuilder, posX + w + sh, posY, cuv, cuv);
|
||||
addVertex(quadBuilder, posX + w - sh, posY + h, cuv, cuv);
|
||||
addVertex(quadBuilder, posX + charWidth[pos] + sh, posY + h, cuv, cuv);
|
||||
addVertex(quadBuilder, posX + charWidth[pos] - sh, posY, cuv, cuv);
|
||||
builder.add(quadBuilder.build());
|
||||
|
||||
quadBuilder = new UnpackedBakedQuad.Builder(format);
|
||||
quadBuilder.setTexture(sprite);
|
||||
quadBuilder.setQuadOrientation(orientation);
|
||||
|
||||
addVertex(quadBuilder, posX + sh, posY + h, cuv, cuv);
|
||||
addVertex(quadBuilder, posX - sh, posY + FONT_HEIGHT, cuv, cuv);
|
||||
addVertex(quadBuilder, posX + charWidth[pos] + sh, posY + FONT_HEIGHT, cuv, cuv);
|
||||
addVertex(quadBuilder, posX + charWidth[pos] - sh, posY + h, cuv, cuv);
|
||||
builder.add(quadBuilder.build());
|
||||
}
|
||||
return charWidth[pos];
|
||||
}
|
||||
|
||||
private final Vector4f vec = new Vector4f();
|
||||
|
||||
private void addVertex(UnpackedBakedQuad.Builder quadBuilder, float x, float y, float u, float v)
|
||||
|
@ -156,44 +108,6 @@ public abstract class SimpleModelFontRenderer extends FontRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
{
|
||||
super.onResourceManagerReload(resourceManager);
|
||||
String p = locationFontTexture.getResourcePath();
|
||||
if(p.startsWith("textures/")) p = p.substring("textures/".length(), p.length());
|
||||
if(p.endsWith(".png")) p = p.substring(0, p.length() - ".png".length());
|
||||
String f = locationFontTexture.getResourceDomain() + ":" + p;
|
||||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract float renderUnicodeChar(char c, boolean italic);
|
||||
|
||||
@Override
|
||||
protected void doDraw(float shift)
|
||||
{
|
||||
posX += (int)shift;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColor(float r, float g, float b, float a)
|
||||
{
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
@Override public void enableAlpha()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindTexture(ResourceLocation location)
|
||||
{
|
||||
}
|
||||
|
||||
public ImmutableList<BakedQuad> build()
|
||||
{
|
||||
ImmutableList<BakedQuad> ret = builder.build();
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -31,7 +32,8 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.ModelStateComposition;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
|
@ -43,19 +45,19 @@ import javax.annotation.Nullable;
|
|||
|
||||
public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
{
|
||||
private final IModel model;
|
||||
private final IUnbakedModel model;
|
||||
private final IModelState state;
|
||||
private final VertexFormat format;
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter;
|
||||
|
||||
public AnimationItemOverrideList(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ItemOverrideList overrides)
|
||||
public AnimationItemOverrideList(IUnbakedModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ItemOverrideList overrides)
|
||||
{
|
||||
this(model, state, format, bakedTextureGetter, overrides.getOverrides().reverse());
|
||||
}
|
||||
|
||||
public AnimationItemOverrideList(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, List<ItemOverride> overrides)
|
||||
public AnimationItemOverrideList(IUnbakedModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, List<ItemOverride> overrides)
|
||||
{
|
||||
super(overrides);
|
||||
super(model, ModelLoader.defaultModelGetter(), bakedTextureGetter, overrides);
|
||||
this.model = model;
|
||||
this.state = state;
|
||||
this.format = format;
|
||||
|
@ -63,7 +65,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
public IBakedModel func_209581_a(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
|
||||
if (asm != null)
|
||||
|
@ -78,8 +80,9 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
|||
world = Minecraft.getMinecraft().world;
|
||||
}
|
||||
IModelState state = asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft();
|
||||
return model.bake(new ModelStateComposition(state, this.state), format, bakedTextureGetter);
|
||||
// TODO where should uvlock data come from?
|
||||
return model.bake(ModelLoader.defaultModelGetter(), bakedTextureGetter, new ModelStateComposition(state, this.state), false, format);
|
||||
}
|
||||
return super.handleItemState(originalModel, stack, world, entity);
|
||||
return super.func_209581_a(originalModel, stack, world, entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package net.minecraftforge.client.model.animation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
|
@ -29,12 +29,13 @@ import net.minecraft.client.renderer.Tessellator;
|
|||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
|
||||
|
@ -75,8 +76,9 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
|||
}
|
||||
Pair<IModelState, Iterable<Event>> pair = capability.apply(timeAlive / 20);
|
||||
handleEvents((T)entity, timeAlive / 20, pair.getRight());
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
IBakedModel bakedModel = model.bake(pair.getLeft(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
|
||||
IUnbakedModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
// TODO where should uvlock data come from?
|
||||
IBakedModel bakedModel = model.bake(ModelLoader.defaultModelGetter(), ModelLoader.defaultTextureGetter(), pair.getLeft(), false, DefaultVertexFormats.ITEM);
|
||||
|
||||
BlockPos pos = new BlockPos(entity.posX, entity.posY + entity.height, entity.posZ);
|
||||
|
||||
|
@ -93,7 +95,9 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
|||
lighter.setState(Blocks.AIR.getDefaultState());
|
||||
lighter.setBlockPos(pos);
|
||||
boolean empty = true;
|
||||
List<BakedQuad> quads = bakedModel.getQuads(null, null, 0);
|
||||
Random random = new Random();
|
||||
random.setSeed(42);
|
||||
List<BakedQuad> quads = bakedModel.func_200117_a(null, null, random);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
lighter.updateBlockInfo();
|
||||
|
@ -105,7 +109,8 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
|||
}
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
{
|
||||
quads = bakedModel.getQuads(null, side, 0);
|
||||
random.setSeed(42);
|
||||
quads = bakedModel.func_200117_a(null, side, random);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
if(empty) lighter.updateBlockInfo();
|
||||
|
|
|
@ -26,7 +26,7 @@ import net.minecraft.client.renderer.BufferBuilder;
|
|||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.animation.Event;
|
||||
import net.minecraftforge.common.animation.IEventHandler;
|
||||
|
@ -36,6 +36,8 @@ import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
|||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +48,7 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
|
|||
protected static BlockRendererDispatcher blockRenderer;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, float partial, BufferBuilder renderer)
|
||||
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, BufferBuilder renderer)
|
||||
{
|
||||
if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))
|
||||
{
|
||||
|
@ -54,9 +56,9 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
|
|||
}
|
||||
if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
BlockPos pos = te.getPos();
|
||||
IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
|
||||
IWorldReader world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if(state.getPropertyKeys().contains(Properties.StaticProperty))
|
||||
if(state.getBlock().getBlockState().getProperties().contains(Properties.StaticProperty))
|
||||
{
|
||||
state = state.withProperty(Properties.StaticProperty, false);
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
|
|||
|
||||
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
|
||||
|
||||
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
|
||||
blockRenderer.getBlockModelRenderer().func_199324_a(world, model, exState, pos, renderer, false, new Random(), 42);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ import net.minecraft.client.renderer.RenderHelper;
|
|||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRenderer<T>
|
||||
public abstract class FastTESR<T extends TileEntity> extends TileEntityRenderer<T>
|
||||
{
|
||||
@Override
|
||||
public final void render(T te, double x, double y, double z, float partialTicks, int destroyStage, float partial)
|
||||
public final void func_199341_a(T te, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
|
@ -55,7 +55,7 @@ public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRe
|
|||
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
|
||||
renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, partial, buffer);
|
||||
renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
||||
buffer.setTranslation(0, 0, 0);
|
||||
|
||||
tessellator.draw();
|
||||
|
@ -64,5 +64,5 @@ public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer);
|
||||
public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, BufferBuilder buffer);
|
||||
}
|
||||
|
|
|
@ -37,9 +37,12 @@ import javax.vecmath.Matrix4f;
|
|||
import javax.vecmath.Quat4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockPart;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Interpolation;
|
||||
|
@ -53,7 +56,6 @@ import net.minecraftforge.common.model.animation.IJoint;
|
|||
import net.minecraftforge.common.model.animation.IJointClip;
|
||||
import net.minecraftforge.common.model.animation.JointClips;
|
||||
import net.minecraftforge.common.util.JsonUtils;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -69,6 +71,8 @@ import com.google.gson.annotations.SerializedName;
|
|||
|
||||
public class ModelBlockAnimation
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final ImmutableMap<String, ImmutableMap<String, float[]>> joints;
|
||||
private final ImmutableMap<String, MBClip> clips;
|
||||
private transient ImmutableMultimap<Integer, MBJointWeight> jointIndexMap;
|
||||
|
@ -553,9 +557,9 @@ public class ModelBlockAnimation
|
|||
{
|
||||
try
|
||||
{
|
||||
try (IResource resource = manager.getResource(armatureLocation))
|
||||
try (IResource resource = manager.func_199002_a(armatureLocation))
|
||||
{
|
||||
ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), ModelBlockAnimation.class);
|
||||
ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.func_199027_b(), StandardCharsets.UTF_8), ModelBlockAnimation.class);
|
||||
//String json = mbaGson.toJson(mba);
|
||||
return mba;
|
||||
}
|
||||
|
@ -567,7 +571,7 @@ public class ModelBlockAnimation
|
|||
}
|
||||
catch(IOException | JsonParseException e)
|
||||
{
|
||||
FMLLog.log.error("Exception loading vanilla model animation {}, skipping", armatureLocation, e);
|
||||
LOGGER.error("Exception loading vanilla model animation {}, skipping", armatureLocation, e);
|
||||
return defaultModelBlockAnimation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package net.minecraftforge.client.model.b3d;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -36,6 +37,7 @@ import javax.vecmath.Vector3f;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
@ -46,7 +48,6 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.ModelStateComposition;
|
||||
|
@ -72,10 +73,14 @@ import net.minecraftforge.common.property.Properties;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
|
@ -96,6 +101,8 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
{
|
||||
INSTANCE;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private IResourceManager manager;
|
||||
|
||||
private final Set<String> enabledDomains = new HashSet<>();
|
||||
|
@ -121,7 +128,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath());
|
||||
if(!cache.containsKey(file))
|
||||
|
@ -131,17 +138,17 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
{
|
||||
try
|
||||
{
|
||||
resource = manager.getResource(file);
|
||||
resource = manager.func_199002_a(file);
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
if(modelLocation.getPath().startsWith("models/block/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/item/" + file.getPath().substring("models/block/".length())));
|
||||
resource = manager.func_199002_a(new ResourceLocation(file.getNamespace(), "models/item/" + file.getPath().substring("models/block/".length())));
|
||||
else if(modelLocation.getPath().startsWith("models/item/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/block/" + file.getPath().substring("models/item/".length())));
|
||||
resource = manager.func_199002_a(new ResourceLocation(file.getNamespace(), "models/block/" + file.getPath().substring("models/item/".length())));
|
||||
else throw e;
|
||||
}
|
||||
B3DModel.Parser parser = new B3DModel.Parser(resource.getInputStream());
|
||||
B3DModel.Parser parser = new B3DModel.Parser(resource.func_199027_b());
|
||||
B3DModel model = parser.parse();
|
||||
cache.put(file, model);
|
||||
}
|
||||
|
@ -402,7 +409,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
}
|
||||
}
|
||||
|
||||
private static final class ModelWrapper implements IModel
|
||||
private static final class ModelWrapper implements IUnbakedModel
|
||||
{
|
||||
private final ResourceLocation modelLocation;
|
||||
private final B3DModel model;
|
||||
|
@ -449,13 +456,19 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
return Collections2.filter(textures.values(), loc -> !loc.getPath().startsWith("#"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
|
||||
|
@ -463,7 +476,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
{
|
||||
if(e.getValue().getPath().startsWith("#"))
|
||||
{
|
||||
FMLLog.log.fatal("unresolved texture '{}' for b3d model '{}'", e.getValue().getPath(), modelLocation);
|
||||
LOGGER.fatal("unresolved texture '{}' for b3d model '{}'", e.getValue().getPath(), modelLocation);
|
||||
builder.put(e.getKey(), missing);
|
||||
}
|
||||
else
|
||||
|
@ -521,7 +534,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.fatal("unknown mesh definition '{}' in array for b3d model '{}'", s.toString(), modelLocation);
|
||||
LOGGER.fatal("unknown mesh definition '{}' in array for b3d model '{}'", s.toString(), modelLocation);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -530,7 +543,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.fatal("unknown mesh definition '{}' for b3d model '{}'", e.toString(), modelLocation);
|
||||
LOGGER.fatal("unknown mesh definition '{}' for b3d model '{}'", e.toString(), modelLocation);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -544,7 +557,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.fatal("unknown keyframe definition '{}' for b3d model '{}'", e.toString(), modelLocation);
|
||||
LOGGER.fatal("unknown keyframe definition '{}' for b3d model '{}'", e.toString(), modelLocation);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -636,7 +649,7 @@ public enum B3DLoader implements ICustomModelLoader
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
{
|
||||
if(side != null) return ImmutableList.of();
|
||||
IModelState modelState = this.state;
|
||||
|
|
|
@ -25,11 +25,11 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -72,7 +72,7 @@ public enum OBJLoader implements ICustomModelLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath());
|
||||
if (!cache.containsKey(file))
|
||||
|
@ -82,14 +82,14 @@ public enum OBJLoader implements ICustomModelLoader {
|
|||
{
|
||||
try
|
||||
{
|
||||
resource = manager.getResource(file);
|
||||
resource = manager.func_199002_a(file);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
if (modelLocation.getPath().startsWith("models/block/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/item/" + file.getPath().substring("models/block/".length())));
|
||||
resource = manager.func_199002_a(new ResourceLocation(file.getNamespace(), "models/item/" + file.getPath().substring("models/block/".length())));
|
||||
else if (modelLocation.getPath().startsWith("models/item/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/block/" + file.getPath().substring("models/item/".length())));
|
||||
resource = manager.func_199002_a(new ResourceLocation(file.getNamespace(), "models/block/" + file.getPath().substring("models/item/".length())));
|
||||
else throw e;
|
||||
}
|
||||
OBJModel.Parser parser = new OBJModel.Parser(resource, manager);
|
||||
|
|
|
@ -44,12 +44,13 @@ import javax.vecmath.Vector4f;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.*;
|
||||
|
@ -61,13 +62,16 @@ import net.minecraftforge.common.model.TRSRTransformation;
|
|||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
|
@ -77,8 +81,10 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class OBJModel implements IModel
|
||||
public class OBJModel implements IUnbakedModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
//private Gson GSON = new GsonBuilder().create();
|
||||
private MaterialLibrary matLib;
|
||||
private final ResourceLocation modelLocation;
|
||||
|
@ -97,7 +103,7 @@ public class OBJModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> func_209559_a(Function<ResourceLocation, IUnbakedModel> p_209559_1_, Set<String> p_209559_2_)
|
||||
{
|
||||
Iterator<Material> materialIterator = this.matLib.materials.values().iterator();
|
||||
List<ResourceLocation> textures = Lists.newArrayList();
|
||||
|
@ -112,16 +118,22 @@ public class OBJModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
{
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
|
||||
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
|
||||
for (Map.Entry<String, Material> e : matLib.materials.entrySet())
|
||||
{
|
||||
if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#"))
|
||||
if (e.getValue().getTexture().getTextureLocation().getPath().startsWith("#"))
|
||||
{
|
||||
FMLLog.log.fatal("OBJLoader: Unresolved texture '{}' for obj model '{}'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation);
|
||||
LOGGER.fatal("OBJLoader: Unresolved texture '{}' for obj model '{}'", e.getValue().getTexture().getTextureLocation().getPath(), modelLocation);
|
||||
builder.put(e.getKey(), missing);
|
||||
}
|
||||
else
|
||||
|
@ -139,14 +151,14 @@ public class OBJModel implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel process(ImmutableMap<String, String> customData)
|
||||
public IUnbakedModel process(ImmutableMap<String, String> customData)
|
||||
{
|
||||
OBJModel ret = new OBJModel(this.matLib, this.modelLocation, new CustomData(this.customData, customData));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel retexture(ImmutableMap<String, String> textures)
|
||||
public IUnbakedModel retexture(ImmutableMap<String, String> textures)
|
||||
{
|
||||
OBJModel ret = new OBJModel(this.matLib.makeLibWithReplacements(textures), this.modelLocation, this.customData);
|
||||
return ret;
|
||||
|
@ -204,8 +216,8 @@ public class OBJModel implements IModel
|
|||
public Parser(IResource from, IResourceManager manager) throws IOException
|
||||
{
|
||||
this.manager = manager;
|
||||
this.objFrom = from.getResourceLocation();
|
||||
this.objStream = new InputStreamReader(from.getInputStream(), StandardCharsets.UTF_8);
|
||||
this.objFrom = from.func_199029_a();
|
||||
this.objStream = new InputStreamReader(from.func_199027_b(), StandardCharsets.UTF_8);
|
||||
this.objReader = new BufferedReader(objStream);
|
||||
}
|
||||
|
||||
|
@ -258,7 +270,7 @@ public class OBJModel implements IModel
|
|||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.error("OBJModel.Parser: (Model: '{}', Line: {}) material '{}' referenced but was not found", objFrom, lineNum, data);
|
||||
LOGGER.error("OBJModel.Parser: (Model: '{}', Line: {}) material '{}' referenced but was not found", objFrom, lineNum, data);
|
||||
}
|
||||
usemtlCounter++;
|
||||
}
|
||||
|
@ -285,7 +297,7 @@ public class OBJModel implements IModel
|
|||
else if (key.equalsIgnoreCase("f")) // Face Elements: f v1[/vt1][/vn1] ...
|
||||
{
|
||||
if (splitData.length > 4)
|
||||
FMLLog.log.warn("OBJModel.Parser: found a face ('f') with more than 4 vertices, only the first 4 of these vertices will be rendered!");
|
||||
LOGGER.warn("OBJModel.Parser: found a face ('f') with more than 4 vertices, only the first 4 of these vertices will be rendered!");
|
||||
|
||||
List<Vertex> v = Lists.newArrayListWithCapacity(splitData.length);
|
||||
|
||||
|
@ -368,7 +380,7 @@ public class OBJModel implements IModel
|
|||
if (!unknownObjectCommands.contains(key))
|
||||
{
|
||||
unknownObjectCommands.add(key);
|
||||
FMLLog.log.info("OBJLoader.Parser: command '{}' (model: '{}') is not currently supported, skipping. Line: {} '{}'", key, objFrom, lineNum, currentLine);
|
||||
LOGGER.info("OBJLoader.Parser: command '{}' (model: '{}') is not currently supported, skipping. Line: {} '{}'", key, objFrom, lineNum, currentLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -502,10 +514,10 @@ public class OBJModel implements IModel
|
|||
this.materials.clear();
|
||||
boolean hasSetTexture = false;
|
||||
boolean hasSetColor = false;
|
||||
String domain = from.getResourceDomain();
|
||||
String domain = from.getNamespace();
|
||||
if (!path.contains("/"))
|
||||
path = from.getResourcePath().substring(0, from.getResourcePath().lastIndexOf("/") + 1) + path;
|
||||
mtlStream = new InputStreamReader(manager.getResource(new ResourceLocation(domain, path)).getInputStream(), StandardCharsets.UTF_8);
|
||||
path = from.getPath().substring(0, from.getPath().lastIndexOf("/") + 1) + path;
|
||||
mtlStream = new InputStreamReader(manager.func_199002_a(new ResourceLocation(domain, path)).func_199027_b(), StandardCharsets.UTF_8);
|
||||
mtlReader = new BufferedReader(mtlStream);
|
||||
|
||||
String currentLine = "";
|
||||
|
@ -545,7 +557,7 @@ public class OBJModel implements IModel
|
|||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.info("OBJModel: A color has already been defined for material '{}' in '{}'. The color defined by key '{}' will not be applied!", material.getName(), new ResourceLocation(domain, path).toString(), key);
|
||||
LOGGER.info("OBJModel: A color has already been defined for material '{}' in '{}'. The color defined by key '{}' will not be applied!", material.getName(), new ResourceLocation(domain, path).toString(), key);
|
||||
}
|
||||
}
|
||||
else if (key.equalsIgnoreCase("map_Ka") || key.equalsIgnoreCase("map_Kd") || key.equalsIgnoreCase("map_Ks"))
|
||||
|
@ -569,7 +581,7 @@ public class OBJModel implements IModel
|
|||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.info("OBJModel: A texture has already been defined for material '{}' in '{}'. The texture defined by key '{}' will not be applied!", material.getName(), new ResourceLocation(domain, path).toString(), key);
|
||||
LOGGER.info("OBJModel: A texture has already been defined for material '{}' in '{}'. The texture defined by key '{}' will not be applied!", material.getName(), new ResourceLocation(domain, path).toString(), key);
|
||||
}
|
||||
}
|
||||
else if (key.equalsIgnoreCase("d") || key.equalsIgnoreCase("Tr"))
|
||||
|
@ -585,7 +597,7 @@ public class OBJModel implements IModel
|
|||
if (!unknownMaterialCommands.contains(key))
|
||||
{
|
||||
unknownMaterialCommands.add(key);
|
||||
FMLLog.log.info("OBJLoader.MaterialLibrary: key '{}' (model: '{}') is not currently supported, skipping", key, new ResourceLocation(domain, path));
|
||||
LOGGER.info("OBJLoader.MaterialLibrary: key '{}' (model: '{}') is not currently supported, skipping", key, new ResourceLocation(domain, path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1306,7 +1318,7 @@ public class OBJModel implements IModel
|
|||
|
||||
// FIXME: merge with getQuads
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
|
||||
public List<BakedQuad> func_200117_a(IBlockState blockState, EnumFacing side, Random rand)
|
||||
{
|
||||
if (side != null) return ImmutableList.of();
|
||||
if (quads == null)
|
||||
|
|
|
@ -24,14 +24,14 @@ import net.minecraft.client.renderer.color.BlockColors;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
public class BlockInfo
|
||||
{
|
||||
private static final EnumFacing[] SIDES = EnumFacing.values();
|
||||
|
||||
private final BlockColors colors;
|
||||
private IBlockAccess world;
|
||||
private IWorldReader world;
|
||||
private IBlockState state;
|
||||
private BlockPos blockPos;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class BlockInfo
|
|||
shz = (float) offset.z;
|
||||
}
|
||||
|
||||
public void setWorld(IBlockAccess world)
|
||||
public void setWorld(IWorldReader world)
|
||||
{
|
||||
this.world = world;
|
||||
cachedTint = -1;
|
||||
|
@ -135,9 +135,9 @@ public class BlockInfo
|
|||
{
|
||||
if(!state.doesSideBlockRendering(world, blockPos, side))
|
||||
{
|
||||
int x = side.getFrontOffsetX() + 1;
|
||||
int y = side.getFrontOffsetY() + 1;
|
||||
int z = side.getFrontOffsetZ() + 1;
|
||||
int x = side.getXOffset() + 1;
|
||||
int y = side.getYOffset() + 1;
|
||||
int z = side.getZOffset() + 1;
|
||||
s[x][y][z] = Math.max(s[1][1][1] - 1, s[x][y][z]);
|
||||
b[x][y][z] = Math.max(b[1][1][1] - 1, b[x][y][z]);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class BlockInfo
|
|||
}
|
||||
}
|
||||
|
||||
public IBlockAccess getWorld()
|
||||
public IWorldReader getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
|
@ -29,7 +30,8 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
|
|||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
|
||||
public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
|
@ -49,7 +51,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean renderModelFlat(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, long rand)
|
||||
public boolean func_199325_c(IWorldReader world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, Random rand, long seed)
|
||||
{
|
||||
if(ForgeMod.forgeLightPipelineEnabled)
|
||||
{
|
||||
|
@ -61,16 +63,16 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
lighterFlat.get().setParent(newCons);
|
||||
}
|
||||
wrFlat.get().setOffset(pos);
|
||||
return render(lighterFlat.get(), world, model, state, pos, buffer, checkSides, rand);
|
||||
return render(lighterFlat.get(), world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.renderModelFlat(world, model, state, pos, buffer, checkSides, rand);
|
||||
return super.func_199325_c(world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderModelSmooth(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, long rand)
|
||||
public boolean func_199326_b(IWorldReader world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, Random rand, long seed)
|
||||
{
|
||||
if(ForgeMod.forgeLightPipelineEnabled)
|
||||
{
|
||||
|
@ -82,21 +84,21 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
lighterSmooth.get().setParent(newCons);
|
||||
}
|
||||
wrSmooth.get().setOffset(pos);
|
||||
return render(lighterSmooth.get(), world, model, state, pos, buffer, checkSides, rand);
|
||||
return render(lighterSmooth.get(), world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.renderModelSmooth(world, model, state, pos, buffer, checkSides, rand);
|
||||
return super.func_199326_b(world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder wr, boolean checkSides, long rand)
|
||||
public static boolean render(VertexLighterFlat lighter, IWorldReader world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder wr, boolean checkSides, Random rand, long seed)
|
||||
{
|
||||
lighter.setWorld(world);
|
||||
lighter.setState(state);
|
||||
lighter.setBlockPos(pos);
|
||||
boolean empty = true;
|
||||
List<BakedQuad> quads = model.getQuads(state, null, rand);
|
||||
List<BakedQuad> quads = model.func_200117_a(state, null, rand);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
lighter.updateBlockInfo();
|
||||
|
@ -108,7 +110,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
}
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
{
|
||||
quads = model.getQuads(state, side, rand);
|
||||
quads = model.func_200117_a(state, side, rand);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
if(!checkSides || state.shouldSideBeRendered(world, pos, side))
|
||||
|
|
|
@ -152,7 +152,7 @@ public class LightUtil
|
|||
{
|
||||
int length = 4 < to.length ? 4 : to.length;
|
||||
VertexFormatElement element = formatFrom.getElement(e);
|
||||
int vertexStart = v * formatFrom.getNextOffset() + formatFrom.getOffset(e);
|
||||
int vertexStart = v * formatFrom.getSize() + formatFrom.getOffset(e);
|
||||
int count = element.getElementCount();
|
||||
VertexFormatElement.EnumType type = element.getType();
|
||||
int size = type.getSize();
|
||||
|
@ -206,7 +206,7 @@ public class LightUtil
|
|||
public static void pack(float[] from, int[] to, VertexFormat formatTo, int v, int e)
|
||||
{
|
||||
VertexFormatElement element = formatTo.getElement(e);
|
||||
int vertexStart = v * formatTo.getNextOffset() + formatTo.getOffset(e);
|
||||
int vertexStart = v * formatTo.getSize() + formatTo.getOffset(e);
|
||||
int count = element.getElementCount();
|
||||
VertexFormatElement.EnumType type = element.getType();
|
||||
int size = type.getSize();
|
||||
|
|
|
@ -35,7 +35,7 @@ public class UnpackedBakedQuad extends BakedQuad
|
|||
|
||||
public UnpackedBakedQuad(float[][][] unpackedData, int tint, EnumFacing orientation, TextureAtlasSprite texture, boolean applyDiffuseLighting, VertexFormat format)
|
||||
{
|
||||
super(new int[format.getNextOffset() /* / 4 * 4 */], tint, orientation, texture, applyDiffuseLighting, format);
|
||||
super(new int[format.getSize() /* / 4 * 4 */], tint, orientation, texture, applyDiffuseLighting, format);
|
||||
this.unpackedData = unpackedData;
|
||||
this.format = format;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class VertexBufferConsumer implements IVertexConsumer
|
|||
{
|
||||
super();
|
||||
this.renderer = renderer;
|
||||
quadData = new int[renderer.getVertexFormat().getNextOffset()/* / 4 * 4 */];
|
||||
quadData = new int[renderer.getVertexFormat().getSize()/* / 4 * 4 */];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
|
|||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
|||
|
||||
private static VertexFormat withNormal(VertexFormat format)
|
||||
{
|
||||
if (format == null || format.hasNormal()) return format;
|
||||
if (format == null || format.func_207751_b()) return format;
|
||||
return new VertexFormat(format).addElement(NORMAL_4F);
|
||||
}
|
||||
|
||||
|
@ -190,10 +190,6 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
|||
color[v][i] *= d;
|
||||
}
|
||||
}
|
||||
if(EntityRenderer.anaglyphEnable)
|
||||
{
|
||||
applyAnaglyph(color[v]);
|
||||
}
|
||||
|
||||
// no need for remapping cause all we could've done is add 1 element to the end
|
||||
for(int e = 0; e < count; e++)
|
||||
|
@ -231,14 +227,6 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
|||
tint = -1;
|
||||
}
|
||||
|
||||
protected void applyAnaglyph(float[] color)
|
||||
{
|
||||
float r = color[0];
|
||||
color[0] = (r * 30 + color[1] * 59 + color[2] * 11) / 100;
|
||||
color[1] = (r * 3 + color[1] * 7) / 10;
|
||||
color[2] = (r * 3 + color[2] * 7) / 10;
|
||||
}
|
||||
|
||||
protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z)
|
||||
{
|
||||
final float e1 = 1f - 1e-2f;
|
||||
|
@ -287,7 +275,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
|||
this.diffuse = diffuse;
|
||||
}
|
||||
|
||||
public void setWorld(IBlockAccess world)
|
||||
public void setWorld(IWorldReader world)
|
||||
{
|
||||
blockInfo.setWorld(world);
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
package net.minecraftforge.client.resource;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* An enum of all {@link IResourceType}s used by the Vanilla game. These should be used if handling vanilla-related
|
||||
* resources.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public enum VanillaResourceType implements IResourceType
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public static TRSRTransformation from(ItemTransformVec3f transform)
|
||||
{
|
||||
return transform.equals(ItemTransformVec3f.DEFAULT) ? identity : new TRSRTransformation(transform);
|
||||
return transform.equals(ItemTransformVec3f.DEFAULT) ? identity : new TRSRTransformation(toVecmath(transform.translation), quatFromXYZDegrees(toVecmath(transform.rotation)), toVecmath(transform.scale), null);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
@ -711,6 +711,10 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
|||
m.func_195885_a(0, 3), m.func_195885_a(1, 3), m.func_195885_a(2, 3), m.func_195885_a(3, 3));
|
||||
}
|
||||
|
||||
public static Quat4f toVecmath(net.minecraft.client.renderer.Quaternion q)
|
||||
{
|
||||
return new Quat4f(q.func_195889_a(), q.func_195891_b(), q.func_195893_c(), q.func_195894_d());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static net.minecraft.client.renderer.Vector3f toMojang(Vector3f vec)
|
||||
|
|
|
@ -218,13 +218,13 @@ public final class AnimationStateMachine implements IAnimationStateMachine
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public static IAnimationStateMachine load(IResourceManager manager, ResourceLocation location, ImmutableMap<String, ITimeValue> customParameters)
|
||||
{
|
||||
try (IResource resource = manager.getResource(location))
|
||||
try (IResource resource = manager.func_199002_a(location))
|
||||
{
|
||||
ClipResolver clipResolver = new ClipResolver();
|
||||
ParameterResolver parameterResolver = new ParameterResolver(customParameters);
|
||||
Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
|
||||
TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
|
||||
AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), AnimationStateMachine.class);
|
||||
AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.func_199027_b(), StandardCharsets.UTF_8), AnimationStateMachine.class);
|
||||
clipResolver.asm = asm;
|
||||
parameterResolver.asm = asm;
|
||||
asm.initialize();
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
|
||||
package net.minecraftforge.common.model.animation;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -60,15 +59,9 @@ public class CapabilityAnimation
|
|||
this.asm = asm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == ANIMATION_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
public <T> OptionalCapabilityInstance<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if(capability == ANIMATION_CAPABILITY)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ package net.minecraftforge.common.model.animation;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -33,11 +34,12 @@ import net.minecraftforge.common.animation.ITimeValue;
|
|||
import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -59,6 +61,8 @@ import javax.annotation.Nullable;
|
|||
*/
|
||||
public final class Clips
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Clip that does nothing.
|
||||
*/
|
||||
|
@ -91,13 +95,13 @@ public final class Clips
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName)
|
||||
{
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
IUnbakedModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
Optional<? extends IClip> clip = model.getClip(clipName);
|
||||
if (clip.isPresent())
|
||||
{
|
||||
return new ModelClip(clip.get(), modelLocation, clipName);
|
||||
}
|
||||
FMLLog.log.error("Unable to find clip {} in the model {}", clipName, modelLocation);
|
||||
LOGGER.error("Unable to find clip {} in the model {}", clipName, modelLocation);
|
||||
// FIXME: missing clip?
|
||||
return new ModelClip(IdentityClip.INSTANCE, modelLocation, clipName);
|
||||
}
|
||||
|
|
|
@ -24,19 +24,14 @@ import com.google.common.collect.HashMultimap;
|
|||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import org.apache.logging.log4j.message.SimpleMessage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.minecraftforge.client.model.ModelLoader.getInventoryVariant;
|
||||
|
@ -45,39 +40,35 @@ public class ModelLoaderErrorMessage extends SimpleMessage
|
|||
{
|
||||
private final ModelResourceLocation resourceLocation;
|
||||
private final Exception exception;
|
||||
private final IRegistry<ModelResourceLocation, IBakedModel> modelRegistry;
|
||||
|
||||
private static Multimap<ModelResourceLocation, IBlockState> reverseBlockMap = HashMultimap.create();
|
||||
private static Multimap<ModelResourceLocation, String> reverseItemMap = HashMultimap.create();
|
||||
|
||||
private static void buildLookups(final BlockModelShapes blockModelShapes, Function<Item,Iterable<String>> itemNameLookup) {
|
||||
private static void buildLookups() {
|
||||
if (!reverseBlockMap.isEmpty()) return;
|
||||
for(Map.Entry<IBlockState, ModelResourceLocation> entry : blockModelShapes.getBlockStateMapper().putAllStateModelLocations().entrySet())
|
||||
{
|
||||
reverseBlockMap.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
||||
ForgeRegistries.BLOCKS.getValues().stream()
|
||||
.flatMap(block -> block.getBlockState().getValidStates().stream())
|
||||
.forEach(state -> reverseBlockMap.put(BlockModelShapes.func_209554_c(state), state));
|
||||
|
||||
ForgeRegistries.ITEMS.forEach(item ->
|
||||
{
|
||||
for(String s : itemNameLookup.apply(item))
|
||||
{
|
||||
ModelResourceLocation memory = getInventoryVariant(s);
|
||||
ModelResourceLocation memory = getInventoryVariant(ForgeRegistries.ITEMS.getKey(item).toString());
|
||||
reverseItemMap.put(memory, item.getRegistryName().toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public ModelLoaderErrorMessage(ModelResourceLocation resourceLocation, Exception exception, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, BlockModelShapes blockModelShapes, Function<Item, Iterable<String>> itemNameLookup)
|
||||
public ModelLoaderErrorMessage(ModelResourceLocation resourceLocation, Exception exception)
|
||||
{
|
||||
// if we're logging these error messages, this will get built for reference
|
||||
buildLookups(blockModelShapes, itemNameLookup);
|
||||
buildLookups();
|
||||
this.resourceLocation = resourceLocation;
|
||||
this.exception = exception;
|
||||
this.modelRegistry = modelRegistry;
|
||||
}
|
||||
|
||||
private void stuffs() {
|
||||
String domain = resourceLocation.getResourceDomain();
|
||||
String domain = resourceLocation.getNamespace();
|
||||
String errorMsg = "Exception loading model for variant " + resourceLocation;
|
||||
Collection<IBlockState> blocks = reverseBlockMap.get(resourceLocation);
|
||||
if(!blocks.isEmpty())
|
||||
|
|
|
@ -107,9 +107,12 @@ public net.minecraft.item.crafting.RecipesBanners$RecipeDuplicatePattern
|
|||
public net.minecraft.block.state.BlockStateContainer$StateImplementation
|
||||
protected net.minecraft.block.state.BlockStateContainer$StateImplementation <init>(Lnet/minecraft/block/Block;Lcom/google/common/collect/ImmutableMap;)V
|
||||
protected net.minecraft.block.state.BlockStateContainer$StateImplementation field_177238_c # propertyValueTable
|
||||
|
||||
# ModelBlock
|
||||
public net.minecraft.client.renderer.block.model.ModelBlock field_178318_c # textures
|
||||
public net.minecraft.client.renderer.block.model.ModelBlock field_178315_d # parent
|
||||
public net.minecraft.client.renderer.block.model.ModelBlock field_178322_i # ambientOcclusion
|
||||
public net.minecraft.client.renderer.block.model.ModelBlock func_209568_a(Lnet/minecraft/client/renderer/block/model/ModelBlock;Ljava/util/function/Function;Ljava/util/function/Function;)Lnet/minecraft/client/renderer/block/model/ItemOverrideList; # getOverrides
|
||||
public net.minecraft.client.renderer.block.model.ModelBlock func_187966_f()Ljava/util/List; # getOverrides
|
||||
|
||||
# ModelBakery
|
||||
|
@ -145,7 +148,11 @@ protected net.minecraft.client.renderer.block.model.ModelBakery func_188638_a(Ln
|
|||
#public net.minecraft.client.renderer.block.model.WeightedBakedModel field_177565_b # models
|
||||
|
||||
# ItemModelMesher
|
||||
protected net.minecraft.client.renderer.ItemModelMesher field_178092_c # shapers
|
||||
# This field is public and uses int IDs, so we hide it and expose ItemModelMesherForge methods instead
|
||||
private net.minecraft.client.renderer.ItemModelMesher field_199313_a
|
||||
|
||||
# ItemOverrideList
|
||||
protected net.minecraft.client.renderer.block.model.ItemOverrideList <init>()V
|
||||
|
||||
# EnumFacing
|
||||
public net.minecraft.util.EnumFacing field_82609_l # VALUES
|
||||
|
|
Loading…
Reference in a new issue