use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.
the class PlayerEvents method onBlockHarvest.
@SubscribeEvent
public void onBlockHarvest(final BlockEvent.HarvestDropsEvent ev) {
if (ev.getHarvester() == null || ev.getHarvester() instanceof FakePlayer)
return;
EntityPlayer pl = ev.getHarvester();
Item tool = pl.getHeldItem(EnumHand.MAIN_HAND).getItem();
if (tool instanceof SpecialHarvestTool)
((SpecialHarvestTool) tool).doHarvestEffect(ev);
if (ev.getWorld().isRemote)
return;
Block bl = ev.getState().getBlock();
if (bl instanceof BlockCrops || bl instanceof BlockFlower || bl instanceof BlockVine || bl instanceof BlockLeaves) {
if (!(bl instanceof BlockCrops) || ((BlockCrops) bl).isMaxAge(ev.getState())) {
if (bl instanceof BlockCrops && ev.getWorld().isDaytime()) {
PlayerUtil.getAdventPlayer(pl).stats().addTribute(Enums.Deities.SELYAN, 2);
if (AdventOfAscension.rand.nextInt(2000) == 0)
pl.entityDropItem(new ItemStack(WeaponRegister.GARDENER), 0);
}
if (bl instanceof BlockLeaves ? AdventOfAscension.rand.nextInt(35) == 0 : bl instanceof BlockCrops ? AdventOfAscension.rand.nextInt(6) == 0 : AdventOfAscension.rand.nextInt(8) == 0) {
EntityAnimaStone animaStone = new EntityAnimaStone(ev.getWorld(), ev.getPos());
ev.getWorld().playSound(null, ev.getPos(), SoundsRegister.HEART_STONE_SPAWN, SoundCategory.MASTER, 1.0f, 1.0f);
ev.getWorld().spawnEntity(animaStone);
}
}
} else if (bl == Blocks.STONE || bl == Blocks.NETHERRACK || bl instanceof StoneBlock || bl == Blocks.END_STONE) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer(pl);
int lvl = plData.stats().getLevel(Enums.Skills.FORAGING);
if (bl != Blocks.NETHERRACK || AdventOfAscension.rand.nextBoolean()) {
if (ForagingUtil.shouldGetLoot(lvl)) {
ev.getDrops().addAll(ForagingUtil.getLoot(pl));
if (plData.equipment().getCurrentFullArmourSet() == Enums.ArmourSets.FORAGING)
ev.getDrops().addAll(ForagingUtil.getLoot(pl));
ev.getWorld().playSound(null, ev.getPos(), SoundsRegister.FORAGING_LOOT, SoundCategory.MASTER, 1.0f, 1.0f);
if (ev.getWorld().provider.getDimension() == 0 && ev.getWorld().isDaytime())
plData.stats().addTribute(Enums.Deities.PLUTON, 11 - lvl / 10);
}
}
} else if (bl instanceof BlockLog) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer(pl);
int lvl = plData.stats().getLevel(Enums.Skills.LOGGING);
if (LoggingUtil.shouldGetLoot(lvl)) {
if (AdventOfAscension.rand.nextBoolean()) {
ev.getDrops().addAll(LoggingUtil.getLoot(pl));
if (plData.equipment().getCurrentFullArmourSet() == Enums.ArmourSets.LOGGING)
ev.getDrops().addAll(LoggingUtil.getLoot(pl));
} else {
ItemStack duplicateStack = ItemStack.EMPTY;
for (ItemStack stack : ev.getDrops()) {
if (stack.getItem() == Item.getItemFromBlock(bl)) {
duplicateStack = stack.copy();
duplicateStack.setCount(lvl > 50 ? 2 : 1);
plData.stats().addXp(Enums.Skills.LOGGING, (float) Math.pow(lvl, 1.65D) * 3, false, false);
break;
}
}
if (!duplicateStack.isEmpty())
ev.getDrops().add(duplicateStack);
}
if (ev.getWorld().provider.getDimension() == 0)
plData.stats().addTribute(Enums.Deities.PLUTON, 11 - lvl / 10);
ev.getWorld().playSound(null, ev.getPos(), SoundsRegister.FORAGING_LOOT, SoundCategory.MASTER, 1.0f, 1.0f);
}
} else if (WorldUtil.isOreBlock(bl) && ev.getPos().getY() <= 5 && ItemUtil.findInventoryItem(pl, new ItemStack(ItemRegister.BLANK_REALMSTONE), true, 1)) {
ItemUtil.givePlayerItemOrDrop(pl, new ItemStack(ItemRegister.DEEPLANDS_REALMSTONE));
}
}
use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.
the class PlayerEvents method onPlayerTick.
@SubscribeEvent
public void onPlayerTick(final TickEvent.PlayerTickEvent ev) {
if (ev.phase == TickEvent.Phase.END) {
if (!ev.player.world.isRemote) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer(ev.player);
plData.tickPlayer();
}
if (!ev.player.world.isRemote && !ev.player.capabilities.isCreativeMode && ev.player.onGround && !ev.player.isRiding())
ExpeditionUtil.handleRunningTick(ev, ev.player);
if (ev.player.dimension == ConfigurationUtil.MainConfig.dimensionIds.shyrelands) {
if (!ev.player.world.isRemote)
ShyrelandsEvents.doPlayerTick(ev.player);
} else if (ev.player.dimension == ConfigurationUtil.MainConfig.dimensionIds.lelyetia) {
LelyetiaEvents.doPlayerTick(ev.player);
} else if (ev.player.dimension == ConfigurationUtil.MainConfig.dimensionIds.voxPonds) {
if (!ev.player.world.isRemote)
VoxPondsEvents.doPlayerTick(ev.player);
}
}
}
use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.
the class PlayerEvents method onPlayerLogin.
@SubscribeEvent
public void onPlayerLogin(final net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent ev) {
if (ev.player instanceof EntityPlayerMP && !ev.player.world.isRemote) {
UUID uuid = ev.player.getGameProfile().getId();
String msg = null;
if (AdventOfAscension.instance().isTslat(uuid)) {
msg = TextFormatting.DARK_RED + "It begins...Is this the end?";
((WorldServer) ev.player.world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, ev.player.posX, ev.player.posY + 0.2, ev.player.posZ, 16, 0.5, 0.5, 0.5, 0.1);
} else if (uuid.equals(UUID.fromString("010318ef-28fc-4c7c-8940-2f0d62eabfa6"))) {
msg = TextFormatting.LIGHT_PURPLE + "Xolova creeps in to watch you suffer. Feel free to die now.";
} else if (PlayerHaloHandler.isCrazyDonator(uuid)) {
msg = TextFormatting.LIGHT_PURPLE + "They approach. Tremble before them.";
}
if (msg != null)
FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().sendMessage(new TextComponentString(msg));
OverworldEvents.alertNewPlayer(ev.player.world, ev.player);
PlayerDataManager plData = PlayerUtil.getAdventPlayer(ev.player);
PlayerDataManager.PlayerStats stats = plData.stats();
if (ConfigurationUtil.MainConfig.skillsEnabled) {
for (Enums.Skills sk : Enums.Skills.values()) {
PacketUtil.network.sendTo(new PacketSkillData(sk.id, stats.getLevelForDisplay(sk), stats.getExp(sk), stats.getSkillData(Enums.Skills.EXPEDITION)), (EntityPlayerMP) ev.player);
}
EntityUtil.applyAttributeModifierSafely(ev.player, SharedMonsterAttributes.MAX_HEALTH, AoAAttributes.innervationHealthBuff(InnervationUtil.getHealthBuff(stats.getLevel(Enums.Skills.INNERVATION))));
}
if (ConfigurationUtil.MainConfig.resourcesEnabled) {
PacketUtil.network.sendTo(new PacketTributeData(stats.getTribute(Enums.Deities.EREBON), stats.getTribute(Enums.Deities.LUXON), stats.getTribute(Enums.Deities.PLUTON), stats.getTribute(Enums.Deities.SELYAN)), (EntityPlayerMP) ev.player);
PacketUtil.network.sendTo(new PacketResourceData(stats.getResourceValue(Enums.Resources.CREATION), stats.getResourceValue(Enums.Resources.ENERGY), stats.getResourceValue(Enums.Resources.RAGE), stats.getResourceValue(Enums.Resources.SOUL), plData.isRevengeActive()), (EntityPlayerMP) ev.player);
}
PlayerHaloHandler.syncWithNewClient((EntityPlayerMP) ev.player);
PlayerAdvancements plAdvancements = ((EntityPlayerMP) ev.player).getAdvancements();
Advancement rootAdv = ModUtil.getAdvancement("overworld/root");
if (rootAdv == null) {
AdventOfAscension.logMessage(Level.WARN, "Unable to find inbuilt advancements, another mod is breaking things.");
if (ConfigurationUtil.MainConfig.doVerboseDebugging) {
AdventOfAscension.logOptionalMessage("Printing out current advancements list...");
FMLCommonHandler.instance().getMinecraftServerInstance().getAdvancementManager().getAdvancements().forEach(advancement -> AdventOfAscension.logOptionalMessage(advancement.getId().toString()));
}
} else if (!plAdvancements.getProgress(rootAdv).isDone()) {
plAdvancements.grantCriterion(ModUtil.getAdvancement("overworld/by_the_books"), "legitimate");
plAdvancements.grantCriterion(rootAdv, "playerjoin");
}
}
}
use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.
the class PlayerEvents method onPlayerFall.
@SubscribeEvent
public void onPlayerFall(final LivingFallEvent ev) {
if (!ev.getEntity().world.isRemote && ev.getEntity() instanceof EntityPlayer) {
if (ev.getDistance() > 25 && ev.getDamageMultiplier() > 0 && ItemUtil.findInventoryItem((EntityPlayer) ev.getEntity(), new ItemStack(ItemRegister.BLANK_REALMSTONE), true, 1))
ItemUtil.givePlayerItemOrDrop((EntityPlayer) ev.getEntity(), new ItemStack(ItemRegister.LELYETIA_REALMSTONE));
PlayerDataManager plData = PlayerUtil.getAdventPlayer((EntityPlayer) ev.getEntity());
plData.handlePlayerFalling(ev);
ExpeditionUtil.handleFallEvent(ev, plData);
}
}
use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.
the class ShyrelandsEvents method doPlayerTick.
public static void doPlayerTick(EntityPlayer pl) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer(pl);
if (PlayerUtil.shouldPlayerBeAffected(pl) && pl.ticksExisted % 80 == 0 && AdventOfAscension.rand.nextInt(3) == 0) {
if (pl.posY >= 55 && pl.world.getHeight((int) pl.posX, (int) pl.posZ) <= pl.posY) {
float gustX = AdventOfAscension.rand.nextFloat();
float gustZ = AdventOfAscension.rand.nextFloat();
plData.sendThrottledChatMessage("message.event.shyrelandsWind");
pl.world.playSound(pl.posX, pl.posY, pl.posZ, SoundsRegister.SHYRELANDS_WIND, SoundCategory.AMBIENT, 1.0f, 1.0f, false);
pl.addVelocity(gustX, 0.05f, gustZ);
pl.velocityChanged = true;
}
}
}
Aggregations