Jump to content

ryanshah

Members
  • Posts

    19
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

ryanshah's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I am currently drawing a compass to my ingame gui as follows: private static void renderCompass(MatrixStack matrixStack, int width, int height) { TextureDrawer.drawGuiTexture(matrixStack, width / 2 - 110, 10, 0, 37, 221, 14); int rot; boolean f0 = mc.player.yRot < 0.0f; if(f0) rot = -MathHelper.floor(mc.player.yRot % 360); else rot = MathHelper.floor(mc.player.yRot % 360); boolean f1 = rot > 0 && rot < 180; boolean f2 = rot <= 270 && rot >= 90; boolean f3 = rot <= 180 && rot >= 0; AtomicInteger targetAngle = new AtomicInteger(-1); mc.player.getCapability(ISkyrimPlayerDataProvider.SKYRIM_PLAYER_DATA_CAPABILITY).ifPresent(cap -> { if(cap.getCurrentTarget() != null && cap.getCurrentTarget().isAlive()) { Vector3d playerPos = mc.player.getLookAngle(); Vector3d targetPos = cap.getCurrentTarget().position(); Vector3d norm = playerPos.subtract(targetPos); double angleDir = (Math.atan2(norm.z, norm.x) / 2 / Math.PI * 360 + 360) % 360; double angleLook = (Math.atan2(playerPos.z, playerPos.x) / 2 / Math.PI * 360 + 360) % 360; targetAngle.set((int)(angleDir - angleLook + 360) % 360); } else targetAngle.set(-1); }); int targetEntityAngle = targetAngle.get(); if(targetEntityAngle > 0 && targetEntityAngle <= 90) TextureDrawer.drawGuiTexture(matrixStack, width / 2 - targetEntityAngle, 14, 105, 52, 6, 6); else if(targetEntityAngle > 90 && targetEntityAngle <= 180) TextureDrawer.drawGuiTexture(matrixStack, width / 2 - targetEntityAngle + 90, 14, 105, 52, 6, 6); if (rot == 0) { drawCenteredString(matrixStack, fontRenderer, "S", width / 2, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, "E", (width / 2) - 90, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, "W", (width / 2) + 90, 13, 16777215); } else if (!f0) { drawCenteredString(matrixStack, fontRenderer, f2 ? "N" : "", (width / 2 - rot) + 180, 13, 16777215); if (!f1) rot -= 360; drawCenteredString(matrixStack, fontRenderer, !f2 ? "S" : "", width / 2 - rot, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, !f3 ? "E" : "", (width / 2 - rot) - 90, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, f3 ? "W" : "", (width / 2 - rot) + 90, 13, 16777215); } else if(f0) { drawCenteredString(matrixStack, fontRenderer, f2 ? "N" : "", (width / 2 + rot) - 180, 13, 16777215); if (!f1) rot -= 360; drawCenteredString(matrixStack, fontRenderer, !f2 ? "S" : "", width / 2 + rot, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, !f3 ? "W" : "", (width / 2 + rot) + 90, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, f3 ? "E" : "", (width / 2 + rot) - 90, 13, 16777215); } } What I'm trying to do is only render the entity texture (the calls including targetEntityAngle) when it is in compass view.
  2. Thanks for the help so far, I think I'm nearly there.. float radius = 2f; // Get origins double u = this.getPosX() - vec3d.x; double v = this.getPosY() - vec3d.y; double w = this.getPosZ() - vec3d.z; Vector3d facing = new Vector3d(getPosX(), getPosY(), getPosZ()); for(double angle = 0.0D; angle < 2 * Math.PI; angle += 4d / 180d * (2 * Math.PI)) { double c = (u * facing.x) + (v * facing.y) + (w * facing.z); // constant double vx = u * c * (1d - MathHelper.cos((float)angle)) + facing.x * MathHelper.cos((float)angle) + (-w * facing.y + v*facing.z) * MathHelper.sin((float)angle); double vy = v * c * (1d - MathHelper.cos((float)angle)) + facing.y * MathHelper.cos((float)angle) + (w * facing.x - u*facing.z) * MathHelper.sin((float)angle); double vz = w * c * (1d - MathHelper.cos((float)angle)) + facing.z * MathHelper.cos((float)angle) + (-v * facing.x + u*facing.y) * MathHelper.sin((float)angle); this.world.addParticle(ParticleTypes.SMOKE, getPosX() + vx * radius, getPosY() + vy * radius, getPosZ() + vz * radius, vec3d.x, vec3d.y, vec3d.z); } So to my understanding, I first get the origin (0, 0, 0) and i want to do the transforms over the unit vector and then apply the vx,vy,vz offsets multiplied by the radius of the circle to the original position. However, nothing here is showing. I think I might have the wrong unit vector to use..
  3. I'll do some constant refactoring later. For now, I have the current code: double radius = 1.25D; double u = this.getPosX() - vec3d.x; double v = this.getPosY() - vec3d.y; double w = this.getPosZ() - vec3d.z; for(double angle = 0.0D; angle < 2 * Math.PI; angle += 4d / 180d * (2 * Math.PI)) { double mod = (u * getPosX()) + (v * getPosY()) + (w * getPosZ()); double vx = u * mod * (1d - MathHelper.cos((float)angle)) + getPosX() * MathHelper.cos((float)angle) + (-w * getPosY() + v*getPosZ()) * MathHelper.sin((float)angle); double vy = v * mod * (1d - MathHelper.cos((float)angle)) + getPosY() * MathHelper.cos((float)angle) + (w * getPosX() - u*getPosZ()) * MathHelper.sin((float)angle); double vz = w * mod * (1d - MathHelper.cos((float)angle)) + getPosZ() * MathHelper.cos((float)angle) + (-v * getPosX() + u*getPosY()) * MathHelper.sin((float)angle); this.world.addParticle(ParticleTypes.SMOKE, vx, vy, vz, vec3d.x, vec3d.y, vec3d.z); } But where would I include the radius of the ring?
  4. I am adding to Y instead of Z for the angle to have my ring appear upwards infront of the player, otherwise it just appears flat.
  5. I'm still not sure I totally understand. For reference I have updated the OP to contain the tick method so you can what posX etc. I am referencing in this question.
  6. I currently spawn a ring of particles around my entity when it is spawned, however depending on how the player is facing to cast the entity the particle ring does not always appear in front of the player. I know this is something to do with the z position (vz), but I dont 100% understand how to set it in this case. For example in some directions it appears fine, but in some the ring is effectively flipped 90 degrees so all I can see is a line of particles instead of the ring. @Override public void tick() { if (this.world.isRemote || (this.shootingEntity == null || !this.shootingEntity.removed) && this.world.isBlockLoaded(new BlockPos(this.getPosX(), this.getPosY(), this.getPosZ()))) { super.tick(); ++this.ticksInAir; RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, entity -> entity.isAlive() && entity != this.shootingEntity); if (raytraceresult.getType() != RayTraceResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { this.onImpact(raytraceresult); } Vector3d vec3d = this.getMotion(); this.setPosition(getPosX() + vec3d.x, getPosY() + vec3d.y, getPosZ() + vec3d.z); //ProjectileHelper.rotateTowardsMovement(this, 0.2f); float f = this.getMotionFactor(); double radius = 1.25D; double d0 = this.getPosX() - vec3d.x; double d1 = this.getPosY() - vec3d.y; double d2 = this.getPosZ() - vec3d.z; for(double angle = 0.0D; angle < 2 * Math.PI; angle += 4d / 180d * (2 * Math.PI)) { double vx = d0 + MathHelper.cos((float)angle) * radius; double vy = d1 + MathHelper.sin((float)angle) * radius; double vz = d2 + MathHelper.sin((float) angle) * radius; this.world.addParticle(ParticleTypes.SMOKE, vx, vy, vz, vec3d.x, vec3d.y, vec3d.z); } this.setMotion(vec3d.add(this.accelerationX, this.accelerationY, this.accelerationZ).scale(f)); //this.setPosition(this.getPosX(), this.getPosY(), this.getPosZ()); } else { this.remove(); } }
  7. Hey everyone! I'm currently creating a new entity based off a biped entity (2 legged entity), however the texture doesnt seem to be rendering on it correctly or the model isn't working.. Here is the code: RenderJonSnow: package net.madcrazydrumma.got.entity.render; import net.madcrazydrumma.got.entity.model.ModelJonSnow; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.layers.LayerCustomHead; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; public class RenderJonSnow extends RenderLiving { private static final ResourceLocation DEFAULT_RES_LOC = new ResourceLocation("got:textures/entity/jonSnow.png"); public ModelJonSnow modelJonSnow; protected float field_77070_b; private static final String __OBFID = "CL_00001001"; public RenderJonSnow(RenderManager p_i46168_1_, ModelJonSnow p_i46168_2_, float p_i46168_3_) { this(p_i46168_1_, p_i46168_2_, p_i46168_3_, 1.0F); this.addLayer(new LayerHeldItem(this)); } public RenderJonSnow(RenderManager p_i46169_1_, ModelJonSnow p_i46169_2_, float p_i46169_3_, float p_i46169_4_) { super(p_i46169_1_, p_i46169_2_, p_i46169_3_); this.modelJonSnow = p_i46169_2_; this.field_77070_b = p_i46169_4_; this.addLayer(new LayerCustomHead(p_i46169_2_.bipedHead)); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityLiving entity) { return DEFAULT_RES_LOC; } public void func_82422_c() { GlStateManager.translate(0.0F, 0.1875F, 0.0F); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity entity) { return this.getEntityTexture((EntityLiving)entity); } } ModelJonSnow: package net.madcrazydrumma.got.entity.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; //@SideOnly(Side.CLIENT) public class ModelJonSnow extends ModelBase { public ModelRenderer bipedHead; /** The Biped's Headwear. Used for the outer layer of player skins. */ public ModelRenderer bipedHeadwear; public ModelRenderer bipedBody; /** The Biped's Right Arm */ public ModelRenderer bipedRightArm; /** The Biped's Left Arm */ public ModelRenderer bipedLeftArm; /** The Biped's Right Leg */ public ModelRenderer bipedRightLeg; /** The Biped's Left Leg */ public ModelRenderer bipedLeftLeg; /** Records whether the model should be rendered holding an item in the left hand, and if that item is a block. */ public int heldItemLeft; /** Records whether the model should be rendered holding an item in the right hand, and if that item is a block. */ public int heldItemRight; public boolean isSneak; /** Records whether the model should be rendered aiming a bow. */ public boolean aimedBow; public ModelJonSnow() { this(0.0F); } public ModelJonSnow(float p_i1148_1_) { this(p_i1148_1_, 0.0F, 64, 32); } public ModelJonSnow(float p_i1149_1_, float p_i1149_2_, int p_i1149_3_, int p_i1149_4_) { this.textureWidth = p_i1149_3_; this.textureHeight = p_i1149_4_; this.bipedHead = new ModelRenderer(this, 0, 0); this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, p_i1149_1_); this.bipedHead.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F); this.bipedHeadwear = new ModelRenderer(this, 32, 0); this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, p_i1149_1_ + 0.5F); this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F); this.bipedBody = new ModelRenderer(this, 16, 16); this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, p_i1149_1_); this.bipedBody.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F); this.bipedRightArm = new ModelRenderer(this, 40, 16); this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, p_i1149_1_); this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + p_i1149_2_, 0.0F); this.bipedLeftArm = new ModelRenderer(this, 40, 16); this.bipedLeftArm.mirror = true; this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, p_i1149_1_); this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + p_i1149_2_, 0.0F); this.bipedRightLeg = new ModelRenderer(this, 0, 16); this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i1149_1_); this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + p_i1149_2_, 0.0F); this.bipedLeftLeg = new ModelRenderer(this, 0, 16); this.bipedLeftLeg.mirror = true; this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i1149_1_); this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + p_i1149_2_, 0.0F); } /** * Sets the models various rotation angles then renders the model. */ public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) { this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); GlStateManager.pushMatrix(); if (this.isChild) { float f6 = 2.0F; GlStateManager.scale(1.5F / f6, 1.5F / f6, 1.5F / f6); GlStateManager.translate(0.0F, 16.0F * p_78088_7_, 0.0F); this.bipedHead.render(p_78088_7_); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.scale(1.0F / f6, 1.0F / f6, 1.0F / f6); GlStateManager.translate(0.0F, 24.0F * p_78088_7_, 0.0F); this.bipedBody.render(p_78088_7_); this.bipedRightArm.render(p_78088_7_); this.bipedLeftArm.render(p_78088_7_); this.bipedRightLeg.render(p_78088_7_); this.bipedLeftLeg.render(p_78088_7_); this.bipedHeadwear.render(p_78088_7_); } else { if (p_78088_1_.isSneaking()) { GlStateManager.translate(0.0F, 0.2F, 0.0F); } this.bipedHead.render(p_78088_7_); this.bipedBody.render(p_78088_7_); this.bipedRightArm.render(p_78088_7_); this.bipedLeftArm.render(p_78088_7_); this.bipedRightLeg.render(p_78088_7_); this.bipedLeftLeg.render(p_78088_7_); this.bipedHeadwear.render(p_78088_7_); } GlStateManager.popMatrix(); } /** * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how * "far" arms and legs can swing at most. */ public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { this.bipedHead.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); this.bipedHead.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); this.bipedRightArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 2.0F * p_78087_2_ * 0.5F; this.bipedLeftArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 2.0F * p_78087_2_ * 0.5F; this.bipedRightArm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; this.bipedRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_; this.bipedLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_; this.bipedRightLeg.rotateAngleY = 0.0F; this.bipedLeftLeg.rotateAngleY = 0.0F; if (this.isRiding) { this.bipedRightArm.rotateAngleX += -((float)Math.PI / 5F); this.bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F); this.bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); this.bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); this.bipedRightLeg.rotateAngleY = ((float)Math.PI / 10F); this.bipedLeftLeg.rotateAngleY = -((float)Math.PI / 10F); } if (this.heldItemLeft != 0) { this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemLeft; } this.bipedRightArm.rotateAngleY = 0.0F; this.bipedRightArm.rotateAngleZ = 0.0F; switch (this.heldItemRight) { case 0: case 2: default: break; case 1: this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight; break; case 3: this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight; this.bipedRightArm.rotateAngleY = -0.5235988F; } this.bipedLeftArm.rotateAngleY = 0.0F; float f6; float f7; if (this.swingProgress > -9990.0F) { f6 = this.swingProgress; this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI * 2.0F) * 0.2F; this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; f6 = 1.0F - this.swingProgress; f6 *= f6; f6 *= f6; f6 = 1.0F - f6; f7 = MathHelper.sin(f6 * (float)Math.PI); float f8 = MathHelper.sin(this.swingProgress * (float)Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; this.bipedRightArm.rotateAngleX = (float)((double)this.bipedRightArm.rotateAngleX - ((double)f7 * 1.2D + (double)f8)); this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; this.bipedRightArm.rotateAngleZ += MathHelper.sin(this.swingProgress * (float)Math.PI) * -0.4F; } if (this.isSneak) { this.bipedBody.rotateAngleX = 0.5F; this.bipedRightArm.rotateAngleX += 0.4F; this.bipedLeftArm.rotateAngleX += 0.4F; this.bipedRightLeg.rotationPointZ = 4.0F; this.bipedLeftLeg.rotationPointZ = 4.0F; this.bipedRightLeg.rotationPointY = 9.0F; this.bipedLeftLeg.rotationPointY = 9.0F; this.bipedHead.rotationPointY = 1.0F; } else { this.bipedBody.rotateAngleX = 0.0F; this.bipedRightLeg.rotationPointZ = 0.1F; this.bipedLeftLeg.rotationPointZ = 0.1F; this.bipedRightLeg.rotationPointY = 12.0F; this.bipedLeftLeg.rotationPointY = 12.0F; this.bipedHead.rotationPointY = 0.0F; } this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; if (this.aimedBow) { f6 = 0.0F; f7 = 0.0F; this.bipedRightArm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F) + this.bipedHead.rotateAngleY; this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F + this.bipedHead.rotateAngleY + 0.4F; this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX; this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX; this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; } copyModelAngles(this.bipedHead, this.bipedHeadwear); } public void setModelAttributes(ModelBase p_178686_1_) { super.setModelAttributes(p_178686_1_); if (p_178686_1_ instanceof ModelJonSnow) { ModelJonSnow modelbiped = (ModelJonSnow)p_178686_1_; this.heldItemLeft = modelbiped.heldItemLeft; this.heldItemRight = modelbiped.heldItemRight; this.isSneak = modelbiped.isSneak; this.aimedBow = modelbiped.aimedBow; } } public void setInvisible(boolean invisible) { this.bipedHead.showModel = invisible; this.bipedHeadwear.showModel = invisible; this.bipedBody.showModel = invisible; this.bipedRightArm.showModel = invisible; this.bipedLeftArm.showModel = invisible; this.bipedRightLeg.showModel = invisible; this.bipedLeftLeg.showModel = invisible; } public void postRenderArm(float p_178718_1_) { this.bipedRightArm.postRender(p_178718_1_); } } here is how I register my entities: public static void registerAllEntities() { registerEntityWithEgg(EntityJonSnow.class, "Jon Snow", 0xffffff, 0xff08ed); } public static void registerEntityRenderers() { RenderingRegistry.registerEntityRenderingHandler(EntityJonSnow.class, new RenderJonSnow(Minecraft.getMinecraft().getRenderManager(), new ModelJonSnow(), 0.5F)); } public static void addEntitiesToWorld() { EntityRegistry.addSpawn(EntityJonSnow.class, 6, 1, 5, EnumCreatureType.CREATURE, BiomeGenBase.beach, BiomeGenBase.extremeHills, BiomeGenBase.desert, BiomeGenBase.taiga, BiomeGenBase.forest); //change the values to vary the spawn rarity, biome, etc. }
  8. Here is how I instantiate my gui in my GuiHandler: @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new GuiSelectHouse(new ContainerSelectHouse()); } return null; } Here is my GuiSelectHouse: package io.ryanshah.got.gui; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Container; public class GuiSelectHouse extends GuiContainer { public GuiSelectHouse(Container par1Container) { super(par1Container); } public void updateScreen() { super.updateScreen(); } public void drawScreen(int par1, int par2, float par3){ //drawDefaultBackground(); drawCenteredString(this.fontRendererObj, "Select a house to join for the rest of time!", this.width / 2, 40, 16777215); super.drawScreen(par1, par2, par3); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { drawDefaultBackground(); } } and here is my ContainerSelectHouse: package io.ryanshah.got.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; public class ContainerSelectHouse extends Container { @Override public boolean canInteractWith(EntityPlayer var1) { return true; } }
  9. @diesieben07 Even when creating a container and stuff, It still doesn't show... so thats not the problem
  10. package io.ryanshah.got.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { /*if(ID == 0) { return new GuiSelectHouse(); } else { return null; }*/ return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new GuiSelectHouse(); } else { return null; } } } And here is my GUI File if you need it: package io.ryanshah.got.gui; import java.util.ArrayList; import net.minecraft.client.gui.GuiScreen; public class GuiSelectHouse extends GuiScreen { public GuiSelectHouse() { } public void updateScreen() { super.updateScreen(); } public void drawScreen(int par1, int par2, float par3){ drawDefaultBackground(); drawCenteredString(this.fontRendererObj, "Select a house to join for the rest of time!", this.width / 2, 40, 16777215); super.drawScreen(par1, par2, par3); } }
  11. Its still not opening, it just goes straight to the game
  12. Using player.openGui(params);... now getting this error: java.lang.ClassCastException: io.ryanshah.got.gui.GuiSelectHouse cannot be cast to net.minecraft.inventory.Container at cpw.mods.fml.common.network.NetworkRegistry.getRemoteGuiContainer(NetworkRegistry.java:241) ~[NetworkRegistry.class:?] at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:75) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2510) ~[EntityPlayer.class:?] at io.ryanshah.got.event.GOTEventHandler.playerLoggedIn(GOTEventHandler.java:16) ~[GOTEventHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_GOTEventHandler_playerLoggedIn_PlayerLoggedInEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.firePlayerLoggedIn(FMLCommonHandler.java:498) ~[FMLCommonHandler.class:?] at net.minecraft.server.management.ServerConfigurationManager.initializeConnectionToPlayer(ServerConfigurationManager.java:156) ~[serverConfigurationManager.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:172) ~[NetworkDispatcher.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.completeHandshake(NetworkDispatcher.java:436) ~[NetworkDispatcher.class:?] at cpw.mods.fml.common.network.internal.HandshakeCompletionHandler.channelRead0(HandshakeCompletionHandler.java:17) ~[HandshakeCompletionHandler.class:?] at cpw.mods.fml.common.network.internal.HandshakeCompletionHandler.channelRead0(HandshakeCompletionHandler.java:11) ~[HandshakeCompletionHandler.class:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[simpleChannelInboundHandler.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:80) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) [MinecraftServer$2.class:?] Any idea? Everything is registered.. here is my EventHandler: package io.ryanshah.got.event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; public class GOTEventHandler { @SubscribeEvent public void playerLoggedIn(PlayerLoggedInEvent event){ if(event.player.getEntityData().hasKey("checkWorld")){ return; } event.player.getEntityData().setBoolean("checkWorld", true); event.player.openGui(CoreMod.instance, 0, event.player.worldObj, (int)event.player.posX, (int)event.player.posY, (int)event.player.posZ); System.out.println(event.player.getEntityData().getBoolean("checkWorld")); System.out.println("Open your GUI"); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.