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