Fixed most errors in the model stuff, except for ModelLoader and b3d and obj getQuads/handleBlockState methods.

This commit is contained in:
RainWarrior 2016-03-01 23:19:38 +03:00
parent d9b69fda65
commit 728319cbb5
31 changed files with 462 additions and 842 deletions

View File

@ -1,13 +1,47 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java
@@ -6,8 +6,9 @@
@@ -6,15 +6,25 @@
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
-public class BakedQuad
+public class BakedQuad implements net.minecraftforge.client.model.pipeline.IVertexProducer
{
+ @Override public void pipe(net.minecraftforge.client.model.pipeline.IVertexConsumer consumer) { net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this); }
protected final int[] vertexData;
protected final int tintIndex;
protected final EnumFacing face;
protected final TextureAtlasSprite field_187509_d;
+ /**
+ * @deprecated Use constructor with the format argument.
+ */
+ @Deprecated
public BakedQuad(int[] p_i46574_1_, int p_i46574_2_, EnumFacing p_i46574_3_, TextureAtlasSprite p_i46574_4_)
{
+ this(p_i46574_1_, p_i46574_2_, p_i46574_3_, p_i46574_4_, net.minecraft.client.renderer.vertex.DefaultVertexFormats.ITEM);
+ }
+
+ public BakedQuad(int[] p_i46574_1_, int p_i46574_2_, EnumFacing p_i46574_3_, TextureAtlasSprite p_i46574_4_, net.minecraft.client.renderer.vertex.VertexFormat format)
+ {
+ this.format = format;
this.vertexData = p_i46574_1_;
this.tintIndex = p_i46574_2_;
this.face = p_i46574_3_;
@@ -45,4 +55,17 @@
{
return this.face;
}
+
+ private final net.minecraft.client.renderer.vertex.VertexFormat format;
+
+ @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;
+ }
}

View File

@ -6,10 +6,13 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
import net.minecraft.client.renderer.block.model.ModelRotation;
import net.minecraft.client.renderer.block.model.Variant;
import net.minecraft.client.renderer.block.model.VariantList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.FMLLog;
@ -20,6 +23,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -55,11 +59,11 @@ public class BlockStateLoader
{
case 1: // Version 1
ForgeBlockStateV1 v1 = GSON.fromJson(reader, ForgeBlockStateV1.class);
List<ModelBlockDefinition.Variants> variants = Lists.newArrayList();
Map<String, VariantList> variants = Maps.newHashMap();
for (Entry<String, Collection<ForgeBlockStateV1.Variant>> entry : v1.variants.asMap().entrySet())
{ // Convert Version1 variants into vanilla variants for the ModelBlockDefinition.
List<ModelBlockDefinition.Variant> mcVars = Lists.newArrayList();
List<Variant> mcVars = Lists.newArrayList();
for (ForgeBlockStateV1.Variant var : entry.getValue())
{
boolean uvLock = var.getUvLock().or(false);
@ -68,14 +72,14 @@ public class BlockStateLoader
int weight = var.getWeight().or(1);
if (var.getModel() != null && var.getSubmodels().size() == 0 && var.getTextures().size() == 0 && var.getCustomData().size() == 0 && var.getState().orNull() instanceof ModelRotation)
mcVars.add(new ModelBlockDefinition.Variant(var.getModel(), (ModelRotation)var.getState().get(), uvLock, weight));
mcVars.add(new Variant(var.getModel(), (ModelRotation)var.getState().get(), uvLock, weight));
else
mcVars.add(new ForgeVariant(var.getModel(), var.getState().or(TRSRTransformation.identity()), uvLock, smooth, gui3d, weight, var.getTextures(), var.getOnlyPartsVariant(), var.getCustomData()));
}
variants.add(new ModelBlockDefinition.Variants(entry.getKey(), mcVars));
variants.put(entry.getKey(), new VariantList(mcVars));
}
return new ModelBlockDefinition(variants);
return new ModelBlockDefinition(variants, null);
default: //Unknown version.. try loading it as normal.
return vanillaGSON.fromJson(reader, ModelBlockDefinition.class);
@ -128,7 +132,7 @@ public class BlockStateLoader
public ImmutableMap<String, String> getCustomData() { return customData; }
}
private static class ForgeVariant extends ModelBlockDefinition.Variant implements ISmartVariant
private static class ForgeVariant extends Variant implements ISmartVariant
{
private final ImmutableMap<String, String> textures;
private final ImmutableMap<String, SubModel> parts;
@ -211,7 +215,7 @@ public class BlockStateLoader
models.put(entry.getKey(), Pair.<IModel, IModelState>of(runModelHooks(model, part.smooth, part.gui3d, part.getTextures(), part.getCustomData()), partState));
}
return new MultiModel(getModelLocation(), hasBase ? base : null, baseTr, models.build());
return new MultiModel(func_188046_a(), hasBase ? base : null, baseTr, models.build());
}
@Override

View File

@ -481,7 +481,7 @@ public class ForgeBlockStateV1 extends Marker
{
ret.state = Optional.<IModelState>of(TRSRTransformation.identity());
}
else if (transform.equals("forge:default-block"))
/*else if (transform.equals("forge:default-block"))
{
TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(
new Vector3f(0, 1.5f / 16, -2.75f / 16),
@ -517,7 +517,7 @@ public class ForgeBlockStateV1 extends Marker
new Vector3f(1.7f, 1.7f, 1.7f),
null));
ret.state = Optional.<IModelState>of(new SimpleModelState(ImmutableMap.of(TransformType.THIRD_PERSON, thirdperson, TransformType.FIRST_PERSON, firstperson)));
}
}*/ // FIXME
else
{
throw new JsonParseException("transform: unknown default string: " + transform);
@ -543,13 +543,37 @@ public class ForgeBlockStateV1 extends Marker
{
TRSRTransformation t = context.deserialize(transform.get("thirdperson"), TRSRTransformation.class);
transform.remove("thirdperson");
transforms.put(TransformType.THIRD_PERSON, TRSRTransformation.blockCenterToCorner(t));
transforms.put(TransformType.THIRD_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t));
}
if(transform.has("thirdperson_righthand"))
{
TRSRTransformation t = context.deserialize(transform.get("thirdperson_righthand"), TRSRTransformation.class);
transform.remove("thirdperson_righthand");
transforms.put(TransformType.THIRD_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t));
}
if(transform.has("thirdperson_lefthand"))
{
TRSRTransformation t = context.deserialize(transform.get("thirdperson_lefthand"), TRSRTransformation.class);
transform.remove("thirdperson_lefthand");
transforms.put(TransformType.THIRD_PERSON_LEFT_HAND, TRSRTransformation.blockCenterToCorner(t));
}
if(transform.has("firstperson"))
{
TRSRTransformation t = context.deserialize(transform.get("firstperson"), TRSRTransformation.class);
transform.remove("firstperson");
transforms.put(TransformType.FIRST_PERSON, TRSRTransformation.blockCenterToCorner(t));
transforms.put(TransformType.FIRST_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t));
}
if(transform.has("firstperson_righthand"))
{
TRSRTransformation t = context.deserialize(transform.get("firstperson_righthand"), TRSRTransformation.class);
transform.remove("firstperson_righthand");
transforms.put(TransformType.FIRST_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t));
}
if(transform.has("firstperson_lefthand"))
{
TRSRTransformation t = context.deserialize(transform.get("firstperson_lefthand"), TRSRTransformation.class);
transform.remove("firstperson_lefthand");
transforms.put(TransformType.FIRST_PERSON_LEFT_HAND, TRSRTransformation.blockCenterToCorner(t));
}
if(transform.has("head"))
{

View File

@ -1,14 +1,16 @@
package net.minecraftforge.client.model;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.EnumFacing;
public interface IColoredBakedQuad {
public static class ColoredBakedQuad extends BakedQuad implements IColoredBakedQuad
{
public ColoredBakedQuad(int[] data, int tintIndex, EnumFacing side)
public ColoredBakedQuad(int[] data, int tintIndex, EnumFacing side, TextureAtlasSprite sprite, VertexFormat format)
{
super(data, tintIndex, side);
super(data, tintIndex, side, sprite, format);
}
}
}

View File

@ -1,78 +0,0 @@
package net.minecraftforge.client.model;
import java.util.List;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.util.EnumFacing;
/*
* Version of IBakedModel with less restriction on camera transformations and with explicit format of the baked array.
*/
@SuppressWarnings("deprecation")
public interface IFlexibleBakedModel extends IBakedModel
{
/*
* Specifies the format which BakedQuads' getVertexData will have.
*/
VertexFormat getFormat();
/*
* Default implementation of IFlexibleBakedModel that should be useful in most cases
*/
public static class Wrapper implements IFlexibleBakedModel
{
private final IBakedModel parent;
VertexFormat format;
public Wrapper(IBakedModel parent, VertexFormat format)
{
this.parent = parent;
this.format = format;
}
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
return parent.getFaceQuads(side);
}
public List<BakedQuad> getGeneralQuads()
{
return parent.getGeneralQuads();
}
public boolean isAmbientOcclusion()
{
return parent.isAmbientOcclusion();
}
public boolean isGui3d()
{
return parent.isGui3d();
}
public boolean isBuiltInRenderer()
{
return parent.isBuiltInRenderer();
}
public TextureAtlasSprite getParticleTexture()
{
return parent.getParticleTexture();
}
@Deprecated
public ItemCameraTransforms getItemCameraTransforms()
{
return parent.getItemCameraTransforms();
}
public VertexFormat getFormat()
{
return new VertexFormat(format);
}
}
}

