Jump to content

Filipsi

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by Filipsi

  1. You are writing data to packet at TileEntity#getDescriptionPacket, but you have to implement reading as well. You need to override TileEntity#onDataPacket, you can get NBTTagCommpound from the packet using S35PacketUpdateTileEntity#func_148857_g.
  2. Where do you register your event? KeyInputEvent is fired on client side, so it should be registered in your client proxy on init. Also, it would probably be a good idea to mark KeyPressEvents class as Client-Side only if you are using it only for KeyInput handling. As far as I know, there is no problem with your code. Tested it in 1.7.10 and worked fine.
  3. NBT can store entire ItemStacks. Take a look at: ItemStack#writeToNBT(NBTTagCompound) ItemStack#loadItemStackFromNBT(NBTTagCompound) EDIT: What list? ArrayList? LinkedList? How do you store your items? What do you need a list for? If you want to just save and load items, array would be better.
  4. Block#getIcon(int, int) is used to create EntityDiggingFX, try override that.
  5. Possible? Yes, of course. Complex? Somewhat. Like allways, know the java first. Let's start with GUIs and Containers, here are some tutorials: (1.6.4) Containers and GUIs on Forge wiki Jabelar's Minecraft Forge Modding Tutorials: Tips For GUI and Input Google is your frend.
  6. Well, there is this, but it goes slow: MinecraftForge/Documentation
  7. I hope that you know at last basic Java, if not I would suggest to start there. So, if you want to make an arrow, a good start would be to take a look at vanilla's EntityArrow. Checking for collision with an entity is done in EntityArrow#onUpdate. Spawning a lightning should be done on server side, you can spawn EntityLightningBolt using World#addWeatherEffect
  8. Here is a few values: link Just combine it with a string. TextColors.darkGrey + "this string has color"
  9. You should be really using @Override annotations. About your problem: You have to read the items from NBT in the same order in which they were saved. You are saving two shorts and then tagList, so you have to read them in the same order.
  10. You are not overriding writeToNBT and readFromNBT correctly. Also readFromNBT is misspelled (redFromNBT).
  11. 1.) TileEntityFusionReactorBlock should implement ISidedInventory, you have methods from the interface in there, but implementation is missing 2.) Like Draco18s said, the ReactorBlock (dummy) should have reference to the main block's TE. This will allow you to insert items to the main's block inventory using ISidedInventory methods
  12. First of all, nice model. Could you post TileEntities for main and dummy block? Also, there is a tutorial on how to make Multiblock structures by MineMaarten. You can take a look at the code, If I remember correctly there is a part about sharing inventories. Here is a
  13. I did it like this: I created a map with TileEntities around the block, witch is updated with onNeighborBlockChange and then if the TileEntity is IEnergyReceiver I try to push energy to it. shareEnergyWithNeighbors pushEnergy getTileEntityNeighborMap
  14. Yeah, right. GuiScreen is Client-Sided too. But that could be solved it by using enum or numerical IDs.
  15. You can't use direct call to Minecraft class, because it has annotation @SideOnly(Side.CLIENT), meaning that Minecraft class is not packed during compilation with dedicated server, so if you even try to reference it, even if you don't use it on server (with world.isRemote condition), dedicated server will crash with java.lang.classnotfoundexception, because that class don't even exists. So, you have to call it through SidedProxy. Something like this: public class CommonProxy { public void displayGui(short guiId) { //NO-OP } } public class ClientProxy extends CommonProxy { @Override public void displayGui(short guiId) { switch(guiId) { case 0: Minecraft.getMinecraft().displayGuiScreen(new GuiTest()); break; } } } Edit: Fixed the code, thanks to diesieben07 for pointing to my mistake
  16. The problem is that you are opening GUI only on client side. Try something like this: @Override onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityCarbonPressurizer) player.openGui(Main.instance, GUIs.carbon_pressurizer.ordinal(), world, x, y, z); return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); }
  17. Okay, I got it! I have created modified version of RenderBlocks class and changed renderBlockAsItem() method for render pass 32 that is used for BlockWall. It works perfectly:
  18. Good day! I am trying to make a book for my mod for players to know how to build structures in my mod. I am using renderItemIntoGUI() method in RenderItem class. And I have a slight problem. And that problem is that I need to force rendering type to some Blocks. Like BlockWall, that is defaultly rendered with two block attachments on sides (picture below) and I need to render it without any connection. So, my question is: Is there any clever way to force block rendering? I am using: Minecraft 1.7.10 Forge 10.13.2.1291
  19. Hello, I have a problem with icon registration using TextureStitchEvent.Post event. When I try to load any texture this is what I get: TextureAtlasSprite{name='testmod:ItemTest', frameCount=0, rotated=false, x=0, y=0, height=0, width=0, u0=0.0, u1=0.0, v0=0.0, v1=0.0} Texture is located in: assets/testmod/textures/items/ItemTest.png When I try to load this texture using a registerIcons in Item class it works perfectly. I am using: Minecraft 1.7.10 Forge 10.13.2.1291 TextureStitchEventHandler class with @SubscribeEvent public class TextureStitchEventHandler { public static IIcon IconTest; @SubscribeEvent public void registerIcons(TextureStitchEvent.Post event) { TextureMap map = event.map; if(map.getTextureType() == 1) { IconTest = map.registerIcon(getTexturePath("ItemTest")); } } private String getTexturePath(String fileName) { return References.ModId.toLowerCase() + ":" + fileName; } } TextureStitchEventHandler registration in ClientProxy public class ClientProxy extends CommonProxy { @Override public void Init() { MinecraftForge.EVENT_BUS.register(new TextureStitchEventHandler()); } } Thanks for any help!
  20. Yeeh, but I think that entity from world.setTileEntity will be overrided by createNewTileEntity Don't know, how to check if TileEntity is allready created in createNewTileEntity(World world, int meta) without x,y,z if(itemstack.stackTagCompound != null){ NBTTagCompound compound = itemstack.getTagCompound(); TileEntityModularWorktable te = new TileEntityModularWorktable(); for(int i = 0; i < 6; i++){ te.setSideModule(compound.getInteger("sideModule" + i), i); } world.setTileEntity(x, y, z, te); } @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityModularWorktable(); }
  21. Hi, I am trying to pick up my block with hammer with saved side configuration. Saving part works ok, but I can't get the loading part working, becouse when i try do it during placeBlockAt(), TileEntity of the block is not created yet. I will be glad for any help. (Sorry for my english, it is not my native language) Saving NTB @Override public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { super.onBlockClicked(world, x, y, z, player); if(!world.isRemote){ TileEntityModularWorktable te = (TileEntityModularWorktable) world.getTileEntity(x, y, z); if(te != null && te instanceof TileEntityModularWorktable){ ItemStack currItem = player.inventory.getCurrentItem(); if(currItem != null){ if(currItem.getItem() instanceof ItemPrecisionWorkhammer){ ItemStack itemstack = new ItemStack(BlockRegistry.modularWorktable); NBTTagCompound compound = new NBTTagCompound(); for(int i = 0; i < 6; i++){ compound.setInteger("sideModule" + i, te.getSideModule(i)); } itemstack.setTagCompound(compound); EntityItem entity = new EntityItem(world, x + 0.5F, y + 0.5F, z + 0.5F, itemstack); world.setBlockToAir(x, y, z); world.spawnEntityInWorld(entity); currItem.damageItem(1, player); System.out.println("Picked up by ItemPrecisionWorkhammer"); } } } } } Custom ItemBlock Loading NBT to TileEntity @Override public boolean placeBlockAt(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { if(itemstack.stackTagCompound != null){ NBTTagCompound compound = itemstack.getTagCompound(); TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityModularWorktable){ for(int i = 0; i < 6; i++){ ((TileEntityModularWorktable)te).setSideModule(compound.getInteger("sideModule" + i), i); } } } return super.placeBlockAt(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); }
  22. Thanks! I thought that I called it in main class. Silly mistake.
  23. Hi, I need some help with my project. I am trying to create custom furnace. I have GUI working and now I am in process of coding container for my furnace. And I bumped in to a problem. In container for my furnace i have this code: @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { if(i == FuelSlot){ return fuelRegistry.isFuel(itemstack); }else{ return false; } } And this is my FuelRegistry class: public class fuelRegistry { private static String[] fuelRegister; public fuelRegistry(){ fuelRegister = new String[] { Items.coal.getUnlocalizedName(), Items.stick.getUnlocalizedName(), Blocks.planks.getUnlocalizedName(), Blocks.log.getUnlocalizedName(), Blocks.coal_block.getUnlocalizedName() }; } public static boolean isFuel(ItemStack itemstack){ return Arrays.asList(fuelRegister).contains(itemstack.getUnlocalizedName()); } } When I am trying to check if furnace can accept fuel this way, it crashes and I have no idea why. I also tryed it with ItemStack array and foreach instead of contains. Thank you for any help. Filipsi
×
×
  • Create New...

Important Information

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