Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mod.drakania.Event;
- import com.mod.drakania.init.ItemMod;
- import com.mod.drakania.items.ItemBackPack;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ChatStyle;
- import net.minecraft.util.EnumChatFormatting;
- public class EventTest
- {
- @SubscribeEvent
- public void tickEvent(PlayerTickEvent event)
- {
- EntityPlayer player = event.player; //Tu récupères le player par l'event
- {
- 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
- {
- if(player.inventory.getStackInSlot(i) != null) //Si le slot n'est pas null alors on passe au prochain
- {
- 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
- {
- if(i >= 2)
- {
- player.addChatComponentMessage(new ChatComponentText("Interdit").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement