Jump to content

Jugbot

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Jugbot

  1. Well I made the entity extend EntityLeashKnot and it still does the same thing I checked for references to EntityHanging and EntityLeashKnot too and can't find anything in the default code that would cause this whatsoever. [move]JUST WORK PLEASE[/move] /cry Edit: http://gamedev.stackexchange.com/questions/81921/tileentityspecialrenderer-only-renders-from-certain-angle This guy seems to have a similar problem but I don't know much of GL and I only used the default lead code.
  2. Well before when I made it behave like this it was extending the leashKnot entity, but put it all into one class just to make sure I didn't need to change anything. I will also look to see if there are references to entityHanging I need to overwrite.
  3. Well, funny enough I got it to work like it previously did: As you can see, the entity is only visible at certain angles and has no hitbox when visible... now what would cause this?
  4. The registerRender is definitely getting called, I didn't have time to see if doRender is getting called yet. I never get errors. Also I didn't mention, before this wasn't working, the leash would render only at certain angles and with no outline. I can't get it to do that agin.
  5. I made the class: public class RenderFactoryRope implements IRenderFactory<EntityRopeKnot> { @Override public Render<? super EntityRopeKnot> createRenderFor(RenderManager manager) { return new RenderRopeKnot(manager); } } And moved register renders into the preinit. Maybe the problem is the entity and/or the render class? How do I make sure those work together?
  6. Just change the render layer to cutout for models like windows. Then you can fix any shading issues like this with "shade": off
  7. I've tried to do the factory method using the commented portion: RenderingRegistry.registerEntityRenderingHandler(EntityRopeKnot.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { return new RenderLeashKnot(manager); } }); And moving the render register to init portion of the client proxy but there is still no change On a side note, I don't suppose there is any harm in using a default rendering class RenderLeashKnot? I only made my own to see if that was somehow a problem.
  8. Can anyone at least see if I am registering correctly?
  9. I am having trouble seeing my custom entity. I register the renders and entity, the entity spawns in the world (/testfor @e and place sound effect indicates that) but it is completely invisible. Most of the code was copied from default since there are not a lot of custom lead entity examples out there... Teh code: Entities.java package net.creativerealmsmc.conquest.init; import net.creativerealmsmc.conquest.Main; import net.creativerealmsmc.conquest.entity.EntityRopeKnot; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLeashKnot; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.registry.EntityRegistry; public class Entities { // https://github.com/micdoodle8/Galacticraft/tree/master/src/main/java/micdoodle8/mods/galacticraft/core/entities //https://github.com/micdoodle8/Galacticraft/blob/edab080014e1ad2603d0555a6449567c41f7560a/src/main/java/micdoodle8/mods/galacticraft/core/util/GCCoreUtil.java public static void init() { registerEntity(EntityRopeKnot.class, "Rope", ; } // /RenderingRegistry.registerEntityRenderingHandler(EntityEvolvedSkeleton.class, (RenderManager manager) -> new RenderEvolvedSkeleton(manager)); public static void register() { //registerBlock(sample); /* EntityList.idToClassMapping.put(nextEggID, var0); EntityList.classToIDMapping.put(var0, nextEggID); EntityList.entityEggs.put(nextEggID, new EntityList.EntityEggInfo(nextEggID, back, fore)); */ } public static void registerRenders() {/* RenderingRegistry.registerEntityRenderingHandler(EntityRopeKnot.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { return new RenderLeashKnot(manager); } });*/ RenderingRegistry.registerEntityRenderingHandler(EntityRopeKnot.class, new RenderLeashKnot(Minecraft.getMinecraft().getRenderManager())); } public static void registerEntity(Class entityClass, String name, int id) { //EntityRegistry.registerGlobalEntityID(entityClass, name, EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 3, false); // //EntityRegistry.registerModEntity(var0, var1, nextInternalID(), GalacticraftCore.instance, trackingDistance, updateFreq, sendVel); } } CommonProxy.java package net.creativerealmsmc.conquest.proxy; import net.creativerealmsmc.conquest.init.Blocks; import net.creativerealmsmc.conquest.init.Entities; import net.creativerealmsmc.conquest.init.Items; import net.creativerealmsmc.conquest.init.MetaBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public abstract class CommonProxy { public void preInit(FMLPreInitializationEvent e) { Entities.init(); MetaBlocks.init(); MetaBlocks.register(); } public void init(FMLInitializationEvent e) { Blocks.init(); Blocks.register(); Items.init(); Items.register(); } public void postInit(FMLPostInitializationEvent e) { } abstract public boolean playerIsInCreativeMode(EntityPlayer player); abstract public boolean isDedicatedServer(); } ClientProxy.java package net.creativerealmsmc.conquest.proxy; import net.creativerealmsmc.conquest.Main; import net.creativerealmsmc.conquest.init.Blocks; import net.creativerealmsmc.conquest.init.Entities; import net.creativerealmsmc.conquest.init.Items; import net.creativerealmsmc.conquest.init.MetaBlocks; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); Entities.registerRenders(); MetaBlocks.registerRenders(); OBJLoader.INSTANCE.addDomain(Main.MODID); } @Override public void init(FMLInitializationEvent e) { super.init(e); MetaBlocks.registerRendersNoMeta(); Items.registerRenders(); } @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } @Override public boolean playerIsInCreativeMode(EntityPlayer player) { if (player instanceof EntityPlayerMP) { EntityPlayerMP entityPlayerMP = (EntityPlayerMP)player; return entityPlayerMP.interactionManager.isCreative(); } else if (player instanceof EntityPlayerSP) { return Minecraft.getMinecraft().playerController.isInCreativeMode(); } return false; } @Override public boolean isDedicatedServer() { return false; } } EntityRopeKnot.java package net.creativerealmsmc.conquest.entity; import java.util.UUID; import javax.annotation.Nullable; import com.google.common.base.Predicate; import net.minecraft.block.BlockFence; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityHanging; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketEntityAttach; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityRopeKnot extends Entity { public EntityRopeKnot(World worldIn) { super(worldIn); this.setSize(0.5F, 0.5F); } public EntityRopeKnot(World worldIn, BlockPos hangingPositionIn) { this(worldIn); this.hangingPosition = hangingPositionIn; this.setPosition((double) hangingPositionIn.getX() + 0.5D, (double) hangingPositionIn.getY() + 0.5D, (double) hangingPositionIn.getZ() + 0.5D); /* float f = 0.125F; float f1 = 0.1875F; float f2 = 0.25F; */ this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 0.1875D, this.posY - 0.25D + 0.125D, this.posZ - 0.1875D, this.posX + 0.1875D, this.posY + 0.25D + 0.125D, this.posZ + 0.1875D)); } private boolean isLeashed; private Entity leashedToEntity; private NBTTagCompound leashNBTTag; //TODO: implemented Entity methods /** Get whether this Entity's AI is disabled */ /*public boolean isAIDisabled() { return true; }*/ @Override protected void entityInit() {} //TODO: Entity Leash /** Sets the x,y,z of the entity from the given parameters. Also seems to set up a bounding box. */ public void setPosition(double x, double y, double z) { x = (double) MathHelper.floor_double(x) + 0.5D; y = (double) MathHelper.floor_double(y) + 0.5D; z = (double) MathHelper.floor_double(z) + 0.5D; //super: this.hangingPosition = new BlockPos(x, y, z); this.updateBoundingBox(); this.isAirBorne = true; } /** Updates the entity bounding box based on current facing */ protected void updateBoundingBox() { this.posX = (double) this.hangingPosition.getX() + 0.5D; this.posY = (double) this.hangingPosition.getY() + 0.5D; this.posZ = (double) this.hangingPosition.getZ() + 0.5D; } /** Updates facing and bounding box based on it */ public void updateFacingWithBoundingBox(EnumFacing facingDirectionIn) {} public int getWidthPixels() { return 9; } public int getHeightPixels() { return 9; } public float getEyeHeight() { return -0.0625F; } /** Checks if the entity is in range to render. */ @SideOnly(Side.CLIENT) public boolean isInRangeToRenderDist(double distance) { return distance < 1024.0D; } /** Called when this entity is broken. Entity parameter may be null. */ public void onBroken(@Nullable Entity brokenEntity) { this.playSound(SoundEvents.ENTITY_LEASHKNOT_BREAK, 1.0F, 1.0F); } /** Either write this entity to the NBT tag given and return true, or return false without doing anything. If this returns false the entity is not saved on disk. Ridden entities return false here as they are saved with their rider. */ public boolean writeToNBTOptional(NBTTagCompound compound) { return false; } public boolean processInitialInteractLeash(EntityPlayer player, @Nullable ItemStack stack, EnumHand hand) //custom, changed name { if (this.worldObj.isRemote) { return true; } else { boolean flag = false; if (stack != null && stack.getItem() == Items.LEAD) { for (EntityLiving entityliving : this.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(this.posX - 7.0D, this.posY - 7.0D, this.posZ - 7.0D, this.posX + 7.0D, this.posY + 7.0D, this.posZ + 7.0D))) { if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == player) { entityliving.setLeashedToEntity(this, true); flag = true; } } } if (!flag) { this.setDead(); if (player.capabilities.isCreativeMode) { for (EntityLiving entityliving1 : this.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(this.posX - 7.0D, this.posY - 7.0D, this.posZ - 7.0D, this.posX + 7.0D, this.posY + 7.0D, this.posZ + 7.0D))) { if (entityliving1.getLeashed() && entityliving1.getLeashedToEntity() == this) { entityliving1.clearLeashed(true, false); } } } } return true; } } /** checks to make sure painting can be placed there */ public boolean onValidSurface() { return this.worldObj.getBlockState(this.hangingPosition).getBlock() instanceof BlockFence; } public static EntityRopeKnot createKnot(World worldIn, BlockPos fence) { EntityRopeKnot entityleashknot = new EntityRopeKnot(worldIn, fence); entityleashknot.forceSpawn = true; worldIn.spawnEntityInWorld(entityleashknot); entityleashknot.playPlaceSound(); return entityleashknot; } public static EntityRopeKnot getKnotForPosition(World worldIn, BlockPos pos) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); for (EntityRopeKnot entityleashknot : worldIn.getEntitiesWithinAABB(EntityRopeKnot.class, new AxisAlignedBB((double) i - 1.0D, (double) j - 1.0D, (double) k - 1.0D, (double) i + 1.0D, (double) j + 1.0D, (double) k + 1.0D))) { if (entityleashknot.getHangingPosition().equals(pos)) { return entityleashknot; } } return null; } public void playPlaceSound() { this.playSound(SoundEvents.ENTITY_LEASHKNOT_PLACE, 1.0F, 1.0F); } //TODO: Entity Hanging private static final Predicate<Entity> IS_HANGING_ENTITY = new Predicate<Entity>() { public boolean apply(@Nullable Entity p_apply_1_) { return p_apply_1_ instanceof EntityHanging; } }; private int tickCounter1; protected BlockPos hangingPosition; /** The direction the entity is facing */ @Nullable public EnumFacing facingDirection; private double func_190202_a(int p_190202_1_) { return p_190202_1_ % 32 == 0 ? 0.5D : 0.0D; } /** Returns true if other Entities should be prevented from moving through this Entity. */ public boolean canBeCollidedWith() { return true; } /** Called when a player attacks an entity. If this returns true the attack will not happen. */ public boolean hitByEntity(Entity entityIn) { return entityIn instanceof EntityPlayer ? this.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityIn), 0.0F) : false; } /** Gets the horizontal facing direction of this Entity. */ public EnumFacing getHorizontalFacing() { return this.facingDirection; } /** Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else { if (!this.isDead && !this.worldObj.isRemote) { this.setDead(); this.setBeenAttacked(); this.onBroken(source.getEntity()); } return true; } } /** Tries to move the entity towards the specified location. */ public void moveEntity(double x, double y, double z) { if (!this.worldObj.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D) { this.setDead(); this.onBroken((Entity) null); } } /** Adds to the current velocity of the entity. */ public void addVelocity(double x, double y, double z) { if (!this.worldObj.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D) { this.setDead(); this.onBroken((Entity) null); } } /** (abstract) Protected helper method to write subclass entity data to NBT. */ /* public void writeEntityToNBT(NBTTagCompound compound) { compound.setByte("Facing", (byte)this.facingDirection.getHorizontalIndex()); BlockPos blockpos = this.getHangingPosition(); compound.setInteger("TileX", blockpos.getX()); compound.setInteger("TileY", blockpos.getY()); compound.setInteger("TileZ", blockpos.getZ()); } */ /** (abstract) Protected helper method to read subclass entity data from NBT. */ /* public void readEntityFromNBT(NBTTagCompound compound) { this.hangingPosition = new BlockPos(compound.getInteger("TileX"), compound.getInteger("TileY"), compound.getInteger("TileZ")); this.updateFacingWithBoundingBox(EnumFacing.getHorizontal(compound.getByte("Facing"))); } */ /** Called when this entity is broken. Entity parameter may be null. */ /** Drops an item at the position of the entity. */ public EntityItem entityDropItem(ItemStack stack, float offsetY) { EntityItem entityitem = new EntityItem(this.worldObj, this.posX + (double) ((float) this.facingDirection.getFrontOffsetX() * 0.15F), this.posY + (double) offsetY, this.posZ + (double) ((float) this.facingDirection.getFrontOffsetZ() * 0.15F), stack); entityitem.setDefaultPickupDelay(); this.worldObj.spawnEntityInWorld(entityitem); return entityitem; } protected boolean shouldSetPosAfterLoading() { return false; } public BlockPos getHangingPosition() { return this.hangingPosition; } /** Transforms the entity's current yaw with the given Rotation and returns it. This does not have a side-effect. */ @SuppressWarnings("incomplete-switch") public float getRotatedYaw(Rotation transformRotation) { if (this.facingDirection != null && this.facingDirection.getAxis() != EnumFacing.Axis.Y) { switch (transformRotation) { case CLOCKWISE_180: this.facingDirection = this.facingDirection.getOpposite(); break; case COUNTERCLOCKWISE_90: this.facingDirection = this.facingDirection.rotateYCCW(); break; case CLOCKWISE_90: this.facingDirection = this.facingDirection.rotateY(); } } float f = MathHelper.wrapDegrees(this.rotationYaw); switch (transformRotation) { case CLOCKWISE_180: return f + 180.0F; case COUNTERCLOCKWISE_90: return f + 90.0F; case CLOCKWISE_90: return f + 270.0F; default: return f; } } /** Transforms the entity's current yaw with the given Mirror and returns it. This does not have a side-effect. */ public float getMirroredYaw(Mirror transformMirror) { return this.getRotatedYaw(transformMirror.toRotation(this.facingDirection)); } /** Called when a lightning bolt hits the entity. */ public void onStruckByLightning(EntityLightningBolt lightningBolt) {} //TODO: LEASHES /** Called to update the entity's position/logic. */ public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.tickCounter1++ == 100 && !this.worldObj.isRemote) { this.tickCounter1 = 0; if (!this.isDead && !this.onValidSurface()) { this.setDead(); this.onBroken((Entity) null); } } //endsuper hanging entity if (!this.worldObj.isRemote) { this.updateLeashedState(); } } /** (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound compound) { compound.setBoolean("Leashed", this.isLeashed); if (this.leashedToEntity != null) { NBTTagCompound nbttagcompound2 = new NBTTagCompound(); if (this.leashedToEntity instanceof EntityLivingBase) { UUID uuid = this.leashedToEntity.getUniqueID(); nbttagcompound2.setUniqueId("UUID", uuid); } else if (this.leashedToEntity instanceof EntityHanging) { BlockPos blockpos = ((EntityHanging) this.leashedToEntity).getHangingPosition(); nbttagcompound2.setInteger("X", blockpos.getX()); nbttagcompound2.setInteger("Y", blockpos.getY()); nbttagcompound2.setInteger("Z", blockpos.getZ()); } compound.setTag("Leash", nbttagcompound2); } } /** (abstract) Protected helper method to read subclass entity data from NBT. */ @Override public void readEntityFromNBT(NBTTagCompound compound) { this.isLeashed = compound.getBoolean("Leashed"); if (this.isLeashed && compound.hasKey("Leash", 10)) { this.leashNBTTag = compound.getCompoundTag("Leash"); } } public final boolean processInitialInteract(EntityPlayer player, @Nullable ItemStack stack, EnumHand hand) { if (this.getLeashed() && this.getLeashedToEntity() == player) { this.clearLeashed(true, !player.capabilities.isCreativeMode); return true; } else if (stack != null && stack.getItem() == Items.LEAD && this.canBeLeashedTo(player)) { this.setLeashedToEntity(player, true); --stack.stackSize; return true; } else { return this.processInteract(player, hand, stack) ? true : super.processInitialInteract(player, stack, hand); } } protected boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) { return processInitialInteractLeash(player, stack, hand); } /** Applies logic related to leashes, for example dragging the entity or breaking the leash. */ protected void updateLeashedState() { if (this.leashNBTTag != null) { this.recreateLeash(); } if (this.isLeashed) { if (!this.isEntityAlive()) { this.clearLeashed(true, true); } if (this.leashedToEntity == null || this.leashedToEntity.isDead) { this.clearLeashed(true, true); } } } /** Removes the leash from this entity */ public void clearLeashed(boolean sendPacket, boolean dropLead) { if (this.isLeashed) { this.isLeashed = false; this.leashedToEntity = null; if (!this.worldObj.isRemote && dropLead) { this.dropItem(Items.LEAD, 1); } if (!this.worldObj.isRemote && sendPacket && this.worldObj instanceof WorldServer) { ((WorldServer) this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, (Entity) null)); } } } public boolean canBeLeashedTo(EntityPlayer player) { return !this.getLeashed() && !(this instanceof IMob); } public boolean getLeashed() { return this.isLeashed; } public Entity getLeashedToEntity() { return this.leashedToEntity; } /** Sets the entity to be leashed to. */ public void setLeashedToEntity(Entity entityIn, boolean sendAttachNotification) { this.isLeashed = true; this.leashedToEntity = entityIn; if (!this.worldObj.isRemote && sendAttachNotification && this.worldObj instanceof WorldServer) { ((WorldServer) this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, this.leashedToEntity)); } if (this.isRiding()) { this.dismountRidingEntity(); } } private void recreateLeash() { if (this.isLeashed && this.leashNBTTag != null) { if (this.leashNBTTag.hasUniqueId("UUID")) { UUID uuid = this.leashNBTTag.getUniqueId("UUID"); for (EntityLivingBase entitylivingbase : this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expandXyz(10.0D))) { if (entitylivingbase.getUniqueID().equals(uuid)) { this.leashedToEntity = entitylivingbase; break; } } } else if (this.leashNBTTag.hasKey("X", 99) && this.leashNBTTag.hasKey("Y", 99) && this.leashNBTTag.hasKey("Z", 99)) { BlockPos blockpos = new BlockPos(this.leashNBTTag.getInteger("X"), this.leashNBTTag.getInteger("Y"), this.leashNBTTag.getInteger("Z")); EntityRopeKnot entityleashknot = EntityRopeKnot.getKnotForPosition(this.worldObj, blockpos); if (entityleashknot == null) { entityleashknot = EntityRopeKnot.createKnot(this.worldObj, blockpos); } this.leashedToEntity = entityleashknot; } else { this.clearLeashed(false, true); } } this.leashNBTTag = null; } } RenderRopeKnot.java package net.creativerealmsmc.conquest.entity.render; import net.creativerealmsmc.conquest.entity.EntityRopeKnot; import net.creativerealmsmc.conquest.entity.model.ModelRopeKnot; import net.minecraft.client.model.ModelLeashKnot; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderRopeKnot extends Render<EntityRopeKnot> { private static final ResourceLocation LEASH_KNOT_TEXTURES = new ResourceLocation("textures/entity/lead_knot.png"); private final ModelRopeKnot leashKnotModel = new ModelRopeKnot(); public RenderRopeKnot(RenderManager renderManagerIn) { super(renderManagerIn); } /** * Renders the desired {@code T} type Entity. */ public void doRender(EntityRopeKnot entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.disableCull(); GlStateManager.translate((float)x, (float)y, (float)z); float f = 0.0625F; GlStateManager.enableRescaleNormal(); GlStateManager.scale(-1.0F, -1.0F, 1.0F); GlStateManager.enableAlpha(); this.bindEntityTexture(entity); if (this.renderOutlines) { GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(this.getTeamColor(entity)); } this.leashKnotModel.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); if (this.renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityRopeKnot entity) { return LEASH_KNOT_TEXTURES; } } ModelRopeKnot.java package net.creativerealmsmc.conquest.entity.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelRopeKnot extends ModelBase { public ModelRenderer knotRenderer; public ModelRopeKnot() { this(0, 0, 32, 32); } public ModelRopeKnot(int p_i46365_1_, int p_i46365_2_, int p_i46365_3_, int p_i46365_4_) { this.textureWidth = p_i46365_3_; this.textureHeight = p_i46365_4_; this.knotRenderer = new ModelRenderer(this, p_i46365_1_, p_i46365_2_); this.knotRenderer.addBox(-3.0F, -6.0F, -3.0F, 6, 8, 6, 0.0F); this.knotRenderer.setRotationPoint(0.0F, 0.0F, 0.0F); } /** * Sets the models various rotation angles then renders the model. */ public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); this.knotRenderer.render(scale); } /** * 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 limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); this.knotRenderer.rotateAngleY = netHeadYaw * 0.017453292F; this.knotRenderer.rotateAngleX = headPitch * 0.017453292F; } } I've spent so long on this I hope I can get help :'( Edit: I have narrowed my situation down to only seeing the entity at certain angles.
  10. Great! Here you go: package com.jugbot.conquest.gui.container; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import com.jugbot.conquest.blocks.tileentity.TileEntityStove; import com.jugbot.conquest.gui.slot.SlotStove; public class ContainerStove extends Container { private IInventory stoveInventory; public ContainerStove(IInventory playerInventory, TileEntityStove stoveInventory) { System.out.println("I came for the cake"); this.stoveInventory = stoveInventory; this.addSlotToContainer(new SlotStove(stoveInventory, 0, 65, 43)); System.out.println("Main slot added"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, j * 18 + 8, i * 18 + 92)); System.out.println(i + " Slot inv added"); } } for (int i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(playerInventory, i, i * 18 + 8, 150)); System.out.println(i + " Slot bar added"); } } @Override public boolean canInteractWith(EntityPlayer player) { return this.stoveInventory.isUseableByPlayer(player); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) { ItemStack itemCopy = null; Slot slot = (Slot) this.inventorySlots.get(slotNum); if (slot != null && slot.getHasStack()) { ItemStack item = slot.getStack(); itemCopy = item.copy(); if (slotNum < 1) { if (!this.mergeItemStack(item, 1, this.inventorySlots.size(), false)) { return null; } } else if (slotNum > 0 && slotNum < 27) { if (!this.mergeItemStack(item, 27, this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(item, 1, 27, false)) { return null; } if (item.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } } return null; } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); this.stoveInventory.closeInventory(player); } } I don't see the need to select a certain slot if there is only one there 0.o Not even quite sure how I'm supposed to do that...
  11. I personally think obj models in minecraft would look bad (with high resolution models). I would rather a slightly expanded model system.
  12. I am having trouble setting the item in my tile entity to null. Shortly after the item is subtracted in the slot to zero, the game crashes. Here is my code: package com.jugbot.conquest.blocks.tileentity; import java.util.Random; //import com.jugbot.conquest.api.RecipeData; import com.jugbot.conquest.util.ParticleSpawner; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.server.gui.IUpdatePlayerListBox; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; //possible broke everything public class TileEntityStove extends TileEntity implements IInventory, IUpdatePlayerListBox { private ItemStack item = null; private ItemStack log = new ItemStack(Blocks.log); private ItemStack log2 = new ItemStack(Blocks.log2); private ItemStack planks = new ItemStack(Blocks.planks); private String customName; private boolean cooking = false; public int progress = 0; public int burnTime = 40; public int count = 0; public ItemStack getItem() { return item; } public void startCooking() { System.out.println(item); if (item != null) { // RecipeData data = // RecipeAPI.getMicrowaveRecipeFromIngredients(item); count = item.stackSize; if (item.isItemEqual(log) || item.isItemEqual(log2)) { cooking = true; burnTime = 80; } else if (item.isItemEqual(planks)) { cooking = true; burnTime = 20; } } } public void stopCooking() { this.cooking = false; this.progress = 0; } public boolean isCooking() { return cooking; } private Random rand = new Random(); private int timer = 0; @Override public void update() { System.out.println("begin update"); boolean flag = this.progress >= burnTime; boolean flag1 = false; if (cooking) { if (this.worldObj.isRemote) { double posX = pos.getX() + 0.35D + (rand.nextDouble() / 3); double posZ = pos.getZ() + 0.35D + (rand.nextDouble() / 3); ParticleSpawner.spawnParticle("smoke", posX, pos.getY() + 0.065D, posZ); } progress++; if (progress >= burnTime) { if (item != null) { this.item.stackSize--; if (item.stackSize <= 0) { System.out.println(item); this.item = null; //this.cooking = false; System.out.println(item); } //this.markDirty(); //YES!! } if (!worldObj.isRemote) { worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "aoc:fire_finish", 0.75F, 1.0F); } timer = 0; progress = 0; if (item.stackSize == 0 ) { cooking = false; } } else //looping sound-play { if (timer == 20) { timer = 0; } if (timer == 0) { worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "aoc:stove_burning", 0.75F, 1.0F); } timer++; } } } @Override public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); if (par1NBTTagCompound.hasKey("Item")) { NBTTagCompound nbt = par1NBTTagCompound.getCompoundTag("Item"); this.item = ItemStack.loadItemStackFromNBT(nbt); } this.cooking = par1NBTTagCompound.getBoolean("Coooking"); this.progress = par1NBTTagCompound.getInteger("Progress"); } @Override public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagCompound nbt = new NBTTagCompound(); if (item != null) { item.writeToNBT(nbt); } par1NBTTagCompound.setTag("Item", nbt); par1NBTTagCompound.setBoolean("Coooking", cooking); par1NBTTagCompound.setInteger("Progress", progress); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { NBTTagCompound tagCom = pkt.getNbtCompound(); this.readFromNBT(tagCom); } @Override public Packet getDescriptionPacket() { NBTTagCompound tagCom = new NBTTagCompound(); this.writeToNBT(tagCom); return new S35PacketUpdateTileEntity(pos, getBlockMetadata(), tagCom); } @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int slot) { return this.item; } @Override public ItemStack decrStackSize(int slot, int number) { if (this.item != null) { ItemStack itemstack; if (this.item.stackSize <= number) { itemstack = this.item; this.item = null; return itemstack; } itemstack = this.item.splitStack(number); if (this.item.stackSize == 0) { this.item = null; } return itemstack; } return null; } @Override public ItemStack getStackInSlotOnClosing(int slot) { return item; } @Override public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.item = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } @Override public int getInventoryStackLimit() { return 16; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return this.worldObj.getTileEntity(pos) != this ? false : entityplayer .getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D; } @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { return false; } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { item = null; } @Override public String getName() { return hasCustomName() ? customName : "Wood Stove"; } @Override public boolean hasCustomName() { return customName != null; } @Override public IChatComponent getDisplayName() { return new ChatComponentText(getName()); } } I know that the item is in fact set to null, its just that it messes something up god knows where... For me I somehow suspect writeToNBT() If you need any other files, just ask PLEASE
×
×
  • Create New...

Important Information

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