View File

@ -2,6 +2,7 @@ package net.minecraftforge.client.model;
import java.util.Collection;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
@ -36,7 +37,7 @@ public interface IModel
* format argument (some attributes can be replaced with padding),
* if there's no such info in this model.
*/
IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter);
IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter);
/*
* Default state this model will be baked with.

View File

@ -4,11 +4,13 @@ import java.util.List;
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.ItemCameraTransforms;
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.util.EnumFacing;
import org.apache.commons.lang3.tuple.Pair;
@ -20,26 +22,26 @@ import com.google.common.collect.ImmutableMap;
* Model that changes based on the rendering perspective
* (first-person, GUI, e.t.c - see TransformType)
*/
public interface IPerspectiveAwareModel extends IFlexibleBakedModel
public interface IPerspectiveAwareModel extends IBakedModel
{
/*
* 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).
*/
Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType);
Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType);
public static class MapWrapper implements IPerspectiveAwareModel
{
private final IFlexibleBakedModel parent;
private final IBakedModel parent;
private final ImmutableMap<TransformType, TRSRTransformation> transforms;
public MapWrapper(IFlexibleBakedModel parent, ImmutableMap<TransformType, TRSRTransformation> transforms)
public MapWrapper(IBakedModel parent, ImmutableMap<TransformType, TRSRTransformation> transforms)
{
this.parent = parent;
this.transforms = transforms;
}
public MapWrapper(IFlexibleBakedModel parent, IModelState state)
public MapWrapper(IBakedModel parent, IModelState state)
{
this(parent, getTransforms(state));
}
@ -58,6 +60,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
return builder.build();
}
@SuppressWarnings("deprecation")
public static ImmutableMap<TransformType, TRSRTransformation> getTransforms(ItemCameraTransforms transforms)
{
ImmutableMap.Builder<TransformType, TRSRTransformation> builder = ImmutableMap.builder();
@ -68,7 +71,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
return builder.build();
}
public static Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(IFlexibleBakedModel model, ImmutableMap<TransformType, TRSRTransformation> transforms, TransformType cameraTransformType)
public static Pair<? extends IBakedModel, Matrix4f> handlePerspective(IBakedModel model, ImmutableMap<TransformType, TRSRTransformation> transforms, TransformType cameraTransformType)
{
TRSRTransformation tr = transforms.get(cameraTransformType);
Matrix4f mat = null;
@ -76,7 +79,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
return Pair.of(model, mat);
}
public static Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(IFlexibleBakedModel model, IModelState state, TransformType cameraTransformType)
public static Pair<? extends IBakedModel, Matrix4f> handlePerspective(IBakedModel model, IModelState state, TransformType cameraTransformType)
{
TRSRTransformation tr = state.apply(Optional.of(cameraTransformType)).or(TRSRTransformation.identity());
if(tr != TRSRTransformation.identity())
@ -88,15 +91,15 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
public boolean isAmbientOcclusion() { return parent.isAmbientOcclusion(); }
public boolean isGui3d() { return parent.isGui3d(); }
public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); }
public boolean func_188618_c() { return parent.func_188618_c(); }
public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
@SuppressWarnings("deprecation")
public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
public List<BakedQuad> getFaceQuads(EnumFacing side) { return parent.getFaceQuads(side); }
public List<BakedQuad> getGeneralQuads() { return parent.getGeneralQuads(); }
public VertexFormat getFormat() { return parent.getFormat(); }
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand) { return parent.func_188616_a(state, side, rand); }
public ItemOverrideList func_188617_f() { return parent.func_188617_f(); }
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
return handlePerspective(this, transforms, cameraTransformType);
}

View File

@ -1,94 +0,0 @@
package net.minecraftforge.client.model;
import java.util.List;
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.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.util.EnumFacing;
import org.apache.commons.lang3.tuple.Pair;
public interface ISmartBlockModel extends IBakedModel
{
IBakedModel handleBlockState(IBlockState state);
public static abstract class Wrapper implements ISmartBlockModel, IFlexibleBakedModel
{
protected final IFlexibleBakedModel parent;
public Wrapper(IFlexibleBakedModel parent)
{
this.parent = parent;
}
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
return parent.getFaceQuads(side);
}
public List<BakedQuad> getGeneralQuads()
{
return parent.getGeneralQuads();
}
public boolean isAmbientOcclusion()
{
return parent.isAmbientOcclusion();
}
public boolean isGui3d()
{
return parent.isGui3d();
}
public boolean isBuiltInRenderer()
{
return parent.isBuiltInRenderer();
}
public TextureAtlasSprite getParticleTexture()
{
return parent.getParticleTexture();
}
public ItemCameraTransforms getItemCameraTransforms()
{
return parent.getItemCameraTransforms();
}
public VertexFormat getFormat()
{
return parent.getFormat();
}
}
public static abstract class PerspectiveWrapper extends Wrapper implements IPerspectiveAwareModel
{
protected final IPerspectiveAwareModel parent;
public PerspectiveWrapper(IPerspectiveAwareModel parent)
{
super(parent);
this.parent = parent;
}
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType type)
{
Pair<? extends IFlexibleBakedModel, Matrix4f> pair = parent.handlePerspective(type);
return Pair.of(new ISmartBlockModel.Wrapper(pair.getLeft())
{
public IBakedModel handleBlockState(IBlockState state)
{
return PerspectiveWrapper.this.handleBlockState(state);
}
}, pair.getRight());
}
}
}

View File

@ -1,9 +0,0 @@
package net.minecraftforge.client.model;
import net.minecraft.item.ItemStack;
import net.minecraft.client.renderer.block.model.IBakedModel;
public interface ISmartItemModel extends IBakedModel
{
IBakedModel handleItemState(ItemStack stack);
}

View File

