Jump to content

ThatBenderGuy

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by ThatBenderGuy

  1. I am making a modpack for 1.15.2 and I am having trouble finding the mod actually crashing during the initializing stage. I am on Forge 31.2.30. I am using Twitch client to make it so as far as I know, it won't provide a debug.log. A latest.log is produced as well as a crash-client text file but no debug log (both attached) The error is thrown from the Apotheosis mod but I contacted the developer through a github issue and he told me it was more than likely not caused by his mod but a mod that loaded before it. Are mods loaded in alphabetical order? If so that may narrow down what mod is causing the issue but regardless since a debug.log is not produced it's all just shots in the dark. latest.log crash-2020-08-09_00.15.45-client.txt
  2. When starting Minecraft I'm getting a "X has failed to load correctly" error with almost any mod I try. I've tried removing the mods causing the issue but then another mod pops up with the same error until I have no mods left. I've done some research on the matter but I can't seem to find any info on this specific error with 1.13.2. I am using the latest version of forge (25.0.219). The error that appears on the main mods is as follows: "net.minecraftforge.forgespi.language.ModFileScanData.getAnnotations()Ljava/util/List;" and optifine is having this warning: "File OptiFine_1.13.2_HD_U_E7.jar is not a valid mod file" Here is my debug.log file https://pastebin.com/raw/h8g8ZPiy
  3. I am trying to make a config for my mod that can be expanded upon. Basically each entry will have 3 things, String of a block's registry, an int, and a boolean. I tried using the annotation system for configs in this manner public final OreReg ironOreReg = new OreReg("minecraft:iron_ore", 1200, true); public final OreReg goldOreReg = new OreReg("minecraft:gold_ore", 1800, true); public final OreReg diamondOreReg = new OreReg("minecraft:diamond_ore", 2000, false); public static class OreReg { public OreReg(final String registry, final int cooldown, final boolean dropNewOre) { this.registry = registry; this.cooldown = cooldown; this.dropNewOre = dropNewOre; } @Config.Comment("The registry for the block") public String registry; @Config.Comment("The Cooldown for the ore") public int cooldown; @Config.Comment("Whether or not to drop the new ore") public boolean dropNewOre; } The config button lights up in game and when I click on it there is nothing in my mod's config menu and a blank cfg file is generated for my mod. I don't have any idea what I'm doing wrong as all I've seen is an example of using the annotation config style. Remember I need it so players can add a new block in this if they want and idk if the setup i'm going for is even right for that. -----------------EDIT---------------- Okay so I somewhat have it figured out (I forgot the static parts) but now my issue is that I can't get them neatly into an array. This is how I have it set up now public static final OreReg IRON_ORE = new OreReg("minecraft:iron_ore", 1200, true); public static final OreReg GOLD_ORE = new OreReg("minecraft:gold_ore", 1800, true); public static final OreReg DIAMOND_ORE = new OreReg("minecraft:diamond_ore", 2000, false); @Config.Comment("Holds all the ores compatible with this mod") public static final OreReg[] ORE_LIST = { IRON_ORE, GOLD_ORE, DIAMOND_ORE }; The problem with this is it creates an entry for all the OreReg objects and the ORE_LIST array but does not put them into that array. ORE_LIST remains empty on the mod config menu. I've tried changing the OreReg variables to private static final but then all that is there is the ORE_LIST array with nothing in it. What am I doing wrong?
  4. Alright thank you guys for all the help. In order to test that the underlying mechanic is working I added a right click event to my item and used this code to see if it gets the smelt result: String rLoc = new ResourceLocation(nbt.getString("parentBlock")).toString(); String itemResultStr = OreRefinerRecipes.getInstance().getSmeltResult(rLoc).getDisplayName(); player.sendMessage(new TextComponentString("Stored Block Smelt Result: " + itemResultStr)); and it returned the proper ingots So assuming all my code elsewhere is correct then my main mechanic to my mod should work. Haven't been this excited to finish a mod in a while. Thank you all so very much
  5. Okay so how does this look. // This is when the item is generated in a different class NBTTagCompound nbt = new NBTTagCompound(); nbt.setString("parentBlock", e.getState().getBlock().getRegistryName().toString()); ore.setTagCompound(nbt); //This is the method to get the smelting result private ItemStack getSmeltResult(String registryName){ Map<ItemStack, ItemStack> smeltingRecipes = FurnaceRecipes.instance().getSmeltingList(); ResourceLocation rLoc = new ResourceLocation(registryName); Block block = ForgeRegistries.BLOCKS.getValue(rLoc); ItemStack ISBlock = new ItemStack(block); for (Entry<ItemStack, ItemStack> entry : smeltingRecipes.entrySet()){ if(entry.getKey() == ISBlock){ return entry.getValue(); } } return new ItemStack(Items.AIR); } // Then what I pass into the above method ItemStack myItem = (ItemStack)this.inventory.get(0); ItemStack result = getSmeltResult(myItem.getTagCompound().getString("parentBlock"));
  6. Alright should I use getRegistryName().toString() ?
  7. Okay several things 1. Does the FurnaceRecipes.instance().getSmeltingList() return recipes from other mods? 2. I still need to get an ItemStack object from the nbt of my item (Which is currently stores strings of the modid and the unlocalized name) I figured out the for-loop to go through the FurnaceRecipes map but I need to convert the string I have on my item's NBT to a ItemStack object and I have no clue how to look up tile names and return with a ItemStack.
  8. I am currently in a conundrum where I need to get a smelting recipe for a block. The simplest way to put it is I have an item and it holds data for a block (modID and unlocalized name) as nbt tags. I want to gather what those blocks will smelt into. I have no clue if this is a job for the CraftingManager or for the OreDictionary. I have googled all over but can't find an answer. I want this to be compatible with other mods as well (at least the ones that have "ore" in their unlocalized name) An example is lets say that my item has the nbt tags for "minecraft" and "tile.iron_ore". With those two pieces of data how can I obtain what a "tile.iron_ore" will smelt into?
  9. So i've tried this: for(CoordEntry entry: connectedNodes) { double bnX = baseNodePos.getX(); double bnY = baseNodePos.getY(); double bnZ = baseNodePos.getZ(); double eX = entry.getPos().getX(); double eY = entry.getPos().getY(); double eZ = entry.getPos().getZ(); List entities = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(eX, eY, eZ, bnX, bnY, bnZ)); if(player != null) player.addChatMessage(new ChatComponentText("Entities: " + entities.size())); } but my chat message always says "Entities: 0" even when I'm in range. Fyi the baseNode position and entry position are on the same X axis but have different Z coordinates is there a better way to debug the bounding box that this.worldObj.getEntitiesWithinAABB creates? I think that would help solve my problem
  10. getEntitiesWithinAABB has a Class parameter and AxisAlignedBB parameter. I have no idea how to use that
  11. I was wondering if there was a function similar to world.getClosestPlayer. I need it something I can iterate through with a for loop. I'm basically trying to heal any player close but hurt any hostile mob close.
  12. That will be incredibly useful! I'm fine with Forge taking a while to update as that will be amazing to not have to worry about id conflicts.
  13. oh ok, well like I said I found the render file I just have no idea how to implement it. Like is there anything I have to do in my client proxy to make it work? Or does something need to be done in my main mod class?
  14. What do you mean "procedural"? Btw, found the rendering file for the tile entity but I don't see anywhere in the regular tile entity that registers the tile entity renderer How would I, for example, apply the tileEntityBeaconRender to my block? At Least to know how to implement it
  15. I looked all over the tile entity for beacon and I can't seem to find what creates the beam fired from the beacon. Any clues?
  16. Extra Terestrial Mod - V0.1 [MC 1.5.1] https://dl.dropbox.com/u/28135786/MinecraftMods/Extra%20Terrastrial%20Mod/images/logo.png[/img] Description: This mod adds new mobs, blocks, tools, and items to minecraft. The future releases of this mod is planned to help give minecraft an extra terestrial feel to it. Changelog: REQUIREMENTS: - Forge Mod Loader - Get It Here Features: - 5 Tools - Blinomium Pickaxe - Blinomium Hoe - Blinomium Spade - Blinomium Axe - Blinomium Sword - Ultimate Blinomium Tool (Paxel: 5 Tools in 1) - Cannon (Block) - Needs an obsidian block below it to function - Has a 30 Second cool down - Can be activated through right click or redstone - Raw Blinmomium Ore (Block) - Generated in the world, slightly rarer than diamond - 4 Items - Uncharged Cannon - Blinomium Crystal - Can be eaten to obtain super digging speed but at the same time nausia and poison - Blinomium Shard - A Blinomium Shard has a 8% chance of being obtained when hitting an enemy with the Blinomium Sword - Impure Blinomium Ore - New Armor - Wearing full armor gives you the effects: Night Vision/Fire Resistance 2 Planned Features: - Lazer animation to the cannon block - More Alien Mobs - Custom Render Models for all the equipment - Custom Vehicles (Spaceships) - Cannon Requiring a special fuel to operate Images: Recipes: Downloads: Version 0.1 For 1.5.1 - Direct Installation Instructions: Install like any other Forge Mod, Take the zip file and put it in appdata/.minecraft/mods/
  17. Ok so I started a thread a while ago about my original issue of my tile entities not saving data. Well now it does save data but for some reason world.createExplosion method no longer works but only on block that were saved through a tile entity. Here is my tile entity class CannonTileEntity.java package com.biosystemstudios; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class CannonTileEntity extends TileEntity{ private boolean powered; private int frontX; private int frontY; private int frontZ; private long coolDownTime; private String frontAxis; private boolean negativeOnAxis; /** * Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); this.powered = par1NBTTagCompound.getBoolean("power"); this.frontX = par1NBTTagCompound.getInteger("fx"); this.frontY = par1NBTTagCompound.getInteger("fy"); this.frontZ = par1NBTTagCompound.getInteger("fz"); this.coolDownTime = par1NBTTagCompound.getLong("cdt"); this.frontAxis = par1NBTTagCompound.getString("fa"); this.negativeOnAxis = par1NBTTagCompound.getBoolean("na"); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setBoolean("power", powered); par1NBTTagCompound.setInteger("fx", frontX); par1NBTTagCompound.setInteger("fy", frontY); par1NBTTagCompound.setInteger("fz", frontZ); par1NBTTagCompound.setLong("cdt", coolDownTime); par1NBTTagCompound.setString("fa", frontAxis); par1NBTTagCompound.setBoolean("na", negativeOnAxis); } public boolean getPowered(){ return powered; } public void powerOn(){ powered = true; } public String destroy(){ if(coolDownTime <= (this.worldObj.getTotalWorldTime())){ if(this.worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.obsidian.blockID){ double Dir = 1.0; float power = 2.0f; if(negativeOnAxis){Dir = -1.0;} for(int steps = 1; steps < 256; steps++){ if(steps<=3) power += 0.5f; if(frontAxis == "x"){ this.worldObj.setBlock(frontX + (int)(steps*Dir), frontY, frontZ, 0); this.worldObj.createExplosion(null, frontX + (steps*Dir), ((double)frontY)+0.5, frontZ, power, true); } if(frontAxis == "z"){ this.worldObj.setBlock(frontX, frontY, frontZ + (int)(steps*Dir), 0); this.worldObj.createExplosion(null, frontX, frontY+0.5, ((double)frontZ) + (steps*Dir), power, true); } } powered = false; coolDownTime = (this.worldObj.getTotalWorldTime()) + 29*20; return "Fired Cannon, please wait " + getCoolDownTime() + " Seconds Before Using Again."; }else{ powered = false; return "Cannon needs an obsidian base to operate"; } }else{ powered = false; return "Cannon Cooling down: "+getCoolDownTime() + " Seconds Left"; } } public void setFrontOfCannon(int x, int y, int z){ frontX = x; frontY = y; frontZ = z; } public void setFrontDirection(String axis, boolean nDirection){ frontAxis = axis; negativeOnAxis = nDirection; } public long getCoolDownTime(){ return ((coolDownTime - this.worldObj.getTotalWorldTime())/20)+1; } public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); } @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { NBTTagCompound tag = packet.customParam1; this.readFromNBT(tag); this.powered = tag.getBoolean("power"); this.frontX = tag.getInteger("fx"); this.frontY = tag.getInteger("fy"); this.frontZ = tag.getInteger("fz"); this.coolDownTime = tag.getLong("cdt"); this.frontAxis = tag.getString("fa"); this.negativeOnAxis = tag.getBoolean("na"); } } I also get this thrown in at random in my console and through debugging my code I found out it's actually just not reaching the if statements that check the axis. Using this version of my destroy() method public String destroy(){ if(coolDownTime <= (this.worldObj.getTotalWorldTime())){ if(this.worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.obsidian.blockID){ double Dir = 1.0; float power = 2.0f; if(negativeOnAxis){Dir = -1.0;} System.out.println(frontAxis); for(int steps = 1; steps < 100; steps++){ System.out.println("Reached 'for' statement"); if(steps<=3) power += 0.5f; if(frontAxis == "x"){ System.out.println("Reached explosion statement"); this.worldObj.setBlock(frontX + (int)(steps*Dir), frontY, frontZ, 0); this.worldObj.createExplosion(null, (double)(frontX + (steps*Dir)), ((double)frontY)+0.5, (double)frontZ, power, true); }else if(frontAxis == "z"){ System.out.println("Reached explosion statement"); this.worldObj.setBlock(frontX, frontY, frontZ + (int)(steps*Dir), 0); this.worldObj.createExplosion(null, frontX, frontY+0.5, ((double)frontZ) + (steps*Dir), power, true); } } powered = false; coolDownTime = (this.worldObj.getTotalWorldTime()) + 29*20; return "Fired Cannon, please wait " + getCoolDownTime() + " Seconds Before Using Again."; }else{ powered = false; return "Cannon needs an obsidian base to operate"; } }else{ powered = false; return "Cannon Cooling down: "+getCoolDownTime() + " Seconds Left"; } } The console feeds back "Reached 'for' statement" but never returns "Reached explosion statement" And remember this is only happening when I place the block down, activate it, then leave and re-enter the world. When I do it before leaving the world the console returns "Reached for statement Reached Explosion statement" /: so confused
  18. Okay so I finally get my tile entity to correctly save data but now I'm getting this message in my console And here is my code package com.biosystemstudios; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class CannonTileEntity extends TileEntity{ private boolean powered; private int frontX; private int frontY; private int frontZ; private long coolDownTime; private String frontAxis; private boolean negativeOnAxis; /** * Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); this.powered = par1NBTTagCompound.getBoolean("power"); this.frontX = par1NBTTagCompound.getInteger("fx"); this.frontY = par1NBTTagCompound.getInteger("fy"); this.frontZ = par1NBTTagCompound.getInteger("fz"); this.coolDownTime = par1NBTTagCompound.getLong("cdt"); this.frontAxis = par1NBTTagCompound.getString("fa"); this.negativeOnAxis = par1NBTTagCompound.getBoolean("na"); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setBoolean("power", powered); par1NBTTagCompound.setInteger("fx", frontX); par1NBTTagCompound.setInteger("fy", frontY); par1NBTTagCompound.setInteger("fz", frontZ); par1NBTTagCompound.setLong("cdt", coolDownTime); par1NBTTagCompound.setString("fa", frontAxis); par1NBTTagCompound.setBoolean("na", negativeOnAxis); } public boolean getPowered(){ return powered; } public void powerOn(){ powered = true; } public String destroy(){ if(coolDownTime <= (this.worldObj.getTotalWorldTime())){ if(this.worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.obsidian.blockID){ double Dir = 1.0; float power = 2.0f; if(negativeOnAxis){Dir = -1.0;} for(int steps = 1; steps < 256; steps++){ if(steps<=3) power += 0.5f; if(frontAxis == "x"){ this.worldObj.setBlock(frontX + (int)(steps*Dir), frontY, frontZ, 0); this.worldObj.createExplosion(null, frontX + (steps*Dir), ((double)frontY)+0.5, frontZ, power, true); } if(frontAxis == "z"){ this.worldObj.setBlock(frontX, frontY, frontZ + (int)(steps*Dir), 0); this.worldObj.createExplosion(null, frontX, frontY+0.5, ((double)frontZ) + (steps*Dir), power, true); } } powered = false; coolDownTime = (this.worldObj.getTotalWorldTime()) + 29*20; return "Fired Cannon, please wait " + getCoolDownTime() + " Seconds Before Using Again."; }else{ powered = false; return "Cannon needs an obsidian base to operate"; } }else{ powered = false; return "Cannon Cooling down: "+getCoolDownTime() + " Seconds Left"; } } public void setFrontOfCannon(int x, int y, int z){ frontX = x; frontY = y; frontZ = z; } public void setFrontDirection(String axis, boolean nDirection){ frontAxis = axis; negativeOnAxis = nDirection; } public long getCoolDownTime(){ return ((coolDownTime - this.worldObj.getTotalWorldTime())/20)+1; } public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); } @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { NBTTagCompound tag = packet.customParam1; this.readFromNBT(tag); } } The thing about my tile entity saving data is that it will remember the private long coolDownTime variable but when I save and quit and leave my world it has seemed to forget all the other vars. I'm thinking it has something to do with the ForgeModLoader message in my console. Any thoughts or ideas on how to fix this?
  19. Thank you thank you thank you that was the problem. It was the only thing preventing me from releasing this mod now time to prep for the release
  20. nope because I have this in my @Init GameRegistry.registerTileEntity(CannonTileEntity.class, "CannonEntityTile"); P.S. Congrats on the 1000th post
  21. ok so here are some of the methods I added to hopefully fix my issue but alas it is still not working public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); } @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { NBTTagCompound tag = packet.customParam1; this.powered = tag.getBoolean("power"); this.frontX = tag.getInteger("fx"); this.frontY = tag.getInteger("fy"); this.frontZ = tag.getInteger("fz"); this.coolDownTime = tag.getLong("cdt"); this.frontAxis = tag.getString("fa"); this.negativeOnAxis = tag.getBoolean("na"); this.readFromNBT(tag); } /: this is starting to get extremely frustrating
  22. Hmm can't seem to find anything on onDataPacket /:
  23. Hmmm considering you're having the same issue I think the both of us are just missing like 1-5 lines of code from making these NBT Tag things work lol
  24. It's strange because I'm using TileEntityNote (Tile Entity for the note block) as a reference but the solution is just not coming to me
  25. So here are my 2 classes (The block and tile entity) Block package com.biosystemstudios; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class CannonBlock extends Block implements ITileEntityProvider { private Icon blockTop; private Icon blockFront; private int xFront; private int zFront; private int yFront; private Entity player; public CannonBlock(int ID) { super(ID, Material.iron); this.setCreativeTab(CreativeTabs.tabBlock); } /** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World par1World) { return new CannonTileEntity(par1World); } /** * set a blocks direction */ private void setDefaultDirection(World par1World, int par2, int par3, int par4) { if (!par1World.isRemote) { int l = par1World.getBlockId(par2, par3, par4 - 1); int i1 = par1World.getBlockId(par2, par3, par4 + 1); int j1 = par1World.getBlockId(par2 - 1, par3, par4); int k1 = par1World.getBlockId(par2 + 1, par3, par4); byte b0 = 3; if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1]) { b0 = 3; } if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l]) { b0 = 2; } if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1]) { b0 = 5; } if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1]) { b0 = 4; } par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2); } } public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; yFront = y; CannonTileEntity cannontileentity = (CannonTileEntity)par1World.getBlockTileEntity(x, y, z); if (l == 0) { par1World.setBlockMetadataWithNotify(x, y, z, 2, 2); xFront = x; zFront = z-1; if(cannontileentity != null){ cannontileentity.setFrontOfCannon(xFront, yFront, zFront); cannontileentity.setFrontDirection("z", true); } } if (l == 1) { par1World.setBlockMetadataWithNotify(x, y, z, 5, 2); xFront = x+1; zFront = z; if(cannontileentity != null){ cannontileentity.setFrontOfCannon(xFront, yFront, zFront); cannontileentity.setFrontDirection("x", false); } } if (l == 2) { par1World.setBlockMetadataWithNotify(x, y, z, 3, 2); xFront = x; zFront = z+1; if(cannontileentity != null){ cannontileentity.setFrontOfCannon(xFront, yFront, zFront); cannontileentity.setFrontDirection("z", false); } } if (l == 3) { par1World.setBlockMetadataWithNotify(x, y, z, 4, 2); xFront = x-1; zFront = z; if(cannontileentity != null){ cannontileentity.setFrontOfCannon(xFront, yFront, zFront); cannontileentity.setFrontDirection("x", true); } } } @Override public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("et:cannonOther"); this.blockFront = par1IconRegister.registerIcon("et:cannonFront"); this.blockTop = par1IconRegister.registerIcon("et:cannonTop"); } public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) { /* * par1 = 1 - Top * par1 = 0 - Bottom */ return par1 == 1 ? this.blockTop : (par1 == 0 ? this.blockIcon : (par1 != par2 ? this.blockIcon : this.blockFront)); } public void onBlockAdded(World par1World, int x, int y, int z) { super.onBlockAdded(par1World, x, y, z); this.setDefaultDirection(par1World, x, y, z); } public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; }else{ CannonTileEntity cannontileentity = (CannonTileEntity)par1World.getBlockTileEntity(x, y, z); if(cannontileentity != null){ cannontileentity.powerOn(); if(cannontileentity.getPowered() == true){ player.sendChatToPlayer(cannontileentity.destroy()); } } return true; } } } TileEntity package com.biosystemstudios; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class CannonTileEntity extends TileEntity{ private boolean powered; private World world; private int frontX; private int frontY; private int frontZ; private long coolDownTime; private String frontAxis; private boolean negativeOnAxis; public CannonTileEntity(World par1World){ world = par1World; } /** * Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); this.powered = par1NBTTagCompound.getBoolean("power"); this.frontX = par1NBTTagCompound.getInteger("fx"); this.frontY = par1NBTTagCompound.getInteger("fy"); this.frontZ = par1NBTTagCompound.getInteger("fz"); this.coolDownTime = par1NBTTagCompound.getLong("cdt"); this.frontAxis = par1NBTTagCompound.getString("fa"); this.negativeOnAxis = par1NBTTagCompound.getBoolean("na"); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setBoolean("power", this.powered); par1NBTTagCompound.setInteger("fx", frontX); par1NBTTagCompound.setInteger("fy", frontY); par1NBTTagCompound.setInteger("fz", frontZ); par1NBTTagCompound.setLong("cdt", coolDownTime); par1NBTTagCompound.setString("fa", this.frontAxis); par1NBTTagCompound.setBoolean("na", this.negativeOnAxis); } public boolean getPowered(){ return powered; } public void powerOn(){ powered = true; } public String destroy(){ if(coolDownTime <= (world.getTotalWorldTime())){ if(world.getBlockId(xCoord, yCoord-1, zCoord) == Block.obsidian.blockID){ double Dir = 1.0; float power = 2.0f; if(negativeOnAxis){Dir = -1.0;} for(int steps = 1; steps < 256; steps++){ if(steps<=3) power += 0.2f; if(frontAxis == "x") world.createExplosion(null, frontX + (steps*Dir), ((double)frontY)+0.5, frontZ, power, true); if(frontAxis == "z") world.createExplosion(null, frontX, frontY+0.5, ((double)frontZ) + (steps*Dir), power, true); } powered = false; coolDownTime = (world.getTotalWorldTime()) + 30*20; return "Fired Cannon, please wait " + getCoolDownTime() + " Seconds Before Using Again."; }else{ return "Cannon needs an obsidian base to operate"; } }else{ return "Cannon Cooling down: "+getCoolDownTime() + " Seconds Left"; } } public void setFrontOfCannon(int x, int y, int z){ frontX = x; frontY = y; frontZ = z; } public void setFrontDirection(String axis, boolean nDirection){ frontAxis = axis; negativeOnAxis = nDirection; } public long getCoolDownTime(){ return (coolDownTime - world.getTotalWorldTime())/20; } } It works fine when I first place the block down. The cool down timer works, the front of block values but when I save and quit and re-enter the world and right click the block it seems to have forgotten not only the cool down timer but also where the front of the block is (instantiated in my block class) Not too sure what is going wrong. I think it may have something to do with my NBTTagCompound in my tile entity class but not quite sure
×
×
  • Create New...

Important Information

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