use of me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic in project pnc-repressurized by TeamPneumatic.
the class BlockHeatSink method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityHeatSink && entity instanceof EntityLivingBase) {
IHeatExchangerLogic heat = ((TileEntityHeatSink) te).getHeatExchangerLogic(null);
int temp = (int) ((TileEntityHeatSink) te).getHeatExchangerLogic(null).getTemperature();
if (temp > 323) {
// +50C
entity.attackEntityFrom(DamageSource.HOT_FLOOR, 2);
if (temp > 373) {
// +100C
entity.setFire(3);
}
} else if (temp < 243) {
// -30C
int durationSec = (243 - (int) heat.getTemperature()) / 10;
int amplifier = (243 - (int) heat.getTemperature()) / 80;
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, durationSec * 20, amplifier));
if (temp < 213) {
// -60C
entity.attackEntityFrom(DamageSourcePneumaticCraft.FREEZING, 2);
}
}
}
}
use of me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic in project pnc-repressurized by TeamPneumatic.
the class HeatExchangerLogic method update.
@Override
public void update() {
if (getThermalCapacity() < 0.1D) {
temperature = 295;
return;
}
if (newBehaviours != null) {
List<HeatBehaviour> oldBehaviours = behaviours;
behaviours = newBehaviours;
newBehaviours = null;
for (HeatBehaviour oldBehaviour : oldBehaviours) {
// Transfer over equal heat behaviour's info.
int equalBehaviourIndex = behaviours.indexOf(oldBehaviour);
if (equalBehaviourIndex >= 0) {
NBTTagCompound tag = new NBTTagCompound();
oldBehaviour.writeToNBT(tag);
behaviours.get(equalBehaviourIndex).readFromNBT(tag);
}
}
}
Iterator<HeatBehaviour> iterator = behaviours.iterator();
while (iterator.hasNext()) {
HeatBehaviour behaviour = iterator.next();
if (behaviour.getWorld() != null) {
// upon loading from NBT the world is null. gets initialized once 'initializeAsHull' is invoked.
if (behaviour.isApplicable()) {
behaviour.update();
} else {
iterator.remove();
}
}
}
for (IHeatExchangerLogic logic : connectedExchangers) {
// As the connected logics also will tick, we should prevent dispersing more when more are connected.
exchange(logic, this, getTickingHeatExchangers());
}
}
use of me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic in project pnc-repressurized by TeamPneumatic.
the class HeatExchangerLogic method initializeAsHull.
@Override
public void initializeAsHull(World world, BlockPos pos, EnumFacing... validSides) {
if (world.isRemote)
return;
for (IHeatExchangerLogic logic : hullExchangers) {
removeConnectedExchanger(logic);
}
hullExchangers.clear();
newBehaviours = new ArrayList<HeatBehaviour>();
for (EnumFacing d : EnumFacing.VALUES) {
if (isSideValid(validSides, d)) {
HeatBehaviourManager.getInstance().addHeatBehaviours(world, pos.offset(d), this, newBehaviours);
IHeatExchangerLogic logic = HeatExchangerManager.getInstance().getLogic(world, pos.offset(d), d.getOpposite());
if (logic != null) {
hullExchangers.add(logic);
addConnectedExchanger(logic);
}
}
}
}
use of me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic in project pnc-repressurized by TeamPneumatic.
the class WailaHeatHandler method getNBTData.
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te instanceof IHeatExchanger) {
Set<IHeatExchangerLogic> heatExchangers = new HashSet<>();
IHeatExchangerLogic logic = null;
boolean isMultisided = true;
for (EnumFacing face : EnumFacing.values()) {
logic = ((IHeatExchanger) te).getHeatExchangerLogic(face);
if (logic != null) {
if (heatExchangers.contains(logic)) {
isMultisided = false;
break;
} else {
heatExchangers.add(logic);
}
}
}
if (isMultisided) {
NBTTagList tagList = new NBTTagList();
for (EnumFacing face : EnumFacing.values()) {
logic = ((IHeatExchanger) te).getHeatExchangerLogic(face);
if (logic != null) {
NBTTagCompound heatTag = new NBTTagCompound();
heatTag.setByte("side", (byte) face.ordinal());
heatTag.setInteger("temp", (int) logic.getTemperature());
tagList.appendTag(heatTag);
}
}
tag.setTag("heat", tagList);
} else if (logic != null) {
tag.setInteger("temp", (int) logic.getTemperature());
}
}
return tag;
}
use of me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic in project pnc-repressurized by TeamPneumatic.
the class ItemManometer method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote)
return EnumActionResult.PASS;
ItemStack iStack = player.getHeldItem(hand);
if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
TileEntity te = world.getTileEntity(pos);
IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
List<ITextComponent> curInfo = new ArrayList<>();
List<String> info = new ArrayList<>();
if (machine != null && machine.getAirHandler(side) != null) {
machine.getAirHandler(side).printManometerMessage(player, info);
}
if (te instanceof IManoMeasurable) {
((IManoMeasurable) te).printManometerMessage(player, info);
}
for (String s : info) curInfo.add(new TextComponentTranslation(s));
if (te instanceof IHeatExchanger) {
IHeatExchangerLogic exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(side);
if (exchanger != null) {
curInfo.add(new TextComponentTranslation("waila.temperature", (int) exchanger.getTemperature() - 273));
} else {
for (EnumFacing d : EnumFacing.VALUES) {
exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (exchanger != null) {
curInfo.add(new TextComponentTranslation("waila.temperature." + d.toString().toLowerCase(), (int) exchanger.getTemperature() - 273));
}
}
}
}
if (curInfo.size() > 0) {
((IPressurizable) iStack.getItem()).addAir(iStack, -30);
for (ITextComponent s : curInfo) {
player.sendStatusMessage(s, false);
}
return EnumActionResult.SUCCESS;
}
} else {
player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "The Manometer doesn't have any charge!"), false);
return EnumActionResult.FAIL;
}
return EnumActionResult.PASS;
}
Aggregations