@ -10,9 +10,12 @@ import javax.vecmath.Vector4f;
import org.apache.commons.lang3.tuple.Pair;
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.ItemCameraTransforms;
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.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
@ -85,7 +88,7 @@ public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
return new ItemLayerModel(builder.build());
}
public IFlexibleBakedModel bake(IModelState state, final VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
public IBakedModel bake(IModelState state, final VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
Optional<TRSRTransformation> transform = state.apply(Optional.<IModelPart>absent());
@ -96,47 +99,21 @@ public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
}
TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
ImmutableMap<TransformType, TRSRTransformation> map = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
return new BakedItemModel(builder.build(), particle, format, map, null);
return new BakedItemModel(builder.build(), particle, map, null);
}
@Deprecated // remove 1.9
public static class BakedModel implements IFlexibleBakedModel
private static class BakedItemModel implements IPerspectiveAwareModel
{
private final ImmutableList<BakedQuad> quads;
private final TextureAtlasSprite particle;
private final VertexFormat format;
public BakedModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format)
{
this.quads = quads;
this.particle = particle;
this.format = format;
}
public boolean isAmbientOcclusion() { return true; }
public boolean isGui3d() { return false; }
public boolean isBuiltInRenderer() { return false; }
public TextureAtlasSprite getParticleTexture() { return particle; }
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
public List<BakedQuad> getFaceQuads(EnumFacing side) { return ImmutableList.of(); }
public List<BakedQuad> getGeneralQuads() { return quads; }
public VertexFormat getFormat() { return format; }
}
private static class BakedItemModel implements IFlexibleBakedModel, IPerspectiveAwareModel
{
private final ImmutableList<BakedQuad> quads;
private final TextureAtlasSprite particle;
private final VertexFormat format;
private final ImmutableMap<TransformType, TRSRTransformation> transforms;
private final IFlexibleBakedModel otherModel;
private final IBakedModel otherModel;
private final boolean isCulled;
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap<TransformType, TRSRTransformation> transforms, IFlexibleBakedModel otherModel)
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TRSRTransformation> transforms, IBakedModel otherModel)
{
this.quads = quads;
this.particle = particle;
this.format = format;
this.transforms = transforms;
if(otherModel != null)
{
@ -153,23 +130,26 @@ public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
builder.add(quad);
}
}
this.otherModel = new BakedItemModel(builder.build(), particle, format, transforms, this);
this.otherModel = new BakedItemModel(builder.build(), particle, transforms, this);
isCulled = false;
}
}
public boolean isAmbientOcclusion() { return true; }
public boolean isGui3d() { return false; }
public boolean isBuiltInRenderer() { return false; }
public boolean func_188618_c() { return false; }
public TextureAtlasSprite getParticleTexture() { return particle; }
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
public List<BakedQuad> getFaceQuads(EnumFacing side) { return ImmutableList.of(); }
public List<BakedQuad> getGeneralQuads() { return quads; }
public VertexFormat getFormat() { return format; }
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType type)
public ItemOverrideList func_188617_f() { return ItemOverrideList.field_188022_a; }
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand)
{
Pair<? extends IFlexibleBakedModel, Matrix4f> pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type);
if(side == null) return quads;
return ImmutableList.of();
}
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType type)
{
Pair<? extends IBakedModel, Matrix4f> pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type);
if(type == TransformType.GUI && !isCulled && pair.getRight() == null)
{
return Pair.of(otherModel, null);

View File

@ -1,31 +1,43 @@
package net.minecraftforge.client.model;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.vecmath.Matrix4f;
import javax.vecmath.Quat4f;
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.ItemCameraTransforms;
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.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.*;
import org.apache.commons.lang3.tuple.Pair;
import javax.vecmath.Matrix4f;
import javax.vecmath.Quat4f;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>, IRetexturableModel<ModelDynBucket>
{
@ -81,7 +93,7 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
}
@Override
public IFlexibleBakedModel bake(IModelState state, VertexFormat format,
public IBakedModel bake(IModelState state, VertexFormat format,
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
@ -104,8 +116,8 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
if (baseLocation != null)
{
// build base (insidest)
IFlexibleBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter);
builder.addAll(model.getGeneralQuads());
IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter);
builder.addAll(model.func_188616_a(null, null, 0));
}
if (liquidLocation != null && fluidSprite != null)
{
@ -123,7 +135,7 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
}
return new BakedDynBucket(this, builder.build(), fluidSprite, format, Maps.immutableEnumMap(transformMap), Maps.<String, IFlexibleBakedModel>newHashMap());
return new BakedDynBucket(this, builder.build(), fluidSprite, format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
@Override
@ -211,26 +223,16 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
}
}
// the dynamic bucket is based on the empty bucket
protected static class BakedDynBucket extends ItemLayerModel.BakedModel implements ISmartItemModel, IPerspectiveAwareModel
protected static final class BakedDynBucketOverrideHandler extends ItemOverrideList
{
private final ModelDynBucket parent;
private final Map<String, IFlexibleBakedModel> cache; // contains all the baked models since they'll never change
private final ImmutableMap<TransformType, TRSRTransformation> transforms;
public BakedDynBucket(ModelDynBucket parent,
ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms,
Map<String, IFlexibleBakedModel> cache)
public static final BakedDynBucketOverrideHandler INSTANCE = new BakedDynBucketOverrideHandler();
private BakedDynBucketOverrideHandler()
{
super(quads, particle, format);
this.parent = parent;
this.transforms = transforms;
this.cache = cache;
super(ImmutableList.of());
}
@Override
public IBakedModel handleItemState(ItemStack stack)
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
{
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
if (fluidStack == null)
@ -245,16 +247,17 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
if (fluidStack == null)
{
// empty bucket
return this;
return originalModel;
}
BakedDynBucket model = (BakedDynBucket)originalModel;
Fluid fluid = fluidStack.getFluid();
String name = fluid.getName();
if (!cache.containsKey(name))
if (!model.cache.containsKey(name))
{
IModel model = parent.process(ImmutableMap.of("fluid", name));
IModel parent = model.parent.process(ImmutableMap.of("fluid", name));
Function<ResourceLocation, TextureAtlasSprite> textureGetter;
textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
{
@ -264,18 +267,62 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
}
};
IFlexibleBakedModel bakedModel = model.bake(new SimpleModelState(transforms), this.getFormat(), textureGetter);
cache.put(name, bakedModel);
IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter);
model.cache.put(name, bakedModel);
return bakedModel;
}
return cache.get(name);
return model.cache.get(name);
}
}
// the dynamic bucket is based on the empty bucket
protected static class BakedDynBucket implements IPerspectiveAwareModel
{
private final ModelDynBucket parent;
// FIXME: guava cache?
private final Map<String, IBakedModel> cache; // contains all the baked models since they'll never change
private final ImmutableMap<TransformType, TRSRTransformation> transforms;
private final ImmutableList<BakedQuad> quads;
private final TextureAtlasSprite particle;
private final VertexFormat format;
public BakedDynBucket(ModelDynBucket parent,
ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms,
Map<String, IBakedModel> cache)
{
this.quads = quads;
this.particle = particle;
this.format = format;
this.parent = parent;
this.transforms = transforms;
this.cache = cache;
}
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
public ItemOverrideList func_188617_f()
{
return BakedDynBucketOverrideHandler.INSTANCE;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, cameraTransformType);
}
@Override
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand)
{
if(side == null) return quads;
return ImmutableList.of();
}
public boolean isAmbientOcclusion() { return true; }
public boolean isGui3d() { return false; }
public boolean func_188618_c() { return false; }
public TextureAtlasSprite getParticleTexture() { return particle; }
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
}
}

View File

@ -12,14 +12,15 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
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;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelRotation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.model.pipeline.LightUtil;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.common.property.IExtendedBlockState;
@ -42,7 +43,6 @@ import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@SuppressWarnings("deprecation")
public class ModelFluid implements IModelCustomData<ModelFluid>
{
public static final ModelFluid waterModel = new ModelFluid(FluidRegistry.WATER);
@ -64,7 +64,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
return ImmutableSet.of(fluid.getStill(), fluid.getFlowing());
}
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap<TransformType, TRSRTransformation> map = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
return new BakedFluid(state.apply(Optional.<IModelPart>absent()), map, format, fluid.getColor(), bakedTextureGetter.apply(fluid.getStill()), bakedTextureGetter.apply(fluid.getFlowing()), fluid.isGaseous(), Optional.<IExtendedBlockState>absent());
@ -95,7 +95,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
}
}
public static class BakedFluid implements IFlexibleBakedModel, ISmartBlockModel, IPerspectiveAwareModel
public static class BakedFluid implements IPerspectiveAwareModel
{
private static final int x[] = { 0, 0, 1, 1 };
private static final int z[] = { 0, 1, 1, 0 };
@ -341,7 +341,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
return false;
}
public boolean isBuiltInRenderer()
public boolean func_188618_c()
{
return false;
}
@ -356,23 +356,9 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
return ItemCameraTransforms.DEFAULT;
}
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
return faceQuads.get(side);
}
public List<BakedQuad> getGeneralQuads()
{
return ImmutableList.of();
}
public VertexFormat getFormat()
{
return format;
}
public IBakedModel handleBlockState(IBlockState state)
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand)
{
BakedFluid model = this;
if(state instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState)state;
@ -386,13 +372,19 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
}
key <<= 1;
key |= 1;
return modelCache.getUnchecked(key);
model = modelCache.getUnchecked(key);
}
return this;
if(side == null) return ImmutableList.of();
return model.faceQuads.get(side);
}
public ItemOverrideList func_188617_f()
{
return ItemOverrideList.field_188022_a;
}
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType type)
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType type)
{
return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type);
}

View File

@ -7,10 +7,8 @@ import java.util.Map;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader.VanillaLoader;
import net.minecraftforge.client.model.b3d.B3DLoader;

View File

