diff --git a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java index fabf50d..b161527 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java @@ -336,7 +336,7 @@ public class RenderEntityEvents Minecraft.getMinecraft().getRenderManager().setRenderShadow(false); - CarryOnOverride carryOverride = ScriptChecker.inspectEntity(entity); + CarryOnOverride carryOverride = ScriptChecker.getOverride(player); if (carryOverride != null) { double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation()); diff --git a/src/main/java/tschipp/carryon/client/event/RenderEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEvents.java index 94ef9b5..fbe5878 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEvents.java @@ -259,15 +259,16 @@ public class RenderEvents this.setLightmapDisabled(true); + if (perspective == 0) + { + event.setCanceled(true); + } + } GlStateManager.scale(1, 1, 1); GlStateManager.popMatrix(); - if (perspective == 0) - { - event.setCanceled(true); - } } else { @@ -375,7 +376,7 @@ public class RenderEvents IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileItem, world, player); - CarryOnOverride carryOverride = ScriptChecker.inspectBlock(state, world, player.getPosition(), tag); + CarryOnOverride carryOverride = ScriptChecker.getOverride(player); if (carryOverride != null) { double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation()); @@ -462,7 +463,7 @@ public class RenderEvents float rotY = model.bipedBody.childModels.get(k).rotateAngleY; float rotZ = model.bipedBody.childModels.get(k).rotateAngleZ; - if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] -0.5f || rotX == rotRight1[0] -0.5f) + if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] - 0.5f || rotX == rotRight1[0] - 0.5f) { model.bipedBody.childModels.remove(k); k = k - 1; @@ -493,7 +494,11 @@ public class RenderEvents model.bipedRightArm.isHidden = true; model.bipedLeftArmwear.isHidden = true; model.bipedRightArmwear.isHidden = true; - + this.fakeLeftArm.isHidden = false; + this.fakeLeftArmwear.isHidden = false; + this.fakeRightArm.isHidden = false; + this.fakeRightArmwear.isHidden = false; + Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc); if (aplayer.getSkinType().equals("default")) @@ -527,19 +532,40 @@ public class RenderEvents if (override.getRenderRotationRightArm() != null) rotRight = ScriptParseHelper.getXYZArray(override.getRenderRotationRightArm()); + boolean renderRight = override.isRenderRightArm(); + boolean renderLeft = override.isRenderLeftArm(); + + if (!renderRight) + { + this.fakeRightArm.isHidden = true; + this.fakeRightArmwear.isHidden = true; + model.bipedRightArm.isHidden = false; + model.bipedRightArmwear.isHidden = false; + } + + + if (!renderLeft) + { + this.fakeLeftArm.isHidden = true; + this.fakeLeftArmwear.isHidden = true; + model.bipedLeftArm.isHidden = false; + model.bipedLeftArmwear.isHidden = false; + } + + if (rotLeft != null) { if (!player.isSneaking()) { this.fakeLeftArm.rotateAngleX = (float) rotLeft[0]; - this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0]; + this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0]; } else { this.fakeLeftArm.rotateAngleX = (float) rotLeft[0] - 0.5f; - this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0] - 0.5f; + this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0] - 0.5f; } - + this.fakeLeftArmwear.rotateAngleY = (float) rotLeft[1]; this.fakeLeftArmwear.rotateAngleZ = (float) rotLeft[2]; this.fakeLeftArm.rotateAngleY = (float) rotLeft[1]; @@ -583,14 +609,14 @@ public class RenderEvents if (!player.isSneaking()) { this.fakeRightArm.rotateAngleX = (float) rotRight[0]; - this.fakeRightArmwear.rotateAngleX = (float) rotRight[0]; + this.fakeRightArmwear.rotateAngleX = (float) rotRight[0]; } else { this.fakeRightArm.rotateAngleX = (float) rotRight[0] - 0.5f; - this.fakeRightArmwear.rotateAngleX = (float) rotRight[0] - 0.5f; + this.fakeRightArmwear.rotateAngleX = (float) rotRight[0] - 0.5f; } - + this.fakeRightArmwear.rotateAngleY = (float) rotRight[1]; this.fakeRightArmwear.rotateAngleZ = (float) rotRight[2]; this.fakeRightArm.rotateAngleY = (float) rotRight[1]; @@ -647,7 +673,7 @@ public class RenderEvents this.fakeLeftArmwear.rotateAngleX = -1.4001F; this.fakeRightArmwear.rotateAngleX = -1.4001F; } - + this.fakeRightArm.rotateAngleY = 0f; this.fakeLeftArm.rotateAngleY = 0f; this.fakeLeftArmwear.rotateAngleY = 0f; @@ -675,7 +701,7 @@ public class RenderEvents this.fakeLeftArmwear.rotateAngleY = 0.15f; this.fakeRightArmwear.rotateAngleY = -0.15f; } - + this.fakeRightArm.rotateAngleZ = 0F; this.fakeLeftArm.rotateAngleZ = 0F; this.fakeLeftArmwear.rotateAngleZ = 0F; @@ -715,7 +741,7 @@ public class RenderEvents float rotY = model.bipedBody.childModels.get(k).rotateAngleY; float rotZ = model.bipedBody.childModels.get(k).rotateAngleZ; - if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] -0.5f || rotX == rotRight1[0] -0.5f) + if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] - 0.5f || rotX == rotRight1[0] - 0.5f) { model.bipedBody.childModels.remove(k); k = k - 1; diff --git a/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java b/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java index 4c54cd3..73dc2a5 100644 --- a/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java +++ b/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java @@ -26,19 +26,19 @@ public class ScriptParseHelper { if (cond.contains("<=")) { - return number >= Double.parseDouble(cond.replace("<=", "")); + return number <= Double.parseDouble(cond.replace("<=", "")); } if (cond.contains(">=")) { - return number <= Double.parseDouble(cond.replace(">=", "")); + return number >= Double.parseDouble(cond.replace(">=", "")); } if (cond.contains("<")) { - return number > Double.parseDouble(cond.replace("<", "")); + return number < Double.parseDouble(cond.replace("<", "")); } if (cond.contains(">")) { - return number < Double.parseDouble(cond.replace(">", "")); + return number > Double.parseDouble(cond.replace(">", "")); } if (cond.contains("=")) { diff --git a/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java b/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java index 4ca6d08..b3bda35 100644 --- a/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java +++ b/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java @@ -40,6 +40,9 @@ public class CarryOnOverride private boolean isBlock; private boolean isEntity; + + private boolean renderLeftArm = true; + private boolean renderRightArm = true; public String getRenderRotationLeftArm() { @@ -61,6 +64,26 @@ public class CarryOnOverride this.renderRotationRightArm = renderRotationRightArm; } + public boolean isRenderLeftArm() + { + return renderLeftArm; + } + + public void setRenderLeftArm(boolean renderLeftArm) + { + this.renderLeftArm = renderLeftArm; + } + + public boolean isRenderRightArm() + { + return renderRightArm; + } + + public void setRenderRightArm(boolean renderRightArm) + { + this.renderRightArm = renderRightArm; + } + @Override public int hashCode() { @@ -74,6 +97,8 @@ public class CarryOnOverride result = prime * result + ((conditionXp == null) ? 0 : conditionXp.hashCode()); result = prime * result + (isBlock ? 1231 : 1237); result = prime * result + (isEntity ? 1231 : 1237); + result = prime * result + (renderLeftArm ? 1231 : 1237); + result = prime * result + (renderRightArm ? 1231 : 1237); result = prime * result + renderMeta; result = prime * result + ((renderNBT == null) ? 0 : renderNBT.hashCode()); result = prime * result + ((renderNameBlock == null) ? 0 : renderNameBlock.hashCode()); diff --git a/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java b/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java index 02f24ed..9ba7cc8 100644 --- a/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java +++ b/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java @@ -72,7 +72,7 @@ public class ScriptChecker public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, NBTTagCompound tag) { - boolean matchname = name == null ? true : name.equals(override.getTypeNameEntity()); + boolean matchname = override.getTypeNameEntity() == null ? true : name.equals(override.getTypeNameEntity()); boolean matchheight = ScriptParseHelper.matches(height, override.getTypeHeight()); boolean matchwidth = ScriptParseHelper.matches(width, override.getTypeWidth()); boolean matchhealth = ScriptParseHelper.matches(health, override.getTypeHealth()); diff --git a/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java b/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java index a69f329..fc3e54c 100644 --- a/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java +++ b/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java @@ -147,6 +147,8 @@ public class ScriptReader JsonElement scale = render.get("scale"); JsonElement rotationLeftArm = render.get("rotation_left_arm"); JsonElement rotationRightArm = render.get("rotation_right_arm"); + JsonElement renderLeftArm = render.get("render_left_arm"); + JsonElement renderRightArm = render.get("render_right_arm"); if(name_block != null) override.setRenderNameBlock(name_block.getAsString()); @@ -166,7 +168,10 @@ public class ScriptReader override.setRenderRotationLeftArm(rotationLeftArm.getAsString()); if(rotationRightArm != null) override.setRenderRotationRightArm(rotationRightArm.getAsString()); - + if(renderLeftArm != null) + override.setRenderLeftArm(renderLeftArm.getAsBoolean()); + if(renderRightArm != null) + override.setRenderRightArm(renderRightArm.getAsBoolean()); } OVERRIDES.put(override.hashCode(), override);