Jump to content

Pardeep

Forge Modder
  • Posts

    59
  • Joined

  • Last visited

Everything posted by Pardeep

  1. So I tried your advice and it didn't work. The NBT data does not seem to be updating on the server side. Is there no way I can change the variable on the server side in the GUI?
  2. I'm making a mod where, at the core, I want to edit custom variables of a player through a button on a gui, opened from right-clicking a block. The only problem is in the GUI class there's no way to get the modification to happen on the server side (as far as I know). Is there a way I can either: 1) Send a client->server packet for NBT, because as far as I know there isn't a PacketHandler method for sending to the server AND specifying which player gets it. OR 2) Some way of changing the variables on the server side within the GUI, perhaps through other classes. All help is appreciated. Thanks in advance.
  3. Thank you to both of you for your help. It now works. I took coolAlias's advice on re-verting everything I changed in GL11, and I used the reference to the pumpkin overlay from TechoMan to help me reproduce the overlay code. All I did was take the code from the pumpkin overlay and stick it in the RenderGameOverlayEvent.Post, with the ElemenType checked for as HELMET.
  4. I'll try that Alias, thank you. I'll play around with it abit first and then report back as to if it worked, in case you want to use it yourself.
  5. I would like to know a way to use the RenderGameOverlayEvent to render something similar to what a pumpkin does (i.e. render's the pumpkin blur overlay on screen but BEHIND all the HUD things). I've tried .Post and .Pre for ElementType of HELMET, ALL and some of the hud stuff, such as EXPERIENCE. If I do .Pre, it renders correctly (my overlay), BUT all the HUD stuff disappears. If I do .Post, it renders correctly, but it renders ABOVE the HUD stuff (i.e. I have a semi-white texture and all the HUD stuff gains the effect of the texture). Does anyone know any way to achieve what I require? Thanks in advance.
  6. Hm, I see what you mean. I ran loads of tests and can confirm the code is running twice, but I'm not sure how to find out which pass of the code causes some of the variables to be null and how to fix this. What did you do when you had your issue?
  7. Concerned code inside my eventhandler: @SubscribeEvent public void onEntityRightClicked(EntityInteractEvent event) { //Current item in hand ItemStack itemstack = event.entityPlayer.inventory.getCurrentItem(); //Cow if(event.target instanceof EntityCow) { if (itemstack != null && itemstack.getItem() == LifeMod.getItem("lm_item_food_mugempty") && !event.entityPlayer.capabilities.isCreativeMode) { if (--itemstack.stackSize == 0) { event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, new ItemStack(LifeMod.getItem("lm_food_otherdrinks_mugmilk"))); } else if(event.entityPlayer.inventory.addItemStackToInventory(new ItemStack(LifeMod.getItem("lm_food_otherdrinks_mugmilk"))) == false); { event.entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(LifeMod.getItem("lm_food_otherdrinks_mugmilk")), false); } } } } What works fine is when I right click a cow with 1 mug, that slot is replaced with 1 mug of milk. Also, when I have a full inventory, the mug of milk is dropped. What does NOT work fine is that when I have an empty or semi-empty inventory, the milk mug is added (or if a stack of that sort exists, merges to that), BUT a milk mug is ALSO dropped, instead of ONLY just being added to the inventory. Does anyone know how to fix this?
  8. I had it registered anyway. But, now it works so thank you
  9. As soon as I placed the block in the world this crash report appeared and the game crashed: ---- Minecraft Crash Report ---- // Who set us up the TNT? Time: 21/04/14 18:17 Description: Exception ticking world java.lang.RuntimeException: class lifemod.blocks.toilet.TileEntityToilet is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:100) at lifemod.blocks.toilet.TileEntityToilet.writeToNBT(TileEntityToilet.java:37) at lifemod.blocks.toilet.TileEntityToilet.getDescriptionPacket(TileEntityToilet.java:51) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendTileToAllPlayersWatchingChunk(PlayerManager.java:521) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendChunkUpdate(PlayerManager.java:463) at net.minecraft.server.management.PlayerManager.updatePlayerInstances(PlayerManager.java:94) at net.minecraft.world.WorldServer.tick(WorldServer.java:194) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:682) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:100) at lifemod.blocks.toilet.TileEntityToilet.writeToNBT(TileEntityToilet.java:37) at lifemod.blocks.toilet.TileEntityToilet.getDescriptionPacket(TileEntityToilet.java:51) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendTileToAllPlayersWatchingChunk(PlayerManager.java:521) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendChunkUpdate(PlayerManager.java:463) at net.minecraft.server.management.PlayerManager.updatePlayerInstances(PlayerManager.java:94) at net.minecraft.world.WorldServer.tick(WorldServer.java:194) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Player715'/240, l='New World', x=257.46, y=4.00, z=-746.51]] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: -5659666563785698564 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: Level spawn location: World: (254,4,-751), Chunk: (at 14,0,1 in 15,-47; contains blocks 240,0,-752 to 255,255,-737), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513) Level time: 3368 game time, 3368 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 143259 (now: false), thunder time: 17049 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:682) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_05, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 912588064 bytes (870 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 4715 (264040 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.01-pre FML v7.2.156.1060 Minecraft Forge 10.12.1.1060 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.156.1060} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.1.1060} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available ss97lifemod{1.0.0} [Life Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 596 (33376 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player715'/240, l='New World', x=257.46, y=4.00, z=-746.51]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
  10. I have a block with a custom model and I have all the code setup so that it renders correctly and the same "front" face points towards the player, depending on from which direction the player places the block (e.g. rotates like a furnace). However, once I exit the world and reload it, the block automatically rotates back to standard position (facing south), instead of staying in the orientation it has been set to. Anyone know what the issue is? I think it has something to do with the NBT data, but i'm not sure why. CODE: Block: package lifemod.blocks.toilet; import lifemod.LifeMod; import lifemod.lifepanel.LifePanel; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class BlockToilet extends BlockContainer { public BlockToilet() { super(Material.rock); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityToilet(); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack) { int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3; int newFacing = 0; if (facing == 0) { newFacing = 2; } if (facing == 1) { newFacing = 5; } if (facing == 2) { newFacing = 3; } if (facing == 3) { newFacing = 4; } TileEntity te = world.getTileEntity(i, j, k); if (te != null && te instanceof TileEntityToilet) { TileEntityToilet tet = (TileEntityToilet) te; tet.setFacingDirection(newFacing); world.markBlockForUpdate(i, j, k); } } } TileEntity package lifemod.blocks.toilet; import lifemod.packethandler.PacketHandler; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; public class TileEntityToilet extends TileEntity { private int facingDirection; public int getFacingDirection() { return this.facingDirection; } public void setFacingDirection(int par1) { this.facingDirection = par1; } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); facingDirection = nbttagcompound.getInteger("facingDirection"); } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); nbttagcompound.setInteger("facingDirection", facingDirection); } } TileEntitySpecialRenderer: package lifemod.blocks.toilet; import lifemod.LifeMod; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; public class TileEntitySpecialRendererToilet extends TileEntitySpecialRenderer { private final ModelToilet model = new ModelToilet(); private static final ResourceLocation texture = new ResourceLocation("lifemod:textures/blocks/toilet.png"); public void render(TileEntityToilet te, double x, double y, double z, float scale) { GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); this.bindTexture(texture); //Rotates model, as for some reason it is initially upside (180 = angle, 1.0F at end = about z axis) GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); int facing = te.getFacingDirection(); int k = 0; //South if (facing == 2) { k = 0; } //North if (facing == 3) { k = 180; } //East if (facing == 4) { k = -90; } //West if (facing == 5) { k = 90; } //Rotates model on the spot, depending on direction, making the front always to player) (k = angle, 1.0F in middle = about y axis) GL11.glRotatef(k, 0.0F, 1.0F, 0.0F); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_ALPHA_TEST); this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { this.render((TileEntityToilet)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); } } Inside the ClientProxy: ClientRegistry.bindTileEntitySpecialRenderer(TileEntityToilet.class, new TileEntitySpecialRendererToilet()); Thanks in advance
  11. My eclipse is setup correctly and I can mod and run and it's all fine. But my problem is this: In the reference libraries, you can look at all the minecraft vanilla files e.g. net.minecraft.entity.player.EntityPlayer.class BUT, if I want to open any file from FML or MinecraftForge, it just says the source is not attached, even though the location of the source is correct (as I can see all the vanilla minecraft stuff). An example is net.minecraftforge.event.entity.player.PlayerUseItemEvent.class I've tried running setupDecompWorkspace, setupDevWorkspace, deleting and reinstalling everything. Still none of the forge or fml source is visible in eclipse. Any help (if it helps, I use JDK8u5, but I have eclipse already patched for that so that shouldn't be the issue). Thanks in advance.
  12. Is there some sort of event that detects if a certain item of food has been eaten? I have this stat thing that needs to go up by a certain value depending on which vanilla food has been eaten. Thanks in advance.
  13. I've added a button to the GuiOptions of vanilla minecraft using Java Reflection. However, now I don't know how to get it so that a new GuiOpens when the button is pressed, as I don't know how to access the actionPerformed method of GuiOptions and use it. Is there a way to do this, or is there possibly an eventhandler I could use? Thanks in advance? Here's my code if it helps: public void onRenderTick(RenderTickEvent event) { try { GuiScreen activeGUI = Minecraft.getMinecraft().currentScreen; if(activeGUI != null && activeGUI instanceof GuiOptions) //whatever GUI you want to add a/multiple button/s to { Field field1 = GuiScreen.class.getDeclaredField("buttonList"); field1.setAccessible(true); List buttonList = (List) field1.get(activeGUI); buttonList.add(new CustomButton(300, 1, 1, 100, 20, "Update Checker")); //you have to make a class extending GuiButton to add function to your button } } catch(Exception e) { e.printStackTrace(); } } NB: the button is visible 100% and works. Just don't know how to add function.
  14. Thank you both. I figured it out now. My getBlock() method was returning null. I got it pointing in the right direction in the end. Thank you again. And @mjhotdog, I don't think there were many or any for that matter of those isRemote booleans in the vanilla code, but thanks for mentioning this as usually I miss these out.
  15. I have this mod that adds something very closely related to the furnace (in function terms, i.e. it smelts something and when that happens, it changes its texture and emits light) and in code terms (it's more or less furnace code tweaked). When I use it in single player, it works 100% fine. However in a server, the following log appears. Error log of server: net.minecraft.util.ReportedException: Ticking block entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:745) ~[MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:339) ~[DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:650) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:528) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:787) [MinecraftServer$2.class:?] Caused by: java.lang.NullPointerException at net.minecraft.world.chunk.storage.ExtendedBlockStorage.func_150818_a(ExtendedBlockStorage.java:100) ~[ExtendedBlockStorage.class:?] at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:685) ~[Chunk.class:?] at net.minecraft.world.World.setBlock(World.java:549) ~[World.class:?] at net.minecraft.world.World.setBlock(World.java:697) ~[World.class:?] at freshpower.blocks.steelifier.BlockSteelifier.updateFurnaceBlockState(BlockSteelifier.java:197) ~[blockSteelifier.class:?] at freshpower.blocks.steelifier.TileEntitySteelifier.updateEntity(TileEntitySteelifier.java:303) ~[TileEntitySteelifier.class:?] at net.minecraft.world.World.updateEntities(World.java:2148) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:536) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:739) ~[MinecraftServer.class:?] The BlockSteelifier line pointed to is: par1World.setBlock(par2, par3, par4, FreshPower.getBlock("fp_steelifierActive")); under the method public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4) The TileEntitySteelifer line is: BlockSteelifier.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); under the method public void updateEntity() I think the error log has something to do with the entity updating. The error occurs when the block has sufficient stuff in the slots to "smelt". But nothing smelts, the block doesn't change to the illuminated one and this error pops up. Moments after, I get kicked out server given a TimeOutException. Anyone know how to fix this. I know this code pointed at is identical to the BlockFurnace one, so I was wondering if vanilla Minecraft has a way of dealing with this for the vanilla Furnace and therefore available for me to use. Thanks in advance.
  16. I've got it so that when a world loads, a message appears in the chat box saying "Click here". I want this string to link to a web address. I know this is possible in non-coding Command Blocks with /tellraw, so I was wondering if anyone knows the whereabouts of the code that handles this. I found a class "ClickEvent" which looks promising but have no idea how to implement it into my code. Thanks in advance. If you need this (which I doubt), here is how I add the message to the chat (which works 100%): FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("Click here..."));
  17. I want it so that I have a gui that opens when you right click it (it basically functions like a furnace) except that there is a string on the gui that is a number and I want this number to change accordingly to what its value is (every tick it decreases by 10). The only problem is the string does not update when I add it to use the string variable I get to be decreasing by 10. Any way to do this? Thanks in advance.
  18. Ah thanks for that. It worked, I love you and indirectly CJLetsGame. @ruabmbua definitely have a look at this
  19. I have a multi-textured block (a custom furnace to be exact). The textures are fine and work fine and when I place the block they orientate correctly. However, the icon in the inventory only shows the side and top textures, not the side, top and front like a normal furnace. Any helps would be appreciated as to how to fix this. Thanks in advance. How the icon looks in the inventory next to a vanilla furnace: The BlockCustomFurnace class (the texture parts): @SideOnly(Side.CLIENT) private IIcon furnaceIconTop; @SideOnly(Side.CLIENT) private IIcon furnaceIconFront; @Override public IIcon getIcon(int par1, int par2) { return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront)); } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("freshpower:superfurnace_side"); this.furnaceIconFront = par1IconRegister.registerIcon(this.isActive ? "freshpower:superfurnace_front_on" : "freshpower:superfurnace_front_off"); this.furnaceIconTop = par1IconRegister.registerIcon("freshpower:superfurnace_top"); } The front texture I want to show on the icon: http://s10.postimg.org/t03lprslh/superfurnace_front_off.png[/img]
  20. This error code is a little outdated now but the thing it flags as an error is the same. The ones about init and preinit were just my way of organising files (they work for other things and so shouldn't really be the issue). The .recipes one is the line with my shapelessrecipe on. So i've got it to work now. I put the code directly in the init constructor of my base class. Now I need to work out how to get it to work when I put it in a different class. i.e. this is my setup: My secondary class: public static void init() { craftingRecipes(); } public static void craftingRecipes() { GameRegistry.addShapelessRecipe(new ItemStack(FreshPower.getItem("fp_ingotFreshSteel"), 9), new Object[]{ FreshPower.getBlock("fp_storageFreshSteel") }); } Base class: @EventHandler public void preinit(FMLPreInitializationEvent event) { SecondaryClass.init(); }
  21. When I use the shapeless recipe method (which, I should mention, I tried before consulting the forums) returned this error: java.lang.RuntimeException: Invalid shapeless recipy! at net.minecraft.item.crafting.CraftingManager.addShapelessRecipe(CraftingManager.java:277) at cpw.mods.fml.common.registry.GameRegistry.addShapelessRecipe(GameRegistry.java:219) at freshpower.FPItems.recipes(FPItems.java:66) at freshpower.FPItems.init(FPItems.java:17) at freshpower.FreshPower.preinit(FreshPower.java:44) I tried the recipe with a different vanilla block and it worked. It may be something to do with my block but I doubt it. If it is, here's the code anyway: This is in the init section of base class registerBlock(new BlockGeneric(Material.iron).setBlockName("fp_storageFreshSteel").setHardness(5.0F).setResistance(10.0F).setBlockTextureName("freshpower:storagefreshsteel")); BlockGeneric public class BlockGeneric extends Block { public BlockGeneric(Material par1) { super(par1); this.setCreativeTab(FreshPower.creativetab); } } This is the method I use to get my block public static Block getBlock(String a) { return GameRegistry.findBlock(FreshPower.MODID, a); } THe recipe: GameRegistry.addShapelessRecipe(new ItemStack(FreshPower.getItem("fp_ingotFreshSteel"), 9), new Object[]{ FreshPower.getBlock("fp_storageFreshSteel") });
  22. I put the recipe as "A","","" and yet still infinite recipe.
  23. Hmm. That fixed the error, but now I have a new one where the crafting table is infintely outputting one of the recipes without anything in the crafting bench.
×
×
  • Create New...

Important Information

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