@ -7,17 +7,17 @@ import java.util.List;
import javax.vecmath.Matrix4f;
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.ItemCameraTransforms;
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.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fml.common.FMLLog;
@ -55,9 +55,9 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
return ImmutableList.of();
}
private static ImmutableMap<Optional<BlockRenderLayer>, IFlexibleBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
private static ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<Optional<BlockRenderLayer>, IFlexibleBakedModel> builder = ImmutableMap.builder();
ImmutableMap.Builder<Optional<BlockRenderLayer>, IBakedModel> builder = ImmutableMap.builder();
for(Optional<BlockRenderLayer> key : models.keySet())
{
IModel model;
@ -76,13 +76,12 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
}
@Override
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
IModel missing = ModelLoaderRegistry.getMissingModel();
return new MultiLayerBakedModel(
buildModels(models, state, format, bakedTextureGetter),
missing.bake(missing.getDefaultState(), format, bakedTextureGetter),
format,
IPerspectiveAwareModel.MapWrapper.getTransforms(state)
);
}
@ -127,38 +126,17 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
return new ModelResourceLocation("builtin/missing", "missing");
}
public static class MultiLayerBakedModel implements IFlexibleBakedModel, ISmartBlockModel, IPerspectiveAwareModel
public static class MultiLayerBakedModel implements IPerspectiveAwareModel
{
private final ImmutableMap<Optional<BlockRenderLayer>, IFlexibleBakedModel> models;
private final VertexFormat format;
private final ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> models;
private final ImmutableMap<TransformType, TRSRTransformation> cameraTransforms;;
private final IFlexibleBakedModel base;
private final IFlexibleBakedModel missing;
private final IBakedModel base;
private final IBakedModel missing;
private final ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> quads;
private static final Function<ResourceLocation, TextureAtlasSprite> defaultTextureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
{
public TextureAtlasSprite apply(ResourceLocation location)
{
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
}
};
@Deprecated // remove 1.9
public MultiLayerBakedModel(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, VertexFormat format, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms)
{
this(
buildModels(models, TRSRTransformation.identity(), format, defaultTextureGetter),
ModelLoaderRegistry.getMissingModel().bake(ModelLoaderRegistry.getMissingModel().getDefaultState(), format, defaultTextureGetter),
format,
cameraTransforms
);
}
public MultiLayerBakedModel(ImmutableMap<Optional<BlockRenderLayer>, IFlexibleBakedModel> models, IFlexibleBakedModel missing, VertexFormat format, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms)
public MultiLayerBakedModel(ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> models, IBakedModel missing, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms)
{
this.models = models;
this.format = format;
this.cameraTransforms = cameraTransforms;
this.missing = missing;
if(models.containsKey(Optional.absent()))
@ -178,33 +156,34 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
quads = quadBuilder.build();
}
private static ImmutableList<BakedQuad> buildQuads(ImmutableMap<Optional<BlockRenderLayer>, IFlexibleBakedModel> models, Optional<EnumFacing> side)
private static ImmutableList<BakedQuad> buildQuads(ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> models, Optional<EnumFacing> side)
{
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
for(IBakedModel model : models.values())
{
if(side.isPresent())
{
builder.addAll(model.getFaceQuads(side.get()));
}
else
{
builder.addAll(model.getGeneralQuads());
}
builder.addAll(model.func_188616_a(null, side.orNull(), 0));
}
return builder.build();
}
@Override
public List<BakedQuad> getFaceQuads(EnumFacing side)
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand)
{
return quads.get(Optional.of(side));
}
@Override
public List<BakedQuad> getGeneralQuads()
{
return quads.get(Optional.absent());
IBakedModel model;
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
if(layer == null)
{
return quads.get(Optional.fromNullable(side));
}
else if(!models.containsKey(layer))
{
model = missing;
}
else
{
model = models.get(Optional.of(layer));
}
return model.func_188616_a(state, side, rand);
}
@Override
@ -220,9 +199,9 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
}
@Override
public boolean isBuiltInRenderer()
public boolean func_188618_c()
{
return base.isBuiltInRenderer();
return base.func_188618_c();
}
@Override
@ -238,27 +217,16 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
}
@Override
public IBakedModel handleBlockState(IBlockState state)
{
Optional<BlockRenderLayer> layer = Optional.of(MinecraftForgeClient.getRenderLayer());
if(!models.containsKey(layer))
{
return missing;
}
return models.get(layer);
}
@Override
public VertexFormat getFormat()
{
return format;
}
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType);
}
@Override
public ItemOverrideList func_188617_f()
{
return ItemOverrideList.field_188022_a;
}
}
public static enum Loader implements ICustomModelLoader

View File

@ -1,7 +1,6 @@
package net.minecraftforge.client.model;
import java.util.Collection;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -10,9 +9,12 @@ import java.util.Set;
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.ItemCameraTransforms;
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.util.EnumFacing;
@ -23,30 +25,30 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.Level;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@SuppressWarnings("deprecation")
// TODO: Switch to vanilla class, or to something similar
@Deprecated
public class MultiModel implements IModel
{
public static class Baked implements IFlexibleBakedModel, IPerspectiveAwareModel
public static class Baked implements IPerspectiveAwareModel
{
protected final IFlexibleBakedModel base;
protected final ImmutableMap<String, IFlexibleBakedModel> parts;
protected final IBakedModel base;
protected final ImmutableMap<String, IBakedModel> parts;
protected final IFlexibleBakedModel internalBase;
protected ImmutableList<BakedQuad> general;
protected ImmutableMap<EnumFacing, ImmutableList<BakedQuad>> faces;
protected final IBakedModel internalBase;
protected ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> quads;
protected final ImmutableMap<TransformType, Pair<Baked, TRSRTransformation>> transforms;
public Baked(IFlexibleBakedModel base, ImmutableMap<String, IFlexibleBakedModel> parts)
public Baked(IBakedModel base, ImmutableMap<String, IBakedModel> parts)
{
this(null, false, base, parts);
}
public Baked(ResourceLocation location, boolean perspective, IFlexibleBakedModel base, ImmutableMap<String, IFlexibleBakedModel> parts)
public Baked(ResourceLocation location, boolean perspective, IBakedModel base, ImmutableMap<String, IBakedModel> parts)
{
this.base = base;
this.parts = parts;
@ -55,7 +57,7 @@ public class MultiModel implements IModel
internalBase = base;
else
{
Iterator<IFlexibleBakedModel> iter = parts.values().iterator();
Iterator<IBakedModel> iter = parts.values().iterator();
if (iter.hasNext())
internalBase = iter.next();
else
@ -69,8 +71,8 @@ public class MultiModel implements IModel
ImmutableMap.Builder<TransformType, Pair<Baked, TRSRTransformation>> builder = ImmutableMap.builder();
for(TransformType type : TransformType.values())
{
Pair<? extends IFlexibleBakedModel, Matrix4f> p = perBase.handlePerspective(type);
IFlexibleBakedModel newBase = p.getLeft();
Pair<? extends IBakedModel, Matrix4f> p = perBase.handlePerspective(type);
IBakedModel newBase = p.getLeft();
builder.put(type, Pair.of(new Baked(location, false, newBase, parts), new TRSRTransformation(p.getRight())));
}
transforms = builder.build();
@ -94,9 +96,9 @@ public class MultiModel implements IModel
}
@Override
public boolean isBuiltInRenderer()
public boolean func_188618_c()
{
return internalBase.isBuiltInRenderer();
return internalBase.func_188618_c();
}
@Override
@ -112,66 +114,64 @@ public class MultiModel implements IModel
}
@Override
public List<BakedQuad> getFaceQuads(EnumFacing side)
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand)
{
if(faces == null)
if(quads == null)
{
// Create map of each face's quads.
EnumMap<EnumFacing, ImmutableList<BakedQuad>> faces = Maps.newEnumMap(EnumFacing.class);
ImmutableMap.Builder<Optional<EnumFacing>, ImmutableList<BakedQuad>> builder = ImmutableMap.builder();
for (EnumFacing face : EnumFacing.values())
{
ImmutableList.Builder<BakedQuad> faceQuads = ImmutableList.builder();
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
if (base != null)
faceQuads.addAll(base.getFaceQuads(face));
for (IFlexibleBakedModel bakedPart : parts.values())
faceQuads.addAll(bakedPart.getFaceQuads(face));
faces.put(face, faceQuads.build());
{
quads.addAll(base.func_188616_a(null, face, 0));
}
for (IBakedModel bakedPart : parts.values())
{
quads.addAll(bakedPart.func_188616_a(null, face, 0));
}
builder.put(Optional.of(face), quads.build());
}
this.faces = Maps.immutableEnumMap(faces);
}
return faces.get(side);
}
@Override
public List<BakedQuad> getGeneralQuads()
{
if(general == null)
{
// Create list of general quads.
ImmutableList.Builder<BakedQuad> genQuads = ImmutableList.builder();
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
if (base != null)
genQuads.addAll(base.getGeneralQuads());
for (IFlexibleBakedModel bakedPart : parts.values())
genQuads.addAll(bakedPart.getGeneralQuads());
general = genQuads.build();
{
quads.addAll(base.func_188616_a(null, null, 0));
}
for (IBakedModel bakedPart : parts.values())
{
quads.addAll(bakedPart.func_188616_a(null, null, 0));
}
builder.put(Optional.absent(), quads.build());
this.quads = builder.build();
}
return general;
return quads.get(Optional.fromNullable(side));
}
@Override
public VertexFormat getFormat()
{
return internalBase.getFormat();
}
public IFlexibleBakedModel getBaseModel()
public IBakedModel getBaseModel()
{
return base;
}
public Map<String, IFlexibleBakedModel> getParts()
public Map<String, IBakedModel> getParts()
{
return parts;
}
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
if(transforms.isEmpty()) return Pair.of(this, null);
Pair<Baked, TRSRTransformation> p = transforms.get(cameraTransformType);
return Pair.of(p.getLeft(), p.getRight().getMatrix());
}
@Override
public ItemOverrideList func_188617_f()
{
// TODO Auto-generated method stub
return null;
}
}
protected final ResourceLocation location;
@ -231,14 +231,14 @@ public class MultiModel implements IModel
}
@Override
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
IFlexibleBakedModel bakedBase = null;
IBakedModel bakedBase = null;
if (base != null)
bakedBase = base.bake(state, format, bakedTextureGetter);
ImmutableMap.Builder<String, IFlexibleBakedModel> mapBuilder = ImmutableMap.builder();
ImmutableMap.Builder<String, IBakedModel> mapBuilder = ImmutableMap.builder();
for (Entry<String, Pair<IModel, IModelState>> entry : parts.entrySet())
{

View File

@ -11,7 +11,7 @@ import javax.vecmath.Vector4f;
import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
import net.minecraft.client.renderer.block.model.ModelRotation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3i;
import net.minecraft.util.math.Vec3i;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;

View File

@ -58,16 +58,16 @@ public class AnimationModelBase<T extends Entity & IAnimationProvider> extends M
GlStateManager.pushMatrix();
GlStateManager.rotate(180, 0, 0, 1);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer VertexBuffer = tessellator.getVertexBuffer();
VertexBuffer VertexBuffer = tessellator.getWorldRenderer();
VertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
VertexBuffer.setTranslation(-0.5, -1.5, -0.5);
lighter.setParent(new VertexBufferConsumer(VertexBuffer));
lighter.setWorld(entity.worldObj);
lighter.setBlock(Blocks.air);
lighter.setState(Blocks.air.getDefaultState());
lighter.setBlockPos(pos);
boolean empty = true;
List<BakedQuad> quads = bakedModel.getGeneralQuads();
List<BakedQuad> quads = bakedModel.func_188616_a(null, null, 0);
if(!quads.isEmpty())
{
lighter.updateBlockInfo();
@ -79,7 +79,7 @@ public class AnimationModelBase<T extends Entity & IAnimationProvider> extends M
}
for(EnumFacing side : EnumFacing.values())
{
quads = bakedModel.getFaceQuads(side);
quads = bakedModel.func_188616_a(null, side, 0);
if(!quads.isEmpty())
{
if(empty) lighter.updateBlockInfo();

View File

@ -1,7 +1,5 @@
package net.minecraftforge.client.model.animation;
import java.util.concurrent.TimeUnit;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
@ -12,16 +10,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.client.model.ISmartBlockModel;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.Properties;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
/**
* Generic TileEntitySpecialRenderer that works with the Forge model system and animations.
*/
@ -29,24 +22,6 @@ public class AnimationTESR<T extends TileEntity & IAnimationProvider> extends Fa
{
protected static BlockRendererDispatcher blockRenderer;
protected static final LoadingCache<Pair<IExtendedBlockState, IModelState>, IBakedModel> modelCache = CacheBuilder.newBuilder().maximumSize(10).expireAfterWrite(100, TimeUnit.MILLISECONDS).build(new CacheLoader<Pair<IExtendedBlockState, IModelState>, IBakedModel>()
{
public IBakedModel load(Pair<IExtendedBlockState, IModelState> key) throws Exception
{
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(key.getLeft().getClean());
if(model instanceof ISmartBlockModel)
{
model = ((ISmartBlockModel)model).handleBlockState(key.getLeft().withProperty(Properties.AnimationProperty, key.getRight()));
}
return model;
}
});
protected static IBakedModel getModel(IExtendedBlockState state, IModelState modelState)
{
return modelCache.getUnchecked(Pair.of(state, modelState));
}
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer)
{
if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
@ -66,11 +41,13 @@ public class AnimationTESR<T extends TileEntity & IAnimationProvider> extends Fa
Pair<IModelState, Iterable<Event>> pair = te.asm().apply(time);
handleEvents(te, time, pair.getRight());
IBakedModel model = getModel(exState, pair.getLeft());
// TODO: caching?
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, renderer, false);
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
}
}
}

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.IModelPart;

