mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
a bit of fluid IO, tooltips for hadron power plugs
This commit is contained in:
parent
85165e0621
commit
5f1c5cc5ba
@ -93,6 +93,10 @@ public interface IEnergyUser extends IEnergyConnector {
|
||||
}
|
||||
}
|
||||
|
||||
public default void updateStandardConnections(World world, TileEntity te) {
|
||||
updateStandardConnections(world, te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
public default void updateStandardConnections(World world, int x, int y, int z) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
|
||||
@ -1,13 +1,20 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.tileentity.machine.TileEntityHadronPower;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class BlockHadronPower extends BlockContainer {
|
||||
public class BlockHadronPower extends BlockContainer implements ILookOverlay {
|
||||
|
||||
public long power;
|
||||
|
||||
@ -20,4 +27,26 @@ public class BlockHadronPower extends BlockContainer {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityHadronPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityHadronPower))
|
||||
return;
|
||||
|
||||
TileEntityHadronPower battery = (TileEntityHadronPower) te;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(BobMathUtil.getShortNumber(battery.getPower()) + " / " + BobMathUtil.getShortNumber(battery.getMaxPower()) + "HE");
|
||||
|
||||
double percent = (double) battery.getPower() / (double) battery.getMaxPower();
|
||||
int charge = (int) Math.floor(percent * 10_000D);
|
||||
int color = ((int) (0xFF - 0xFF * percent)) << 16 | ((int)(0xFF * percent) << 8);
|
||||
|
||||
text.add("&[" + color + "&]" + (charge / 100D) + "%");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.blocks.machine.BlockHadronPower;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
@ -8,7 +9,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityHadronPower extends TileEntityLoadedBase implements IEnergyUser {
|
||||
public class TileEntityHadronPower extends TileEntityLoadedBase implements IEnergyUser, INBTPacketReceiver {
|
||||
|
||||
public long power;
|
||||
|
||||
@ -24,9 +25,18 @@ public class TileEntityHadronPower extends TileEntityLoadedBase implements IEner
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
INBTPacketReceiver.networkPack(this, data, 15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.power = nbt.getLong("power");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long i) {
|
||||
power = i;
|
||||
|
||||
@ -13,6 +13,7 @@ import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
@ -20,9 +21,8 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineCMBFactory extends TileEntityLoadedBase implements ISidedInventory, IEnergyUser, IFluidContainer, IFluidAcceptor {
|
||||
public class TileEntityMachineCMBFactory extends TileEntityLoadedBase implements ISidedInventory, IEnergyUser, IFluidContainer, IFluidAcceptor, IFluidStandardReceiver {
|
||||
|
||||
private ItemStack slots[];
|
||||
|
||||
@ -309,21 +309,18 @@ public class TileEntityMachineCMBFactory extends TileEntityLoadedBase implements
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
this.updateStandardConnections(worldObj, this);
|
||||
this.subscribeToAllAround(tank.getTankType(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long i) {
|
||||
power = i;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return power;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -356,4 +353,9 @@ public class TileEntityMachineCMBFactory extends TileEntityLoadedBase implements
|
||||
if(type.name().equals(tank.getTankType().name()))
|
||||
tank.setFill(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tank};
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,8 +20,10 @@ import com.hbm.main.MainRegistry;
|
||||
import com.hbm.sound.AudioWrapper;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@ -31,7 +33,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineChemplant extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor {
|
||||
public class TileEntityMachineChemplant extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor, IFluidStandardTransceiver {
|
||||
|
||||
public long power;
|
||||
public static final long maxPower = 100000;
|
||||
@ -195,14 +197,25 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
this.trySubscribe(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
public DirPos[] getConPos() {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
|
||||
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, rot);
|
||||
this.trySubscribe(worldObj, xCoord - rot.offsetX * 2, yCoord, zCoord - rot.offsetZ * 2, rot.getOpposite());
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 + dir.offsetX, yCoord, zCoord + rot.offsetZ * 3 + dir.offsetZ, rot);
|
||||
this.trySubscribe(worldObj, xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, rot.getOpposite());
|
||||
|
||||
return new DirPos[] {
|
||||
new DirPos(xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, rot),
|
||||
new DirPos(xCoord - rot.offsetX * 2, yCoord, zCoord - rot.offsetZ * 2, rot.getOpposite()),
|
||||
new DirPos(xCoord + rot.offsetX * 3 + dir.offsetX, yCoord, zCoord + rot.offsetZ * 3 + dir.offsetZ, rot),
|
||||
new DirPos(xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, rot.getOpposite())
|
||||
};
|
||||
}
|
||||
|
||||
private boolean canProcess() {
|
||||
@ -565,4 +578,14 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return new FluidTank[] {tanks[2], tanks[3]};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tanks[0], tanks[1]};
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ public class TileEntityMachineCoal extends TileEntityLoadedBase implements ISide
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
|
||||
this.subscribeToAllAround(Fluids.WATER, worldObj, xCoord, yCoord, zCoord);
|
||||
this.subscribeToAllAround(Fluids.WATER, this);
|
||||
|
||||
//Water
|
||||
tank.loadTank(0, 3, slots);
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
@ -13,9 +10,11 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -24,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineCrystallizer extends TileEntityMachineBase implements IEnergyUser, IFluidAcceptor {
|
||||
public class TileEntityMachineCrystallizer extends TileEntityMachineBase implements IEnergyUser, IFluidAcceptor, IFluidStandardReceiver {
|
||||
|
||||
public long power;
|
||||
public static final long maxPower = 1000000;
|
||||
@ -101,18 +100,34 @@ public class TileEntityMachineCrystallizer extends TileEntityMachineBase impleme
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
protected DirPos[] getConPos() {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
|
||||
if(dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) {
|
||||
this.trySubscribe(worldObj, xCoord + 2, yCoord + 5, zCoord, Library.POS_X);
|
||||
this.trySubscribe(worldObj, xCoord - 2, yCoord + 5, zCoord, Library.NEG_X);
|
||||
|
||||
return new DirPos[] {
|
||||
new DirPos(xCoord + 2, yCoord + 5, zCoord, Library.POS_X),
|
||||
new DirPos(xCoord - 2, yCoord + 5, zCoord, Library.NEG_X)
|
||||
};
|
||||
}
|
||||
|
||||
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
|
||||
this.trySubscribe(worldObj, xCoord, yCoord + 5, zCoord + 2, Library.POS_Z);
|
||||
this.trySubscribe(worldObj, xCoord, yCoord + 5, zCoord - 2, Library.NEG_Z);
|
||||
|
||||
return new DirPos[] {
|
||||
new DirPos(xCoord, yCoord + 5, zCoord + 2, Library.POS_Z),
|
||||
new DirPos(xCoord, yCoord + 5, zCoord - 2, Library.NEG_Z)
|
||||
};
|
||||
}
|
||||
|
||||
return new DirPos[0];
|
||||
}
|
||||
|
||||
public void networkUnpack(NBTTagCompound data) {
|
||||
@ -360,4 +375,9 @@ public class TileEntityMachineCrystallizer extends TileEntityMachineBase impleme
|
||||
if(stack != null && i >= 5 && i <= 6 && stack.getItem() instanceof ItemMachineUpgrade)
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tank};
|
||||
}
|
||||
}
|
||||
|
||||
39
src/main/java/com/hbm/util/fauxpointtwelve/DirPos.java
Normal file
39
src/main/java/com/hbm/util/fauxpointtwelve/DirPos.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.hbm.util.fauxpointtwelve;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class DirPos extends BlockPos {
|
||||
|
||||
protected ForgeDirection dir;
|
||||
|
||||
public DirPos(int x, int y, int z, ForgeDirection dir) {
|
||||
super(x, y, z);
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
public DirPos(TileEntity te, ForgeDirection dir) {
|
||||
super(te);
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
public DirPos(double x, double y, double z, ForgeDirection dir) {
|
||||
super(x, y, z);
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirPos rotate(Rotation rotationIn) {
|
||||
switch(rotationIn) {
|
||||
case NONE:
|
||||
default: return this;
|
||||
case CLOCKWISE_90: return new DirPos(-this.getZ(), this.getY(), this.getX(), this.getDir().getRotation(ForgeDirection.UP));
|
||||
case CLOCKWISE_180: return new DirPos(-this.getX(), this.getY(), -this.getZ(), this.getDir().getOpposite());
|
||||
case COUNTERCLOCKWISE_90: return new DirPos(this.getZ(), this.getY(), -this.getX(), this.getDir().getRotation(ForgeDirection.DOWN));
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection getDir() {
|
||||
return this.dir;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user