Fix bucket model. Some mask textures were not added to the repository, and the bucket override generation was broken.
Fix OBJ loading crash due to a float value being parsed as int. Fixes 6377
|
@ -1,6 +1,13 @@
|
|||
--- a/net/minecraft/client/renderer/model/BakedQuad.java
|
||||
+++ b/net/minecraft/client/renderer/model/BakedQuad.java
|
||||
@@ -12,7 +12,17 @@
|
||||
@@ -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[] field_178215_a;
|
||||
protected final int field_178213_b;
|
||||
protected final Direction field_178214_c;
|
||||
protected final TextureAtlasSprite field_187509_d;
|
||||
|
||||
|
@ -18,14 +25,20 @@
|
|||
this.field_178215_a = p_i46574_1_;
|
||||
this.field_178213_b = p_i46574_2_;
|
||||
this.field_178214_c = p_i46574_3_;
|
||||
@@ -34,4 +44,19 @@
|
||||
@@ -34,4 +44,25 @@
|
||||
public Direction func_178210_d() {
|
||||
return this.field_178214_c;
|
||||
}
|
||||
+
|
||||
+ // Forge start
|
||||
+ 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;
|
||||
+ }
|
||||
|
|
|
@ -19,17 +19,18 @@
|
|||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.TRSRTransformer;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
@ -38,12 +39,10 @@ import java.util.Arrays;
|
|||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Forge reimplementation of vanilla {@link ItemModelGenerator}, i.e. builtin/generated models,
|
||||
* with the following changes:
|
||||
|
@ -86,19 +85,24 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
|||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform sprite, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
//TODO: Verify
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
TransformationMatrix transform = sprite.func_225615_b_();
|
||||
boolean identity = transform.isIdentity();
|
||||
for(int i = 0; i < textures.size(); i++)
|
||||
{
|
||||
TextureAtlasSprite tas = spriteGetter.apply(textures.get(i));
|
||||
builder.addAll(getQuadsForSprite(i, tas, DefaultVertexFormats.BLOCK, transform));
|
||||
}
|
||||
ImmutableList<BakedQuad> quads = getQuadsForSprites(textures, DefaultVertexFormats.BLOCK, transform, spriteGetter);
|
||||
TextureAtlasSprite particle = spriteGetter.apply(
|
||||
owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : textures.get(0)
|
||||
);
|
||||
ImmutableMap<TransformType, TransformationMatrix> map = PerspectiveMapWrapper.getTransforms(sprite);
|
||||
return new BakedItemModel(builder.build(), particle, map, overrides, identity);
|
||||
return new BakedItemModel(quads, particle, map, overrides, transform.isIdentity());
|
||||
}
|
||||
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprites(List<Material> textures, VertexFormat format, TransformationMatrix transform, Function<Material, TextureAtlasSprite> spriteGetter)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
for(int i = 0; i < textures.size(); i++)
|
||||
{
|
||||
TextureAtlasSprite tas = spriteGetter.apply(textures.get(i));
|
||||
builder.addAll(getQuadsForSprite(i, tas, format, transform));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprite(int tint, TextureAtlasSprite sprite, VertexFormat format, TransformationMatrix transform)
|
||||
|
|
|
@ -19,13 +19,10 @@
|
|||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
@ -34,7 +31,9 @@ import net.minecraft.client.renderer.Quaternion;
|
|||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.*;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.PngSizeInfo;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
@ -48,19 +47,23 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
@ -123,7 +126,7 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform sprite, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
Material particleLocation = owner.resolveTexture("particle");
|
||||
if (MissingTextureSprite.getLocation().toString().equals(particleLocation))
|
||||
|
@ -152,35 +155,30 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
|
||||
IModelTransform transformsFromModel = owner.getCombinedTransform();
|
||||
|
||||
IModelTransform state = sprite;
|
||||
ImmutableMap<TransformType, TransformationMatrix> transformMap = transformsFromModel != null ?
|
||||
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(transformsFromModel, state)) :
|
||||
PerspectiveMapWrapper.getTransforms(state);
|
||||
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(transformsFromModel, modelTransform)) :
|
||||
PerspectiveMapWrapper.getTransforms(modelTransform);
|
||||
|
||||
TextureAtlasSprite particleSprite = particleLocation != null ? spriteGetter.apply(particleLocation) : null;
|
||||
|
||||
// if the fluid is lighter than air, will manipulate the initial state to be rotated 180deg to turn it upside down
|
||||
if (flipGas && fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir())
|
||||
{
|
||||
sprite = new ModelTransformComposition(state, new SimpleModelTransform(new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null).blockCenterToCorner()));
|
||||
state = sprite;
|
||||
modelTransform = new ModelTransformComposition(modelTransform, new SimpleModelTransform(new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null)));
|
||||
}
|
||||
|
||||
TransformationMatrix transform = state.func_225615_b_();
|
||||
TransformationMatrix transform = modelTransform.func_225615_b_();
|
||||
|
||||
TextureAtlasSprite fluidSprite = fluid != Fluids.EMPTY ? spriteGetter.apply(ForgeHooksClient.getBlockMaterial(fluid.getAttributes().getStillTexture())) : null;
|
||||
|
||||
if (particleSprite == null) particleSprite = fluidSprite;
|
||||
|
||||
Random random = new Random();
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
|
||||
if (baseLocation != null)
|
||||
{
|
||||
// build base (insidest)
|
||||
IBakedModel model = new ItemLayerModel(ImmutableList.of(baseLocation)).bake(owner, bakery, spriteGetter, sprite, ItemOverrideList.EMPTY, modelLocation);
|
||||
random.setSeed(42);
|
||||
builder.addAll(model.getQuads(null, null, random));
|
||||
builder.addAll(ItemLayerModel.getQuadsForSprites(ImmutableList.of(baseLocation), DefaultVertexFormats.BLOCK, transform, spriteGetter));
|
||||
}
|
||||
|
||||
if (fluidMaskLocation != null && fluidSprite != null)
|
||||
|
@ -218,7 +216,7 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
}
|
||||
}
|
||||
|
||||
return new BakedDynBucket(bakery, owner, this, builder.build(), particleSprite, DefaultVertexFormats.BLOCK, Maps.immutableEnumMap(transformMap), Maps.newHashMap(), transform.isIdentity());
|
||||
return new BakedDynBucket(bakery, owner, this, builder.build(), particleSprite, DefaultVertexFormats.BLOCK, Maps.immutableEnumMap(transformMap), Maps.newHashMap(), transform.isIdentity(), modelTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -418,7 +416,7 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
if (!model.cache.containsKey(name))
|
||||
{
|
||||
ModelDynBucket parent = model.parent.withFluid(fluid);
|
||||
IBakedModel bakedModel = parent.bake(model.owner, bakery, ModelLoader.defaultTextureGetter(), new SimpleModelTransform(model.transforms), model.getOverrides(), new ResourceLocation("forge:bucket_override"));
|
||||
IBakedModel bakedModel = parent.bake(model.owner, bakery, ModelLoader.defaultTextureGetter(), model.originalTransform, model.getOverrides(), new ResourceLocation("forge:bucket_override"));
|
||||
model.cache.put(name, bakedModel);
|
||||
return bakedModel;
|
||||
}
|
||||
|
@ -437,6 +435,7 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
private final ModelDynBucket parent;
|
||||
private final Map<String, IBakedModel> cache; // contains all the baked models since they'll never change
|
||||
private final VertexFormat format;
|
||||
private final IModelTransform originalTransform;
|
||||
|
||||
BakedDynBucket(ModelBakery bakery,
|
||||
IModelConfiguration owner, ModelDynBucket parent,
|
||||
|
@ -445,13 +444,15 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
VertexFormat format,
|
||||
ImmutableMap<TransformType, TransformationMatrix> transforms,
|
||||
Map<String, IBakedModel> cache,
|
||||
boolean untransformed)
|
||||
boolean untransformed,
|
||||
IModelTransform originalTransform)
|
||||
{
|
||||
super(quads, particle, transforms, new BakedDynBucketOverrideHandler(bakery), untransformed);
|
||||
this.owner = owner;
|
||||
this.format = format;
|
||||
this.parent = parent;
|
||||
this.cache = cache;
|
||||
this.originalTransform = originalTransform;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
{
|
||||
if (transforms.hasCustomTransform(type))
|
||||
{
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)).blockCenterToCorner());
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)));
|
||||
}
|
||||
}
|
||||
return ImmutableMap.copyOf(map);
|
||||
|
@ -96,7 +96,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
}
|
||||
else if (transforms.hasCustomTransform(type))
|
||||
{
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)).blockCenterToCorner());
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)));
|
||||
}
|
||||
}
|
||||
return ImmutableMap.copyOf(map);
|
||||
|
@ -107,9 +107,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
TransformationMatrix tr = transforms.getOrDefault(cameraTransformType, TransformationMatrix.func_227983_a_());
|
||||
if (!tr.isIdentity())
|
||||
{
|
||||
// Push to the matrix to make it not empty and indicate that we want to transform things
|
||||
mat.func_227860_a_();
|
||||
mat.func_227866_c_().func_227870_a_().func_226595_a_(tr.blockCornerToCenter().func_227988_c_());
|
||||
tr.push(mat);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
@ -119,9 +117,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
TransformationMatrix tr = state.getPartTransformation(cameraTransformType);
|
||||
if (!tr.isIdentity())
|
||||
{
|
||||
// Push to the matrix to make it not empty and indicate that we want to transform things
|
||||
mat.func_227860_a_();
|
||||
mat.func_227866_c_().func_227870_a_().func_226595_a_(tr.blockCornerToCenter().func_227988_c_());
|
||||
tr.push(mat);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class QuadTransformer
|
|||
private void processVertices(int[] inData, int[] outData)
|
||||
{
|
||||
// TODO: Extract rotation matrix and fix NORMALs if present.
|
||||
int stride = format.getSize() / 4;
|
||||
int stride = format.getIntegerSize();
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
int offset = positionOffset + i * stride;
|
||||
|
|
|
@ -75,7 +75,7 @@ public class MaterialLibrary
|
|||
break;
|
||||
|
||||
case "Ns":
|
||||
currentMaterial.specularHighlight = Integer.parseInt(line[1]);
|
||||
currentMaterial.specularHighlight = Float.parseFloat(line[1]);
|
||||
break;
|
||||
|
||||
case "map_Ks":
|
||||
|
|
|
@ -58,7 +58,7 @@ public class UnpackedBakedQuad extends BakedQuad
|
|||
return vertexData;
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
public void pipe(IVertexConsumer consumer)
|
||||
{
|
||||
int[] eMap = LightUtil.mapFormats(consumer.getVertexFormat(), format);
|
||||
|
|
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 181 B |
After Width: | Height: | Size: 172 B |
Before Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 179 B |
BIN
src/main/resources/assets/forge/textures/white.png
Normal file
After Width: | Height: | Size: 139 B |
|
@ -1,31 +1,5 @@
|
|||
{
|
||||
"parent": "forge:item/bucket_drip",
|
||||
"loader": "forge:bucket",
|
||||
"fluid": "new_fluid_test:test_fluid",
|
||||
"display": {
|
||||
"ground": {
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"translation": [ 0, 2, 0],
|
||||
"scale":[ 0.5, 0.5, 0.5 ]
|
||||
},
|
||||
"head": {
|
||||
"rotation": [ 0, 180, 0 ],
|
||||
"translation": [ 0, 13, 7],
|
||||
"scale":[ 1, 1, 1]
|
||||
},
|
||||
"thirdperson_righthand": {
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"translation": [ 0, 3, 1 ],
|
||||
"scale": [ 0.55, 0.55, 0.55 ]
|
||||
},
|
||||
"firstperson_righthand": {
|
||||
"rotation": [ 0, -90, 25 ],
|
||||
"translation": [ 1.13, 3.2, 1.13],
|
||||
"scale": [ 0.68, 0.68, 0.68 ]
|
||||
},
|
||||
"fixed": {
|
||||
"rotation": [ 0, 180, 0 ],
|
||||
"scale": [ 1, 1, 1 ]
|
||||
}
|
||||
}
|
||||
"fluid": "new_fluid_test:test_fluid"
|
||||
}
|
||||
|
|