use of mcjty.rftools.PlayerBuff in project RFTools by McJty.
the class PotionEffectModule method processEntities.
private void processEntities(World world, BlockPos pos, int radius, int miny, int maxy, EnvironmentalControllerTileEntity controllerTileEntity) {
double maxsqdist = radius * radius;
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.getX() - radius, pos.getY() - radius, pos.getZ() - radius, pos.getX() + radius, pos.getY() + radius, pos.getZ() + radius));
for (EntityLivingBase entity : entities) {
double py = entity.posY;
if (py >= miny && py <= maxy) {
double px = entity.posX;
double pz = entity.posZ;
double sqdist = (px - pos.getX()) * (px - pos.getX()) + (pz - pos.getZ()) * (pz - pos.getZ());
if (sqdist < maxsqdist) {
if (controllerTileEntity.isEntityAffected(entity)) {
if (!(entity instanceof EntityPlayer) || allowedForPlayers()) {
entity.addPotionEffect(new PotionEffect(potion, MAXTICKS * 3, amplifier, true, false));
PlayerBuff buff = getBuff();
if (buff != null) {
if (entity instanceof EntityPlayer) {
BuffProperties.addBuffToPlayer((EntityPlayer) entity, buff, MAXTICKS);
}
}
}
} else if (entity instanceof EntityPlayer) {
PlayerBuff buff = getBuff();
if (buff != null) {
BuffProperties.addBuffToPlayer((EntityPlayer) entity, buff, MAXTICKS);
}
}
}
}
}
}
use of mcjty.rftools.PlayerBuff in project RFTools by McJty.
the class BuffProperties method saveNBTData.
public void saveNBTData(NBTTagCompound compound) {
compound.setBoolean("onElevator", onElevator);
compound.setInteger("buffTicks", buffTimeout);
compound.setBoolean("allowFlying", allowFlying);
compound.setBoolean("oldAllowFlying", oldAllowFlying);
int[] buffArray = new int[buffs.size()];
int[] timeoutArray = new int[buffs.size()];
int idx = 0;
for (Map.Entry<PlayerBuff, Integer> entry : buffs.entrySet()) {
PlayerBuff buff = entry.getKey();
buffArray[idx] = buff.ordinal();
timeoutArray[idx] = entry.getValue();
idx++;
}
compound.setIntArray("buffs", buffArray);
compound.setIntArray("buffTimeouts", timeoutArray);
}
use of mcjty.rftools.PlayerBuff in project RFTools by McJty.
the class BuffProperties method performBuffs.
private void performBuffs(EntityPlayerMP player) {
// Perform all buffs that we can perform here (not potion effects and also not
// passive effects like feather falling.
boolean enableFlight = false;
if (onElevator) {
enableFlight = true;
player.capabilities.isFlying = true;
} else {
for (PlayerBuff buff : buffs.keySet()) {
if (buff == PlayerBuff.BUFF_FLIGHT) {
enableFlight = true;
break;
}
}
}
boolean oldAllow = player.capabilities.allowFlying;
if (enableFlight) {
if (!allowFlying) {
// We were not already allowing flying.
oldAllowFlying = player.capabilities.allowFlying;
allowFlying = true;
}
player.capabilities.allowFlying = true;
} else {
if (allowFlying) {
// We were flying before.
player.capabilities.allowFlying = oldAllowFlying;
if (player.capabilities.isCreativeMode) {
player.capabilities.allowFlying = true;
}
allowFlying = false;
}
}
if (player.capabilities.allowFlying != oldAllow) {
if (!player.capabilities.allowFlying) {
player.capabilities.isFlying = false;
}
}
player.sendPlayerAbilities();
}
use of mcjty.rftools.PlayerBuff in project RFTools by McJty.
the class PotionEffectModule method processPlayers.
private void processPlayers(World world, BlockPos pos, int radius, int miny, int maxy, EnvironmentalControllerTileEntity controllerTileEntity) {
double maxsqdist = radius * radius;
List<EntityPlayer> players = new ArrayList<>(world.playerEntities);
for (EntityPlayer player : players) {
double py = player.posY;
if (py >= miny && py <= maxy) {
double px = player.posX;
double pz = player.posZ;
double sqdist = (px - pos.getX()) * (px - pos.getX()) + (pz - pos.getZ()) * (pz - pos.getZ());
if (sqdist < maxsqdist) {
if (controllerTileEntity.isPlayerAffected(player)) {
player.addPotionEffect(new PotionEffect(potion, MAXTICKS * 3, amplifier, true, false));
PlayerBuff buff = getBuff();
if (buff != null) {
BuffProperties.addBuffToPlayer(player, buff, MAXTICKS);
}
}
}
}
}
}
Aggregations