Jump to content

Pardeep

Forge Modder
  • Posts

    59
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://www.youtube.com/sikhstar97
  • Personal Text
    Moving at 1000mph... all day

Pardeep's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  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.
×
×
  • Create New...

Important Information

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