
AlexDGr8r
Members-
Posts
23 -
Joined
-
Last visited
Everything posted by AlexDGr8r
-
This problem was solved by simply doing a fresh install of Minecraft. I'm still befuddled as to what could have caused it, but nonetheless, it is resolved.
-
I am getting this crash on the latest forge build (10.13.0.1208). This is with no mods installed. Going back in to the same world again causes the same crash. Latest Log: https://gist.github.com/AlexDGr8r/9bf46dba0c24fc331b70#file-crash-report-on-world-startup-L34-L54 Crash Report: https://gist.github.com/AlexDGr8r/a44bfb2f5698a459300a Edit: Removed all resource packs (even though they were not enabled) to be sure. Still the same error.
-
[SOLVED]Custom Tile Entity rendering twice while near a beacon?
AlexDGr8r replied to AlexDGr8r's topic in Modder Support
Okay it is now fixed! Thanks TheGreyGhost! The problem was that the beacon renderer was disabling GL_CULL_FACE and enabling GL_BLEND when I need it to be the opposite for my meteor shield. Ensuring that these properties were correct made my tile entity render correctly. -
[SOLVED]Custom Tile Entity rendering twice while near a beacon?
AlexDGr8r replied to AlexDGr8r's topic in Modder Support
This is great! Thanks for this. I'll get back here with the results as soon as I can test it out. -
You'll want to look at the addInformation method in the Item class to add lore to your items.
-
[SOLVED]Custom Tile Entity rendering twice while near a beacon?
AlexDGr8r replied to AlexDGr8r's topic in Modder Support
Sorry for the extremely late reply (life got in the way). It's hard to really display in a screenshot so I uploaded a quick little video to show you all what I mean. -
Right now Waila has an issue with launching in my dev environment. I'd like to keep its source in my dev environment so that my mod compiles fine, but I don't want the mod to run when I run my mod for debugging purposes. Is there a way to disable it from running whenever I launch minecraft from my dev environment? I am using eclipse. Sorry for the stupid question if it is stupid.
-
I've noticed this problem for a little while now, but I'm still unsure as to what causes it. If the tile entity is placed before the beacon, then it will render just fine when I place down the beacon. But, if I place down the beacon and then the tile entity, it will appear like it is rendering twice with all the clipping it has. Here's the associated files: TileEntityMeteorShield package net.meteor.common.tileentity; import java.util.ArrayList; import java.util.List; import java.util.Random; import net.meteor.common.ClientHandler; import net.meteor.common.ClientProxy; import net.meteor.common.EnumMeteor; import net.meteor.common.IMeteorShield; import net.meteor.common.MeteorItems; import net.meteor.common.MeteorsMod; import net.meteor.common.climate.HandlerMeteor; import net.meteor.common.climate.MeteorShieldData; import net.meteor.common.entity.EntityComet; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileEntityMeteorShield extends TileEntity implements ISidedInventory, IMeteorShield { public static final int CHARGE_TIME = 1600; private boolean shieldedChunks; public String owner; private int range; private int powerLevel; private int cometX; private int cometZ; private int cometType = -1; public int age; // Inventory stuff private ItemStack[] inv; public TileEntityMeteorShield() { this.range = 0; this.powerLevel = 0; this.age = 0; this.shieldedChunks = false; this.inv = new ItemStack[13]; } public TileEntityMeteorShield(String theOwner) { this(); this.owner = theOwner; } @Override public void updateEntity() { ++age; if (!this.shieldedChunks) { if (powerLevel > 0) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { MeteorsMod.proxy.metHandlers.get(worldObj.provider.dimensionId).getShieldManager().addShield(this); } this.shieldedChunks = true; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } else if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { GenerateParticles(this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.worldObj.rand); } else if (age >= CHARGE_TIME) { setCharged(); if (!worldObj.isRemote) { if (owner != null && owner.length() > 0) { EntityPlayer player = worldObj.getPlayerEntityByName(owner); if (player != null) { player.addChatMessage(ClientHandler.createMessage(StatCollector.translateToLocal("MeteorShield.howToUpgrade"), EnumChatFormatting.GOLD)); } } } } } if (this.shieldedChunks) { range = powerLevel * MeteorsMod.instance.ShieldRadiusMultiplier; // update range (may load as 0 for old updates, thus check with this) } } public void setCharged() { if (powerLevel == 0) { powerLevel = 1; } } public EnumMeteor getCometType() { if (cometType == -1) return EnumMeteor.METEORITE; return EnumMeteor.getTypeFromID(cometType); } public List<String> getDisplayInfo() { List<String> info = new ArrayList<String>(); if (powerLevel == 0) { info.add("Charging..."); info.add("Charged: " + (int)((float)age / (float)CHARGE_TIME * 100) + "%"); } else { info.add("Power Level: " + powerLevel + " / 5"); info.add("Range: " + range + " blocks"); } info.add("Owner: " + owner); if (powerLevel != 0) { if (cometType != -1) { EnumMeteor type = EnumMeteor.getTypeFromID(cometType); info.add("Comet Entered Orbit at:"); info.add("X: " + cometX); info.add("Z: " + cometZ); } else { info.add("No Comets Detected"); } } return info; } public void addMeteorMaterials(List<ItemStack> items) { for (int i = 0; i < items.size(); i++) { ItemStack par1ItemStack = items.get(i); System.out.println(par1ItemStack); ItemStack itemstack1; int k = 5; if (par1ItemStack.isStackable()) { while (par1ItemStack.stackSize > 0 && k >= 5 && k < this.getSizeInventory()) { itemstack1 = inv[k]; if (itemstack1 != null && itemstack1.getItem() == par1ItemStack.getItem() && (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(par1ItemStack, itemstack1)) { int l = itemstack1.stackSize + par1ItemStack.stackSize; if (l <= par1ItemStack.getMaxStackSize()) { par1ItemStack.stackSize = 0; itemstack1.stackSize = l; } else if (itemstack1.stackSize < par1ItemStack.getMaxStackSize()) { par1ItemStack.stackSize -= par1ItemStack.getMaxStackSize() - itemstack1.stackSize; itemstack1.stackSize = par1ItemStack.getMaxStackSize(); } } ++k; } } if (par1ItemStack.stackSize > 0) { k = 5; while (k >= 5 && k < this.getSizeInventory()) { itemstack1 = inv[k]; if (itemstack1 == null) { inv[k] = par1ItemStack.copy(); par1ItemStack.stackSize = 0; break; } ++k; } } } worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); this.markDirty(); } public void detectComet(EntityComet comet) { this.cometX = (int)comet.posX; this.cometZ = (int)comet.posZ; this.cometType = comet.meteorType.getID(); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); this.markDirty(); } @SideOnly(Side.CLIENT) private void GenerateParticles(World world, int x, int y, int z, Random random) { if (world.getBlock(x, y + 1, z).isOpaqueCube()) return; for (int currX = x - 2; currX <= x + 2; currX++) { for (int currZ = z - 2; currZ <= z + 2; currZ++) { if ((currX > x - 2) && (currX < x + 2) && (currZ == z - 1)) { currZ = z + 2; } if (random.nextInt(100) == 25) { for (int currY = y; currY <= y + 1; currY++) { if (!world.isAirBlock((currX - x) / 2 + x, currY, (currZ - z) / 2 + z)) { break; } ClientProxy.spawnParticle("meteorshield", x + 0.5D, y + 2.0D, z + 0.5D, currX - x + random.nextFloat() - 0.5D, currY - y - random.nextFloat() - 1.0F, currZ - z + random.nextFloat() - 0.5D, world, -1); } } } } } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.owner = nbt.getString("owner"); if (owner == null || owner.trim().isEmpty()) { owner = "None"; } this.powerLevel = nbt.getInteger("powerLevel"); this.range = MeteorsMod.instance.ShieldRadiusMultiplier * powerLevel; if (nbt.hasKey("cometType")) { this.cometType = nbt.getInteger("cometType"); this.cometX = nbt.getInteger("cometX"); this.cometZ = nbt.getInteger("cometZ"); } NBTTagList nbttaglist = nbt.getTagList("Items", 10); this.inv = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < this.inv.length) { this.inv[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setString("owner", this.owner); nbt.setInteger("powerLevel", powerLevel); if (cometType != -1) { nbt.setInteger("cometType", cometType); nbt.setInteger("cometX", cometX); nbt.setInteger("cometZ", cometZ); } NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < inv.length; i++) { if (inv[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.inv[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbt.setTag("Items", nbttaglist); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); } @Override public Packet getDescriptionPacket() { NBTTagCompound var1 = new NBTTagCompound(); writeToNBT(var1); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, var1); } @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1.5, zCoord + 1); } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int i) { return inv[i]; } @Override public ItemStack decrStackSize(int i, int j) { ItemStack stack = getStackInSlot(i); if (stack != null) { if (stack.stackSize <= j) { setInventorySlotContents(i, null); } else { ItemStack stack2 = stack.splitStack(j); if (stack.stackSize <= 0) { setInventorySlotContents(i, null); } stack = stack2; } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int i) { return null; // not needed, no items should be dropped } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { if (itemstack == null) { inv[i] = null; if (i > 0 && i < 5 && powerLevel > 1) { this.updateRange(); } } else if (isItemValidForSlot(i, itemstack)) { if (i < 5 && itemstack.stackSize > 1) { itemstack.stackSize = 1; } if (i == 0) { this.setCharged(); this.worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "meteors:shield.powerup", 1.0F, 0.6F); this.markDirty(); } else if (i > 0 && i < 5) { inv[i] = itemstack; this.updateRange(); } } } @Override public int getInventoryStackLimit() { return 1; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; // TODO put in some proper checks for this } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { if (itemstack.getItem() == MeteorItems.itemRedMeteorGem) { return powerLevel > 0 && i > 0 && i < 5 && powerLevel < 5 && inv[i] == null; } else if (itemstack.getItem() == MeteorItems.itemMeteorChips) { return i == 0 && powerLevel == 0; } return false; } @Override public String getInventoryName() { return "Meteor Shield"; } @Override public boolean hasCustomInventoryName() { return false; // TODO localize later } @Override public void openInventory() {} @Override public void closeInventory() {} private void updateRange() { int powerCrystals = 0; for (int i = 1; i <= 4; i++) { if (inv[i] != null && inv[i].getItem() == MeteorItems.itemRedMeteorGem) { powerCrystals++; } } int oldLevel = this.powerLevel; this.powerLevel = 1 + powerCrystals; this.range = MeteorsMod.instance.ShieldRadiusMultiplier * powerLevel; this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); if (powerLevel > oldLevel) { this.worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "meteors:shield.powerup", 1.0F, powerLevel / 10.0F + 0.5F); if (MeteorsMod.instance.ShieldRadiusMultiplier <= 0 && !worldObj.isRemote) { EntityPlayer player = worldObj.getPlayerEntityByName(owner); if (player != null) { player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("MeteorShield.noUpgrade"))); } } } else if (powerLevel < oldLevel) { // TODO Add sound for power down } this.markDirty(); } @Override public int getRange() { return this.range; } @Override public int getX() { return this.xCoord; } @Override public int getY() { return this.yCoord; } @Override public int getZ() { return this.zCoord; } @Override public boolean isTileEntity() { return true; } @Override public String getOwner() { return this.owner; } @Override public int getPowerLevel() { return this.powerLevel; } @Override public boolean equals(Object o) { if (o instanceof IMeteorShield) { IMeteorShield shield = (IMeteorShield)o; return (this.getX() == shield.getX()) && (this.getY() == shield.getY()) && (this.getZ() == shield.getZ()); } return super.equals(o); } @Override public void onChunkUnload() { if (!this.worldObj.isRemote) { HandlerMeteor metHandler = MeteorsMod.proxy.metHandlers.get(worldObj.provider.dimensionId); metHandler.getShieldManager().addShield(new MeteorShieldData(xCoord, yCoord, zCoord, powerLevel, owner)); } } @Override public int[] getAccessibleSlotsFromSide(int side) { int[] slots = new int[8]; for (int i = 0; i < 8; i++) { slots[i] = i + 5; } return slots; } @Override public boolean canInsertItem(int slot, ItemStack item, int side) { return slot < 5 && isItemValidForSlot(slot, item); } @Override public boolean canExtractItem(int slot, ItemStack item, int side) { return slot > 4; } } BlockMeteorShield package net.meteor.common.block; import java.util.Random; import net.meteor.common.ClientHandler; import net.meteor.common.MeteorsMod; import net.meteor.common.tileentity.TileEntityMeteorShield; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockMeteorShield extends BlockContainerMeteorsMod { public BlockMeteorShield() { super(Material.rock); this.setLightOpacity(0); this.setBlockBounds(0.0625F, 0.375F, 0.0625F, 0.9375F, 1.0F, 0.9375F); } @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack itemstack) { if ((par5EntityLiving instanceof EntityPlayer)) { EntityPlayer player = (EntityPlayer)par5EntityLiving; if (!par1World.isRemote) { player.addChatMessage(ClientHandler.createMessage(StatCollector.translateToLocal("MeteorShield.charging"), EnumChatFormatting.YELLOW)); } TileEntityMeteorShield shield = (TileEntityMeteorShield) par1World.getTileEntity(par2, par3, par4); shield.owner = player.getCommandSenderName(); par1World.playSoundEffect(par2, par3, par4, "meteors:shield.humm", 1.0F, 1.0F); } int l = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 2); } if (l == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 2); } if (l == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLiving, itemstack); } @Override public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { TileEntityMeteorShield shield = (TileEntityMeteorShield)par1World.getTileEntity(par2, par3, par4); if (!par1World.isRemote) { if (MeteorsMod.proxy.metHandlers.get(par1World.provider.dimensionId).getShieldManager().meteorShields.remove(shield)) { //MeteorsMod.log.info("METEOR SHIELD SHOULD BE REMOVED"); } par1World.playSoundEffect(par2 + 0.5D, par3 + 0.5D, par4 + 0.5D, "meteors:shield.powerdown", 1.0F, 1.0F); } if (shield != null) { for (int i1 = 0; i1 < shield.getSizeInventory(); ++i1) { ItemStack itemstack = shield.getStackInSlot(i1); if (itemstack != null) { float f = par1World.rand.nextFloat() * 0.8F + 0.1F; float f1 = par1World.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = par1World.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { int j1 = par1World.rand.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double)((float)par1World.rand.nextGaussian() * f3); entityitem.motionY = (double)((float)par1World.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double)((float)par1World.rand.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } } } } } super.breakBlock(par1World, par2, par3, par4, par5, par6); } @SideOnly(Side.CLIENT) @Override public void randomDisplayTick(World world, int i, int j, int k, Random random) { if (MeteorsMod.instance.meteorShieldSound && random.nextInt(256) == 100) { world.playSound(i + 0.5D, j + 0.5D, k + 0.5D, "meteors:shield.humm", 0.6F, 1.0F, false); } } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { player.openGui(MeteorsMod.instance, 0, world, i, j, k); return true; } @Override public TileEntity createNewTileEntity(World world, int metadata) { return new TileEntityMeteorShield(); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * The type of render function that is called for this block */ public int getRenderType() { return -1; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } } ModelMeteorShield package net.meteor.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.util.MathHelper; public class ModelMeteorShield extends ModelBase { //fields private ModelRenderer BaseShape; private ModelRenderer TopLayer; private ModelRenderer MiddleLayer; private ModelRenderer BottomLayer; private ModelRenderer Side1; private ModelRenderer Side2; private ModelRenderer Side3; private ModelRenderer Side4; private ModelRenderer Leg1; private ModelRenderer Leg2; private ModelRenderer Leg3; private ModelRenderer Leg4; private ModelRenderer Foot1; private ModelRenderer Foot2; private ModelRenderer Foot3; private ModelRenderer Foot4; private ModelRenderer InnerSlope1; private ModelRenderer InnerSlope2; private ModelRenderer InnerSlope3; private ModelRenderer InnerSlope4; private ModelRenderer SidePanel1; private ModelRenderer SidePanel2; private float topY; private float midY; private float botY; public ModelMeteorShield() { textureWidth = 128; textureHeight = 64; BaseShape = new ModelRenderer(this, 0, 0); BaseShape.addBox(-6F, 0F, -6F, 12, 0, 12); BaseShape.setRotationPoint(0F, 15F, 0F); BaseShape.setTextureSize(128, 64); BaseShape.mirror = true; setRotation(BaseShape, 0F, 0F, 0F); TopLayer = new ModelRenderer(this, 0, 14); TopLayer.addBox(-5F, -8F, -5F, 10, 1, 10); TopLayer.setRotationPoint(0F, 15F, 0F); TopLayer.setTextureSize(128, 64); TopLayer.mirror = true; setRotation(TopLayer, 0F, 0F, 0F); topY = TopLayer.rotationPointY; MiddleLayer = new ModelRenderer(this, 0, 26); MiddleLayer.addBox(-4F, -10F, -4F, 8, 1, ; MiddleLayer.setRotationPoint(0F, 15F, 0F); MiddleLayer.setTextureSize(128, 64); MiddleLayer.mirror = true; setRotation(MiddleLayer, 0F, 0F, 0F); midY = MiddleLayer.rotationPointY; BottomLayer = new ModelRenderer(this, 0, 35); BottomLayer.addBox(-3F, -12F, -3F, 6, 1, 6); BottomLayer.setRotationPoint(0F, 15F, 0F); BottomLayer.setTextureSize(128, 64); BottomLayer.mirror = true; setRotation(BottomLayer, 0F, 0F, 0F); botY = BottomLayer.rotationPointY; Side1 = new ModelRenderer(this, 66, 0); Side1.addBox(-7F, -7F, -7F, 14, 10, 1); Side1.setRotationPoint(0F, 15F, 0F); Side1.setTextureSize(128, 64); Side1.mirror = true; setRotation(Side1, 0F, 0F, 0F); Side2 = new ModelRenderer(this, 66, 0); Side2.addBox(-7F, -7F, 6F, 14, 10, 1); Side2.setRotationPoint(0F, 15F, 0F); Side2.setTextureSize(128, 64); Side2.mirror = true; setRotation(Side2, 0F, 0F, 0F); Side3 = new ModelRenderer(this, 83, 0); Side3.addBox(-7F, -7F, -7F, 1, 10, 14); Side3.setRotationPoint(0F, 15F, 0F); Side3.setTextureSize(128, 64); Side3.mirror = true; setRotation(Side3, 0F, 0F, 0F); Side4 = new ModelRenderer(this, 83, 0); Side4.addBox(6F, -7F, -7F, 1, 10, 14); Side4.setRotationPoint(0F, 15F, 0F); Side4.setTextureSize(128, 64); Side4.mirror = true; setRotation(Side4, 0F, 0F, 0F); Leg1 = new ModelRenderer(this, 48, 0); Leg1.addBox(-0.5F, 0F, -0.5F, 1, 6, 1); Leg1.setRotationPoint(-6F, 18F, 6F); Leg1.setTextureSize(128, 64); Leg1.mirror = true; setRotation(Leg1, 0.2617994F, -0.7853982F, 0F); Leg2 = new ModelRenderer(this, 48, 0); Leg2.addBox(-0.5F, 0F, -0.5F, 1, 6, 1); Leg2.setRotationPoint(6F, 18F, 6F); Leg2.setTextureSize(128, 64); Leg2.mirror = true; setRotation(Leg2, 0.2617994F, 0.7853982F, 0F); Leg3 = new ModelRenderer(this, 48, 0); Leg3.addBox(-0.5F, 0F, -0.5F, 1, 6, 1); Leg3.setRotationPoint(6F, 18F, -6F); Leg3.setTextureSize(128, 64); Leg3.mirror = true; setRotation(Leg3, -0.2617994F, -0.7853982F, 0F); Leg4 = new ModelRenderer(this, 48, 0); Leg4.addBox(-0.5F, 0F, -0.5F, 1, 6, 1); Leg4.setRotationPoint(-6F, 18F, -6F); Leg4.setTextureSize(128, 64); Leg4.mirror = true; setRotation(Leg4, -0.2617994F, 0.7853982F, 0F); Foot1 = new ModelRenderer(this, 52, 0); Foot1.addBox(-0.5F, 0F, -0.5F, 1, 1, 2); Foot1.setRotationPoint(-7F, 23F, 7F); Foot1.setTextureSize(128, 64); Foot1.mirror = true; setRotation(Foot1, 0F, -0.7853982F, 0F); Foot2 = new ModelRenderer(this, 52, 0); Foot2.addBox(-0.5F, 0F, -0.5F, 1, 1, 2); Foot2.setRotationPoint(7F, 23F, 7F); Foot2.setTextureSize(128, 64); Foot2.mirror = true; setRotation(Foot2, 0F, 0.7853982F, 0F); Foot3 = new ModelRenderer(this, 52, 0); Foot3.addBox(-0.5F, 0F, -0.5F, 1, 1, 2); Foot3.setRotationPoint(-7F, 23F, -7F); Foot3.setTextureSize(128, 64); Foot3.mirror = true; setRotation(Foot3, 0F, -2.356194F, 0F); Foot4 = new ModelRenderer(this, 52, 0); Foot4.addBox(-0.5F, 0F, -0.5F, 1, 1, 2); Foot4.setRotationPoint(7F, 23F, -7F); Foot4.setTextureSize(128, 64); Foot4.mirror = true; setRotation(Foot4, 0F, 2.356194F, 0F); InnerSlope1 = new ModelRenderer(this, 32, 26); InnerSlope1.addBox(-6F, 1F, 1F, 12, 0, 7); InnerSlope1.setRotationPoint(0F, 15F, 0F); InnerSlope1.setTextureSize(128, 64); InnerSlope1.mirror = true; setRotation(InnerSlope1, 0.8203047F, 0F, 0F); InnerSlope2 = new ModelRenderer(this, 32, 26); InnerSlope2.addBox(-6F, 1F, -8F, 12, 0, 7); InnerSlope2.setRotationPoint(0F, 15F, 0F); InnerSlope2.setTextureSize(128, 64); InnerSlope2.mirror = true; setRotation(InnerSlope2, -0.8203047F, 0F, 0F); InnerSlope3 = new ModelRenderer(this, 32, 14); InnerSlope3.addBox(-8F, 1F, -6F, 7, 0, 12); InnerSlope3.setRotationPoint(0F, 15F, 0F); InnerSlope3.setTextureSize(128, 64); InnerSlope3.mirror = true; setRotation(InnerSlope3, 0F, 0F, 0.8203047F); InnerSlope4 = new ModelRenderer(this, 32, 14); InnerSlope4.addBox(1F, 1F, -6F, 7, 0, 12); InnerSlope4.setRotationPoint(0F, 15F, 0F); InnerSlope4.setTextureSize(128, 64); InnerSlope4.mirror = true; setRotation(InnerSlope4, 0F, 0F, -0.8203047F); SidePanel1 = new ModelRenderer(this, 32, 34); SidePanel1.addBox(6F, 1F, -2F, 1, 4, 4); SidePanel1.setRotationPoint(0F, 12F, 0F); SidePanel1.setTextureSize(128, 64); SidePanel1.mirror = true; setRotation(SidePanel1, 0F, 0F, -0.2617994F); SidePanel2 = new ModelRenderer(this, 32, 34); SidePanel2.addBox(-7F, 1F, -2F, 1, 4, 4); SidePanel2.setRotationPoint(0F, 12F, 0F); SidePanel2.setTextureSize(128, 64); SidePanel2.mirror = true; setRotation(SidePanel2, 0F, 0F, 0.2617994F); } public void render(int pLevel, float partialTick, float f1, float f2, float f3, float f4, float f5, int age) { setRotationAngles(partialTick, f1, f2, f3, f4, f5, pLevel, age); float bobModifier = MathHelper.sin(((float)age + partialTick) / 1600F * 360F) * 0.5F - 0.3F; BottomLayer.rotationPointY = botY + bobModifier; MiddleLayer.rotationPointY = midY + bobModifier; TopLayer.rotationPointY = topY + bobModifier; BaseShape.render(f5); switch (pLevel) { case 5: case 4: BottomLayer.render(f5); case 3: MiddleLayer.render(f5); case 2: TopLayer.render(f5); } Side1.render(f5); Side2.render(f5); Side3.render(f5); Side4.render(f5); Leg1.render(f5); Leg2.render(f5); Leg3.render(f5); Leg4.render(f5); Foot1.render(f5); Foot2.render(f5); Foot3.render(f5); Foot4.render(f5); InnerSlope1.render(f5); InnerSlope2.render(f5); InnerSlope3.render(f5); InnerSlope4.render(f5); SidePanel1.render(f5); SidePanel2.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, int pLevel, int age) { if (pLevel == 0) { return; } TopLayer.rotateAngleY = ((float)age + f) / (140F / pLevel); MiddleLayer.rotateAngleY = ((float)age + f) / (70F / pLevel); BottomLayer.rotateAngleY = ((float)age + f) / (40F / pLevel); } } TileEntityMeteorShieldRenderer package net.meteor.client.tileentity; import net.meteor.client.model.ModelMeteorShield; import net.meteor.common.MeteorsMod; import net.meteor.common.tileentity.TileEntityMeteorShield; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TileEntityMeteorShieldRenderer extends TileEntitySpecialRenderer { private static final ResourceLocation shieldTexture = new ResourceLocation(MeteorsMod.MOD_ID, "textures/entities/meteorShield.png"); private ModelMeteorShield modelShield; public TileEntityMeteorShieldRenderer() { this.modelShield = new ModelMeteorShield(); } public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) { renderAModelAt((TileEntityMeteorShield)tileentity, d, d1, d2, f); } public void renderAModelAt(TileEntityMeteorShield shield, double par2, double par4, double par6, float par8) { int level = shield.getPowerLevel(); if (!shield.getWorldObj().isAirBlock(shield.xCoord, shield.yCoord + 1, shield.zCoord)) { level = 0; } int meta = shield.getBlockMetadata(); GL11.glPushMatrix(); GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 1.5F, (float)par6 + 0.5F); this.bindTexture(shieldTexture); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(meta * -90F, 0.0F, 1.0F, 0.0F); this.modelShield.render(level, par8, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, shield.age); GL11.glPopMatrix(); GL11.glPopMatrix(); } } And yes, I've registered it forge and such. Side question, is there a way to check to see if this is being rendered twice? Just as a way to validate that the tile entity is indeed the tile entity that needs to be rendered and not some possibly memory leaked tile entity?
-
I'd like to know a little bit more though. More specifically on how to exclude it from the final build of of my mod. Including the files directly into my source would just compile the java files at build time and put it with the rest of my source files in the final jar. So how can I reference to these java files, but not include them into the final build?
-
I'm having trouble getting my custom animated textures to work properly. Please know that this is similar to how the compass work. In fact, the code mirrors off of the TextureCompass class. In MC 1.5, everything worked fine. I've hooked into the Pre-TextureStitchEvent to set the texture entry for the custom animation, but now that appears to not register it. The texture itself animates, but only from reading the png file. In other words, the compass just keeps turning, but it's not calling my updateAnimation() method. My debug code shows me it set's the texture entry, but it still doesn't call the TextureDetector class updateAnimation() method. Here's some code for you all: Hook for registering the texture entry: package net.minecraft.src.meteor; import net.meteor.common.MeteorsMod; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.event.ForgeSubscribe; public class HandlerTextures { @ForgeSubscribe public void registerTextures(TextureStitchEvent.Pre event) { TextureMap map = event.map; if (map.textureType == 1) { // Items map.setTextureEntry("meteors:MeteorDetectorProximity", new TextureDetector("meteors:MeteorDetectorProximity", 0)); map.setTextureEntry("meteors:MeteorDetectorTime", new TextureDetector("meteors:MeteorDetectorTime", 1)); map.setTextureEntry("meteors:MeteorDetectorCrash", new TextureDetector("meteors:MeteorDetectorCrash", 2)); MeteorsMod.log.info("Textures set for detector!"); } } } And here's my TextureDetector class: package net.minecraft.src.meteor; import net.meteor.common.ClientHandler; import net.meteor.common.MeteorsMod; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; public class TextureDetector extends TextureAtlasSprite { public double currentAngle; public double angleDelta; public int detectorType; // 0 = Proximity, 1 = Time, 2 = Crash public TextureDetector(String s, int type) { super(s); this.detectorType = type; } @Override public void updateAnimation() { Minecraft minecraft = Minecraft.getMinecraft(); if (minecraft.theWorld != null && minecraft.thePlayer != null) { this.updateCompass(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ, (double)minecraft.thePlayer.rotationYaw, false, false); } else { this.updateCompass((World)null, 0.0D, 0.0D, 0.0D, true, false); } } public void updateCompass(World par1World, double par2, double par4, double par6, boolean par8, boolean par9) { if (this.field_110976_a.isEmpty()) return; MeteorsMod.log.info("Updating Detector in compass method!"); double d3 = 0.0D; if (par1World != null && !par8) { ChunkCoordinates chunkcoordinates; if (this.detectorType == 0) { chunkcoordinates = ClientHandler.nearestTimeLocation; } else if (this.detectorType == 1) { chunkcoordinates = ClientHandler.getClosestIncomingMeteor(par2, par4); } else { chunkcoordinates = ClientHandler.lastCrashLocation; } if (chunkcoordinates != null) { double d4 = (double)chunkcoordinates.posX - par2; double d5 = (double)chunkcoordinates.posZ - par4; par6 %= 360.0D; d3 = -((par6 - 90.0D) * Math.PI / 180.0D - Math.atan2(d5, d4)); MeteorsMod.log.info("Chunk coords are NOT null"); } else { d3 = Math.random() * Math.PI * 2.0D; MeteorsMod.log.info("Chunk coords are null"); } if (!par1World.provider.isSurfaceWorld()) { d3 = Math.random() * Math.PI * 2.0D; } } if (par9) { this.currentAngle = d3; } else { double d6; for (d6 = d3 - this.currentAngle; d6 < -Math.PI; d6 += (Math.PI * 2D)) { ; } while (d6 >= Math.PI) { d6 -= (Math.PI * 2D); } if (d6 < -1.0D) { d6 = -1.0D; } if (d6 > 1.0D) { d6 = 1.0D; } this.angleDelta += d6 * 0.1D; this.angleDelta *= 0.8D; this.currentAngle += this.angleDelta; } int i; for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double)this.field_110976_a.size()) % this.field_110976_a.size(); i < 0; i = (i + this.field_110976_a.size()) % this.field_110976_a.size()) { ; } if (i != this.field_110973_g) { this.field_110973_g = i; //this.textureSheet.copyFrom(this.originX, this.originY, (Texture)this.field_110976_a.get(this.frameCounter), this.rotated); TextureUtil.func_110998_a((int[])this.field_110976_a.get(this.field_110973_g), this.field_130223_c, this.field_130224_d, this.field_110975_c, this.field_110974_d, false, false); } } } Item variables declaration: itemMeteorProximityDetector = new ItemMeteorsMod(IDs[33]).setUnlocalizedName("MeteorDetectorProximity").func_111206_d("meteors:MeteorDetectorProximity").setCreativeTab(meteorTab); itemMeteorTimeDetector = new ItemMeteorsMod(IDs[34]).setUnlocalizedName("MeteorDetectorTime").func_111206_d("meteors:MeteorDetectorTime").setCreativeTab(meteorTab); itemMeteorCrashDetector = new ItemMeteorsMod(IDs[35]).setUnlocalizedName("MeteorDetectorCrash").func_111206_d("meteors:MeteorDetectorCrash").setCreativeTab(meteorTab); And yes, I register the TextureStitchEvent in my client proxy during my mod's Pre-initialization. Any help on this would be great.
-
Write String Array in a Packet250CustomPayload??
AlexDGr8r replied to Flood2d's topic in Modder Support
You can also just use Packet.writeString(String, DataOutputStream) and Packet.readString(DataInputStream, maxLength) -
[1.4.2] Help trying to render a custom entity. [Solved]
AlexDGr8r replied to Tinker's topic in General Discussion
One thing I figured out when I spawned my meteors in my mod was that not all the data server-side when an entity spawns is there. On the client, it just uses the regular world constructor for the entity. So that may be your issue. Look at the interface IEntityAdditionalSpawnData and that might fix your issue. Oh and Tinker, don't forget to put the RenderingRegistry in a client-sided proxy. You don't want the server to be rendering stuff. -
Look at the JavaDoc information in the interface. It tells you where to implement the interface. But yes, that is how the function is used. You return a path to the texture file. Also notice how the function is passing in an ItemStack. That is there so you can distinguish between the chestplate and the rest of the armor pieces for rendering purposes.
-
Forge has an interface for this. Look at IArmorTextureProvider for a solution
-
Look at the interface IArmorTextureProvider
-
Two things for you to look into: Metadata and the method in the Block class getBlockTextureFromSideAndMetadata(int i, int j)
-
Also when you spawn the entity through code or whatever, make sure that worldObj.isRemote == false. Otherwise you won't see anything at all or you'll get a dummy entity.
-
[Solved]Only renders server-side entities? and entity spawn issues
AlexDGr8r replied to AlexDGr8r's topic in Modder Support
The meteor handler in this case is to just call my random functions for getting the meteor types and size and such. But the main purpose of the meteor handler is handle the flow of how often meteors spawn as well as where they spawn. The ticks and updates for this are on server-side though and appears to be working fine. But thank you so much for giving me this information. I was unaware of that interface and will use it to try and get things working. EDIT: Works great now. Thanks again! -
I'm having issues with my falling meteors mod in which the meteors that are "summoned" do not render properly. When the entity summoner is thrown on the ground, it creates a new instance of my EntityMeteor that passes in arguments for position, size, meteor type, etc. Then I use worldObj.spawnEntityInWorld(meteor) and it only does this when worldObj.isRemote == false. I put some debug code in my entity meteor constructors to notice that after I call my custom constructor to set the position and such, it then calls another instance of the meteor but only through the constructor that has just the world argument (e.g. public EntityMeteor(World world)). This new meteor however does not have the properties of the meteor I spawned. It is just a default regular, small meteor. So I only see that meteor rendering in the game and not the custom meteor I told it to spawn. However, when it crashes to the ground, it has the effects of the custom meteor I spawned. I know this is a lot of rambling on, but I have everything setup properly I believe. I do have rendering setup to where it only renders client side with my proxy. I shall throw some of the code and see if anyone can help me. Ask me if you need more information on the topic. EntitySummoner onImpact method: protected void onImpact(MovingObjectPosition movingobjectposition) { if (!worldObj.isRemote) { EntityMeteor meteorToSpawn = new EntityMeteor(worldObj, MeteorHandler.getMeteorSize(), posX, posZ, MeteorHandler.getMeteorType(), true); worldObj.spawnEntityInWorld(meteorToSpawn); setDead(); } } EntityMeteor class (I've stripped all the useless code) public EntityMeteor(World world) { super(world); preventEntitySpawning = true; setSize(0.98F, 0.98F); yOffset = height / 2.0F; meteorStage = MeteorStage.Falling; fallOnlyAtNight = MeteorsMod.instance.meteorsFallOnlyAtNight; MeteorsMod.log.info("Instantiated meteor: World"); meteorType = EnumMeteor.METEORITE; } public EntityMeteor(World world, int mSize, double x, double z, EnumMeteor metType, boolean summon) { this(world); size = mSize; meteorType = metType; summoned = summon; setPosition(x, 250D, z); prevPosX = x; prevPosY = 250D; prevPosZ = z; meteorStage = MeteorStage.Falling; MeteorsMod.log.info("Instantiated new meteor through passed args."); } public void onUpdate() { prevPosX = posX; prevPosY = posY; prevPosZ = posZ; motionY -= 0.039999999105930328D; moveEntity(motionX, motionY, motionZ); motionX *= 0.98000001907348633D; motionY *= 0.98000001907348633D; motionZ *= 0.98000001907348633D; if(onGround) { setDead(); if(!worldObj.isRemote) { // Does all explosions and generation of crash site WorldGenMeteorCrash worldGen = getWorldGen(); if (worldGen.generate(worldObj, rand, (int)posX, (int)posY, (int)posZ)) { worldGen.afterCrashCompleted(worldObj, (int)posX, (int)posY, (int)posZ); } } meteorStage = MeteorStage.HitGround; } } public void writeEntityToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setInteger("size", size); nbttagcompound.setInteger("meteorstage", getMeteorStageInt()); nbttagcompound.setBoolean("summoned", summoned); MeteorsMod.log.info("Writing NBT"); nbttagcompound.setInteger("metTypeID", meteorType.getID()); } public void readEntityFromNBT(NBTTagCompound nbttagcompound) { size = nbttagcompound.getInteger("size"); setMeteorStage(nbttagcompound.getInteger("meteorstage")); summoned = nbttagcompound.getBoolean("summoned"); MeteorsMod.log.info("Reading NBT"); meteorType = EnumMeteor.getTypeFromID(nbttagcompound.getInteger("metTypeID")); } Often what I get after I spawn the entity into the world is this debug code so you can see what happens: 2012-10-31 13:11:41 [iNFO] [ForgeModLoader] Instantiated meteor: World 2012-10-31 13:11:41 [iNFO] [ForgeModLoader] Instantiated new meteor through passed args. 2012-10-31 13:11:41 [iNFO] [ForgeModLoader] Instantiated meteor: World If someone has general info on this situation such as which side (client/server) things need to be done please inform me of those as well.
-
I am having the same issue. I've done everything correctly just like you, and my living entities render correctly along with my EntityThrowable. My meteors don't want to render. (Author of the Falling Meteors mod = me) They are alive and working because they cause the explosion, but they are not rendering at all.
-
Does anyone have experience with the handling of chunk loading. I have an entity that I spawn far away (out of the already loaded chunk zone) and it affects blocks around it once a certain requirement is met. Is there any way to use the Forge API to get a chunk to load (even newly generate) and then stay loaded until my entity has finished its business. I have some ideas of how to handle it, but I want to know if I'm missing something important.