mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1562 from MellowArpeggiation/master
Add overlay tooltip to Solar Boiler
This commit is contained in:
commit
1644cfbf91
@ -1,15 +1,23 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntitySolarBoiler;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MachineSolarBoiler extends BlockDummyable {
|
||||
public class MachineSolarBoiler extends BlockDummyable implements ILookOverlay {
|
||||
|
||||
public MachineSolarBoiler(Material mat) {
|
||||
super(mat);
|
||||
@ -45,4 +53,28 @@ public class MachineSolarBoiler extends BlockDummyable {
|
||||
|
||||
this.makeExtra(world, x, y + 2, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
int[] pos = findCore(world, x, y, z);
|
||||
|
||||
if(pos == null)
|
||||
return;
|
||||
|
||||
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(!(te instanceof TileEntitySolarBoiler))
|
||||
return;
|
||||
|
||||
TileEntitySolarBoiler boiler = (TileEntitySolarBoiler) te;
|
||||
|
||||
List<String> text = new ArrayList<>();
|
||||
|
||||
FluidTank[] tanks = boiler.getAllTanks();
|
||||
|
||||
for(int i = 0; i < tanks.length; i++)
|
||||
text.add((i < 1 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + tanks[i].getTankType().getLocalizedName() + ": " + tanks[i].getFill() + "/" + tanks[i].getMaxFill() + "mB");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,16 +10,21 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.BufPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IBufPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
public class TileEntitySolarBoiler extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IFluidStandardTransceiver {
|
||||
public class TileEntitySolarBoiler extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IFluidStandardTransceiver, IBufPacketReceiver {
|
||||
|
||||
private FluidTank water;
|
||||
private FluidTank steam;
|
||||
@ -56,6 +61,8 @@ public class TileEntitySolarBoiler extends TileEntityLoadedBase implements IFlui
|
||||
this.sendFluid(steam, worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y);
|
||||
|
||||
heat = 0;
|
||||
|
||||
networkPackNT(15);
|
||||
} else {
|
||||
|
||||
//a delayed queue of mirror positions because we can't expect the boiler to always tick first
|
||||
@ -190,4 +197,20 @@ public class TileEntitySolarBoiler extends TileEntityLoadedBase implements IFlui
|
||||
public FluidTank[] getAllTanks() {
|
||||
return new FluidTank[] { water, steam };
|
||||
}
|
||||
|
||||
public void networkPackNT(int range) {
|
||||
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new BufPacket(xCoord, yCoord, zCoord, this), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
water.serialize(buf);
|
||||
steam.serialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
water.deserialize(buf);
|
||||
steam.deserialize(buf);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user