Search in sources :

Example 56 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project Overloaded by CJ-MC-Mods.

the class MultiToolRightClickHandler method onMessage.

/**
     * Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply
     * is needed.
     *
     * @param message The message
     * @param ctx the context of the message
     * @return an optional return message
     */
@Override
@Nullable
public IMessage onMessage(MultiToolRightClickMessage message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    WorldServer world = player.getServerWorld();
    world.addScheduledTask(() -> ModItems.itemMultiTool.rightClickWithItem(world, player, message.getPos(), message.getHitSide(), message.getHitX(), message.getHitY(), message.getHitZ()));
    // Nothing to send to client from here
    return null;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) Nullable(javax.annotation.Nullable)

Example 57 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project ICBM-Classic by BuiltBrokenModding.

the class BlastEnderman method doExplode.

@Override
public void doExplode() {
    if (this.world().isRemote) {
        int r = (int) (this.getRadius() - ((double) this.callCount / (double) this.duration) * this.getRadius());
        for (int x = -r; x < r; x++) {
            for (int z = -r; z < r; z++) {
                for (int y = -r; y < r; y++) {
                    Location targetPosition = position.add(new Pos(x, y, z));
                    double distance = targetPosition.distance(position);
                    if (distance < r && distance > r - 1) {
                        if (targetPosition.getBlock(world()) != Blocks.air)
                            continue;
                        if (this.world().rand.nextFloat() < Math.max(0.001 * r, 0.01)) {
                            float velX = (float) ((targetPosition.x() - position.x()) * 0.6);
                            float velY = (float) ((targetPosition.y() - position.y()) * 0.6);
                            float velZ = (float) ((targetPosition.z() - position.z()) * 0.6);
                            ICBMClassic.proxy.spawnParticle("portal", world(), targetPosition, velX, velY, velZ, 5f, 1);
                        }
                    }
                }
            }
        }
    }
    int radius = (int) this.getRadius();
    AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
    List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, bounds);
    boolean explosionCreated = false;
    for (Entity entity : allEntities) {
        if (entity != this.controller) {
            double xDifference = entity.posX - position.x();
            double yDifference = entity.posY - position.y();
            double zDifference = entity.posZ - position.z();
            int r = (int) this.getRadius();
            if (xDifference < 0)
                r = (int) -this.getRadius();
            entity.motionX -= (r - xDifference) * Math.abs(xDifference) * 0.0006;
            r = (int) this.getRadius();
            if (entity.posY > position.y())
                r = (int) -this.getRadius();
            entity.motionY += (r - yDifference) * Math.abs(yDifference) * 0.0011;
            r = (int) this.getRadius();
            if (zDifference < 0)
                r = (int) -this.getRadius();
            entity.motionZ -= (r - zDifference) * Math.abs(zDifference) * 0.0006;
            if (new Pos(entity.posX, entity.posY, entity.posZ).distance(position) < 4) {
                if (!explosionCreated && callCount % 5 == 0) {
                    world().spawnParticle("hugeexplosion", entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D);
                    explosionCreated = true;
                }
                try {
                    /** If a target doesn't exist, search for a random one within 100 block
                         * range. */
                    if (this.teleportTarget == null) {
                        int checkY;
                        int checkX = this.world().rand.nextInt(300) - 150 + (int) this.controller.posX;
                        int checkZ = this.world().rand.nextInt(300) - 150 + (int) this.controller.posZ;
                        for (checkY = 63; !this.world().isAirBlock(checkX, checkY, checkZ) && !this.world().isAirBlock(checkX, checkY + 1, checkZ); ++checkY) {
                            ;
                        }
                        this.teleportTarget = new Pos(checkX, checkY, checkZ);
                    }
                    this.world().playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F);
                    if (entity instanceof EntityPlayerMP) {
                        ((EntityPlayerMP) entity).playerNetServerHandler.setPlayerLocation(this.teleportTarget.x() + 0.5, this.teleportTarget.y() + 0.5, this.teleportTarget.z() + 0.5, entity.rotationYaw, entity.rotationPitch);
                    } else {
                        entity.setPosition(this.teleportTarget.x() + 0.5, this.teleportTarget.y() + 0.5, this.teleportTarget.z() + 0.5);
                    }
                } catch (Exception e) {
                    ICBMClassic.INSTANCE.logger().error("Failed to teleport entity to the End.", e);
                }
            }
        }
    }
    this.world().playSound(this.position.x(), this.position.y(), this.position.z(), "portal.portal", 2F, world().rand.nextFloat() * 0.4F + 0.8F, false);
    if (this.callCount > this.duration) {
        this.controller.endExplosion();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 58 with EntityPlayerMP

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

the class CustomDropsCommand method canCommandSenderUseCommand.

@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 59 with EntityPlayerMP

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

the class CustomToolTipsCommand method canCommandSenderUseCommand.

@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 60 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)

Aggregations

EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)124 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 Entity (net.minecraft.entity.Entity)15 ItemStack (net.minecraft.item.ItemStack)15 TileEntity (net.minecraft.tileentity.TileEntity)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)13 EntityLivingBase (net.minecraft.entity.EntityLivingBase)12 BlockPos (net.minecraft.util.math.BlockPos)9 WrongUsageException (net.minecraft.command.WrongUsageException)7 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 Block (net.minecraft.block.Block)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 World (net.minecraft.world.World)6 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5 MinecraftServer (net.minecraft.server.MinecraftServer)5 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)4 TextComponentString (net.minecraft.util.text.TextComponentString)4 WorldServer (net.minecraft.world.WorldServer)4