mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-15 17:14:51 +00:00
Fixes to scripted item rendering.
IItemCustom: -Removed unnecessary setters.
This commit is contained in:
1 parent
bfce45028c
commit
58932ffe55
5 files changed
+66
-111
No files matched your search
@@ -13,8 +13,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.items.ItemRenderInterface;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -76,11 +74,18 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
return;
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glPushMatrix();
|
||||
renderInventoryCustomItem(scriptCustomItem);
|
||||
GL11.glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.ENTITY) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
float bobbingY = ((float)(Math.sin((float)this.entityRenderTicks /40.0F) + 1)/6.0F);
|
||||
GL11.glTranslatef(0.0F, (Math.max(scriptCustomItem.scaleY,1)-1) * (1.0F/4), 0.0F);
|
||||
|
||||
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
|
||||
@@ -90,6 +95,7 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1);
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(0.0F, bobbingY, 0.0F);
|
||||
|
||||
int color = scriptCustomItem.getColor();
|
||||
float itemRed = (color >> 16 & 255) / 255f;
|
||||
@@ -99,9 +105,13 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
|
||||
EntityItem entityItem = (EntityItem) data[1];
|
||||
renderEntityCustomItem(scriptCustomItem, itemStack, entityItem);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslatef(0.9375F, 0.0625F, 0.0F);
|
||||
GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
@@ -129,19 +139,17 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
|
||||
EntityLivingBase entityLivingBase = (EntityLivingBase) data[1];
|
||||
renderItem3d(scriptCustomItem, entityLivingBase, itemStack);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderEntityCustomItem(ScriptCustomItem scriptCustomItem, ItemStack itemStack, EntityItem entityItem) {
|
||||
this.entityRenderTicks++;
|
||||
if (!Minecraft.getMinecraft().isGamePaused()) {
|
||||
this.entityRenderTicks++;
|
||||
}
|
||||
int pass = 0;
|
||||
float bobbingY = (float)(Math.sin((float)this.entityRenderTicks /40.0F) + 1) * scriptCustomItem.scaleY/6.0F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, bobbingY, 0.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up.
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
ResourceLocation location = new ResourceLocation(scriptCustomItem.texture);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
|
||||
|
||||
@@ -283,10 +291,6 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -300,15 +304,13 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up.
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
ResourceLocation location = new ResourceLocation(scriptCustomItem.texture);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
|
||||
renderCustomItemSlot(0,0,16,16, scriptCustomItem.item);
|
||||
renderCustomItemSlot(0,0,16,16, itemRed, itemGreen, itemBlue);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
if (scriptCustomItem.item.hasEffect(0))
|
||||
{
|
||||
@@ -361,9 +363,10 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
public void renderCustomItemSlot(int posX, int posY, int imageWidth, int imageHeight, ItemStack itemStack) {
|
||||
public void renderCustomItemSlot(int posX, int posY, int imageWidth, int imageHeight, float itemRed, float itemGreen, float itemBlue) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(itemRed, itemGreen, itemBlue, 1.0F);
|
||||
tessellator.addVertexWithUV((double)(posX), (double)(posY + imageHeight), 0, 0, 1);
|
||||
tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY + imageHeight), 0, 1, 1);
|
||||
tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY), 0, 1, 0);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package noppes.npcs.entity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
public class EntityItemScripted extends EntityItem {
|
||||
private final ScriptCustomItem customItem;
|
||||
|
||||
public EntityItemScripted(World p_i1709_1_, double p_i1709_2_, double p_i1709_4_, double p_i1709_6_, ItemStack p_i1710_8_) {
|
||||
super(p_i1709_1_, p_i1709_2_, p_i1709_4_, p_i1709_6_, p_i1710_8_);
|
||||
this.customItem = ItemScripted.GetWrapper(this.getEntityItem());
|
||||
float entitySize = (float)(Math.sqrt(Math.pow(customItem.scaleX,2) + Math.pow(customItem.scaleZ,2)));
|
||||
this.width = 0.4F * entitySize;
|
||||
this.height = 0.4F * customItem.scaleY;
|
||||
this.delayBeforeCanPickup = 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePushed() {
|
||||
if (this.delayBeforeCanPickup > 0) {
|
||||
return false;
|
||||
}
|
||||
return super.canBePushed();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityItemScripted;
|
||||
import noppes.npcs.scripted.event.ItemEvent;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
@@ -159,6 +159,21 @@ public class ItemScripted extends Item implements ItemRenderInterface {
|
||||
@Override
|
||||
public void renderSpecial() {}
|
||||
|
||||
public boolean hasCustomEntity(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public EntityItemScripted createEntity(World world, Entity location, ItemStack itemstack)
|
||||
{
|
||||
EntityItemScripted entityScriptedItem = new EntityItemScripted(world,location.posX,location.posY,location.posZ, itemstack);
|
||||
entityScriptedItem.motionX = location.motionX;
|
||||
entityScriptedItem.motionY = location.motionY;
|
||||
entityScriptedItem.motionZ = location.motionZ;
|
||||
|
||||
return entityScriptedItem;
|
||||
}
|
||||
|
||||
public void renderOffset(ScriptCustomItem scriptCustomItem) {
|
||||
GL11.glTranslatef(0.135F * scriptCustomItem.scaleX, 0.2F * scriptCustomItem.scaleY, 0.07F * scriptCustomItem.scaleZ);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces.item;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.IScriptHandler;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public interface IItemCustom extends IItemStack, IScriptHandler {
|
||||
|
||||
@@ -68,30 +59,6 @@ public interface IItemCustom extends IItemStack, IScriptHandler {
|
||||
|
||||
void setTranslate(float translateX, float translateY, float translateZ);
|
||||
|
||||
void setRotationX(float rotationX);
|
||||
|
||||
void setRotationY(float rotationY);
|
||||
|
||||
void setRotationZ(float rotationZ);
|
||||
|
||||
void setRotationXRate(float rotationXRate);
|
||||
|
||||
void setRotationYRate(float rotationYRate);
|
||||
|
||||
void setRotationZRate(float rotationZRate);
|
||||
|
||||
void setScaleX(float scaleX);
|
||||
|
||||
void setScaleY(float scaleY);
|
||||
|
||||
void setScaleZ(float scaleZ);
|
||||
|
||||
void setTranslateX(float translateX);
|
||||
|
||||
void setTranslateY(float translateY);
|
||||
|
||||
void setTranslateZ(float translateZ);
|
||||
|
||||
float getRotationX();
|
||||
|
||||
float getRotationY();
|
||||
|
||||
@@ -295,66 +295,6 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationX(float rotationX) {
|
||||
this.rotationX = rotationX;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationY(float rotationY) {
|
||||
this.rotationY = rotationY;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationZ(float rotationZ) {
|
||||
this.rotationZ = rotationZ;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationXRate(float rotationXRate) {
|
||||
this.rotationXRate = rotationXRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationYRate(float rotationYRate) {
|
||||
this.rotationYRate = rotationYRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationZRate(float rotationZRate) {
|
||||
this.rotationZRate = rotationZRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setScaleX(float scaleX) {
|
||||
this.scaleX = scaleX;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setScaleY(float scaleY) {
|
||||
this.scaleY = scaleY;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setScaleZ(float scaleZ) {
|
||||
this.scaleZ = scaleZ;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setTranslateX(float translateX) {
|
||||
this.translateX = translateX;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setTranslateY(float translateY) {
|
||||
this.translateY = translateY;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setTranslateZ(float translateZ) {
|
||||
this.translateZ = translateZ;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public float getRotationX() {
|
||||
return rotationX;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user