Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package com.mod.drakania.Event;
  2.  
  3. import com.mod.drakania.init.ItemMod;
  4. import com.mod.drakania.items.ItemBackPack;
  5.  
  6. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  7. import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.util.ChatComponentText;
  10. import net.minecraft.util.ChatStyle;
  11. import net.minecraft.util.EnumChatFormatting;
  12.  
  13. public class EventTest
  14. {
  15. @SubscribeEvent
  16. public void tickEvent(PlayerTickEvent event)
  17. {
  18. EntityPlayer player = event.player; //Tu récupères le player par l'event
  19.  
  20. {
  21.  
  22. for(int i = 0; i < player.inventory.getSizeInventory(); i++) //Boucle ou l'on crée une variable i qui représente les slots de l'inventaire du joueur
  23. {
  24. if(player.inventory.getStackInSlot(i) != null) //Si le slot n'est pas null alors on passe au prochain
  25. {
  26. if(player.inventory.getStackInSlot(i).getItem() instanceof ItemBackPack) //Si l'item dans le slot est l'instance de ton item alors tu exécutes quelque chose
  27. {
  28. if(i >= 2)
  29. {
  30. player.addChatComponentMessage(new ChatComponentText("Interdit").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
  31. }
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement