mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 14:39:43 +00:00
Add Is Normal Item Rendering type for Scripted Items to Hold them regularly
This commit is contained in:
1 parent
72ea93bfef
commit
f22b40ffd8
3 files changed
+73
-17
No files matched your search
@@ -78,17 +78,21 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
float entityRenderTicks = Minecraft.getMinecraft().timer.renderPartialTicks;
|
||||
float bobbing = MathHelper.sin(((float)entityItem.age + entityRenderTicks) / 10.0F + entityItem.hoverStart) * 0.1F + 0.1F;
|
||||
|
||||
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
|
||||
if(!scriptCustomItem.isNormalItem){
|
||||
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
|
||||
}
|
||||
|
||||
GL11.glRotatef(scriptCustomItem.rotationXRate * entityRenderTicks %360, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks %360, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks %360, 0, 0, 1);
|
||||
|
||||
if (!renderInFrame) {
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(0.0F, (Math.max(scriptCustomItem.scaleY, 1) - 1) * (1.0F / 4), 0.0F);
|
||||
if(!scriptCustomItem.isNormalItem){
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(0.0F, (Math.max(scriptCustomItem.scaleY, 1) - 1) * (1.0F / 4), 0.0F);
|
||||
}
|
||||
GL11.glTranslatef(0.0F, -bobbing, 0.0F);
|
||||
}
|
||||
|
||||
@@ -104,22 +108,60 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON && scriptCustomItem.isNormalItem) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.9375F, 0.0625F, 0.0F);
|
||||
GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.135F, 0.2F, 0.07F);
|
||||
|
||||
int color = scriptCustomItem.getColor();
|
||||
float itemRed = (color >> 16 & 255) / 255f;
|
||||
float itemGreen = (color >> 8 & 255) / 255f;
|
||||
float itemBlue = (color & 255) / 255f;
|
||||
GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F);
|
||||
|
||||
GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.09375F, 0.0625F, 0.0F);
|
||||
|
||||
EntityLivingBase entityLivingBase = (EntityLivingBase) data[1];
|
||||
renderItem3d(scriptCustomItem, entityLivingBase, itemStack);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslatef(0.9375F, 0.0625F, 0.0F);
|
||||
GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
((ItemScripted) itemStack.getItem()).renderOffset(scriptCustomItem);
|
||||
GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ);
|
||||
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
|
||||
if(scriptCustomItem.isNormalItem){
|
||||
GL11.glTranslatef(-0.05F, 0.3F, 0.3F);
|
||||
GL11.glRotatef(50, 1, 0, 0);
|
||||
GL11.glRotatef(-80, 0, 1, 0);
|
||||
GL11.glRotatef(80, 0, 0, 1);
|
||||
|
||||
GL11.glRotatef(scriptCustomItem.rotationXRate * item3dRenderTicks %360, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationYRate * item3dRenderTicks %360, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * item3dRenderTicks %360, 0, 0, 1);
|
||||
GL11.glRotatef(scriptCustomItem.rotationXRate * item3dRenderTicks %360, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationYRate * item3dRenderTicks %360, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * item3dRenderTicks %360, 0, 0, 1);
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glScalef(0.6F, 0.6F,0.6F);
|
||||
}
|
||||
else {
|
||||
GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ);
|
||||
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
|
||||
|
||||
GL11.glRotatef(scriptCustomItem.rotationXRate * item3dRenderTicks %360, 1, 0, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationYRate * item3dRenderTicks %360, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * item3dRenderTicks %360, 0, 0, 1);
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
}
|
||||
|
||||
int color = scriptCustomItem.getColor();
|
||||
float itemRed = (color >> 16 & 255) / 255f;
|
||||
@@ -234,7 +276,8 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
if(!scriptCustomItem.isNormalItem)
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
|
||||
|
||||
for (int k = 0; k < b0; ++k)
|
||||
|
||||
@@ -30,6 +30,7 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IN
|
||||
public int maxItemUseDuration = 20;
|
||||
public int itemUseAction = 0; //0: none, 1: block, 2: bow, 3: eat, 4: drink
|
||||
|
||||
public boolean isNormalItem = false;
|
||||
public boolean isTool = false;
|
||||
public int digSpeed = 1;
|
||||
public int armorType = -2; //-2: Fits in no armor slot, -1: Fits in all slots, 0 - 4: Fits in Head -> Boots slot respectively
|
||||
@@ -109,8 +110,8 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IN
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean bo) {
|
||||
this.enabled = bo;
|
||||
public void setEnabled(boolean enable) {
|
||||
this.enabled = enable;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
@@ -173,6 +174,16 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IN
|
||||
return this.isTool;
|
||||
}
|
||||
|
||||
public void setIsNormalItem(boolean normalItem){
|
||||
this.isNormalItem = normalItem;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public boolean isNormalItem(){
|
||||
return this.isNormalItem;
|
||||
}
|
||||
|
||||
|
||||
public void setDigSpeed(int digSpeed){
|
||||
this.digSpeed = digSpeed;
|
||||
saveItemData();
|
||||
@@ -367,6 +378,7 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IN
|
||||
compound.setFloat("TranslateZ",this.translateZ);
|
||||
|
||||
compound.setBoolean("IsTool", this.isTool);
|
||||
compound.setBoolean("IsNormalItem", this.isNormalItem);
|
||||
compound.setInteger("DigSpeed", this.digSpeed);
|
||||
compound.setInteger("ArmorType", this.armorType);
|
||||
compound.setInteger("Enchantability", this.enchantability);
|
||||
@@ -403,6 +415,7 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IN
|
||||
this.translateZ = compound.getFloat("TranslateZ");
|
||||
|
||||
this.isTool = compound.getBoolean("IsTool");
|
||||
this.isNormalItem = compound.getBoolean("IsNormalItem");
|
||||
this.digSpeed = compound.getInteger("DigSpeed");
|
||||
this.armorType = compound.getInteger("ArmorType");
|
||||
this.enchantability = compound.getInteger("Enchantability");
|
||||
|
||||
Reference in new issue
Block a user