RendererLivingEntity, RenderEntityItem, RenderItem, RenderManager, LayerArmorBase; Item.getModel + ISmartItemModel are now inside ItemOverrideList; fix class rename in TESR patch.

This commit is contained in:
RainWarrior committed 2016-03-01 20:13:37 +03:00
1 parent c9a01a439d
commit 153fb6b30d
12 files changed
+313 -275

No files matched your search

@@ -0,0 +1,97 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/RenderItem.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/RenderItem.java
@@ -71,7 +71,7 @@
public RenderItem(TextureManager p_i46552_1_, ModelManager p_i46552_2_, ItemColors p_i46552_3_)
{
this.textureManager = p_i46552_1_;
- this.itemModelMesher = new ItemModelMesher(p_i46552_2_);
+ this.itemModelMesher = new net.minecraftforge.client.ItemModelMesherForge(p_i46552_2_);
this.registerItems();
this.field_184395_f = p_i46552_3_;
}
@@ -223,7 +223,7 @@
k = k | -16777216;
}
- this.renderQuad(renderer, bakedquad, k);
+ net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
}
}
@@ -245,17 +245,7 @@
public IBakedModel func_184393_a(ItemStack p_184393_1_, World p_184393_2_, EntityLivingBase p_184393_3_)
{
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(p_184393_1_);
- Item item = p_184393_1_.getItem();
-
- if (item != null && item.func_185040_i())
- {
- ResourceLocation resourcelocation = ibakedmodel.func_188617_f().func_188021_a(p_184393_1_, p_184393_2_, p_184393_3_);
- return resourcelocation == null ? ibakedmodel : this.itemModelMesher.getModelManager().getModel(new ModelResourceLocation(resourcelocation, "inventory"));
- }
- else
- {
- return ibakedmodel;
- }
+ return ibakedmodel.func_188617_f().handleItemState(ibakedmodel, p_184393_1_, p_184393_2_, p_184393_3_);
}
public void func_184392_a(ItemStack p_184392_1_, EntityLivingBase p_184392_2_, ItemCameraTransforms.TransformType p_184392_3_, boolean p_184392_4_)
@@ -279,14 +269,9 @@
GlStateManager.enableBlend();
GlStateManager.func_187428_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.pushMatrix();
- ItemCameraTransforms itemcameratransforms = p_184394_2_.getItemCameraTransforms();
- ItemCameraTransforms.func_188034_a(itemcameratransforms.getTransform(p_184394_3_), p_184394_4_);
+ // TODO: check if negative scale is a thing
+ p_184394_2_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_184394_2_, p_184394_3_);
- if (this.func_183005_a(itemcameratransforms.getTransform(p_184394_3_)))
- {
- GlStateManager.func_187407_a(GlStateManager.CullFace.FRONT);
- }
-
this.renderItem(p_184394_1_, p_184394_2_);
GlStateManager.func_187407_a(GlStateManager.CullFace.BACK);
GlStateManager.popMatrix();
@@ -319,7 +304,7 @@
GlStateManager.func_187401_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.setupGuiTransform(p_184390_2_, p_184390_3_, p_184390_4_.isGui3d());
- p_184390_4_.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GUI);
+ p_184390_4_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_184390_4_, ItemCameraTransforms.TransformType.GUI);
this.renderItem(p_184390_1_, p_184390_4_);
GlStateManager.disableAlpha();
GlStateManager.disableRescaleNormal();
@@ -426,10 +411,11 @@
GlStateManager.enableDepth();
}
- if (stack.isItemDamaged())
+ if (stack.getItem().showDurabilityBar(stack))
{
- int j = (int)Math.round(13.0D - (double)stack.getItemDamage() * 13.0D / (double)stack.getMaxDamage());
- int i = (int)Math.round(255.0D - (double)stack.getItemDamage() * 255.0D / (double)stack.getMaxDamage());
+ double health = stack.getItem().getDurabilityForDisplay(stack);
+ int j = (int)Math.round(13.0D - health * 13.0D);
+ int i = (int)Math.round(255.0D - health * 255.0D);
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
@@ -440,7 +426,7 @@
this.func_181565_a(vertexbuffer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
this.func_181565_a(vertexbuffer, xPosition + 2, yPosition + 13, 12, 1, (255 - i) / 4, 64, 0, 255);
this.func_181565_a(vertexbuffer, xPosition + 2, yPosition + 13, j, 1, 255 - i, i, 0, 255);
- GlStateManager.enableBlend();
+ //GlStateManager.enableBlend(); // Forge: Disable Blend because it screws with a lot of things down the line.
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
@@ -1053,6 +1039,7 @@
this.registerBlock(Blocks.field_185779_df, TileEntityStructure.Mode.LOAD.func_185110_a(), "structure_block");
this.registerBlock(Blocks.field_185779_df, TileEntityStructure.Mode.CORNER.func_185110_a(), "structure_block");
this.registerBlock(Blocks.field_185779_df, TileEntityStructure.Mode.DATA.func_185110_a(), "structure_block");
+ net.minecraftforge.client.model.ModelLoader.onRegisterItems(this.itemModelMesher);
}
public void onResourceManagerReload(IResourceManager resourceManager)
@@ -1,12 +1,10 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java
@@ -20,7 +20,9 @@
@@ -20,6 +20,7 @@
TextureAtlasSprite getParticleTexture();
+ @Deprecated
ItemCameraTransforms getItemCameraTransforms();
+ @Deprecated
ItemOverrideList func_188617_f();
}
@@ -0,0 +1,40 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java
@@ -1,7 +1,10 @@
package net.minecraft.client.renderer.block.model;
import com.google.common.collect.Lists;
+
import java.util.List;
+
+import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -27,6 +30,7 @@
}
}
+ @Deprecated
public ResourceLocation func_188021_a(ItemStack p_188021_1_, World p_188021_2_, EntityLivingBase p_188021_3_)
{
if (!this.field_188023_b.isEmpty())
@@ -42,4 +46,18 @@
return null;
}
+
+ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
+ {
+ net.minecraft.item.Item item = stack.getItem();
+ if (item != null && item.func_185040_i())
+ {
+ ResourceLocation location = func_188021_a(stack, world, entity);
+ if (location != null)
+ {
+ return Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel(new ModelResourceLocation(location, "inventory"));
+ }
+ }
+ return originalModel;
+ }
}
@@ -9,7 +9,53 @@
float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);
@@ -192,4 +192,25 @@
@@ -114,16 +114,13 @@
GlStateManager.pushMatrix();
IBakedModel ibakedmodel = this.itemRenderer.func_184393_a(itemstack, entity.worldObj, (EntityLivingBase)null);
int j = this.func_177077_a(entity, x, y, z, partialTicks, ibakedmodel);
- float f = ibakedmodel.getItemCameraTransforms().ground.scale.x;
- float f1 = ibakedmodel.getItemCameraTransforms().ground.scale.y;
- float f2 = ibakedmodel.getItemCameraTransforms().ground.scale.z;
boolean flag1 = ibakedmodel.isGui3d();
if (!flag1)
{
- float f3 = -0.0F * (float)(j - 1) * 0.5F * f;
- float f4 = -0.0F * (float)(j - 1) * 0.5F * f1;
- float f5 = -0.09375F * (float)(j - 1) * 0.5F * f2;
+ float f3 = -0.0F * (float)(j - 1) * 0.5F;
+ float f4 = -0.0F * (float)(j - 1) * 0.5F;
+ float f5 = -0.09375F * (float)(j - 1) * 0.5F;
GlStateManager.translate(f3, f4, f5);
}
@@ -144,10 +141,10 @@
float f7 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f9 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f6 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
- GlStateManager.translate(f7, f9, f6);
+ GlStateManager.translate(shouldSpreadItems() ? f7 : 0, shouldSpreadItems() ? f9 : 0, f6);
}
- ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GROUND);
+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND);
this.itemRenderer.renderItem(itemstack, ibakedmodel);
GlStateManager.popMatrix();
}
@@ -162,10 +159,10 @@
GlStateManager.translate(f8, f10, 0.0F);
}
- ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GROUND);
+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND);
this.itemRenderer.renderItem(itemstack, ibakedmodel);
GlStateManager.popMatrix();
- GlStateManager.translate(0.0F * f, 0.0F * f1, 0.09375F * f2);
+ GlStateManager.translate(0.0F, 0.0F, 0.09375F);
}
}
@@ -192,4 +189,25 @@
{
return TextureMap.locationBlocksTexture;
}
@@ -1,53 +1,51 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java
@@ -32,6 +32,9 @@
protected List<LayerRenderer<T>> layerRenderers = Lists.<LayerRenderer<T>>newArrayList();
protected boolean renderOutlines = false;
protected boolean field_188323_j = false;
+ public static float NAME_TAG_RANGE = 64.0f;
+ public static float NAME_TAG_RANGE_SNEAK = 32.0f;
+
public RendererLivingEntity(RenderManager renderManagerIn, ModelBase modelBaseIn, float shadowSizeIn)
public RenderLivingBase(RenderManager renderManagerIn, ModelBase modelBaseIn, float shadowSizeIn)
{
super(renderManagerIn);
++++ END PATCH
++++ REJECTED PATCH 2
@@ -77,10 +80,12 @@
public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks)
{
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre(entity, this, x, y, z))) return;
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre<T>(entity, this, x, y, z))) return;
GlStateManager.pushMatrix();
GlStateManager.disableCull();
this.mainModel.swingProgress = this.getSwingProgress(entity, partialTicks);
- this.mainModel.isRiding = entity.isRiding();
+ boolean shouldSit = entity.isRiding() && (entity.ridingEntity != null && entity.ridingEntity.shouldRiderSit());
- this.mainModel.isRiding = entity.func_184218_aH();
+ boolean shouldSit = entity.func_184218_aH() && (entity.func_184187_bx() != null && entity.func_184187_bx().shouldRiderSit());
+ this.mainModel.isRiding = shouldSit;
this.mainModel.isChild = entity.isChild();
try
++++ END PATCH
++++ REJECTED PATCH 3
@@ -89,7 +94,7 @@
float f1 = this.interpolateRotation(entity.prevRotationYawHead, entity.rotationYawHead, partialTicks);
float f2 = f1 - f;
- if (entity.isRiding() && entity.ridingEntity instanceof EntityLivingBase)
+ if (shouldSit && entity.ridingEntity instanceof EntityLivingBase)
- if (entity.func_184218_aH() && entity.func_184187_bx() instanceof EntityLivingBase)
+ if (shouldSit && entity.func_184187_bx() instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)entity.ridingEntity;
EntityLivingBase entitylivingbase = (EntityLivingBase)entity.func_184187_bx();
f = this.interpolateRotation(entitylivingbase.prevRenderYawOffset, entitylivingbase.renderYawOffset, partialTicks);
++++ END PATCH
++++ REJECTED PATCH 4
{
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post(entity, this, x, y, z));
@@ -197,6 +202,7 @@
GlStateManager.enableCull();
GlStateManager.popMatrix();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post<T>(entity, this, x, y, z));
}
protected boolean setScoreTeamColor(T entityLivingBaseIn)
++++ END PATCH
++++ REJECTED PATCH 5
public float func_188322_c(T p_188322_1_, float p_188322_2_)
@@ -452,10 +458,11 @@
public void renderName(T entity, double x, double y, double z)
{
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Pre(entity, this, x, y, z))) return;
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Pre<T>(entity, this, x, y, z))) return;
if (this.canRenderName(entity))
{
double d0 = entity.getDistanceSqToEntity(this.renderManager.livingPlayer);
@@ -56,13 +54,11 @@
if (d0 < (double)(f * f))
{
++++ END PATCH
++++ REJECTED PATCH 6
}
@@ -464,6 +471,7 @@
this.func_188296_a(entity, x, y, z, s, d0);
}
}
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Post(entity, this, x, y, z));
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Post<T>(entity, this, x, y, z));
}
protected boolean canRenderName(T entity)
++++ END PATCH
@@ -13,3 +13,15 @@
public void setRenderPosition(double renderPosXIn, double renderPosYIn, double renderPosZIn)
{
@@ -253,9 +258,9 @@
IBlockState iblockstate = worldIn.getBlockState(new BlockPos(livingPlayerIn));
Block block = iblockstate.getBlock();
- if (block == Blocks.bed)
+ if (block.isBed(worldIn, new BlockPos(livingPlayerIn), (EntityLivingBase)livingPlayerIn))
{
- int i = ((EnumFacing)iblockstate.getValue(BlockBed.field_185512_D)).getHorizontalIndex();
+ int i = block.getBedDirection(worldIn, new BlockPos(livingPlayerIn)).getHorizontalIndex();
this.playerViewY = (float)(i * 90 + 180);
this.playerViewX = 0.0F;
}
@@ -1,6 +1,46 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java
@@ -140,11 +140,13 @@
@@ -59,29 +59,27 @@
T t = this.func_188360_a(p_188361_9_);
t.setModelAttributes(this.renderer.getMainModel());
t.setLivingAnimations(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_4_);
+ t = getArmorModelHook(p_188361_1_, itemstack, p_188361_9_, t);
this.func_188359_a(t, p_188361_9_);
boolean flag = this.func_188363_b(p_188361_9_);
- this.renderer.bindTexture(this.getArmorResource(itemarmor, flag));
+ this.renderer.bindTexture(this.getArmorResource(p_188361_1_, itemstack, p_188361_9_, null));
- switch (itemarmor.getArmorMaterial())
- {
- case LEATHER:
int i = itemarmor.getColor(itemstack);
+ {
+ if (i != -1) // Allow this for anything, not only cloth
+ {
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
float f2 = (float)(i & 255) / 255.0F;
GlStateManager.color(this.colorR * f, this.colorG * f1, this.colorB * f2, this.alpha);
t.render(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_);
- this.renderer.bindTexture(this.getArmorResource(itemarmor, flag, "overlay"));
- case CHAIN:
- case IRON:
- case GOLD:
- case DIAMOND:
+ this.renderer.bindTexture(this.getArmorResource(p_188361_1_, itemstack, p_188361_9_, "overlay"));
+ }
+ { // Non-colored
GlStateManager.color(this.colorR, this.colorG, this.colorB, this.alpha);
t.render(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_);
- default:
-
- if (!this.field_177193_i && itemstack.isItemEnchanted())
+ } // Default
+ if (!this.field_177193_i && itemstack.hasEffect())
{
func_188364_a(this.renderer, p_188361_1_, t, p_188361_2_, p_188361_3_, p_188361_4_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_);
}
@@ -140,11 +138,13 @@
GlStateManager.disableBlend();
}
@@ -14,3 +54,53 @@
private ResourceLocation getArmorResource(ItemArmor p_177178_1_, boolean p_177178_2_, String p_177178_3_)
{
String s = String.format("textures/models/armor/%s_layer_%d%s.png", new Object[] {p_177178_1_.getArmorMaterial().getName(), Integer.valueOf(p_177178_2_ ? 2 : 1), p_177178_3_ == null ? "" : String.format("_%s", new Object[]{p_177178_3_})});
@@ -162,4 +162,49 @@
protected abstract void initArmor();
protected abstract void func_188359_a(T p_188359_1_, EntityEquipmentSlot p_188359_2_);
+
+ /*=================================== FORGE START =========================================*/
+
+ /**
+ * Hook to allow item-sensitive armor model. for LayerBipedArmor.
+ */
+ protected T getArmorModelHook(EntityLivingBase entity, ItemStack itemStack, EntityEquipmentSlot slot, T model)
+ {
+ return model;
+ }
+
+ /**
+ * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide.
+ *
+ * @param entity Entity wearing the armor
+ * @param stack ItemStack for the armor
+ * @param slot Slot ID that the item is in
+ * @param type Subtype, can be null or "overlay"
+ * @return ResourceLocation pointing at the armor's texture
+ */
+ public ResourceLocation getArmorResource(net.minecraft.entity.Entity entity, ItemStack stack, EntityEquipmentSlot slot, String type)
+ {
+ ItemArmor item = (ItemArmor)stack.getItem();
+ String texture = item.getArmorMaterial().getName();
+ String domain = "minecraft";
+ int idx = texture.indexOf(':');
+ if (idx != -1)
+ {
+ domain = texture.substring(0, idx);
+ texture = texture.substring(idx + 1);
+ }
+ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (func_188363_b(slot) ? 2 : 1), type == null ? "" : String.format("_%s", type));
+
+ s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
+ ResourceLocation resourcelocation = (ResourceLocation)ARMOR_TEXTURE_RES_MAP.get(s1);
+
+ if (resourcelocation == null)
+ {
+ resourcelocation = new ResourceLocation(s1);
+ ARMOR_TEXTURE_RES_MAP.put(s1, resourcelocation);
+ }
+
+ return resourcelocation;
+ }
+ /*=================================== FORGE END ===========================================*/
}
@@ -5,5 +5,5 @@
return false;
}
+
+ public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, net.minecraft.client.renderer.WorldRenderer worldRenderer) {}
+ public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, net.minecraft.client.renderer.VertexBuffer buffer) {}
}
@@ -1,39 +0,0 @@
++++ REJECTED PATCH 2
for (int j = 0; j < i; ++j)
{
- if (ibakedmodel.isGui3d())
{
GlStateManager.pushMatrix();
++++ END PATCH
++++ REJECTED PATCH 3
float f = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f1 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f2 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
- GlStateManager.translate(f, f1, f2);
+ GlStateManager.translate(shouldSpreadItems() ? f : 0.0F, shouldSpreadItems() ? f1 : 0.0F, f2);
}
+ if (ibakedmodel.isGui3d())
GlStateManager.scale(0.5F, 0.5F, 0.5F);
- ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GROUND);
+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND);
this.itemRenderer.renderItem(itemstack, ibakedmodel);
GlStateManager.popMatrix();
}
- else
- {
- GlStateManager.pushMatrix();
- ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GROUND);
- this.itemRenderer.renderItem(itemstack, ibakedmodel);
- GlStateManager.popMatrix();
- float f3 = ibakedmodel.getItemCameraTransforms().ground.scale.x;
- float f4 = ibakedmodel.getItemCameraTransforms().ground.scale.y;
- float f5 = ibakedmodel.getItemCameraTransforms().ground.scale.z;
- GlStateManager.translate(0.0F * f3, 0.0F * f4, 0.046875F * f5);
- }
}
GlStateManager.popMatrix();
++++ END PATCH
@@ -1,96 +0,0 @@
++++ REJECTED PATCH 1
public RenderItem(TextureManager textureManager, ModelManager modelManager)
{
this.textureManager = textureManager;
- this.itemModelMesher = new ItemModelMesher(modelManager);
+ this.itemModelMesher = new net.minecraftforge.client.ItemModelMesherForge(modelManager);
this.registerItems();
}
++++ END PATCH
++++ REJECTED PATCH 2
k = k | -16777216;
}
- this.renderQuad(renderer, bakedquad, k);
+ net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
}
}
++++ END PATCH
++++ REJECTED PATCH 3
modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory");
}
}
+ else
+ {
+ // TODO: maybe switch to the smart player model / normal smart item model?
+ modelresourcelocation = item.getModel(stack, entityplayer, entityplayer.getItemInUseCount());
+ }
if (modelresourcelocation != null)
{
++++ END PATCH
++++ REJECTED PATCH 4
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.pushMatrix();
- ItemCameraTransforms itemcameratransforms = model.getItemCameraTransforms();
- itemcameratransforms.applyTransform(cameraTransformType);
+ // TODO: check if negative scale is a thing
+ model = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(model, cameraTransformType);
- if (this.func_183005_a(itemcameratransforms.getTransform(cameraTransformType)))
- {
- GlStateManager.cullFace(1028);
- }
-
this.renderItem(stack, model);
GlStateManager.cullFace(1029);
GlStateManager.popMatrix();
++++ END PATCH
++++ REJECTED PATCH 5
GlStateManager.blendFunc(770, 771);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.setupGuiTransform(x, y, ibakedmodel.isGui3d());
- ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GUI);
+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GUI);
this.renderItem(stack, ibakedmodel);
GlStateManager.disableAlpha();
GlStateManager.disableRescaleNormal();
++++ END PATCH
++++ REJECTED PATCH 6
GlStateManager.enableDepth();
}
- if (stack.isItemDamaged())
+ if (stack.getItem().showDurabilityBar(stack))
{
- int j = (int)Math.round(13.0D - (double)stack.getItemDamage() * 13.0D / (double)stack.getMaxDamage());
- int i = (int)Math.round(255.0D - (double)stack.getItemDamage() * 255.0D / (double)stack.getMaxDamage());
+ double health = stack.getItem().getDurabilityForDisplay(stack);
+ int j = (int)Math.round(13.0D - health * 13.0D);
+ int i = (int)Math.round(255.0D - health * 255.0D);
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
++++ END PATCH
++++ REJECTED PATCH 7
this.func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
this.func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 12, 1, (255 - i) / 4, 64, 0, 255);
this.func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, j, 1, 255 - i, i, 0, 255);
- GlStateManager.enableBlend();
+ //GlStateManager.enableBlend(); // Forge: Disable Blend because it screws with a lot of things down the line.
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
++++ END PATCH
++++ REJECTED PATCH 8
this.registerBlock(Blocks.brown_mushroom_block, BlockHugeMushroom.EnumType.ALL_INSIDE.getMetadata(), "brown_mushroom_block");
this.registerBlock(Blocks.red_mushroom_block, BlockHugeMushroom.EnumType.ALL_INSIDE.getMetadata(), "red_mushroom_block");
this.registerBlock(Blocks.dragon_egg, "dragon_egg");
+ net.minecraftforge.client.model.ModelLoader.onRegisterItems(this.itemModelMesher);
}
public void onResourceManagerReload(IResourceManager resourceManager)
++++ END PATCH
@@ -1,13 +0,0 @@
++++ REJECTED PATCH 2
IBlockState iblockstate = worldIn.getBlockState(new BlockPos(livingPlayerIn));
Block block = iblockstate.getBlock();
- if (block == Blocks.bed)
+ if (block.isBed(worldIn, new BlockPos(livingPlayerIn), (EntityLivingBase)livingPlayerIn))
{
- int i = ((EnumFacing)iblockstate.getValue(BlockBed.FACING)).getHorizontalIndex();
+ int i = block.getBedDirection(worldIn, new BlockPos(livingPlayerIn)).getHorizontalIndex();
this.playerViewY = (float)(i * 90 + 180);
this.playerViewX = 0.0F;
}
++++ END PATCH
@@ -1,93 +0,0 @@
++++ REJECTED PATCH 1
T t = this.func_177175_a(armorSlot);
t.setModelAttributes(this.renderer.getMainModel());
t.setLivingAnimations(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_4_);
+ t = getArmorModelHook(entitylivingbaseIn, itemstack, armorSlot, t);
this.func_177179_a(t, armorSlot);
boolean flag = this.isSlotForLeggings(armorSlot);
- this.renderer.bindTexture(this.getArmorResource(itemarmor, flag));
+ this.renderer.bindTexture(this.getArmorResource(entitylivingbaseIn, itemstack, flag ? 2 : 1, null));
- switch (itemarmor.getArmorMaterial())
- {
- case LEATHER:
int i = itemarmor.getColor(itemstack);
+ {
+ if (i != -1) // Allow this for anything, not only cloth.
+ {
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
float f2 = (float)(i & 255) / 255.0F;
GlStateManager.color(this.colorR * f, this.colorG * f1, this.colorB * f2, this.alpha);
t.render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
- this.renderer.bindTexture(this.getArmorResource(itemarmor, flag, "overlay"));
- case CHAIN:
- case IRON:
- case GOLD:
- case DIAMOND:
+ this.renderer.bindTexture(this.getArmorResource(entitylivingbaseIn, itemstack, flag ? 2 : 1, "overlay"));
+ }
+ { // Non-colored
GlStateManager.color(this.colorR, this.colorG, this.colorB, this.alpha);
t.render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
- default:
-
- if (!this.field_177193_i && itemstack.isItemEnchanted())
+ }
+ // Default
+ if (!this.field_177193_i && itemstack.hasEffect())
{
this.func_177183_a(entitylivingbaseIn, t, p_177182_2_, p_177182_3_, p_177182_4_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
}
++++ END PATCH
++++ REJECTED PATCH 3
protected abstract void initArmor();
protected abstract void func_177179_a(T p_177179_1_, int p_177179_2_);
+
+ /*=================================== FORGE START =========================================*/
+
+ /**
+ * Hook to allow item-sensitive armor model. for LayerBipedArmor.
+ */
+ protected T getArmorModelHook(EntityLivingBase entity, ItemStack itemStack, int slot, T model)
+ {
+ return model;
+ }
+
+ /**
+ * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide.
+ *
+ * @param entity Entity wearing the armor
+ * @param stack ItemStack for the armor
+ * @param slot Slot ID that the item is in
+ * @param type Subtype, can be null or "overlay"
+ * @return ResourceLocation pointing at the armor's texture
+ */
+ public ResourceLocation getArmorResource(net.minecraft.entity.Entity entity, ItemStack stack, int slot, String type)
+ {
+ ItemArmor item = (ItemArmor)stack.getItem();
+ String texture = item.getArmorMaterial().getName();
+ String domain = "minecraft";
+ int idx = texture.indexOf(':');
+ if (idx != -1)
+ {
+ domain = texture.substring(0, idx);
+ texture = texture.substring(idx + 1);
+ }
+ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type));
+
+ s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
+ ResourceLocation resourcelocation = (ResourceLocation)ARMOR_TEXTURE_RES_MAP.get(s1);
+
+ if (resourcelocation == null)
+ {
+ resourcelocation = new ResourceLocation(s1);
+ ARMOR_TEXTURE_RES_MAP.put(s1, resourcelocation);
+ }
+
+ return resourcelocation;
+ }
+ /*=================================== FORGE END ===========================================*/
}
++++ END PATCH