Search in sources :

Example 71 with EntityPlayerMP

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

the class AssortedHandler method livingTick.

@SubscribeEvent
public void livingTick(LivingEvent.LivingUpdateEvent updateEvent) {
    final EntityLivingBase entity = updateEvent.getEntityLiving();
    World world = entity.getEntityWorld();
    UUID uuid = entity.getUniqueID();
    BlockPos pos = entity.getPosition();
    if (!world.isRemote) {
        if (entity.isPotionActive(ModPotions.boss)) {
            if (!BossList.containsKey(uuid)) {
                BossInfoServer displayData = (BossInfoServer) new BossInfoServer(entity.getDisplayName(), Color.PURPLE, Overlay.PROGRESS).setDarkenSky(false);
                BossList.put(uuid, displayData);
                List<EntityPlayerMP> entities = world.getEntitiesWithinAABB(EntityPlayerMP.class, new AxisAlignedBB(pos).expand(24, 24, 24));
                if (entities != null)
                    for (EntityPlayerMP ply : entities) {
                        displayData.addPlayer(ply);
                    }
            } else {
                BossInfoServer bossInfo = BossList.get(uuid);
                bossInfo.setPercent(entity.getHealth() / entity.getMaxHealth());
            }
        } else if (world.getMinecraftServer().getTickCounter() % BossCleanupThreshold == 0 && BossList.containsKey(uuid)) {
            BossInfoServer bossInfo = BossList.get(uuid);
            for (EntityPlayerMP ply : bossInfo.getPlayers()) {
                bossInfo.removePlayer(ply);
            }
            BossList.remove(uuid);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) UUID(java.util.UUID) BossInfoServer(net.minecraft.world.BossInfoServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 72 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project NyaSamaRailway by NSDN.

the class Item74HC04 method onConnectorUseLast.

@Override
public boolean onConnectorUseLast(EntityPlayer player, UUID uuid, TileEntity tileEntity) {
    if (Railcraft.getInstance() != null) {
        if (Railcraft.getInstance().verifySwitch(tileEntity)) {
            if (receiverRails.containsKey(uuid)) {
                if (receiverRails.get(uuid) instanceof TileEntityActuator) {
                    TileEntityActuator actuator = (TileEntityActuator) receiverRails.get(uuid);
                    if (actuator.getTarget() != tileEntity) {
                        actuator.setTarget(tileEntity);
                        if (player instanceof EntityPlayerMP)
                            player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                        updateTileEntity(actuator);
                        updateTileEntity(tileEntity);
                    } else {
                        actuator.setTarget(null);
                        if (player instanceof EntityPlayerMP)
                            player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                        updateTileEntity(actuator);
                        updateTileEntity(tileEntity);
                    }
                }
                receiverRails.remove(uuid);
            } else {
                if (player instanceof EntityPlayerMP)
                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntityActuator(club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 73 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project NyaSamaRailway by NSDN.

the class ItemNTP32Bit method clearCart.

public void clearCart(ItemStack itemStack, EntityPlayer player) {
    int[] array = new int[] { -1 };
    power.set(itemStack, 0);
    brake.set(itemStack, 5);
    dir.set(itemStack, 0);
    carts.set(itemStack, array);
    if (player instanceof EntityPlayerMP) {
        TrainPacket packet = new TrainPacket();
        packet.fromStack(itemStack);
        NetworkWrapper.instance.sendTo(packet, (EntityPlayerMP) player);
    }
    player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.cleared"));
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket)

Example 74 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project NyaSamaRailway by NSDN.

the class ItemNTP8Bit method clearCart.

public void clearCart(ItemStack itemStack, EntityPlayer player) {
    power.set(itemStack, 0);
    brake.set(itemStack, 5);
    dir.set(itemStack, 0);
    cart.set(itemStack, -1);
    if (player instanceof EntityPlayerMP) {
        TrainPacket packet = new TrainPacket();
        packet.fromStack(itemStack);
        NetworkWrapper.instance.sendTo(packet, (EntityPlayerMP) player);
    }
    player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.cleared"));
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket)

Example 75 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project NyaSamaRailway by NSDN.

the class ItemNTP8Bit method onCreated.

@Override
public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
    power.set(itemStack, 0);
    brake.set(itemStack, 5);
    dir.set(itemStack, 0);
    cart.set(itemStack, -1);
    if (player instanceof EntityPlayerMP) {
        TrainPacket packet = new TrainPacket();
        packet.fromStack(itemStack);
        NetworkWrapper.instance.sendTo(packet, (EntityPlayerMP) player);
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket)

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