Fixes
Gui at night while carrying entities, arrows causing console spam, height of carried entity in first person, entity name
This commit is contained in:
parent
b787aec975
commit
e0e9e979dd
|
|
@ -2,9 +2,12 @@ package tschipp.carryon.client.event;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
|
@ -116,6 +119,8 @@ public class RenderEntityEvents
|
|||
@SubscribeEvent
|
||||
public void renderHand(RenderHandEvent event)
|
||||
{
|
||||
|
||||
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
|
||||
|
|
@ -123,6 +128,7 @@ public class RenderEntityEvents
|
|||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
||||
float partialticks = event.getPartialTicks();
|
||||
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
BlockPos pos = player.getPosition();
|
||||
|
|
@ -143,24 +149,28 @@ public class RenderEntityEvents
|
|||
float multiplier = height * width;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.scale(.8, .8, .8);
|
||||
GlStateManager.rotate(180, 0, 1, 0);
|
||||
GlStateManager.translate(0.0, -height, width + 0.1);
|
||||
GlStateManager.translate(0.0, -height - .1, width + 0.1);
|
||||
GlStateManager.enableAlpha();
|
||||
|
||||
if (perspective == 0)
|
||||
|
||||
|
||||
if (perspective == 0 && Minecraft.getMinecraft().inGameHasFocus)
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
|
||||
}
|
||||
|
||||
GlStateManager.disableAlpha();
|
||||
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if (perspective == 0)
|
||||
event.setCanceled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -229,17 +239,8 @@ public class RenderEntityEvents
|
|||
|
||||
}
|
||||
|
||||
public void renderEntityStatic(Entity entityIn, float partialTicks, boolean p_188388_3_)
|
||||
public void renderEntityStaticCO(Entity entityIn, float partialTicks, boolean p_188388_3_)
|
||||
{
|
||||
Field fieldX = RenderManager.class.getDeclaredFields()[4];
|
||||
Field fieldY = RenderManager.class.getDeclaredFields()[5];
|
||||
Field fieldZ = RenderManager.class.getDeclaredFields()[6];
|
||||
fieldX.setAccessible(true);
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ.setAccessible(true);
|
||||
|
||||
RenderManager manager = Minecraft.getMinecraft().getRenderManager();
|
||||
|
||||
if (entityIn.ticksExisted == 0)
|
||||
{
|
||||
entityIn.lastTickPosX = entityIn.posX;
|
||||
|
|
@ -247,12 +248,17 @@ public class RenderEntityEvents
|
|||
entityIn.lastTickPosZ = entityIn.posZ;
|
||||
}
|
||||
|
||||
double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
|
||||
double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
|
||||
double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
|
||||
double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
|
||||
double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
|
||||
double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
|
||||
float f = entityIn.prevRotationYaw + (entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks;
|
||||
int i = entityIn.getBrightnessForRender(partialTicks);
|
||||
|
||||
int i = 0;
|
||||
if (!Minecraft.getMinecraft().world.isDaytime()) {
|
||||
i = entityIn.getBrightnessForRender(partialTicks);
|
||||
} else {
|
||||
i = 50000;
|
||||
}
|
||||
if (entityIn.isBurning())
|
||||
{
|
||||
i = 15728880;
|
||||
|
|
@ -260,16 +266,10 @@ public class RenderEntityEvents
|
|||
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
try
|
||||
{
|
||||
manager.doRenderEntity(entityIn, d0 - fieldX.getDouble(manager), d1 - fieldY.getDouble(manager), d2 - fieldZ.getDouble(manager), f, partialTicks, p_188388_3_);
|
||||
}
|
||||
catch (IllegalArgumentException | IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
RenderManager manager = Minecraft.getMinecraft().getRenderManager();
|
||||
manager.doRenderEntity(entityIn, d0, d1, d2, f, partialTicks, p_188388_3_);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package tschipp.carryon.client.event;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
|
@ -280,16 +282,20 @@ public class RenderEvents
|
|||
ItemStack stack = player.getHeldItemMainhand();
|
||||
ModelPlayer model = event.getRenderer().getMainModel();
|
||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
||||
|
||||
|
||||
ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID());
|
||||
|
||||
ModelRenderer fakeLeftArm = new ModelRenderer(model, 32, 48);
|
||||
ModelRenderer fakeRightArm = new ModelRenderer(model, 40, 16);
|
||||
|
||||
|
||||
player.setArrowCountInEntity(0); //TODO Temporary Fix
|
||||
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)))
|
||||
{
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) {
|
||||
model.bipedBody.childModels.clear();
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
|
||||
|
|
@ -354,6 +360,7 @@ public class RenderEvents
|
|||
{
|
||||
model.bipedLeftArm.isHidden = false;
|
||||
model.bipedRightArm.isHidden = false;
|
||||
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
{
|
||||
model.bipedBody.childModels.clear();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,25 @@ public class ItemEntity extends Item
|
|||
{
|
||||
if (hasEntityData(stack))
|
||||
{
|
||||
return I18n.translateToLocal(EntityList.getTranslationName(new ResourceLocation(getEntityName(stack))));
|
||||
|
||||
/*
|
||||
ResourceLocation key = new ResourceLocation(getEntityName(stack));
|
||||
|
||||
String name = I18n.translateToLocal(EntityList.getClass(key).getCanonicalName());
|
||||
|
||||
System.out.println(EntityList.getClass(key).getCanonicalName());
|
||||
System.out.println(EntityList.getClass(key).getSimpleName());
|
||||
System.out.println(EntityList.getClass(key).getName());
|
||||
|
||||
|
||||
|
||||
//I18n.translateToLocal(entity.getDisplayName().getFormattedText())
|
||||
|
||||
//return name;
|
||||
*/
|
||||
|
||||
return I18n.translateToLocal("entity."+EntityList.getTranslationName(new ResourceLocation(getEntityName(stack))) + ".name");
|
||||
//return getCustomName(stack);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
@ -90,7 +108,7 @@ public class ItemEntity extends Item
|
|||
if (hasEntityData(stack))
|
||||
{
|
||||
BlockPos finalPos = pos;
|
||||
|
||||
|
||||
if (!block.isReplaceable(world, pos))
|
||||
{
|
||||
finalPos = pos.offset(facing);
|
||||
|
|
@ -116,7 +134,7 @@ public class ItemEntity extends Item
|
|||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
|
|
@ -124,15 +142,15 @@ public class ItemEntity extends Item
|
|||
{
|
||||
if(getEntity(stack, world) == null)
|
||||
stack = ItemStack.EMPTY;
|
||||
|
||||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if(entity instanceof EntityPlayer && CarryOnConfig.settings.slownessInCreative ? false : ((EntityPlayer)entity).isCreative())
|
||||
return;
|
||||
|
||||
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 1, potionLevel(stack, world), false, false));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -184,13 +202,27 @@ public class ItemEntity extends Item
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String getCustomName(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if (tag.hasKey("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
||||
return tag.toString();
|
||||
} else {
|
||||
return tag.toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int potionLevel(ItemStack stack, World world)
|
||||
{
|
||||
Entity e = getEntity(stack, world);
|
||||
if(e == null)
|
||||
return 1;
|
||||
|
||||
|
||||
int i = (int) (e.height * e.width);
|
||||
if (i > 4)
|
||||
i = 4;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user