View File

@ -18,7 +18,7 @@ public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRe
public final void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage)
{
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer VertexBuffer = tessellator.getVertexBuffer();
VertexBuffer VertexBuffer = tessellator.getWorldRenderer();
this.bindTexture(TextureMap.locationBlocksTexture);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

View File

@ -13,7 +13,7 @@ import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
import net.minecraft.client.renderer.block.model.BlockPart;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.client.model.TRSRTransformation;
import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Interpolation;

View File

@ -16,6 +16,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.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@ -24,7 +25,7 @@ import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.*;
import net.minecraftforge.client.model.animation.IClip;
@ -127,65 +128,11 @@ public class B3DLoader implements ICustomModelLoader
}
B3DModel model = cache.get(file);
if(model == null) return ModelLoaderRegistry.getMissingModel();
if(modelLocation instanceof B3DMeshLocation)
{
String mesh = ((B3DMeshLocation)modelLocation).getMesh();
if(!model.getMeshes().containsKey(mesh))
{
FMLLog.severe("No mesh named %s in model %s, skipping", mesh, modelLocation);
return ModelLoaderRegistry.getMissingModel();
}
return new ModelWrapper(modelLocation, model, ImmutableSet.of(mesh), 1);
}
if(!(model.getRoot().getKind() instanceof Mesh))
{
return new ModelWrapper(modelLocation, model, ImmutableSet.<String>of(), 1);
}
return new ModelWrapper(modelLocation, model, ImmutableSet.of(((Node<Mesh>)model.getRoot()).getName()), 1);
}
/**
* @deprecated Use json or IModelCustomData.process
*/
@Deprecated
public static class B3DMeshLocation extends ResourceLocation
{
public final String mesh;
public B3DMeshLocation(String domain, String path, String mesh)
{
super(domain, path);
this.mesh = mesh;
}
public String getMesh()
{
return mesh;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((mesh == null) ? 0 : mesh.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (!super.equals(obj)) return false;
if (getClass() != obj.getClass()) return false;
B3DMeshLocation other = (B3DMeshLocation) obj;
if (mesh == null)
{
if (other.mesh != null) return false;
}
else if (!mesh.equals(other.mesh)) return false;
return true;
return new ModelWrapper(modelLocation, model, ImmutableSet.<String>of(), true, true, 1);
}
return new ModelWrapper(modelLocation, model, ImmutableSet.of(((Node<Mesh>)model.getRoot()).getName()), true, true, 1);
}
public static class B3DState implements IModelState
@ -454,166 +401,6 @@ public class B3DLoader implements ICustomModelLoader
}
}
/**
* @deprecated Use ModelWrapper, this will be removed in 1.9
*/
@Deprecated
public static class Wrapper extends PartWrapper<Mesh> implements IRetexturableModel<Wrapper>, IModelCustomData<Wrapper>
{
private final ResourceLocation location;
private final ImmutableSet<String> meshes;
private final ImmutableMap<String, ResourceLocation> textures;
public Wrapper(ResourceLocation location, List<Texture> textures, B3DModel.Node<Mesh> mesh)
{
this(location, ImmutableSet.<String>of(), buildTextures(textures), mesh);
}
public Wrapper(ResourceLocation location, ImmutableMap<String, ResourceLocation> textures, B3DModel.Node<Mesh> mesh)
{
this(location, ImmutableSet.<String>of(), textures, mesh);
}
public Wrapper(ResourceLocation location, ImmutableSet<String> meshes, List<Texture> textures, B3DModel.Node<Mesh> mesh)
{
this(location, meshes, buildTextures(textures), mesh);
}
public Wrapper(ResourceLocation location, ImmutableSet<String> meshes, ImmutableMap<String, ResourceLocation> textures, B3DModel.Node<Mesh> mesh)
{
super(mesh);
this.location = location;
this.meshes = meshes;
this.textures = textures;
}
private static ImmutableMap<String, ResourceLocation> buildTextures(List<Texture> textures)
{
ImmutableMap.Builder<String, ResourceLocation> builder = ImmutableMap.builder();
for(Texture t : textures)
{
String path = t.getPath();
String location = getLocation(path);
if(!location.startsWith("#")) location = "#" + location;
builder.put(path, new ResourceLocation(location));
}
return builder.build();
}
private static String getLocation(String path)
{
if(path.endsWith(".png")) path = path.substring(0, path.length() - ".png".length());
return path;
}
public Collection<ResourceLocation> getDependencies()
{
// no dependencies for in-file models
// FIXME maybe add child meshes
return Collections.emptyList();
}
public Collection<ResourceLocation> getTextures()
{
return Collections2.filter(textures.values(), new Predicate<ResourceLocation>()
{
public boolean apply(ResourceLocation loc)
{
return !loc.getResourcePath().startsWith("#");
}
});
}
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
for(Map.Entry<String, ResourceLocation> e : textures.entrySet())
{
if(e.getValue().getResourcePath().startsWith("#"))
{
FMLLog.severe("unresolved texture '%s' for b3d model '%s'", e.getValue().getResourcePath(), location);
builder.put(e.getKey(), missing);
}
else
{
builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue()));
}
}
builder.put("missingno", missing);
return new BakedWrapper(getNode(), state, format, meshes, builder.build());
}
public ResourceLocation getLocation()
{
return location;
}
public ImmutableMap<String, ResourceLocation> getTextureMap()
{
return textures;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((location == null) ? 0 : location.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Wrapper other = (Wrapper) obj;
if (location == null)
{
if (other.location != null) return false;
}
else if (!location.equals(other.location)) return false;
return true;
}
@Override
public IModel retexture(ImmutableMap<String, String> textures)
{
ImmutableMap.Builder<String, ResourceLocation> builder = ImmutableMap.builder();
for(Map.Entry<String, ResourceLocation> e : this.textures.entrySet())
{
String path = e.getKey();
String loc = getLocation(path);
if(textures.containsKey(loc))
{
String newLoc = textures.get(loc);
if(newLoc == null) newLoc = getLocation(path);
builder.put(e.getKey(), new ResourceLocation(newLoc));
}
else
{
builder.put(e);
}
}
return new Wrapper(location, builder.build(), getNode());
}
@Override
public IModel process(ImmutableMap<String, String> customData)
{
return this;
}
@Override
public IModelState getDefaultState()
{
return new B3DState(getNode().getAnimation(), 1);
}
}
public static class ModelWrapper implements IRetexturableModel<ModelWrapper>, IModelCustomData<ModelWrapper>, IModelSimpleProperties<ModelWrapper>, IAnimatedModel
{
private final ResourceLocation modelLocation;
@ -624,23 +411,11 @@ public class B3DLoader implements ICustomModelLoader
private final boolean gui3d;
private final int defaultKey;
@Deprecated // remove in 1.9
public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet<String> meshes, int defaultKey)
{
this(modelLocation, model, meshes, true, true, defaultKey);
}
public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet<String> meshes, boolean smooth, boolean gui3d, int defaultKey)
{
this(modelLocation, model, meshes, smooth, gui3d, defaultKey, buildTextures(model.getTextures()));
}
@Deprecated // remove in 1.9
public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet<String> meshes, int defaultKey, ImmutableMap<String, ResourceLocation> textures)
{
this(modelLocation, model, meshes, true, true, defaultKey, textures);
}
public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet<String> meshes, boolean smooth, boolean gui3d, int defaultKey, ImmutableMap<String, ResourceLocation> textures)
{
this.modelLocation = modelLocation;
@ -691,7 +466,7 @@ public class B3DLoader implements ICustomModelLoader
}
@Override
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
@ -730,7 +505,7 @@ public class B3DLoader implements ICustomModelLoader
builder.put(e);
}
}
return new ModelWrapper(modelLocation, model, meshes, defaultKey, builder.build());
return new ModelWrapper(modelLocation, model, meshes, smooth, gui3d, defaultKey, builder.build());
}
@Override
@ -741,7 +516,7 @@ public class B3DLoader implements ICustomModelLoader
JsonElement e = new JsonParser().parse(data.get("mesh"));
if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isString())
{
return new ModelWrapper(modelLocation, model, ImmutableSet.of(e.getAsString()), defaultKey, textures);
return new ModelWrapper(modelLocation, model, ImmutableSet.of(e.getAsString()), smooth, gui3d, defaultKey, textures);
}
else if (e.isJsonArray())
{
@ -758,7 +533,7 @@ public class B3DLoader implements ICustomModelLoader
return this;
}
}
return new ModelWrapper(modelLocation, model, builder.build(), defaultKey, textures);
return new ModelWrapper(modelLocation, model, builder.build(), smooth, gui3d, defaultKey, textures);
}
else
{
@ -771,7 +546,7 @@ public class B3DLoader implements ICustomModelLoader
JsonElement e = new JsonParser().parse(data.get("key"));
if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber())
{
return new ModelWrapper(modelLocation, model, meshes, e.getAsNumber().intValue(), textures);
return new ModelWrapper(modelLocation, model, meshes, smooth, gui3d, e.getAsNumber().intValue(), textures);
}
else
{
@ -817,7 +592,7 @@ public class B3DLoader implements ICustomModelLoader
}
}
private static class BakedWrapper implements IFlexibleBakedModel, ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel
private static class BakedWrapper implements IPerspectiveAwareModel
{
private final Node<?> node;
private final IModelState state;
@ -830,12 +605,6 @@ public class B3DLoader implements ICustomModelLoader
private ImmutableList<BakedQuad> quads;
@Deprecated // remove in 1.9
public BakedWrapper(Node<?> node, IModelState state, VertexFormat format, ImmutableSet<String> meshes, ImmutableMap<String, TextureAtlasSprite> textures)
{
this(node, state, true, true, format, meshes, textures);
}
public BakedWrapper(final Node<?> node, final IModelState state, final boolean smooth, final boolean gui3d, final VertexFormat format, final ImmutableSet<String> meshes, final ImmutableMap<String, TextureAtlasSprite> textures)
{
this(node, state, smooth, gui3d, format, meshes, textures, CacheBuilder.newBuilder()
@ -857,12 +626,6 @@ public class B3DLoader implements ICustomModelLoader
}));
}
@Deprecated // remove in 1.9
public BakedWrapper(Node<?> node, IModelState state, VertexFormat format, ImmutableSet<String> meshes, ImmutableMap<String, TextureAtlasSprite> textures, LoadingCache<Integer, BakedWrapper> cache)
{
this(node, state, true, true, format, meshes, textures, cache);
}
public BakedWrapper(Node<?> node, IModelState state, boolean smooth, boolean gui3d, VertexFormat format, ImmutableSet<String> meshes, ImmutableMap<String, TextureAtlasSprite> textures, LoadingCache<Integer, BakedWrapper> cache)
{
this.node = node;
@ -875,11 +638,8 @@ public class B3DLoader implements ICustomModelLoader
this.cache = cache;
}
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
return Collections.emptyList();
}
// FIXME merge with handleBlockState
@Override
public List<BakedQuad> getGeneralQuads()
{
if(quads == null)
@ -887,7 +647,7 @@ public class B3DLoader implements ICustomModelLoader
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
for(Node<?> child : node.getNodes().values())
{
builder.addAll(new BakedWrapper(child, state, format, meshes, textures).getGeneralQuads());
builder.addAll(new BakedWrapper(child, state, smooth, gui3d, format, meshes, textures).getGeneralQuads());
}
if(node.getKind() instanceof Mesh && meshes.contains(node.getName()))
{
@ -996,7 +756,7 @@ public class B3DLoader implements ICustomModelLoader
return gui3d;
}
public boolean isBuiltInRenderer()
public boolean func_188618_c()
{
return false;
}
@ -1012,6 +772,7 @@ public class B3DLoader implements ICustomModelLoader
return ItemCameraTransforms.DEFAULT;
}
// FIXME merge with getQuads
@Override
public BakedWrapper handleBlockState(IBlockState state)
{
@ -1040,7 +801,7 @@ public class B3DLoader implements ICustomModelLoader
return cache.getUnchecked(s.getFrame());
}
B3DState newState = new B3DState(newAnimation, s.getFrame(), s.getNextFrame(), s.getProgress(), parent);
return new BakedWrapper(node, newState, format, meshes, textures);
return new BakedWrapper(node, newState, smooth, gui3d, format, meshes, textures);
}
}
else if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
@ -1055,25 +816,14 @@ public class B3DLoader implements ICustomModelLoader
IModelState newState = exState.getValue(Properties.AnimationProperty);
if(newState != null)
{
return new BakedWrapper(node, new ModelStateComposition(parent, newState), format, meshes, textures);
return new BakedWrapper(node, new ModelStateComposition(parent, newState), smooth, gui3d, format, meshes, textures);
}
}
}
return this;
}
public VertexFormat getFormat()
{
return format;
}
public BakedWrapper handleItemState(ItemStack stack)
{
// TODO specify how to get B3DState from ItemStack
return this;
}
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType);
}

