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;
}
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;
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
Aggregations