
Enginecrafter
Members-
Posts
100 -
Joined
-
Last visited
Everything posted by Enginecrafter
-
[1.7.10]Container error in transferStack()
Enginecrafter replied to Enginecrafter's topic in Modder Support
It worked fine. And, can you explain me this method, if you can? Please... -
[1.7.10]Container error in transferStack()
Enginecrafter replied to Enginecrafter's topic in Modder Support
And, thank you very much for answering me. :) :) -
[1.7.10]Container error in transferStack()
Enginecrafter replied to Enginecrafter's topic in Modder Support
Sorry, I did't understood the code, just followed tutorial. I didn't know why is it 0, 35. -
I have never did this, but I think you can use WorldEvent.playerJoinEventv. then add your book to player's inventory and add a variable to player's nbt that he got the book(boolean and set it to true). And before you add the book to player's invemtory you have to check if player's nbt isn't null and if the variable is't false.
-
And, I have an container, that duplicates items when moving items out of it using shift click, but only when player hasn't got itemstack to merge with. I think error is in this function. Please, help me. Only small reply. Every reply will help. I have solving this for 5 months but without result. Function where is the bug. @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot)inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); if(slot < 9) { if (!this.mergeItemStack(stackInSlot, 0, 35, true)) { System.out.println("There are " + stackInSlot.stackSize + " of " + stackInSlot.getItem().getUnlocalizedName()); return null; } } else { if(!this.mergeItemStack(stackInSlot, 0, 9, false)) { System.out.println("There are " + stackInSlot.stackSize + " of " + stackInSlot.getItem().getUnlocalizedName()); return null; } } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; }
-
[1.7.10] How to render a gui over another gui?
Enginecrafter replied to HappyKiller1O1's topic in Modder Support
If you are opening GUIs using Minecraft.getMinecraft().displayGuiScreen(GuiScreen) your mod becomes multiplayer inpompatible. If you try to play multiplayer with that, it always opens the gui to server's owner. For example, server owner has his server and you are it's admin and you installed your mod to this server. And when you open the gui, the gui opens to admin. I think you don't want this. Use: player.openGui(ModInstance, GuiID, world, x, y, z); And I recommend to watch diesieben07's tutorial about simple packet handling. It's very usefull if you are changing something like tile entity that is on server side. Tutorial link http://www.minecraftforge.net/forum/index.php/topic,20135.0.html -
Hi everyone. I have a little bug with my own block that is currently called TrialInventory. I have also container for this block. I followed one tutorial for container creation, but it was for 1.6.4(I had no choice because I found only this tutorial), but some things were broken(code for some things in 1.6.4 was not equivalent to same thing code for 1.7.10), that means I had to replace broken code with other code. I thinked it will work fine. Well it worked fine, except shift-click. When I moved item from my inventory to container, it worked fine, but when I moved this item back, it duplicated it's amount. I searched for the bug in my code and on forums so long, but with no result. With that bug, it is only CHEAT MACHINE, not basic storage block. I really want to fix this bug. Can you help me? And, if you decide to delete this topic, please, PM me with the reason why you delete this topic. My code:
-
Ok, I found the error. The error was in my PacketMessage.java where in both fromBytes and ToBytes I checked if the password is required using this: if(!password.equals("not set")) and when it was null, it throwed me exception. :-) I repaired it with adding boolean isPasswordRequired and in second constructor(first must be default) setted this variable to false and in third constructor(only for changing password) setted it to true.
-
Registering packet and SimpleNetworkWrapper(Main mod class) public static SimpleNetworkWrapper packets = NetworkRegistry.INSTANCE.newSimpleChannel("MyChannel"); @EventHandler public static void preLoad(FMLPreInitializationEvent PreEvent) { packets.registerMessage(PacketMessage.Handler.class, PacketMessage.class, 0, Side.SERVER); } *Don't think I have only packet in my mod. I have some other things in my mod.
-
I have still problems with that. I have seen You (diesieben07) wrote to one member: You can't simply change tile entity variables. It's used to prevent from hacks. What did you mean at "hacks"? If it is true, how could some modders made this? And, I followed your tutorial and created this class. There can be two errors: handler's method onMessage does not work or I wrong coded sender. I used this for sending this packet. MainRegistry.packets is SimpleNetworkWrapper as showed in your tutorial. MainRegistry.packets.sendToServer(new PacketMessage("unlock", x, y, z)); Here is my code for this packet.
-
I followed one tutorial, but I know Containers are used to create slots in Gui. And I don't need any slots in this gui. And when I make some slots I just made cheat machine, because I had problem with container with item duplication and administrators deleted these 3 topics about it. I posted it first time, they deleted it, I posted, they deleted it and the same at third time. I really don't know why they deleted the first topic about it.
-
Hi. I have a block called Password Lock that when you set up your code and receiver for it, when you type right code, receiver sends a redstone signel. For receiver, I have done this through metadata. And the password lock through tile entity. But there isn's this problem. Problem is in it's gui. I opened it through Minecraft.getMinecraft().displayGuiScreen(new PasswordLockScreen(world, x, y, z)) and it worked fine, but when I tried it in Lan(First player,(Me from first window, and opened LAN through this window) and second player playing through another window(All on one computer) When first player opened it's GUI, it displayed to him, but when second player tried this, nothing happens to him, but it displayed to first player. Then, I tried this using player.openGUI() <Through GUI Handler> and GUI opens, but when I typed right password and clicked UNLOCK, nothing happened. I think it is because it has to be opened on server side, but GUI screen opens on client side and this block has no container because it has no slots. And when you decide to delete my topic, please send me a reason. In my code I currently use MainLib.openGui(new PasswordLockScreen(world, x, y, z)) that does Minecraft.getMinecraft().displayGuiScreen(new PasswordLockScreen(world, x, y, z)); This blocks also has a feature for changing password, that is PasswordChangeScreen.java Here is my code.
-
[1.8] make my items work in a server. ¿ is my code wrong
Enginecrafter replied to perromercenary00's topic in Modder Support
What do these variables and where they are used? -
Sorry, I made a mistake in first post. It was player.inventory.getCurrentItem().equals(new ItemStack(ItemWrench.item)). But I solved it another way. I converted them from ItemStack to Item. Item currentItem = player.inventory.getCurrentItem().getItem(); boolean hasWrench = currentItem.equals(ItemWrench.item) And, I have a tile entity for this block. I want to get owner(that is set when is block placed) and compare it with player, who is trying to dismantle the block. I used: TileEntityPasswordLock tile = (TileEntityPasswordLock)world.getTileEntity(bX, bY, bZ); String playerName = new String(player.getCommandSenderName()); String owner = tile.owner; boolean isOwner = owner == playerName; And it always returned false. When I used .equal(something) insteaded of == it throws an error.
-
I have a block that is called Password Lock. I am currently adding a wrench, that when used on this block, it dismantles it(sets it to air and drops it). But I don't know how to get Item, that is currently held by player. I will use it at onBlockActivated when It is held (and the current player is it's owner), don't open the gui, but dismantle. When I used player.inventory.getCurrentItem().equals(ItemWrench.item) it always returned false.