From 149fe1978ee54752a339c8cfef703bf608ecf265 Mon Sep 17 00:00:00 2001 From: Tschipp Date: Mon, 23 Jul 2018 00:29:02 +0200 Subject: [PATCH] [1.12.2] Added thaumcraft to blacklist, redone arm rendering --- src/main/java/tschipp/carryon/CarryOn.java | 2 +- .../client/event/RenderEntityEvents.java | 10 +- .../carryon/client/event/RenderEvents.java | 479 ++++++------------ .../carryon/common/config/CarryOnConfig.java | 42 +- .../carryon/common/config/Configs.java | 7 + .../carryon/common/event/ItemEvents.java | 64 ++- .../common/scripting/ScriptReader.java | 1 + .../playerstorage/recipes/_constants.json | 44 -- 8 files changed, 238 insertions(+), 411 deletions(-) delete mode 100644 src/main/resources/assets/playerstorage/recipes/_constants.json diff --git a/src/main/java/tschipp/carryon/CarryOn.java b/src/main/java/tschipp/carryon/CarryOn.java index 7f53551..c708da4 100644 --- a/src/main/java/tschipp/carryon/CarryOn.java +++ b/src/main/java/tschipp/carryon/CarryOn.java @@ -32,7 +32,7 @@ public class CarryOn { public static CarryOn instance; public static final String MODID = "carryon"; - public static final String VERSION = "1.9.1"; + public static final String VERSION = "1.9.2"; public static final String NAME = "Carry On"; public static final String ACCEPTED_VERSIONS = "[1.12.2,1.13)"; public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/"; diff --git a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java index b5d0f47..09e9fa6 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java @@ -13,6 +13,7 @@ import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -291,7 +292,7 @@ public class RenderEntityEvents } /* - * Renders the Block in Third Person + * Renders the Entity in Third Person */ @SideOnly(Side.CLIENT) @SubscribeEvent @@ -307,8 +308,13 @@ public class RenderEntityEvents if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)) { Entity entity = ItemEntity.getEntity(stack, world); - float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks); + float rotation = 0; + if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase) + rotation = -(player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks); + else + rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks); + if (entity != null) { double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks; diff --git a/src/main/java/tschipp/carryon/client/event/RenderEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEvents.java index 1a95114..636ab72 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEvents.java @@ -1,5 +1,6 @@ package tschipp.carryon.client.event; +import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -17,13 +18,11 @@ import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; @@ -35,7 +34,9 @@ import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; @@ -57,10 +58,6 @@ import tschipp.carryon.network.server.SyncKeybindPacket; public class RenderEvents { private static boolean initModels; - private ModelRenderer fakeLeftArm; - private ModelRenderer fakeRightArm; - private ModelRenderer fakeLeftArmwear; - private ModelRenderer fakeRightArmwear; /* * Prevents the Player from scrolling @@ -130,7 +127,7 @@ public class RenderEvents Minecraft.getMinecraft().setIngameFocus(); } - + } } } @@ -202,7 +199,7 @@ public class RenderEvents GlStateManager.pushMatrix(); GlStateManager.scale(2.5, 2.5, 2.5); GlStateManager.translate(0, -0.6, -1); - + if (CarryOnConfig.settings.facePlayer ? !isChest(block) : isChest(block)) { GlStateManager.rotate(180, 0, 1f, 0); @@ -276,28 +273,6 @@ public class RenderEvents GlStateManager.popMatrix(); } - else - { - if (stack.isEmpty() ? true : stack.getItem() != RegistrationHandler.itemEntity) - { - event.setCanceled(false); - Minecraft mc = Minecraft.getMinecraft(); - RenderManager manager = mc.getRenderManager(); - RenderPlayer renderPlayer = manager.getSkinMap().get(aplayer.getSkinType()); - ModelPlayer modelPlayer = renderPlayer.getMainModel(); - - if (modelPlayer != null) - { - if (modelPlayer.bipedLeftArm != null && modelPlayer.bipedRightArm != null) - { - modelPlayer.bipedLeftArm.isHidden = false; - modelPlayer.bipedRightArm.isHidden = false; - modelPlayer.bipedLeftArmwear.isHidden = false; - modelPlayer.bipedRightArmwear.isHidden = false; - } - } - } - } } @SideOnly(Side.CLIENT) @@ -353,7 +328,12 @@ public class RenderEvents NBTTagCompound tag = ItemTile.getTileData(stack); ItemStack tileItem = ItemTile.getItemStack(stack); - float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks); + float rotation = 0f; + + if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase) + rotation = -(player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks); + else + rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks); double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks; double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks; @@ -444,356 +424,183 @@ public class RenderEvents * Renders correct arm rotation */ @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onPlayerRenderPre(RenderPlayerEvent.Pre event) + @SubscribeEvent(priority = EventPriority.NORMAL) + public void onEvent(RenderPlayerEvent.Post event) { - if (!Loader.isModLoaded("mobends") && CarryOnConfig.settings.renderArms) + if (handleMobends()) { EntityPlayer player = event.getEntityPlayer(); - AbstractClientPlayer aplayer = (AbstractClientPlayer) player; + EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player; + float partialticks = event.getPartialRenderTick(); + ItemStack stack = player.getHeldItemMainhand(); - ModelPlayer model = event.getRenderer().getMainModel(); - ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID()); - - if (!initModels) - { - this.fakeLeftArm = new ModelRenderer(model, 32, 48); - this.fakeRightArm = new ModelRenderer(model, 40, 16); - this.fakeLeftArmwear = new ModelRenderer(model, 48, 48); - this.fakeRightArmwear = new ModelRenderer(model, 40, 32); - initModels = true; - } - - player.setArrowCountInEntity(0); // TODO Temporary Fix - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)) { - CarryOnOverride overrider = ScriptChecker.getOverride(player); - if (overrider != null) - { - if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) - { - for (int k = 0; k < model.bipedBody.childModels.size(); k++) - { - double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm()); - double[] rotRight1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm()); + ModelPlayer model = event.getRenderer().getMainModel(); + float rotation = 0; - float rotX = model.bipedBody.childModels.get(k).rotateAngleX; - 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.7f || rotX == rotRight1[0] - 0.7f) - { - model.bipedBody.childModels.remove(k); - k = k - 1; - } - } - } - } + if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase) + rotation = (player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks); else - { - if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) - { - for (int k = 0; k < model.bipedBody.childModels.size(); k++) - { - float chkRot = model.bipedBody.childModels.get(k).rotateAngleX; + rotation = (player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks); - if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.6001F || chkRot == -1.9001F) - { - model.bipedBody.childModels.remove(k); - k = k - 1; - } - } - } - } + AbstractClientPlayer aplayer = (AbstractClientPlayer) player; + ResourceLocation skinLoc = aplayer.getLocationSkin(); - Item item = stack.getItem(); + double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks; + double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks; + double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks; - model.bipedLeftArm.isHidden = true; - 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; + double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * partialticks; + double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * partialticks; + double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * partialticks; + + double xOffset = d0 - c0; + double yOffset = d1 - c1; + double zOffset = d2 - c2; + + GlStateManager.pushMatrix(); + GlStateManager.translate(xOffset, yOffset, zOffset); Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc); - if (aplayer.getSkinType().equals("default")) - { - // left arm - this.fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F); - this.fakeLeftArmwear.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F + 0.25F); - - // right arm - this.fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F); - this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F + 0.25F); - } - else - { - // left arm - this.fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F); - this.fakeLeftArmwear.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F + 0.25F); - - // right arm - this.fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F); - this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F + 0.25F); - } - - CarryOnOverride override = ScriptChecker.getOverride(player); - if (override != null) + CarryOnOverride overrider = ScriptChecker.getOverride(player); + if (overrider != null) { double[] rotLeft = null; double[] rotRight = null; - if (override.getRenderRotationLeftArm() != null) - rotLeft = ScriptParseHelper.getXYZArray(override.getRenderRotationLeftArm()); - if (override.getRenderRotationRightArm() != null) - rotRight = ScriptParseHelper.getXYZArray(override.getRenderRotationRightArm()); + if (overrider.getRenderRotationLeftArm() != null) + rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm()); + if (overrider.getRenderRotationRightArm() != null) + rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm()); - boolean renderRight = override.isRenderRightArm(); - boolean renderLeft = override.isRenderLeftArm(); + boolean renderRight = overrider.isRenderRightArm(); + boolean renderLeft = overrider.isRenderLeftArm(); - if (!renderRight) + if (renderLeft && rotLeft != null) { - this.fakeRightArm.isHidden = true; - this.fakeRightArmwear.isHidden = true; - model.bipedRightArm.isHidden = false; - model.bipedRightArmwear.isHidden = false; + renderArmPost(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation, false, player.isSneaking()); + renderArmPost(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation, false, player.isSneaking()); + } + else if (renderLeft) + { + renderArmPost(model.bipedLeftArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking()); + renderArmPost(model.bipedLeftArmwear, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking()); } - if (!renderLeft) + if (renderRight && rotRight != null) { - this.fakeLeftArm.isHidden = true; - this.fakeLeftArmwear.isHidden = true; - model.bipedLeftArm.isHidden = false; - model.bipedLeftArmwear.isHidden = false; + renderArmPost(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation, true, player.isSneaking()); + renderArmPost(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation, true, player.isSneaking()); + } + else if (renderRight) + { + renderArmPost(model.bipedRightArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking()); + renderArmPost(model.bipedRightArmwear, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking()); } - if (rotLeft != null) - { - if (!player.isSneaking()) - { - this.fakeLeftArm.rotateAngleX = (float) rotLeft[0]; - this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0]; - } - else - { - this.fakeLeftArm.rotateAngleX = (float) rotLeft[0] - 0.7f; - this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0] - 0.7f; - } - - this.fakeLeftArmwear.rotateAngleY = (float) rotLeft[1]; - this.fakeLeftArmwear.rotateAngleZ = (float) rotLeft[2]; - this.fakeLeftArm.rotateAngleY = (float) rotLeft[1]; - this.fakeLeftArm.rotateAngleZ = (float) rotLeft[2]; - } - else - { - if (item == RegistrationHandler.itemTile) - { - if (!player.isSneaking()) - { - this.fakeLeftArm.rotateAngleX = -.9001F; - this.fakeLeftArmwear.rotateAngleX = -.9001F; - } - else - { - this.fakeLeftArm.rotateAngleX = -1.6001F; - this.fakeLeftArmwear.rotateAngleX = -1.6001F; - } - } - else - { - if (!player.isSneaking()) - { - this.fakeLeftArm.rotateAngleX = -1.2001F; - this.fakeLeftArmwear.rotateAngleX = -1.2001F; - } - else - { - this.fakeLeftArm.rotateAngleX = -1.9001F; - this.fakeLeftArmwear.rotateAngleX = -1.9001F; - } - - this.fakeLeftArm.rotateAngleY = 0.15f; - this.fakeLeftArmwear.rotateAngleY = 0.15f; - } - } - - if (rotRight != null) - { - if (!player.isSneaking()) - { - this.fakeRightArm.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.rotateAngleY = (float) rotRight[1]; - this.fakeRightArmwear.rotateAngleZ = (float) rotRight[2]; - this.fakeRightArm.rotateAngleY = (float) rotRight[1]; - this.fakeRightArm.rotateAngleZ = (float) rotRight[2]; - } - else - { - if (item == RegistrationHandler.itemTile) - { - if (!player.isSneaking()) - { - this.fakeRightArm.rotateAngleX = -.9001F; - this.fakeRightArmwear.rotateAngleX = -.9001F; - } - else - { - this.fakeRightArm.rotateAngleX = -1.6001F; - this.fakeRightArmwear.rotateAngleX = -1.6001F; - } - } - else - { - if (!player.isSneaking()) - { - this.fakeRightArm.rotateAngleX = -1.2001F; - this.fakeRightArmwear.rotateAngleX = -1.2001F; - } - else - { - this.fakeRightArm.rotateAngleX = -1.9001F; - this.fakeRightArmwear.rotateAngleX = -1.9001F; - } - - this.fakeRightArm.rotateAngleY = -0.15f; - this.fakeRightArmwear.rotateAngleY = -0.15f; - } - } } else { - if (item == RegistrationHandler.itemTile) - { - if (!player.isSneaking()) - { - this.fakeRightArm.rotateAngleX = -.9001F; - this.fakeLeftArm.rotateAngleX = -.9001F; - this.fakeLeftArmwear.rotateAngleX = -.9001F; - this.fakeRightArmwear.rotateAngleX = -.9001F; - } - else - { - this.fakeRightArm.rotateAngleX = -1.6001F; - this.fakeLeftArm.rotateAngleX = -1.6001F; - this.fakeLeftArmwear.rotateAngleX = -1.6001F; - this.fakeRightArmwear.rotateAngleX = -1.6001F; - } - - this.fakeRightArm.rotateAngleY = 0f; - this.fakeLeftArm.rotateAngleY = 0f; - this.fakeLeftArmwear.rotateAngleY = 0f; - this.fakeRightArmwear.rotateAngleY = 0f; - } - else - { - if (!player.isSneaking()) - { - this.fakeRightArm.rotateAngleX = -1.2001F; - this.fakeLeftArm.rotateAngleX = -1.2001F; - this.fakeLeftArmwear.rotateAngleX = -1.2001F; - this.fakeRightArmwear.rotateAngleX = -1.2001F; - } - else - { - this.fakeRightArm.rotateAngleX = -1.9001F; - this.fakeLeftArm.rotateAngleX = -1.9001F; - this.fakeLeftArmwear.rotateAngleX = -1.9001F; - this.fakeRightArmwear.rotateAngleX = -1.9001F; - } - - this.fakeRightArm.rotateAngleY = -0.15f; - this.fakeLeftArm.rotateAngleY = 0.15f; - this.fakeLeftArmwear.rotateAngleY = 0.15f; - this.fakeRightArmwear.rotateAngleY = -0.15f; - } - - this.fakeRightArm.rotateAngleZ = 0F; - this.fakeLeftArm.rotateAngleZ = 0F; - this.fakeLeftArmwear.rotateAngleZ = 0F; - this.fakeRightArmwear.rotateAngleZ = 0F; - } - - model.bipedBody.addChild(this.fakeLeftArm); - model.bipedBody.addChild(this.fakeRightArm); - - if (player.isWearing(EnumPlayerModelParts.LEFT_SLEEVE)) - { - model.bipedBody.addChild(this.fakeLeftArmwear); - } - if (player.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE)) - { - model.bipedBody.addChild(this.fakeRightArmwear); + renderArmPost(model.bipedRightArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking()); + renderArmPost(model.bipedLeftArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking()); + renderArmPost(model.bipedLeftArmwear, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking()); + renderArmPost(model.bipedRightArmwear, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking()); } + GlStateManager.popMatrix(); } - else + } + } + + /* + * Hides the vanilla arm for rendering the rotation + */ + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.NORMAL) + public void onEvent(RenderPlayerEvent.Pre event) + { + if (handleMobends()) + { + EntityPlayer player = event.getEntityPlayer(); + ItemStack stack = player.getHeldItemMainhand(); + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)) { - model.bipedLeftArm.isHidden = false; - model.bipedRightArm.isHidden = false; - model.bipedLeftArmwear.isHidden = false; - model.bipedRightArmwear.isHidden = false; + ModelPlayer model = event.getRenderer().getMainModel(); CarryOnOverride overrider = ScriptChecker.getOverride(player); if (overrider != null) { - if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) + boolean renderRight = overrider.isRenderRightArm(); + boolean renderLeft = overrider.isRenderLeftArm(); + + if (renderRight) { - for (int k = 0; k < model.bipedBody.childModels.size(); k++) - { - double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm()); - double[] rotRight1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm()); + renderArmPre(model.bipedRightArm); + renderArmPre(model.bipedRightArmwear); + } - float rotX = model.bipedBody.childModels.get(k).rotateAngleX; - 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.7f || rotX == rotRight1[0] - 0.7f) - { - model.bipedBody.childModels.remove(k); - k = k - 1; - } - } + if (renderLeft) + { + renderArmPre(model.bipedLeftArm); + renderArmPre(model.bipedLeftArmwear); } } else { - if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) - { - for (int k = 0; k < model.bipedBody.childModels.size(); k++) - { - float chkRot = model.bipedBody.childModels.get(k).rotateAngleX; - - if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.6001F || chkRot == -1.9001F) - { - model.bipedBody.childModels.remove(k); - k = k - 1; - } - } - } + renderArmPre(model.bipedRightArm); + renderArmPre(model.bipedLeftArm); + renderArmPre(model.bipedLeftArmwear); + renderArmPre(model.bipedRightArmwear); } } - - if (stack.isEmpty() || stack.getItem() != RegistrationHandler.itemTile && stack.getItem() != RegistrationHandler.itemEntity) - { - model.bipedLeftArm.isHidden = false; - model.bipedRightArm.isHidden = false; - model.bipedLeftArmwear.isHidden = false; - model.bipedRightArmwear.isHidden = false; - } } } + @SideOnly(Side.CLIENT) + public void renderArmPost(ModelRenderer arm, float x, float z, float rotation, boolean right, boolean sneaking) + { + arm.isHidden = false; + if (right) + { + arm.rotationPointZ = -MathHelper.sin((float) Math.toRadians(rotation)) * 4.75F; + arm.rotationPointX = -MathHelper.cos((float) Math.toRadians(rotation)) * 4.75F; + } + else + { + arm.rotationPointZ = MathHelper.sin((float) Math.toRadians(rotation)) * 4.75F; + arm.rotationPointX = MathHelper.cos((float) Math.toRadians(rotation)) * 4.75F; + } + + if (!sneaking) + arm.rotationPointY = 20; + else + arm.rotationPointY = 15; + + arm.rotateAngleX = (float) x; + arm.rotateAngleY = (float) -Math.toRadians(rotation); + arm.rotateAngleZ = (float) z; + arm.renderWithRotation(0.0625F); + arm.rotationPointY = 2; + } + + @SideOnly(Side.CLIENT) + public void renderArmPre(ModelRenderer arm) + { + arm.isHidden = true; + } + + public boolean handleMobends() + { + if (Loader.isModLoaded("mobends")) + { + Configuration config = new Configuration(new File(CarryOn.CONFIGURATION_FILE.getPath().substring(0, CarryOn.CONFIGURATION_FILE.getPath().length() - 16), "mobends.cfg")); + + boolean renderPlayer = config.get("animated", "player", true).getBoolean(); + return !renderPlayer; + } + return true; + } + public static boolean isChest(Block block) { return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST; diff --git a/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java b/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java index 5bd4b75..35e7ddc 100644 --- a/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java +++ b/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java @@ -17,36 +17,37 @@ import tschipp.carryon.CarryOn; import tschipp.carryon.common.helper.ReflectionUtil; @Config(modid = CarryOn.MODID) -public class CarryOnConfig { +public class CarryOnConfig +{ @Config.LangKey(CarryOn.MODID) @Config.Comment("General Mod Settings") public static Configs.Settings settings = new Configs.Settings(); - + @Config.LangKey(CarryOn.MODID) @Config.Comment("Blacklist for Blocks and Entities") public static Configs.Blacklist blacklist = new Configs.Blacklist(); - + @Config.LangKey(CarryOn.MODID) @Config.Comment("Whitelist for Blocks and Entities (useWhitelist must be true!)") public static Configs.WhiteList whitelist = new Configs.WhiteList(); - + @Config.LangKey(CarryOn.MODID) @Config.Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!") public static Configs.ModelOverrides modelOverrides = new Configs.ModelOverrides(); - + @Config.LangKey(CarryOn.MODID) @Config.Comment("Custom Pickup Conditions for certain blocks. ONLY WORKS WHEN GAMESTAGES IS INSTALLED! Advanced Users Only!") public static Configs.CustomPickupConditions customPickupConditions = new Configs.CustomPickupConditions(); - + @Mod.EventBusSubscriber - public static class EventHandler { + public static class EventHandler + { /** * The {@link ConfigManager#CONFIGS} getter. */ private static final MethodHandle CONFIGS_GETTER = ReflectionUtil.findFieldGetter(ConfigManager.class, "CONFIGS"); - /** * The {@link Configuration} instance. @@ -61,22 +62,22 @@ public class CarryOnConfig { * * @return The Configuration instance */ - public static Configuration getConfiguration() { + public static Configuration getConfiguration(String modid) + { if (EventHandler.configuration == null) - try { - final String fileName = CarryOn.MODID + ".cfg"; + try + { + final String fileName = modid + ".cfg"; @SuppressWarnings("unchecked") - final Map configsMap = (Map) EventHandler.CONFIGS_GETTER - .invokeExact(); + final Map configsMap = (Map) EventHandler.CONFIGS_GETTER.invokeExact(); - final Optional> entryOptional = configsMap.entrySet().stream() - .filter(entry -> fileName.equals(new File(entry.getKey()).getName())).findFirst(); + final Optional> entryOptional = configsMap.entrySet().stream().filter(entry -> fileName.equals(new File(entry.getKey()).getName())).findFirst(); - entryOptional - .ifPresent(stringConfigurationEntry -> EventHandler.configuration = stringConfigurationEntry - .getValue()); - } catch (Throwable throwable) { + entryOptional.ifPresent(stringConfigurationEntry -> EventHandler.configuration = stringConfigurationEntry.getValue()); + } + catch (Throwable throwable) + { throwable.printStackTrace(); } @@ -91,7 +92,8 @@ public class CarryOnConfig { * The event */ @SubscribeEvent - public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { + public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) + { if (event.getModID().equals(CarryOn.MODID)) ConfigManager.load(CarryOn.MODID, Config.Type.INSTANCE); diff --git a/src/main/java/tschipp/carryon/common/config/Configs.java b/src/main/java/tschipp/carryon/common/config/Configs.java index b8ad9c9..d5c2082 100644 --- a/src/main/java/tschipp/carryon/common/config/Configs.java +++ b/src/main/java/tschipp/carryon/common/config/Configs.java @@ -144,6 +144,13 @@ public class Configs { "malisisdoors:*", "industrialforegoing:*", "minecolonies:*", + "thaumcraft:pillar*", + "thaumcraft:infernal_furnace", + "thaumcraft:placeholder*", + "thaumcraft:infusion_matrix", + "thaumcraft:golem_builder", + "thaumcraft:thaumatorium*", + }; @Config.RequiresMcRestart() diff --git a/src/main/java/tschipp/carryon/common/event/ItemEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEvents.java index b68928b..e9a23ff 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEvents.java +++ b/src/main/java/tschipp/carryon/common/event/ItemEvents.java @@ -21,9 +21,9 @@ import net.minecraft.util.text.event.ClickEvent; import net.minecraft.util.text.event.ClickEvent.Action; import net.minecraft.world.GameRules; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; @@ -54,9 +54,9 @@ public class ItemEvents @SubscribeEvent(priority = EventPriority.HIGH) public void onBlockClick(PlayerInteractEvent.RightClickBlock event) { - if(event.isCanceled()) + if (event.isCanceled()) return; - + EntityPlayer player = event.getEntityPlayer(); ItemStack stack = player.getHeldItemMainhand(); if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) @@ -197,7 +197,7 @@ public class ItemEvents event.setCanceled(true); } } - + @SubscribeEvent public void harvestSpeed(BreakEvent event) { @@ -209,8 +209,7 @@ public class ItemEvents event.setCanceled(true); } } - - + @SubscribeEvent public void playerAttack(LivingAttackEvent event) { @@ -248,7 +247,6 @@ public class ItemEvents Block block = world.getBlockState(pos).getBlock(); IBlockState state = world.getBlockState(pos); - if (main.isEmpty() && off.isEmpty() && CarryOnKeybinds.isKeyPressed(player)) { @@ -301,7 +299,7 @@ public class ItemEvents s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues")); player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s)); } - + } } @@ -379,4 +377,54 @@ public class ItemEvents } } + @SubscribeEvent + public void dropNonHotbarItems(LivingUpdateEvent event) + { + EntityLivingBase entity = event.getEntityLiving(); + if (entity instanceof EntityPlayer && !entity.world.isRemote) + { + EntityPlayer player = (EntityPlayer) entity; + + boolean hasCarried = player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemTile)) || player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemEntity)); + ItemStack inHand = player.getHeldItemMainhand(); + + if (hasCarried) + { + if (inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity) + { + int slotBlock = getSlot(player, RegistrationHandler.itemTile); + int slotEntity = getSlot(player, RegistrationHandler.itemEntity); + + EntityItem item = null; + if(slotBlock != -1) + { + ItemStack dropped = player.inventory.removeStackFromSlot(slotBlock); + item = new EntityItem(player.world, player.posX, player.posY, player.posZ, dropped); + } + if(slotEntity != -1) + { + ItemStack dropped = player.inventory.removeStackFromSlot(slotEntity); + item = new EntityItem(player.world, player.posX, player.posY, player.posZ, dropped); + } + if(item != null) + { + player.world.spawnEntity(item); + CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, 256)); + } + } + } + } + } + + public int getSlot(EntityPlayer player, Item item) + { + for(int i = 0; i < player.inventory.getSizeInventory(); i++) + { + ItemStack stack = player.inventory.getStackInSlot(i); + if(stack.getItem() == item) + return i; + } + return -1; + } + } diff --git a/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java b/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java index 07a5a70..adb0eb8 100644 --- a/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java +++ b/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java @@ -29,6 +29,7 @@ public class ScriptReader public static void preInit(FMLPreInitializationEvent event) { CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts/"); + if (!CarryOn.CONFIGURATION_FILE.exists()) CarryOn.CONFIGURATION_FILE.mkdir(); diff --git a/src/main/resources/assets/playerstorage/recipes/_constants.json b/src/main/resources/assets/playerstorage/recipes/_constants.json deleted file mode 100644 index 601a700..0000000 --- a/src/main/resources/assets/playerstorage/recipes/_constants.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "ingredient": { - "type": "forge:ore_dict", - "ore": "enderpearl" - }, - "name": "ENDERPEARL" - }, - { - "ingredient": { - "type": "forge:ore_dict", - "ore": "gemDiamond" - }, - "name": "GEMDIAMOND" - }, - { - "ingredient": { - "type": "forge:ore_dict", - "ore": "ingotIron" - }, - "name": "INGOTIRON" - }, - { - "ingredient": { - "type": "forge:ore_dict", - "ore": "nuggetIron" - }, - "name": "NUGGETIRON" - }, - { - "ingredient": { - "type": "forge:ore_dict", - "ore": "paper" - }, - "name": "PAPER" - }, - { - "ingredient": { - "type": "forge:ore_dict", - "ore": "stone" - }, - "name": "STONE" - } -] \ No newline at end of file