use of uk.co.wehavecookies56.kk.common.network.packet.client.SpawnCureParticles in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class BlockSavePoint method updateState.
private void updateState(World world, BlockPos pos) {
List list = world.getEntitiesWithinAABBExcludingEntity((Entity) null, new AxisAlignedBB(pos.add(0, 0, 0), pos.add(1, 1, 1)));
if (!list.isEmpty())
for (int i = 0; i < list.size(); i++) {
Entity e = (Entity) list.get(i);
if (e instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) e;
IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
// System.out.println(player.getBedLocation());
// System.out.println(pos.getX());
boolean samePos;
BlockPos bedPos;
if (player.getBedLocation() == null) {
IFirstTimeJoin originalPos = player.getCapability(ModCapabilities.FIRST_TIME_JOIN, null);
bedPos = new BlockPos(originalPos.getPosX(), originalPos.getPosY(), originalPos.getPosZ());
} else {
bedPos = player.getBedLocation();
}
samePos = bedPos.getX() == pos.getX() && bedPos.getY() == pos.getY() && bedPos.getZ() == pos.getZ();
if (player.isSneaking() && !samePos) {
player.setSpawnChunk(pos, true, 0);
player.setSpawnPoint(pos, true);
TextHelper.sendFormattedChatMessage("Spawn point saved!", TextFormatting.GREEN, player);
world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.savespawn, SoundCategory.BLOCKS, 1.0f, 1.0f);
}
if (player.getHealth() < player.getMaxHealth() || STATS.getMP() < STATS.getMaxMP()) {
player.heal(1);
STATS.addMP(2);
if (player.getFoodStats().getFoodLevel() < 20)
player.getFoodStats().addStats(4, 0);
if (timeHealed + 1 <= (int) Minecraft.getSystemTime() / 1000) {
world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.savepoint, SoundCategory.BLOCKS, 1.0f, 1.0f);
PacketDispatcher.sendToAllAround(new SpawnCureParticles(pos, true), player, 64.0D);
}
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), STATS), (EntityPlayerMP) player);
}
}
}
world.scheduleUpdate(new BlockPos(pos), this, this.tickRate(world));
}
Aggregations