Search in sources :

Example 1 with BossInfoServer

use of net.minecraft.world.BossInfoServer 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 2 with BossInfoServer

use of net.minecraft.world.BossInfoServer 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)

Example 3 with BossInfoServer

use of net.minecraft.world.BossInfoServer 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 4 with BossInfoServer

use of net.minecraft.world.BossInfoServer in project SpongeCommon by SpongePowered.

the class ServerBossBarBuilder method build.

@Override
public ServerBossBar build() {
    checkState(this.name != null, "name must be set");
    checkState(this.color != null, "color must be set");
    checkState(this.overlay != null, "overlay must be set");
    BossInfoServer bar = new BossInfoServer(SpongeTexts.toComponent(this.name), (BossInfo.Color) (Object) this.color, (BossInfo.Overlay) (Object) this.overlay);
    bar.setPercent(this.percent);
    bar.setDarkenSky(this.darkenSky);
    bar.setPlayEndBossMusic(this.playEndBossMusic);
    bar.setCreateFog(this.createFog);
    bar.setVisible(this.visible);
    return (ServerBossBar) bar;
}
Also used : ServerBossBar(org.spongepowered.api.boss.ServerBossBar) BossInfoServer(net.minecraft.world.BossInfoServer) BossInfo(net.minecraft.world.BossInfo)

Aggregations

BossInfoServer (net.minecraft.world.BossInfoServer)4 UUID (java.util.UUID)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 BossInfo (net.minecraft.world.BossInfo)1 World (net.minecraft.world.World)1 ServerBossBar (org.spongepowered.api.boss.ServerBossBar)1