Search in sources :

Example 66 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project NewHorizonsCoreMod by GTNewHorizons.

the class HazardousItemsCommand method canCommandSenderUseCommand.

/*
    private void ProcessRemoveItemCommand(EntityPlayer pPlayer, ItemStack pInHand, String[] pArgs)
    {
        boolean bFlag = false;
        if (pArgs.length == 2)
        {
            String pSecondArg = pArgs[1];
            if (pSecondArg.equalsIgnoreCase("all")) bFlag = true;
        }

        if (!MainRegistry.Module_HazardousItems.RemoveItemFromList(pInHand,bFlag))
        {
            PlayerChatHelper.SendWarn(pPlayer, "Nothing removed. Either there was no such item,");
            PlayerChatHelper.SendWarn(pPlayer, "or an error occurred");
        } else
            PlayerChatHelper.SendInfo(pPlayer, "Item(s) removed. Don't forget to save");
    }

    private void ProcessAddDamageEffectCommand(EntityPlayer pPlayer, ItemStack pInHand, String[] pArgs)
    {
        try
        {
            String tDmgSource = pArgs[1];
            float tDmgAmount = Float.parseFloat(pArgs[2]);

            if (!DamageTypeHelper.IsValidDamageSource(tDmgSource))
                PlayerChatHelper.SendError(pPlayer, "This damagesource is invalid");
            else
            {
                if (MainRegistry.Module_HazardousItems.AddDamageEffectToItem(pInHand, tDmgSource, tDmgAmount))
                    PlayerChatHelper.SendInfo(pPlayer, "Effect added to item. Don't forget to save");
                else
                    PlayerChatHelper.SendError(pPlayer, "Unable to add item. Please check your logfile");
            }
        } catch (Exception e)
        {
            PlayerChatHelper.SendError(pPlayer,
                    "Error in your command. Check your syntax");
        }
    }

    private void ProcessAddPotionEffectCommand(EntityPlayer pPlayer, ItemStack pInHand, String[] pArgs)
    {
        try
        {
            int tPotionID = Integer.parseInt(pArgs[1]);
            int tTickDuration = Integer.parseInt(pArgs[2]);
            int tLevel = Integer.parseInt(pArgs[3]);

            if (!PotionHelper.IsValidPotionID(tPotionID)) PlayerChatHelper
                    .SendError(pPlayer, "This potion ID is invalid");
            else
            {
                if (MainRegistry.Module_HazardousItems.AddPotionEffectToItem(pInHand, tPotionID, tTickDuration, tLevel))
                    PlayerChatHelper.SendInfo(pPlayer, "Effect added to item. Don't forget to save");
                else
                    PlayerChatHelper.SendError(pPlayer, "Unable to add item. Please check your logfile");
            }
        } catch (Exception e)
        {
            PlayerChatHelper.SendError(pPlayer, "Error in your command. Check your syntax");
        }
    }
*/
/*
     * Make sure only an op/admin can execute this command
     */
@Override
public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) {
    if (pCommandSender instanceof EntityPlayerMP) {
        EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender;
        boolean tPlayerOpped = MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile());
        // && tIncreative;
        return tPlayerOpped;
    } else if (pCommandSender instanceof MinecraftServer)
        return true;
    else
        return false;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 67 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project VanillaTeleporter by dyeo.

the class TeleporterUtility method teleport.

public static TeleporterNode teleport(EntityLivingBase entity, BlockPos pos) {
    boolean teleportSuccess = false;
    TeleporterNetwork netWrapper = TeleporterNetwork.get(entity.world);
    TeleporterNode sourceNode = netWrapper.getNode(pos, entity.world.provider.getDimension());
    TeleporterNode destinationNode = netWrapper.getNextNode(entity, sourceNode);
    if (destinationNode != null) {
        double x = destinationNode.pos.getX() + (BlockTeleporter.TELEPORTER_AABB.maxX * 0.5D);
        double y = destinationNode.pos.getY() + (BlockTeleporter.TELEPORTER_AABB.maxY);
        double z = destinationNode.pos.getZ() + (BlockTeleporter.TELEPORTER_AABB.maxZ * 0.5D);
        float yaw = entity.rotationYaw;
        float pitch = entity.rotationPitch;
        if (// if (sourceNode.type == BlockTeleporter.EnumType.REGULAR || entity.dimension == destinationNode.dimension)
        !sourceNode.type.isEnder() || entity.dimension == destinationNode.dimension) {
            if (entity instanceof EntityPlayerMP) {
                teleportSuccess = setPlayerPosition((EntityPlayerMP) entity, x, y, z, yaw, pitch);
            } else {
                teleportSuccess = setEntityPosition(entity, x, y, z, yaw, pitch);
            }
        } else if (!(sourceNode.dimension != destinationNode.dimension && !entity.getPassengers().isEmpty())) {
            if (entity instanceof EntityPlayerMP) {
                teleportSuccess = transferPlayerToDimension((EntityPlayerMP) entity, x, y, z, yaw, pitch, destinationNode.dimension);
            } else {
                teleportSuccess = transferEntityToDimension(entity, x, y, z, yaw, pitch, destinationNode.dimension);
            }
        }
    }
    if (teleportSuccess) {
        entity.world.playSound(null, sourceNode.pos.getX(), sourceNode.pos.getY(), sourceNode.pos.getZ(), ModSounds.PORTAL_ENTER, SoundCategory.BLOCKS, 0.9f, 1.0f);
        entity.world.playSound(null, destinationNode.pos.getX(), destinationNode.pos.getY(), destinationNode.pos.getZ(), ModSounds.PORTAL_EXIT, SoundCategory.BLOCKS, 0.9f, 1.0f);
    } else {
        entity.world.playSound(null, sourceNode.pos.getX(), sourceNode.pos.getY(), sourceNode.pos.getZ(), ModSounds.PORTAL_ERROR, SoundCategory.BLOCKS, 0.9f, 1.0f);
        ITeleportHandler handler = entity.getCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null);
        handler.setTeleportStatus(EnumTeleportStatus.FAILED);
    }
    MinecraftForge.EVENT_BUS.post(new TeleportEvent.EntityTeleportedEvent(entity));
    return destinationNode;
}
Also used : ITeleportHandler(net.dyeo.teleporter.capabilities.ITeleportHandler) TeleportEvent(net.dyeo.teleporter.event.TeleportEvent) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 68 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project VanillaTeleporter by dyeo.