View File

@ -53,7 +53,6 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@SuppressWarnings("deprecation")
public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<OBJModel>
{
//private Gson GSON = new GsonBuilder().create();
@ -95,7 +94,7 @@ public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<
}
@Override
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
builder.put(ModelLoader.White.loc.toString(), ModelLoader.White.instance);
@ -1300,7 +1299,7 @@ public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<
}
}
public class OBJBakedModel implements IFlexibleBakedModel, ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel
public class OBJBakedModel implements IPerspectiveAwareModel
{
private final OBJModel model;
private IModelState state;
@ -1323,12 +1322,7 @@ public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<
this.quads = null;
}
@Override
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
return Collections.emptyList();
}
// FIXME: merge with getQuads
@Override
public List<BakedQuad> getGeneralQuads()
{
@ -1479,7 +1473,7 @@ public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<
}
@Override
public boolean isBuiltInRenderer()
public boolean func_188618_c()
{
return false;
}
@ -1496,18 +1490,7 @@ public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<
return ItemCameraTransforms.DEFAULT;
}
@Override
public VertexFormat getFormat()
{
return format;
}
@Override
public IBakedModel handleItemState(ItemStack stack)
{
return this;
}
// FIXME: merge with getQuads
@Override
public OBJBakedModel handleBlockState(IBlockState state)
{
@ -1591,7 +1574,7 @@ public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<
}
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType);
}

