mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Introduce rework of Capability provider. And reduce errors to <2000
This commit is contained in:
1 parent
12869710de
commit
eac693e785
25 files changed
+485
-176
No files matched your search
@@ -380,7 +380,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
{
|
||||
vbo.bindBuffer();
|
||||
|
||||
int stride = FORMAT.getNextOffset();
|
||||
int stride = FORMAT.getSize();
|
||||
GlStateManager.glVertexPointer(3, GL11.GL_FLOAT, stride, 0);
|
||||
GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
GlStateManager.glTexCoordPointer(2, GL11.GL_FLOAT, stride, 12);
|
||||
@@ -390,9 +390,9 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.limit(FORMAT.getNextOffset());
|
||||
buffer.limit(FORMAT.getSize());
|
||||
for (int i = 0; i < FORMAT.getElementCount(); i++)
|
||||
FORMAT.getElements().get(i).getUsage().preDraw(FORMAT, i, FORMAT.getNextOffset(), buffer);
|
||||
FORMAT.getElements().get(i).getUsage().preDraw(FORMAT, i, FORMAT.getSize(), buffer);
|
||||
buffer.position(0);
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
|
||||
buffer.limit(0);
|
||||
for (int i = 0; i < FORMAT.getElementCount(); i++)
|
||||
FORMAT.getElements().get(i).getUsage().postDraw(FORMAT, i, FORMAT.getNextOffset(), buffer);
|
||||
FORMAT.getElements().get(i).getUsage().postDraw(FORMAT, i, FORMAT.getSize(), buffer);
|
||||
buffer.position(0);
|
||||
|
||||
// Disable our coloring.
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.annotation.Nonnull;
|
||||
public class FluidContainerColorer implements IItemColor
|
||||
{
|
||||
@Override
|
||||
public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex)
|
||||
public int getColor(@Nonnull ItemStack stack, int tintIndex)
|
||||
{
|
||||
if (tintIndex != 1) return 0xFFFFFFFF;
|
||||
FluidStack fluidStack = FluidUtil.getFluidContained(stack);
|
||||
|
||||
@@ -22,9 +22,10 @@ package net.minecraftforge.client;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ForgeClientHandler
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class ForgeClientHandler
|
||||
// register model for the universal bucket, if it exists
|
||||
if (FluidRegistry.isUniversalBucketEnabled())
|
||||
{
|
||||
ModelLoader.setBucketModelDefinition(ForgeModContainer.getInstance().universalBucket);
|
||||
ModelLoader.setBucketModelDefinition(ForgeMod.getInstance().universalBucket);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class ForgeClientHandler
|
||||
{
|
||||
if (FluidRegistry.isUniversalBucketEnabled())
|
||||
{
|
||||
event.getItemColors().registerItemColorHandler(new FluidContainerColorer(), ForgeModContainer.getInstance().universalBucket);
|
||||
event.getItemColors().registerItemColorHandler(new FluidContainerColorer(), ForgeMod.getInstance().universalBucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,8 @@ public class Attributes
|
||||
*/
|
||||
public static boolean moreSpecific(VertexFormat first, VertexFormat second)
|
||||
{
|
||||
int size = first.getNextOffset();
|
||||
if(size != second.getNextOffset()) return false;
|
||||
int size = first.getSize();
|
||||
if(size != second.getSize()) return false;
|
||||
|
||||
int padding = 0;
|
||||
int j = 0;
|
||||
|
||||
@@ -35,6 +35,9 @@ import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Quat4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
@@ -43,7 +46,6 @@ import net.minecraftforge.client.model.BlockStateLoader.Marker;
|
||||
import net.minecraftforge.client.model.BlockStateLoader.SubModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -62,6 +64,7 @@ import com.google.gson.JsonParseException;
|
||||
|
||||
public class ForgeBlockStateV1 extends Marker
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
ForgeBlockStateV1.Variant defaults;
|
||||
Multimap<String, ForgeBlockStateV1.Variant> variants = LinkedHashMultimap.create();
|
||||
|
||||
@@ -181,9 +184,9 @@ public class ForgeBlockStateV1 extends Marker
|
||||
String value = v.textures.get(tex.getValue().substring(1));
|
||||
if (value == null)
|
||||
{
|
||||
FMLLog.log.fatal("Could not resolve texture name \"{}\" for permutation \"{}\"", tex.getValue(), e.getKey());
|
||||
LOGGER.fatal("Could not resolve texture name \"{}\" for permutation \"{}\"", tex.getValue(), e.getKey());
|
||||
for (Entry<String, String> t: v.textures.entrySet())
|
||||
FMLLog.log.fatal("{}={}", t.getKey(), t.getValue());
|
||||
LOGGER.fatal("{}={}", t.getKey(), t.getValue());
|
||||
throw new JsonParseException("Could not resolve texture name \"" + tex.getValue() + "\" for permutation \"" + e.getKey() + "\"");
|
||||
}
|
||||
v.textures.put(tex.getKey(), value);
|
||||
@@ -441,7 +444,7 @@ public class ForgeBlockStateV1 extends Marker
|
||||
protected ResourceLocation getBlockLocation(String location)
|
||||
{
|
||||
ResourceLocation tmp = new ResourceLocation(location);
|
||||
return new ResourceLocation(tmp.getResourceDomain(), "block/" + tmp.getResourcePath());
|
||||
return new ResourceLocation(tmp.getNamespace(), "block/" + tmp.getPath());
|
||||
}
|
||||
|
||||
/** Throws an error if there are submodels in this submodel. */
|
||||
|
||||
@@ -24,22 +24,20 @@ import java.util.function.Predicate;
|
||||
import net.minecraftforge.client.resource.IResourceType;
|
||||
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.client.resource.VanillaResourceType;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface ICustomModelLoader extends ISelectiveResourceReloadListener
|
||||
{
|
||||
@Override
|
||||
void onResourceManagerReload(IResourceManager resourceManager);
|
||||
void func_195410_a(IResourceManager resourceManager);
|
||||
|
||||
@Override
|
||||
default void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate)
|
||||
{
|
||||
if (resourcePredicate.test(VanillaResourceType.MODELS))
|
||||
{
|
||||
onResourceManagerReload(resourceManager);
|
||||
func_195410_a(resourceManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ 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;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
@@ -449,15 +449,15 @@ public final class ItemLayerModel implements IModel
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
public void func_195410_a(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return modelLocation.getResourceDomain().equals(ForgeVersion.MOD_ID) && (
|
||||
modelLocation.getResourcePath().equals("item-layer") ||
|
||||
modelLocation.getResourcePath().equals("models/block/item-layer") ||
|
||||
modelLocation.getResourcePath().equals("models/item/item-layer"));
|
||||
return modelLocation.getNamespace().equals(ForgeVersion.MOD_ID) && (
|
||||
modelLocation.getPath().equals("item-layer") ||
|
||||
modelLocation.getPath().equals("models/block/item-layer") ||
|
||||
modelLocation.getPath().equals("models/item/item-layer"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,10 +36,10 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -61,11 +61,13 @@ 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.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class ModelDynBucket implements IModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final ModelResourceLocation LOCATION = new ModelResourceLocation(new ResourceLocation(ForgeVersion.MOD_ID, "dynbucket"), "inventory");
|
||||
|
||||
// minimal Z offset to prevent depth-fighting
|
||||
@@ -93,13 +95,6 @@ public final class ModelDynBucket implements IModel
|
||||
this(null, null, null, null, false, true);
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #ModelDynBucket(ResourceLocation, ResourceLocation, ResourceLocation, Fluid, boolean, boolean)} */
|
||||
@Deprecated // TODO: remove
|
||||
public ModelDynBucket(@Nullable ResourceLocation baseLocation, @Nullable ResourceLocation liquidLocation, @Nullable ResourceLocation coverLocation, @Nullable Fluid fluid, boolean flipGas)
|
||||
{
|
||||
this(baseLocation, liquidLocation, coverLocation, fluid, flipGas, true);
|
||||
}
|
||||
|
||||
public ModelDynBucket(@Nullable ResourceLocation baseLocation, @Nullable ResourceLocation liquidLocation, @Nullable ResourceLocation coverLocation, @Nullable Fluid fluid, boolean flipGas, boolean tint)
|
||||
{
|
||||
this.baseLocation = baseLocation;
|
||||
@@ -255,7 +250,7 @@ public final class ModelDynBucket implements IModel
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return modelLocation.getResourceDomain().equals(ForgeVersion.MOD_ID) && modelLocation.getResourcePath().contains("forgebucket");
|
||||
return modelLocation.getNamespace().equals(ForgeVersion.MOD_ID) && modelLocation.getPath().contains("forgebucket");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -265,7 +260,7 @@ public final class ModelDynBucket implements IModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
public void func_195410_a(IResourceManager resourceManager)
|
||||
{
|
||||
// no need to clear cache since we create a new model instance
|
||||
}
|
||||
@@ -397,7 +392,7 @@ public final class ModelDynBucket implements IModel
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Failed to close resource", e);
|
||||
LOGGER.error("Failed to close resource", e);
|
||||
}
|
||||
|
||||
this.clearFramesTextureData();
|
||||
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformT
|
||||
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.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
@@ -48,9 +48,10 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
@@ -63,6 +64,7 @@ import com.google.gson.JsonParser;
|
||||
|
||||
public final class ModelFluid implements IModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final ModelFluid WATER = new ModelFluid(FluidRegistry.WATER);
|
||||
public static final ModelFluid LAVA = new ModelFluid(FluidRegistry.LAVA);
|
||||
|
||||
@@ -102,15 +104,15 @@ public final class ModelFluid implements IModel
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
public void func_195410_a(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return modelLocation.getResourceDomain().equals(ForgeVersion.MOD_ID) && (
|
||||
modelLocation.getResourcePath().equals("fluid") ||
|
||||
modelLocation.getResourcePath().equals("models/block/fluid") ||
|
||||
modelLocation.getResourcePath().equals("models/item/fluid"));
|
||||
return modelLocation.getNamespace().equals(ForgeVersion.MOD_ID) && (
|
||||
modelLocation.getPath().equals("fluid") ||
|
||||
modelLocation.getPath().equals("models/block/fluid") ||
|
||||
modelLocation.getPath().equals("models/item/fluid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -346,7 +348,7 @@ public final class ModelFluid implements IModel
|
||||
// sides
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
EnumFacing side = EnumFacing.getHorizontal((5 - i) % 4); // [W, S, E, N]
|
||||
EnumFacing side = EnumFacing.byHorizontalIndex((5 - i) % 4); // [W, S, E, N]
|
||||
boolean useOverlay = overlay.isPresent() && sideOverlays[side.getHorizontalIndex()];
|
||||
int si = i; // local var for lambda capture
|
||||
|
||||
@@ -502,7 +504,7 @@ public final class ModelFluid implements IModel
|
||||
String fluid = e.getAsString();
|
||||
if(!FluidRegistry.isFluidRegistered(fluid))
|
||||
{
|
||||
FMLLog.log.fatal("fluid '{}' not found", fluid);
|
||||
LOGGER.fatal("fluid '{}' not found", fluid);
|
||||
return WATER;
|
||||
}
|
||||
return new ModelFluid(FluidRegistry.getFluid(fluid));
|
||||
|
||||
@@ -35,8 +35,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockPart;
|
||||
import net.minecraft.client.renderer.block.model.BlockPartFace;
|
||||
@@ -50,7 +50,6 @@ import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition.MissingVariantException;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.MultipartBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
||||
@@ -59,14 +58,12 @@ import net.minecraft.client.renderer.block.model.VariantList;
|
||||
import net.minecraft.client.renderer.block.model.WeightedBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Multipart;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Selector;
|
||||
import net.minecraft.client.renderer.block.statemap.BlockStateMapper;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
@@ -81,7 +78,6 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.client.ClientModLoader;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.ProgressManager;
|
||||
import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
|
||||
import net.minecraftforge.logging.ModelLoaderErrorMessage;
|
||||
@@ -183,7 +179,7 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("Exception baking model for location(s) {}:", modelLocations, e);
|
||||
LOGGEr.error("Exception baking model for location(s) {}:", modelLocations, e);
|
||||
bakedModels.put(model, missingBaked);
|
||||
}
|
||||
}
|
||||
@@ -335,7 +331,7 @@ public final class ModelLoader extends ModelBakery
|
||||
@Override
|
||||
protected ResourceLocation getModelLocation(ResourceLocation model)
|
||||
{
|
||||
return new ResourceLocation(model.getResourceDomain(), model.getResourcePath() + ".json");
|
||||
return new ResourceLocation(model.getNamespace(), model.getPath() + ".json");
|
||||
}
|
||||
|
||||
private final class VanillaModelWrapper implements IModel
|
||||
@@ -474,7 +470,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
transformation = transformation.compose(newTransforms.get(i));
|
||||
BlockPartRotation rot = part.partRotation;
|
||||
if(rot == null) rot = new BlockPartRotation(new org.lwjgl.util.vector.Vector3f(), EnumFacing.Axis.Y, 0, false);
|
||||
if(rot == null) rot = new BlockPartRotation(new Vector3f(), EnumFacing.Axis.Y, 0, false);
|
||||
part = new BlockPart(part.positionFrom, part.positionTo, part.mapFaces, rot, part.shade);
|
||||
}
|
||||
for(Map.Entry<EnumFacing, BlockPartFace> e : part.mapFaces.entrySet())
|
||||
@@ -764,7 +760,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
try
|
||||
{
|
||||
missingModel = VanillaLoader.INSTANCE.loadModel(new ResourceLocation(MODEL_MISSING.getResourceDomain(), MODEL_MISSING.getResourcePath()));
|
||||
missingModel = VanillaLoader.INSTANCE.loadModel(new ResourceLocation(MODEL_MISSING.getNamespace(), MODEL_MISSING.getPath()));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -838,7 +834,7 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
// NOOP, handled in loader
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
public void func_195410_a(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
@@ -853,12 +849,12 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
return loader.getMissingModel();
|
||||
}
|
||||
String modelPath = modelLocation.getResourcePath();
|
||||
if(modelLocation.getResourcePath().startsWith("models/"))
|
||||
String modelPath = modelLocation.getPath();
|
||||
if(modelLocation.getPath().startsWith("models/"))
|
||||
{
|
||||
modelPath = modelPath.substring("models/".length());
|
||||
}
|
||||
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getResourceDomain(), "armatures/" + modelPath + ".json");
|
||||
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json");
|
||||
ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(loader.resourceManager, armatureLocation);
|
||||
ModelBlock model = loader.loadModel(modelLocation);
|
||||
IModel iModel = loader.new VanillaModelWrapper(modelLocation, model, false, animation);
|
||||
@@ -917,6 +913,7 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class ItemLoadingException extends ModelLoaderRegistry.LoaderException
|
||||
{
|
||||
private final Exception normalException;
|
||||
@@ -1065,7 +1062,7 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
// NOOP, handled in loader
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
public void func_195410_a(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
@@ -1091,7 +1088,7 @@ public final class ModelLoader extends ModelBakery
|
||||
IModel model = loader.multipartModels.get(definition);
|
||||
if (model == null)
|
||||
{
|
||||
model = new MultipartModel(new ResourceLocation(variant.getResourceDomain(), variant.getResourcePath()), definition.getMultipartData());
|
||||
model = new MultipartModel(new ResourceLocation(variant.getNamespace(), variant.getPath()), definition.getMultipartData());
|
||||
loader.multipartModels.put(definition, model);
|
||||
}
|
||||
return model;
|
||||
|
||||
@@ -33,7 +33,7 @@ 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.resources.IResourceManager;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -41,9 +41,10 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.Optional;
|
||||
@@ -54,6 +55,7 @@ import com.google.gson.JsonParser;
|
||||
|
||||
public final class MultiLayerModel implements IModel
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final MultiLayerModel INSTANCE = new MultiLayerModel(ImmutableMap.of());
|
||||
|
||||
private final ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models;
|
||||
@@ -121,7 +123,7 @@ public final class MultiLayerModel implements IModel
|
||||
{
|
||||
return new ModelResourceLocation(e.getAsString());
|
||||
}
|
||||
FMLLog.log.fatal("Expect ModelResourceLocation, got: {}", json);
|
||||
LOGGER.fatal("Expect ModelResourceLocation, got: {}", json);
|
||||
return new ModelResourceLocation("builtin/missing", "missing");
|
||||
}
|
||||
|
||||
@@ -205,15 +207,15 @@ public final class MultiLayerModel implements IModel
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
public void func_195410_a(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return modelLocation.getResourceDomain().equals(ForgeVersion.MOD_ID) && (
|
||||
modelLocation.getResourcePath().equals("multi-layer") ||
|
||||
modelLocation.getResourcePath().equals("models/block/multi-layer") ||
|
||||
modelLocation.getResourcePath().equals("models/item/multi-layer"));
|
||||
return modelLocation.getNamespace().equals(ForgeVersion.MOD_ID) && (
|
||||
modelLocation.getPath().equals("multi-layer") ||
|
||||
modelLocation.getPath().equals("models/block/multi-layer") ||
|
||||
modelLocation.getPath().equals("models/item/multi-layer"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,14 +28,13 @@ import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformT
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
@@ -68,7 +68,6 @@ import net.minecraftforge.common.model.animation.IJoint;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -108,7 +107,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager manager)
|
||||
public void func_195410_a(IResourceManager manager)
|
||||
{
|
||||
this.manager = manager;
|
||||
cache.clear();
|
||||
@@ -117,14 +116,14 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return enabledDomains.contains(modelLocation.getResourceDomain()) && modelLocation.getResourcePath().endsWith(".b3d");
|
||||
return enabledDomains.contains(modelLocation.getNamespace()) && modelLocation.getPath().endsWith(".b3d");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath());
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath());
|
||||
if(!cache.containsKey(file))
|
||||
{
|
||||
IResource resource = null;
|
||||
@@ -136,10 +135,10 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
if(modelLocation.getResourcePath().startsWith("models/block/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/item/" + file.getResourcePath().substring("models/block/".length())));
|
||||
else if(modelLocation.getResourcePath().startsWith("models/item/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/block/" + file.getResourcePath().substring("models/item/".length())));
|
||||
if(modelLocation.getPath().startsWith("models/block/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/item/" + file.getPath().substring("models/block/".length())));
|
||||
else if(modelLocation.getPath().startsWith("models/item/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/block/" + file.getPath().substring("models/item/".length())));
|
||||
else throw e;
|
||||
}
|
||||
B3DModel.Parser parser = new B3DModel.Parser(resource.getInputStream());
|
||||
@@ -452,7 +451,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections2.filter(textures.values(), loc -> !loc.getResourcePath().startsWith("#"));
|
||||
return Collections2.filter(textures.values(), loc -> !loc.getPath().startsWith("#"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -462,9 +461,9 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
|
||||
for(Map.Entry<String, ResourceLocation> e : textures.entrySet())
|
||||
{
|
||||
if(e.getValue().getResourcePath().startsWith("#"))
|
||||
if(e.getValue().getPath().startsWith("#"))
|
||||
{
|
||||
FMLLog.log.fatal("unresolved texture '{}' for b3d model '{}'", e.getValue().getResourcePath(), modelLocation);
|
||||
FMLLog.log.fatal("unresolved texture '{}' for b3d model '{}'", e.getValue().getPath(), modelLocation);
|
||||
builder.put(e.getKey(), missing);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -25,16 +25,17 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/*
|
||||
* Loader for OBJ models.
|
||||
@@ -44,6 +45,7 @@ import org.apache.logging.log4j.Level;
|
||||
public enum OBJLoader implements ICustomModelLoader {
|
||||
INSTANCE;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private IResourceManager manager;
|
||||
private final Set<String> enabledDomains = new HashSet<>();
|
||||
private final Map<ResourceLocation, OBJModel> cache = new HashMap<>();
|
||||
@@ -52,11 +54,11 @@ public enum OBJLoader implements ICustomModelLoader {
|
||||
public void addDomain(String domain)
|
||||
{
|
||||
enabledDomains.add(domain.toLowerCase());
|
||||
FMLLog.log.info("OBJLoader: Domain {} has been added.", domain.toLowerCase());
|
||||
LOGGER.info("OBJLoader: Domain {} has been added.", domain.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
public void func_195410_a(IResourceManager resourceManager)
|
||||
{
|
||||
this.manager = resourceManager;
|
||||
cache.clear();
|
||||
@@ -66,13 +68,13 @@ public enum OBJLoader implements ICustomModelLoader {
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return enabledDomains.contains(modelLocation.getResourceDomain()) && modelLocation.getResourcePath().endsWith(".obj");
|
||||
return enabledDomains.contains(modelLocation.getNamespace()) && modelLocation.getPath().endsWith(".obj");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath());
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath());
|
||||
if (!cache.containsKey(file))
|
||||
{
|
||||
IResource resource = null;
|
||||
@@ -84,10 +86,10 @@ public enum OBJLoader implements ICustomModelLoader {
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
if (modelLocation.getResourcePath().startsWith("models/block/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/item/" + file.getResourcePath().substring("models/block/".length())));
|
||||
else if (modelLocation.getResourcePath().startsWith("models/item/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/block/" + file.getResourcePath().substring("models/item/".length())));
|
||||
if (modelLocation.getPath().startsWith("models/block/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/item/" + file.getPath().substring("models/block/".length())));
|
||||
else if (modelLocation.getPath().startsWith("models/item/"))
|
||||
resource = manager.getResource(new ResourceLocation(file.getNamespace(), "models/block/" + file.getPath().substring("models/item/".length())));
|
||||
else throw e;
|
||||
}
|
||||
OBJModel.Parser parser = new OBJModel.Parser(resource, manager);
|
||||
|
||||
+3
-3
@@ -21,13 +21,13 @@ package net.minecraftforge.client.resource;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
|
||||
public interface ISelectiveResourceReloadListener extends IResourceManagerReloadListener
|
||||
{
|
||||
@Override
|
||||
default void onResourceManagerReload(IResourceManager resourceManager)
|
||||
default void func_195410_a(IResourceManager resourceManager)
|
||||
{
|
||||
// For compatibility, call the selective version from the non-selective function
|
||||
onResourceManagerReload(resourceManager, SelectiveReloadStateHandler.INSTANCE.get());
|
||||
|
||||
Reference in new issue
Block a user