the class BlockTeleporter method onEntityWalk.

@Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
    TeleporterNode destinationNode = null;
    IBlockState state = world.getBlockState(pos);
    EnumType type = EnumType.byMetadata(getMetaFromState(state));
    if (entity instanceof EntityLivingBase && entity.hasCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null)) {
        ITeleportHandler teleportHandler = entity.getCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null);
        if (!world.isRemote) {
            if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
                teleportHandler.setOnTeleporter(entity.getPosition().distanceSq(pos) <= 1);
                teleportHandler.setDimension(entity.dimension);
                if (teleportHandler.getOnTeleporter()) {
                    boolean isHostile = (entity instanceof EntityMob) || (entity instanceof EntityWolf && ((EntityWolf) entity).isAngry());
                    boolean isPassive = (entity instanceof EntityAnimal);
                    if ((isHostile == false || isHostile == ModConfiguration.teleportHostileMobs) && (isPassive == false || isPassive == ModConfiguration.teleportPassiveMobs)) {
                        destinationNode = TeleporterUtility.teleport((EntityLivingBase) entity, pos);
                    }
                }
            }
        }
        if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
            TileEntityTeleporter tEnt = (TileEntityTeleporter) world.getTileEntity(pos);
            if (tEnt != null) {
                tEnt.spawnParticles();
            }
        }
        if (type.isRecall() && entity instanceof EntityPlayerMP && destinationNode != null) {
            WorldServer nextWorld = world.getMinecraftServer().worldServerForDimension(destinationNode.dimension);
            breakBlockRecall(world, nextWorld, pos, destinationNode.pos, state, (EntityPlayerMP) entity);
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IBlockState(net.minecraft.block.state.IBlockState) TeleporterNode(net.dyeo.teleporter.teleport.TeleporterNode) ITeleportHandler(net.dyeo.teleporter.capabilities.ITeleportHandler) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) EntityWolf(net.minecraft.entity.passive.EntityWolf) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) TileEntityTeleporter(net.dyeo.teleporter.tileentity.TileEntityTeleporter)

Example 69 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project BetterWithAddons by DaedalusGame.

the class AssortedHandler method beginTrack.

/*@SubscribeEvent
    public void onArtifactInteract(PlayerInteractEvent event) {
        World world = event.getWorld();
        BlockPos pos = event.getPos();
        IBlockState blockstate = world.getBlockState(pos);
        EntityPlayer player = event.getEntityPlayer();

        if (blockstate.getBlock() instanceof BlockQuartz) {
            ItemStack stack = player.getHeldItemMainhand();
            Item item = stack.getItem();

            if (!stack.isEmpty() && (item instanceof ItemTool || item instanceof ItemSword || item instanceof ItemArmor || item instanceof ItemBow)) {
                player.swingArm(EnumHand.MAIN_HAND);
                player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ModItems.brokenArtifact.makeFrom(stack));

                if (!event.getWorld().isRemote) {
                    event.setCanceled(true);
                }
            }
        }
    }*/
@SubscribeEvent
public void beginTrack(PlayerEvent.StartTracking trackEvent) {
    if (!trackEvent.getEntityPlayer().getEntityWorld().isRemote) {
        Entity target = trackEvent.getTarget();
        EntityPlayerMP player = (EntityPlayerMP) trackEvent.getEntityPlayer();
        UUID uuid = target.getUniqueID();
        if (BossList.containsKey(uuid)) {
            BossInfoServer bossInfo = BossList.get(uuid);
            bossInfo.addPlayer(player);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) UUID(java.util.UUID) BossInfoServer(net.minecraft.world.BossInfoServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 70 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project BetterWithAddons by DaedalusGame.

the class AssortedHandler method endTrack.

@SubscribeEvent
public void endTrack(PlayerEvent.StopTracking trackEvent) {
    if (!trackEvent.getEntityPlayer().getEntityWorld().isRemote) {
        Entity target = trackEvent.getTarget();
        EntityPlayerMP player = (EntityPlayerMP) trackEvent.getEntityPlayer();
        UUID uuid = target.getUniqueID();
        if (BossList.containsKey(uuid)) {
            BossInfoServer bossInfo = BossList.get(uuid);
            bossInfo.removePlayer(player);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) UUID(java.util.UUID) BossInfoServer(net.minecraft.world.BossInfoServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)163 EntityPlayer (net.minecraft.entity.player.EntityPlayer)32 ItemStack (net.minecraft.item.ItemStack)23 TileEntity (net.minecraft.tileentity.TileEntity)18 Entity (net.minecraft.entity.Entity)17 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)14 BlockPos (net.minecraft.util.math.BlockPos)14 Block (net.minecraft.block.Block)11 IBlockState (net.minecraft.block.state.IBlockState)8 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 World (net.minecraft.world.World)8 WrongUsageException (net.minecraft.command.WrongUsageException)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)5 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5