View File

@ -1,16 +1,18 @@
package net.minecraftforge.client.model.pipeline;
import net.minecraft.block.Block;
import net.minecraft.block.Block.EnumOffsetType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
public class BlockInfo
{
private final BlockColors colors;
private IBlockAccess world;
private Block block;
private IBlockState state;
private BlockPos blockPos;
private final boolean[][][] translucent = new boolean[3][3][3];
@ -25,11 +27,16 @@ public class BlockInfo
private int cachedTint = -1;
private int cachedMultiplier = -1;
public BlockInfo(BlockColors colors)
{
this.colors = colors;
}
public int getColorMultiplier(int tint)
{
if(cachedTint == tint) return cachedMultiplier;
cachedTint = tint;
cachedMultiplier = block.colorMultiplier(world, blockPos, tint);
cachedMultiplier = colors.func_186724_a(state, world, blockPos, tint);
return cachedMultiplier;
}
@ -41,12 +48,12 @@ public class BlockInfo
public void updateShift(boolean ignoreY)
{
long rand = 0;
if(block.getOffsetType() != EnumOffsetType.NONE)
if(state.getBlock().getOffsetType() != EnumOffsetType.NONE)
{
rand = MathHelper.getCoordinateRandom(blockPos.getX(), ignoreY ? 0 : blockPos.getY(), blockPos.getZ());
shx = ((float)((rand >> 16) & 0xF) / 0xF - .5f) * .5f;
shz = ((float)((rand >> 24) & 0xF) / 0xF - .5f) * .5f;
if(block.getOffsetType() == EnumOffsetType.XYZ)
if(state.getBlock().getOffsetType() == EnumOffsetType.XYZ)
{
shy = ((float)((rand >> 20) & 0xF) / 0xF - 1) * .2f;
}
@ -60,9 +67,9 @@ public class BlockInfo
cachedMultiplier = -1;
}
public void setBlock(Block block)
public void setState(IBlockState state)
{
this.block = block;
this.state = state;
cachedTint = -1;
cachedMultiplier = -1;
}
@ -94,16 +101,16 @@ public class BlockInfo
for(int z = 0; z <= 2; z++)
{
BlockPos pos = blockPos.add(x - 1, y - 1, z - 1);
Block block = world.getBlockState(pos).getBlock();
translucent[x][y][z] = block.isTranslucent();
IBlockState state = world.getBlockState(pos);
translucent[x][y][z] = state.func_185895_e();
//translucent[x][y][z] = world.getBlockState(pos).getBlock().getLightOpacity(world, pos) == 0;
int brightness = this.block.getMixedBrightnessForBlock(world, pos);
int brightness = state.func_185889_a(world, pos);
s[x][y][z] = (brightness >> 0x14) & 0xF;
b[x][y][z] = (brightness >> 0x04) & 0xF;
ao[x][y][z] = block.getAmbientOcclusionLightValue();
ao[x][y][z] = state.func_185892_j();
if(x == 1 && y == 1 && z == 1)
{
full = block.isFullCube();
full = state.func_185917_h();
}
}
}
@ -150,9 +157,9 @@ public class BlockInfo
return world;
}
public Block getBlock()
public IBlockState getState()
{
return block;
return state;
}
public BlockPos getBlockPos()

View File

