Hamster_Furtif
Members-
Posts
100 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Hamster_Furtif
-
Maybe this could help: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 4 column 26
-
Solved [1.8]NBTTag keeps reseting
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Finally solved ! Thanks ! -
Solved [1.8]NBTTag keeps reseting
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
public static class PacketBourseHandler implements IMessageHandler<PacketGuiBourse, IMessage> { EntityPlayer player; @Override public IMessage onMessage(final PacketGuiBourse packet, final MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; mainThread.addScheduledTask(new Runnable() { @Override public void run() { EntityPlayerMP sendingPlayer = ctx.getServerHandler().playerEntity; if (sendingPlayer instanceof EntityPlayer){ player = (EntityPlayer)sendingPlayer; ItemStack bourse = player.getCurrentEquippedItem(); bourse.getTagCompound().setInteger("bronze", bourse.getTagCompound().getInteger("bronze") + 1); System.out.println(packet.bourse.getTagCompound().getInteger("bronze")); } } }); return null; } } Thanks ! It's working ! I posted my solution because you often find something wrong I don't expect. But it's really nice to have people like you willing to help ! -
Solved [1.8]NBTTag keeps reseting
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Yep, sorry, should have been more focused. I don't have anymore errors in the console, yet the NBT doesn't seems to change, it still prints the same amount. The good new is that the NBTTag doesn't get reseted ! Here is the packet related class: public class PacketGuiBourse implements IMessage{ public materiau type; public int nbr; public ItemStack bourse; public PacketGuiBourse(){} public PacketGuiBourse(materiau type, int nbr, ItemStack bourse){ this.type = type; this.nbr = nbr; this.bourse = bourse; } @Override public void fromBytes(ByteBuf buf) { nbr = buf.readInt(); bourse = ByteBufUtils.readItemStack(buf); type = materiau.values()[buf.readInt()]; } @Override public void toBytes(ByteBuf buf) { buf.writeInt(nbr); ByteBufUtils.writeItemStack(buf, bourse); buf.writeInt(type.ordinal()); } public static class PacketBourseHandler implements IMessageHandler<PacketGuiBourse, IMessage> { @Override public IMessage onMessage(final PacketGuiBourse packet, MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; mainThread.addScheduledTask(new Runnable() { @Override public void run() { packet.bourse.getTagCompound().setInteger("bronze", packet.bourse.getTagCompound().getInteger("bronze") + 1); System.out.println(packet.bourse.getTagCompound().getInteger("bronze")); } }); return null; } } } And in the gui class: if (button.id == 2){ if (player.getCurrentEquippedItem().getItem() == Elisance.bourse){ ItemStack bourse = player.getCurrentEquippedItem(); Elisance.channel.sendToServer(new PacketGuiBourse(materiau.BRONZE, 1, bourse)); System.out.println(bourse.getTagCompound().getInteger("bronze")); } The onMessage() method prints 6 while the GUI prints 5, but it doesn't increases when I clik multiple times. Is the GUI wainting for some kind of response ? -
Solved [1.8]NBTTag keeps reseting
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Well, I followed the tutorial you sent me but it's not working... Here is (are) the package related class: With this in my main class: @EventHandler public void preInit(FMLPreInitializationEvent event) { channel = NetworkRegistry.INSTANCE.newSimpleChannel(References.MODID); channel.registerMessage(PacketBourseHandler.class, PacketGuiBourse.class, 0, Side.SERVER); } and this when you press the gui button: if (button.id == 2){ if (player.getCurrentEquippedItem().getItem() == Elisance.bourse){ ItemStack bourse = player.getCurrentEquippedItem(); Elisance.channel.sendToServer(new PacketGuiBourse(materiau.BRONZE, 1, bourse)); System.out.println(bourse.getTagCompound().getInteger("bronze")); } I know there is no security right now, and a player good easily cheat, but I'm tring to figure out the packets right now. -
Solved [1.8]NBTTag keeps reseting
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Thank you all ! I'm gonna take a look at this tutorial, it should be interesting. I hope the title of my next message will be "Solved" ! -
Solved [1.8]NBTTag keeps reseting
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Packets ? Damn ! Is this the only way ? Because I don't see why it's not working here... But anyway, I learned how to make GUIs yesterday, I guess I can learn how to deal with packets today ! -
Hey ! I've got an item that allows you to stock your money. I'm trying to stock the amount of money with the NBTTags, but the NBTTag resets. You can edit the amount of money with a Gui, but whenevr I close the Gui, it resets the nbttag. For exemple, if I set the value to "10", and then I close and reopen the gui, the value will be reset to 0. The item code: The Gui code: The "Tag created" string appears in my console every time I right-click, so I would like to know how to check if there is a NBTTag attributed to the ItemStack, or if there is a way to set a default NBTTag. Thanks !
-
[1.8] Problems with Customblock Rendering
Hamster_Furtif replied to Kavaeron's topic in Modder Support
A very easy to make custom 3d models is to use this tool: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/2146545-opls-model-creator-free-3d-model-editor You modelise your block, and it creates a .json. Just use this .json for your block and it's done. But maube someone more experienced is going to tell me that I shouldn't use this for whatever reason. Do you guys recommand it ? -
Solved [1.8]Get blocks metadata (or equivalent)
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Yep, you're right. Here is what I did: player.inventory.setInventorySlotContents(player.inventory.currentItem, block.getPickBlock(new MovingObjectPosition(player), event.world, pos)); Thanks ! -
Solved [1.8]Get blocks metadata (or equivalent)
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
I'm aware of that, there's a whole list of blocks I don't want the player to pick up (such a buttons, levers, and everything you need to right click on): public boolean isBlockEditable(Block block){ @SuppressWarnings("rawtypes") Class[] forbidden = {BlockDoor.class, BlockButton.class, BlockContainer.class, BlockCrops.class, BlockFenceGate.class, BlockPortal.class, BlockLiquid.class, BlockFire.class, BlockLever.class, BlockRedstoneDiode.class, BlockTrapDoor.class, BlockPistonExtension.class, BlockPistonBase.class, BlockDragonEgg.class, BlockWorkbench.class, BlockAnvil.class}; Boolean isblockeditable = true; for (int i=0; i<forbidden.length; i++){ if (forbidden[i].isInstance(block) || block == Blocks.obsidian || block == Blocks.bedrock || block == Blocks.bed) isblockeditable = false; } return isblockeditable; } -
Solved [1.8]Get blocks metadata (or equivalent)
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
Thanks for these infos, they're duly noted. I don't allow BlockContainers to be picked up, so I don't have any problems, but it's good to know if i ever need to know how to pick up flowerpots, thanks ! -
Solved [1.8]Get blocks metadata (or equivalent)
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
It's working, thanks ! -
Solved [1.8]Get blocks metadata (or equivalent)
Hamster_Furtif replied to Hamster_Furtif's topic in Modder Support
getPickBlock requires a moving object position, and it can only be accessed from an item. I want all this stuff to work when the player doesn't have an item. Plus, I think it would be usefull to know how to get the damn colors from the block, I may need it some day. Anyway, if you know how to get a moving object position without an Item, it would be usefull too ! -
Hey ! I'm trying to make it so when you right click on a block with an empty hand, it goes in your inventory. The problem is that when I right click on a blue flower, it gives me a red flower. I know there are no more metadatas, but some properties. I would like to know how to get the color of the block I'm rightclicking on, and then convert it into an int so I can give it to my player. Here is my code: public void clickEnderman(BlockPos pos, EntityPlayer player, Block block, PlayerInteractEvent event){ if (isBlockEditable(block) == true && player.getCurrentEquippedItem() == null && (player.experienceLevel >= 1 || player.capabilities.isCreativeMode)){ player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(block, 1)); event.world.setBlockToAir(pos); player.addExperienceLevel(-1); } } Any help will be welcome !
-
With Eclipse: [12:54:22] [Client thread/INFO]: [com.hamsterfurtif.masks.masques.ItemMask:getArmorTexture:26]: masks:/textures/armor/mask_gardien_armor.png With minecraft: [13:01:40] [Client thread/INFO] [sTDOUT]: [com.hamsterfurtif.masks.masques.ItemMask:getArmorTexture:26]: masks:/textures/armor/mask_gardien_armor.png
-
So, I'm gonna bump and add a few infos: I tried using the iron armor textures to check if my armor texture was broken, but it's still not working. I moved all my armor texture in another file with my item texture, but it didn't work. Once again, no problem when I use Eclipse, but textures are not working when I test the mod in Minecraft.
-
Thank you, it's working now !
-
Ho, yeah, should have precised. I'm using forge 1.8. I'm using the version 1.8-11.14.1.1402, but I just saw the version Build 1.8-11.14.1.1404 added Maybe I should use the latest version. Is there any way to do it easily ?
-
Well, the only places it doesn't work are Nether Fortress. Any idea ?
-
Hey ! I need to generate items in chests, but it's not working. Here is what I've done: public void chestLoots() { ChestGenHooks mineshaft = ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR); ChestGenHooks nether = ChestGenHooks.getInfo(ChestGenHooks.NETHER_FORTRESS); ChestGenHooks sh_couloir = ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR); ItemStack ame_loot = new ItemStack(ame); // addItem(Item, min, max, chances) // NB:Les chances de spawn du pain sont de 100 mineshaft.addItem(new WeightedRandomChestContent(ame_loot, 1, 1, 1)); nether.addItem(new WeightedRandomChestContent(ame_loot , 1, 10, 9001)); sh_couloir.addItem(new WeightedRandomChestContent(ame_loot, 1, 1, 20)); } and : @EventHandler public void init(FMLInitializationEvent event) { chestLoots(); } But it's not generating. You can see the chances are over 9000 in the nether, so this is not the problem. Thank you for your help !