Jump to content

phlinther1

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by phlinther1

  1. Wow, what a nice answer! To your points: 1. I didn't really know that the server would automatically send a packet to the client telling him to open the gui, so I did this, but now I know it better 2. Yea, recognized that later and changed it already (it was even the wrong number ) 3. You are right, I really don't need this check, changed it. 4. I changed it before posting, but then I thought: hm it's in vanilla code, it must be there for SOMETHING (although I could'nt find any use for it), and changed it back. Why is it even there? 5. okay I will 6. same as 4. 7. done 8. haha don't know why I didn't recognize it yesterday, it's really super weird 9. same as 8., pretty obvious, but I just didn't see it... Everything works perfectly now, this forum here is great (or is it just Ernio who is great?) Now the same for the crafting table, I'll come back if I need help with it, but I guess it should be fine. EDIT: Aaaand here I am again. I've got the custom crafting table set up, but what's the right way to open it? (I want to open it instead of the standard crafting table). I tried: but this will still open the standard one... however if I remove the check for the block type (if it's a crafting table which we clicked on), it will open my custom crafting table when I right click at any block.
  2. Thank you, but not quite what I'm looking for because this will just make the restricted recipes to just not show up. I'd like them to show up, but you should not be able to take the output out of the crafting slot which seems to be A LOT harder to do ^^ However, I've got the custom player inventory set up (I'll do the same with the crafting table later), but I need help again. I replaced the original inventory with my own one and added my custom slot as the output slot (which is usually SlotCrafting, mine is SlotCraftingCustom). PROBLEM: When I try to take something out it got this weird server-and-client-not-synchronized behavior which is why I guess I have to send a packet, but where and which one? Or is it another problem? STRANGE THING: (look at my code) In class "KeyHandler" if I ask for the container which is open AFTER I opened my custom one, it will still say "ContainerPlayer" instead of "ContainerCustom" although I sent a packet. Why? Is it even my container which is being opened there, but if not, how can't it be mine? I checked if it's actually my custom inventory which is opened by removing the little entity in the top right corner which is looking at the mouse pointer which did work. On the server side I just removed some slots which of course resulted in errors when something is being put in there. So it's definitely my custom inventory which is being shown Here is my code: KeyHandler: (actually just KeyInputEvent) GuiHandler: ContainerCustom: (copy&paste from vanilla code, only changed the crafting output slot from "SlotCrafting" to "SlotCraftingCustom") GuiCustomPlayerInventory: (copy&paste from vanilla code) SlotCraftingCustom: I'd be grateful if you could help me again! [btw if my text was too confusing: I'm actually only asking for the place in my code where I have to send the packet to the client telling him that the crafting output slot (index 0) is my custom one with my custom behavior; I also appreciate any other comments on my code] @Ernio your profile pic makes me freak out
  3. I actually did something like that: I gave the player 0 dirt as output if he isn't allowed to craft the itemm It worked l, but I wasn't satisfied with the solution because I thought there must be a better way. Unfortunately, this event is not cancelable (because it's fired when the item is taken out already) which makes everything a lot harder. I'll try to replace the whole inventory gui with my own one, because what would also be great is to add some "cannot be crafted" message or something like that.
  4. The reason I want to do this is because I thought it might be a way to implement player-based crafting restrictions (that's why I checked for the item). I didn't think about the effect that changing the slot will break the container. I'd like to have this behavior: If you are not allowed to craft an item, you can't take it out of the crafting slot. What do you suggest I should do? As I said I'm new to forge which is why I'm not sure what's doable and what not.
  5. That doesn't sound too bad, but I really don't know where to start, any tutorial suggestions or something like that?
  6. Thank you for your help, i managed to get the correct slot and used packets to synchronize server and client (which was indeed necessary as you guessed correctly). But if I replace the crafting output slot of the inventory I can't make it work again afterwards. I tried saving the original slot: SlotCrafting craftingSlot = (SlotCrafting) player.openContainer.inventorySlots.get(0); // 0 is the crafting output slot (or whatever you call it) in case you don't know then change it to my custom slot, but after setting it back to the original slot: player.openContainer.inventorySlots.set(0, craftingSlot); it won't work properly anymore which means it will result in some weird behavior if you craft something (you can take out the crafted item by drag and drop but the items in the crafting matrix won't be consumed / if you shift click, the items in the crafting matrix will be consumed, but the output will disappear). I sent a packet to the client already, so synchronization I believe isn't the problem. How can I make it work again? I'd be very grateful if you could help me another time
  7. That stick check is irrelevant, just ignore it, it was just for testing. I guess I'll check it by if (.getItem.equals(Items.SOMETHING)) then, but that's not the point anyway. I do have basic knowledge of Java, but just theoretical. So I thought why not improve my skills and gather practical experience by having some fun with Minecraft mods. So I guess you are unable to answer my core question? Or don't you want to answer it?
  8. Hey guys! I'm new to this forum, to forge and to Java generally, but I'd like to learn I'm trying to "deactivate" an inventory slot, but it doesn't seem to work (probably because my code is completely wrong ), but maybe you can help me. This is what I did: class CustomSlot: (creating my own subclass and modifying some methods, just have a look ^^) event: I guess the new Slot is just in the list of slots, but it's not actually being applied or whatever you call it, is tgere a way of doing this? I'd really be grateful if someone could help me since I'm a beginner
  9. Hey guys! I'm very new to forge (actually I started 2 hours ago ) and I'd like to ask 2 questions: First one: Where should I start? I can't find any good and updated tutorials which are not absolutely basic. Is there another short documentation beside the JavaDocs? Would safe me lots of time. Second one: I want to restrict certain items from being crafted, but the event PlayerEvent.ItemCraftedEvent is not cancellable (i tried it out). So how can I make it cancelable or something similar to this? I'd really appreciate some help, especially some hints on how I can get started, because information I find on the net is sometimes quite confusing since most of it is outdated. @SubscribeEvent public void onItemCrafted(PlayerEvent.ItemCraftedEvent event) { if(event.isCancelable()) // but it's not... { event.setCanceled(true); } }
×
×
  • Create New...

Important Information

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