@ -2,13 +2,14 @@ package net.minecraftforge.client.model.pipeline;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.util.math.BlockPos;
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.minecraftforge.common.ForgeModContainer;
@ -19,7 +20,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
@Override
protected VertexLighterFlat initialValue()
{
return new VertexLighterFlat();
return new VertexLighterFlat(colors);
}
};
@ -28,7 +29,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
@Override
protected VertexLighterSmoothAo initialValue()
{
return new VertexLighterSmoothAo();
return new VertexLighterSmoothAo(colors);
}
};
@ -37,55 +38,64 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
private final ThreadLocal<VertexBuffer> lastRendererFlat = new ThreadLocal<VertexBuffer>();
private final ThreadLocal<VertexBuffer> lastRendererSmooth = new ThreadLocal<VertexBuffer>();
private final BlockColors colors;
public ForgeBlockModelRenderer(BlockColors colors)
{
// TODO Auto-generated constructor stub
super(colors);
this.colors = colors;
}
@Override
public boolean renderModelStandard(IBlockAccess world, IBakedModel model, Block block, BlockPos pos, VertexBuffer wr, boolean checkSides)
public boolean func_187497_c(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer buffer, boolean checkSides, long rand)
{
if(ForgeModContainer.forgeLightPipelineEnabled)
{
if(wr != lastRendererFlat.get())
if(buffer != lastRendererFlat.get())
{
lastRendererFlat.set(wr);
VertexBufferConsumer newCons = new VertexBufferConsumer(wr);
lastRendererFlat.set(buffer);
VertexBufferConsumer newCons = new VertexBufferConsumer(buffer);
wrFlat.set(newCons);
lighterFlat.get().setParent(newCons);
}
wrFlat.get().setOffset(pos);
return render(lighterFlat.get(), world, model, block, pos, wr, checkSides);
return render(lighterFlat.get(), world, model, state, pos, buffer, checkSides, rand);
}
else
{
return super.renderModelStandard(world, model, block, pos, wr, checkSides);
return super.func_187497_c(world, model, state, pos, buffer, checkSides, rand);
}
}
@Override
public boolean renderModelAmbientOcclusion(IBlockAccess world, IBakedModel model, Block block, BlockPos pos, VertexBuffer wr, boolean checkSides)
public boolean func_187498_b(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer buffer, boolean checkSides, long rand)
{
if(ForgeModContainer.forgeLightPipelineEnabled)
{
if(wr != lastRendererSmooth.get())
if(buffer != lastRendererSmooth.get())
{
lastRendererSmooth.set(wr);
VertexBufferConsumer newCons = new VertexBufferConsumer(wr);
lastRendererSmooth.set(buffer);
VertexBufferConsumer newCons = new VertexBufferConsumer(buffer);
wrSmooth.set(newCons);
lighterSmooth.get().setParent(newCons);
}
wrSmooth.get().setOffset(pos);
return render(lighterSmooth.get(), world, model, block, pos, wr, checkSides);
return render(lighterSmooth.get(), world, model, state, pos, buffer, checkSides, rand);
}
else
{
return super.renderModelAmbientOcclusion(world, model, block, pos, wr, checkSides);
return super.func_187498_b(world, model, state, pos, buffer, checkSides, rand);
}
}
public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, Block block, BlockPos pos, VertexBuffer wr, boolean checkSides)
public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer wr, boolean checkSides, long rand)
{
lighter.setWorld(world);
lighter.setBlock(block);
lighter.setState(state);
lighter.setBlockPos(pos);
boolean empty = true;
List<BakedQuad> quads = model.getGeneralQuads();
List<BakedQuad> quads = model.func_188616_a(state, null, rand);
if(!quads.isEmpty())
{
lighter.updateBlockInfo();
@ -97,10 +107,10 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
}
for(EnumFacing side : EnumFacing.values())
{
quads = model.getFaceQuads(side);
quads = model.func_188616_a(state, side, rand);
if(!quads.isEmpty())
{
if(!checkSides || block.shouldSideBeRendered(world, pos.offset(side), side))
if(!checkSides || state.func_185894_c(world, pos.offset(side), side))
{
if(empty) lighter.updateBlockInfo();
empty = false;

View File

@ -3,7 +3,6 @@ package net.minecraftforge.client.model.pipeline;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
@ -11,6 +10,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.model.IColoredBakedQuad;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -71,18 +72,16 @@ public class LightUtil
}
}
private static final LoadingCache<VertexFormat, int[]> formatMaps = CacheBuilder.newBuilder()
private static final LoadingCache<Pair<VertexFormat, VertexFormat>, int[]> formatMaps = CacheBuilder.newBuilder()
.maximumSize(10)
.build(new CacheLoader<VertexFormat, int[]>()
.build(new CacheLoader<Pair<VertexFormat, VertexFormat>, int[]>()
{
public int[] load(VertexFormat format)
public int[] load(Pair<VertexFormat, VertexFormat> pair)
{
return mapFormats(format, DefaultVertexFormats.ITEM);
return mapFormats(pair.getLeft(), pair.getRight());
}
});
private static final int itemCount = DefaultVertexFormats.ITEM.getElementCount();
public static void putBakedQuad(IVertexConsumer consumer, BakedQuad quad)
{
consumer.setQuadOrientation(quad.getFace());
@ -96,16 +95,18 @@ public class LightUtil
}
//int[] eMap = mapFormats(consumer.getVertexFormat(), DefaultVertexFormats.ITEM);
float[] data = new float[4];
VertexFormat format = consumer.getVertexFormat();
int count = format.getElementCount();
int[] eMap = formatMaps.getUnchecked(format);
VertexFormat formatFrom = consumer.getVertexFormat();
VertexFormat formatTo = quad.getFormat();
int countFrom = formatFrom.getElementCount();
int countTo = formatTo.getElementCount();
int[] eMap = formatMaps.getUnchecked(Pair.of(formatFrom, formatTo));
for(int v = 0; v < 4; v++)
{
for(int e = 0; e < count; e++)
for(int e = 0; e < countFrom; e++)
{
if(eMap[e] != itemCount)
if(eMap[e] != countTo)
{
unpack(quad.getVertexData(), data, DefaultVertexFormats.ITEM, v, eMap[e]);
unpack(quad.getVertexData(), data, quad.getFormat(), v, eMap[e]);
consumer.put(e, data);
}
else
@ -240,7 +241,7 @@ public class LightUtil
if(tessellator == null)
{
Tessellator tes = Tessellator.getInstance();
VertexBuffer wr = tes.getVertexBuffer();
VertexBuffer wr = tes.getWorldRenderer();
tessellator = new VertexBufferConsumer(wr);
}
return tessellator;
@ -260,7 +261,7 @@ public class LightUtil
public static void renderQuadColorSlow(VertexBuffer wr, BakedQuad quad, int auxColor)
{
ItemConsumer cons;
if(wr == Tessellator.getInstance().getVertexBuffer())
if(wr == Tessellator.getInstance().getWorldRenderer())
{
cons = getItemConsumer();
}

View File

@ -1,6 +1,7 @@
package net.minecraftforge.client.model.pipeline;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.IColoredBakedQuad;
@ -13,9 +14,9 @@ public class UnpackedBakedQuad extends BakedQuad
protected final VertexFormat format;
protected boolean packed = false;
public UnpackedBakedQuad(float[][][] unpackedData, int tint, EnumFacing orientation, VertexFormat format)
public UnpackedBakedQuad(float[][][] unpackedData, int tint, EnumFacing orientation, TextureAtlasSprite texture, VertexFormat format)
{
super(new int[format.getNextOffset() /* / 4 * 4 */], tint, orientation);
super(new int[format.getNextOffset() /* / 4 * 4 */], tint, orientation, texture, format);
this.unpackedData = unpackedData;
this.format = format;
}
@ -69,9 +70,9 @@ public class UnpackedBakedQuad extends BakedQuad
public static class Colored extends UnpackedBakedQuad implements IColoredBakedQuad
{
public Colored(float[][][] unpackedData, int tint, EnumFacing orientation, VertexFormat format)
public Colored(float[][][] unpackedData, int tint, EnumFacing orientation, TextureAtlasSprite texture, VertexFormat format)
{
super(unpackedData, tint, orientation, format);
super(unpackedData, tint, orientation, texture, format);
}
}
@ -81,6 +82,7 @@ public class UnpackedBakedQuad extends BakedQuad
private final float[][][] unpackedData;
private int tint = -1;
private EnumFacing orientation;
private TextureAtlasSprite texture;
private boolean isColored = false;
private int vertices = 0;
@ -108,6 +110,11 @@ public class UnpackedBakedQuad extends BakedQuad
this.orientation = orientation;
}
public void setTexture(TextureAtlasSprite texture)
{
this.texture = texture;
}
public void setQuadColored()
{
this.isColored = true;
@ -146,9 +153,9 @@ public class UnpackedBakedQuad extends BakedQuad
}
if(isColored)
{
return new Colored(unpackedData, tint, orientation, format);
return new Colored(unpackedData, tint, orientation, texture, format);
}
return new UnpackedBakedQuad(unpackedData, tint, orientation, format);
return new UnpackedBakedQuad(unpackedData, tint, orientation, texture, format);
}
}
}

View File

@ -7,7 +7,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
/**
* Assumes VertexFormatElement is present in the WorlRenderer's vertex format.
* Assumes VertexFormatElement is present in the VertexBuffer's vertex format.
*/
public class VertexBufferConsumer implements IVertexConsumer
{

View File

@ -2,19 +2,20 @@ package net.minecraftforge.client.model.pipeline;
import javax.vecmath.Vector3f;
import com.google.common.base.Objects;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import com.google.common.base.Objects;
public class VertexLighterFlat extends QuadGatheringTransformer
{
protected final BlockInfo blockInfo = new BlockInfo();
protected final BlockInfo blockInfo;
private int tint = -1;
protected int posIndex = -1;
@ -22,6 +23,11 @@ public class VertexLighterFlat extends QuadGatheringTransformer
protected int colorIndex = -1;
protected int lightmapIndex = -1;
public VertexLighterFlat(BlockColors colors)
{
this.blockInfo = new BlockInfo(colors);
}
@Override
public void setParent(IVertexConsumer parent)
{
@ -197,7 +203,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
float e2 = 0.95f;
BlockPos pos = blockInfo.getBlockPos();
boolean full = blockInfo.getBlock().isFullCube();
boolean full = blockInfo.getState().func_185917_h();
if((full || y < -e1) && normal[1] < -e2) pos = pos.down();
if((full || y > e1) && normal[1] > e2) pos = pos.up();
@ -206,7 +212,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
if((full || x < -e1) && normal[0] < -e2) pos = pos.west();
if((full || x > e1) && normal[0] > e2) pos = pos.east();
int brightness = blockInfo.getBlock().getMixedBrightnessForBlock(blockInfo.getWorld(), pos);
int brightness = blockInfo.getState().func_185889_a(blockInfo.getWorld(), pos);
lightmap[0] = ((float)((brightness >> 0x04) & 0xF) * 0x20) / 0xFFFF;
lightmap[1] = ((float)((brightness >> 0x14) & 0xF) * 0x20) / 0xFFFF;
@ -235,9 +241,9 @@ public class VertexLighterFlat extends QuadGatheringTransformer
blockInfo.setWorld(world);
}
public void setBlock(Block block)
public void setState(IBlockState state)
{
blockInfo.setBlock(block);
blockInfo.setState(state);
}
public void setBlockPos(BlockPos blockPos)

View File

@ -1,10 +1,16 @@
package net.minecraftforge.client.model.pipeline;
import net.minecraft.util.MathHelper;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.util.math.MathHelper;
public class VertexLighterSmoothAo extends VertexLighterFlat
{
public VertexLighterSmoothAo(BlockColors colors)
{
super(colors);
}
@Override
protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z)
{

View File

@ -45,3 +45,4 @@ net/minecraft/stats/StatList.mergeStatBases([Lnet/minecraft/stats/StatBase;Lnet/
net/minecraft/item/ItemStack.<init>(Lnet/minecraft/item/Item;IILnet/minecraft/nbt/NBTTagCompound;)V=|p_i1881_1_,p_i1881_2_,p_i1881_3_,capNBT
net/minecraft/block/BlockRedstoneWire.canConnectTo(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/EnumFacing;Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/util/math/BlockPos;)Z=p_176343_0_,p_176343_1_,world,pos
net/minecraft/client/renderer/block/model/BakedQuad.<init>([IILnet/minecraft/util/EnumFacing;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/client/renderer/vertex/VertexFormat)V=|p_i46574_1_,p_i46574_2_,p_i46574_3_,p_i46574_4_,format