Jump to content

Lambda

Members
  • Posts

    486
  • Joined

  • Last visited

Everything posted by Lambda

  1. Yeah, and I thought this when coding it, but I'm so inexperienced within NBT that I can't figure out whats wrong. So instead of creating a new NBTTagCompound, I'm going to use the one within the method itself. How would my write method be written as then? I find all enchants within the hashmap, get their registry name then how would I write it to an NBTTagList then store it to the compound? Thanks.
  2. ok, so I think I have it mostly right, however I'm getting a crash: Which points to this line: enRegStorage.setString(e.getRegistryName().toString(), e.getRegistryName().toString()); within this block of code in the writeNBT: NBTTagList enchantList = new NBTTagList(); NBTTagCompound enRegStorage = new NBTTagCompound(); for(Enchantment e : knownEnchants) { enRegStorage.setString(e.getRegistryName().toString(), e.getRegistryName().toString()); } enchantList.appendTag(enRegStorage); compound.setTag("enchantList", enchantList); Now I know the line I wrote is wrong, because visually it doesn't look right, however thinking about it, it makes since. and for reading I'm doing this: NBTTagList list = compound.getTagList("enchantList", 10); if(list != null) { for(int i = 0; i < list.tagCount(); i++) { Enchantment theEnch = Enchantment.getEnchantmentByLocation(list.getStringTagAt(i)); knownEnchants.add(theEnch); } } thanks.
  3. Oh yeah, for some reason that totally slipped my mind. So still have the hashmap, still save to it every time it needs to. However, how do I write to it then? Do I iterate through the hashmap and append it to the TagList within the write NBT method? Then how would I read it and assign it back to the map? Thanks
  4. Okay, so I got completely rid of the hashmap and I'm now using: public NBTTagList enchantNBT = new NBTTagList(); and every time an Item is used by the machine -- this line runs: this.enchantNBT.appendTag(itemInput.getEnchantmentTagList()); However, I'm having issues with finding how to save this NBTListTag to the TE's NBT. thanks for the help!
  5. Edit: I ended up using a hashset for this as because I do not want duplicate enchantments. So how to save to NBT with a hashset?
  6. Hey everyone. So I have this block that takes enchants from items and turns it into "enchant essence", this part of the block works great, however I also want the block to "learn" the enchants given, so it can be applied to a different item using said essence. I have most of that system figured out; the only part I don't is: Saving all given enchants to a hashset, then storing it to NBT Have a list of buttons (with a scroll menu) for the user to select their enchant, and have another set of buttons to display what level of enchant (have this figured out other than the scroll menu ) So my question is: How can I save the array list to NBT & create a list of buttons (via scroll menu) to display all enchants?
  7. Maybe I should do a bit of looking around before asking for more help. EnumFacing.getOpposite() seems to work great for this. Thanks for your help!
  8. Okay I changed to use the property from BlockHorizontal, but I didn't understand what you meant by: As I still don't see the problem on why its crashing. Okay, I picked up on what you meant, I changed your code to this: EnumFacing face = state.getValue(BlockHorizontal.FACING); However, the back of the machine is being ignored, not the front
  9. I changed my code: @Override public IEnergyStorage getEnergyStorage(EnumFacing facing) { IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing face = state.getValue(BlockDirectional.FACING); if(facing != face) { return this.storage; } return null; } @Override public IFluidHandler getFluidHandler(EnumFacing facing) { IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing face = state.getValue(BlockDirectional.FACING); if(facing != face) { return this.fluidStorage; } return null; } @Override public IItemHandler getItemHandler(EnumFacing facing) { IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing face = state.getValue(BlockDirectional.FACING); if(facing != face) { return this.slots; } return null; } However now it crashes: java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[down, up, north, south, west, east]} as it does not exist in BlockStateContainer{block=ce:void_infuser, properties=[facing]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204) at com.unassigned.customenchants.blocks.tile.TileEntityVoidInfuser.getEnergyStorage(TileEntityVoidInfuser.java:167) at com.unassigned.customenchants.blocks.tile.base.TileEntityBase.getCapability(TileEntityBase.java:144) at com.unassigned.customenchants.blocks.tile.base.TileEntityBase.hasCapability(TileEntityBase.java:133) at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.cacheTile(DuctUnitEnergy.java:115) at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.cacheTile(DuctUnitEnergy.java:19) at cofh.thermaldynamics.duct.tiles.DuctUnit.loadSignificantCache(DuctUnit.java:157) at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.handleTileSideUpdate(DuctUnitEnergy.java:88) at cofh.thermaldynamics.duct.tiles.DuctUnit.handleTileSideUpdate(DuctUnit.java:115) at cofh.thermaldynamics.duct.tiles.DuctUnit.updateAllSides(DuctUnit.java:231) at cofh.thermaldynamics.duct.tiles.TileGrid.onNeighborBlockChange(TileGrid.java:195) at cofh.thermaldynamics.duct.tiles.DuctUnit.onNeighborBlockChange(DuctUnit.java:283) at cofh.thermaldynamics.multiblock.MultiBlockFormer.checkMultiBlock(MultiBlockFormer.java:33) at cofh.thermaldynamics.multiblock.MultiBlockFormer.formGrid(MultiBlockFormer.java:23) at cofh.thermaldynamics.duct.tiles.DuctUnit.formGrid(DuctUnit.java:252) at cofh.thermaldynamics.duct.tiles.DuctUnit.singleTick(DuctUnit.java:349) at cofh.thermaldynamics.util.WorldGridList.tickEnd(WorldGridList.java:84) at cofh.thermaldynamics.util.TickHandler.tick(TickHandler.java:93) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_63_TickHandler_tick_WorldTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:273) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:849) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) at java.lang.Thread.run(Unknown Source) here is my block class:
  10. Hello all, So I have this directional block in my mod, that accepts 3 types of capabilities (fluids, energy and items), however, on the front of the 'machine' I want the capabilities to return null, so it does not connect to any power handlers / fluid handlers / item handlers. I have most of it working, other than finding the side for it to return null on. I have tried this: IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing front = EnumFacing.getFront(state.getBlock().getMetaFromState(state)); if(facing != front) { return this.storage; } return null; however, only 1 direction (north) actually returns null on the front. How can I find the front of a directional block? Thanks.
  11. huh. eclipse didn't flag it has deprecated, so I thought I was using the correct one. Now it works, thanks.
  12. I did however, it is in the base class: @Override public boolean hasTileEntity() { return true; } and, if moved to the block itself, it still doesn't work.
  13. Also, it seems like it doesn't interact with any of its provided capabilities (energy/fluid) as it did before.
  14. EDIT 2: Well after further testing, I find out that I cannot open/interact with my block, as if it doesnt have a TE. I have extended both but they dont seem to work. here is the new base: and here is the new block itself: package com.unassigned.customenchants.blocks; import com.unassigned.customenchants.CustomEnchants; import com.unassigned.customenchants.blocks.base.BlockTEBase; import com.unassigned.customenchants.blocks.tile.TileEntityVoidInfuser; import com.unassigned.customenchants.blocks.tile.inventory.gui.GuiHandler; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockVoidInfuser extends BlockTEBase { public BlockVoidInfuser(String name, Material materialIn) { super(name, materialIn); } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityVoidInfuser(); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ if(!world.isRemote){ TileEntityVoidInfuser tile = (TileEntityVoidInfuser)world.getTileEntity(pos); if(tile != null){ player.openGui(CustomEnchants.instance, GuiHandler.GuiTypes.VOID_INFUSER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; } return true; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } }
  15. You still haven't provided the entirety of your log I believe, there isn't any signs of a crash if not.
  16. Hey everyone, So I'm trying to implement a custom block model, however it displays in the hand, but is just an empty block when placed. Here is the .json files: - blockstate: { "variants": { "normal": { "model": "ce:void_infuser" } } } - block model: item model: { "parent": "ce:block/void_infuser" } Lastly, the block itself: Thanks!
  17. Okay, so I got the button half working. Its there and it clicks, but no hovering text. Aswell, how would I make the button go away when x condition is met: Here is what I have so far: It follows your code's basic principal and it still doesn't work; as well, what I mean by condition x is this: if(this.tileVoidInfuser.hasWater == false){ this.drawTexturedModalRect(this.guiLeft+148, this.guiTop+42, 180, 0, 19, 18); }else { this.tickTime = (55.00F / (float)this.tileVoidInfuser.runtime) * 100.00F; //55 ticks being MOST efficient this.fontRenderer.drawString((int)(this.tickTime) + "%", this.guiLeft+142, this.guiTop+75, StringUtil.COLOR_WHITE); } If hasWater is false, it displays that little icon -- I want the button to also appear/disappear with that. Thanks -- Nevermind! I found my error, I didn't iterate through the ubttons to check if the mouse is over! Thanks for my help. and this is the fix:
  18. Okay, and how do I set the button to not "highlight" itself and set the texture to what I have it as now?
  19. Yes I found this function, however is there a method to detect where the mouse is and display the hover box when its only over that area?
  20. Hello! So my block needs water to run (ex. raining/water buckets, etc) and I have a popup next to the gui inventory that shows that it needs one: I want it to have the functionality for when you hover over it, it creates a text box saying "Needs water!" or something like that. I want the text box to be similar to the ones found when you hover over an item. Thank you!
  21. Hello everyone, Can anyone tell me the key shortcut in eclipse to save and reload the current code (in debug mode) and apply it to the already running game? I'm tired of restarting making a simple change to a tile entity.' I remember doing this, however I haven't coded in nearly a year now. Thank you.
  22. Some info on what the problem is would help. (ex. actual error itself)
  23. Hello there! So I'm looking to expand a particles life time of a already existing particle (ENCHANTMENT_TABLE), I wan't this effect: however, I want the particles to reach the block from the max height of the world before disappearing, will this do it if I increase the age, or would I need to create a new particle to do this? Thank you.
  24. Alright, I was just making sure if I had to register another event. Thanks!
×
×
  • Create New...

Important Information

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