Search in sources :

Example 61 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project BetterStorage by copygirl.

the class BackpackHandler method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    if (event.entity.worldObj.isRemote || !(event.entity instanceof EntityPlayerMP) || !(event.target instanceof EntityLivingBase) || (((EntityPlayerMP) event.entity).playerNetServerHandler == null) || ((event.target instanceof EntityPlayer) && !BetterStorage.globalConfig.getBoolean(GlobalConfig.enableBackpackInteraction)))
        return;
    EntityPlayerMP player = (EntityPlayerMP) event.entity;
    EntityLivingBase target = (EntityLivingBase) event.target;
    if (ItemBackpack.openBackpack(player, target))
        player.swingItem();
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 62 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project BetterStorage by copygirl.

the class ChannelHandler method sendToAllAround.

public void sendToAllAround(IMessage message, World world, double x, double y, double z, double distance, EntityPlayer except) {
    for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
        if (player == except)
            continue;
        double dx = x - player.posX;
        double dy = y - player.posY;
        double dz = z - player.posZ;
        if ((dx * dx + dy * dy + dz * dz) < (distance * distance))
            sendTo(message, player);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List)

Example 63 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Guide-API by TeamAmeriFrance.

the class EventHandler method onPlayerJoinWorld.

@SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event) {
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntity();
        NBTTagCompound tag = getModTag(player, GuideMod.ID);
        if (ConfigHandler.canSpawnWithBooks) {
            for (Book book : GuideAPI.getBooks().values()) {
                if (book.isSpawnWithBook() && !tag.getBoolean("hasInitial" + book.getTitle())) {
                    ItemHandlerHelper.giveItemToPlayer(player, GuideAPI.getStackFromBook(book));
                    tag.setBoolean("hasInitial" + book.getTitle(), true);
                }
            }
        }
    }
}
Also used : Book(amerifrance.guideapi.api.impl.Book) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 64 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Witchworks by Um-Mitternacht.

the class ItemTaglock method getVictim.

public Optional<EntityLivingBase> getVictim(ItemStack stack, World world) {
    UUID uuid = NBTHelper.getUniqueID(stack, TAGLOCK_ENTITY);
    for (Entity entity : world.loadedEntityList) {
        if (entity instanceof EntityLivingBase && entity.getUniqueID().equals(uuid)) {
            return Optional.of((EntityLivingBase) entity);
        }
    }
    EntityPlayer victim = world.getPlayerEntityByUUID(uuid);
    return Optional.ofNullable(victim);
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) UUID(java.util.UUID)

Example 65 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onRightClickBlock.

@SubscribeEvent()
public void onRightClickBlock(RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        ItemStack stack = event.getItemStack();
        if (stack != null && stack.getItem() instanceof ItemNameTag) {
            BlockPos posAt = event.getPos();
            EntityPlayer player = event.getEntityPlayer();
            World world = event.getWorld();
            PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
            if (wrapper != null) {
                wrapper.setCustomNameTag(stack.getDisplayName());
                --stack.stackSize;
                event.setCanceled(true);
            }
        }
    }
}
Also used : ItemNameTag(net.minecraft.item.ItemNameTag) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)625 ItemStack (net.minecraft.item.ItemStack)169 EntityLivingBase (net.minecraft.entity.EntityLivingBase)104 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)81 Entity (net.minecraft.entity.Entity)77 World (net.minecraft.world.World)73 BlockPos (net.minecraft.util.math.BlockPos)61 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)49 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)44 TileEntity (net.minecraft.tileentity.TileEntity)43 PotionEffect (net.minecraft.potion.PotionEffect)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 EntityItem (net.minecraft.entity.item.EntityItem)37 Block (net.minecraft.block.Block)36 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)35 ArrayList (java.util.ArrayList)33 IBlockState (net.minecraft.block.state.IBlockState)33 List (java.util.List)28 TextComponentString (net.minecraft.util.text.TextComponentString)27 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)23