mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
chemfac new fluid API, boxduct rendering fix, some RTTY funnies
This commit is contained in:
parent
bb404bc703
commit
30038b7f06
@ -151,6 +151,12 @@ public class FluidDuctBox extends FluidDuctBase implements IBlockMulti, ILookOve
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubCount() {
|
||||
|
||||
@ -2,22 +2,27 @@ package com.hbm.interfaces;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@Deprecated
|
||||
public interface IFluidAcceptor extends IFluidContainer {
|
||||
|
||||
@Deprecated int getMaxFluidFill(FluidType type);
|
||||
|
||||
int getMaxFluidFill(FluidType type);
|
||||
|
||||
@Deprecated
|
||||
public default void setFluidFillForReceive(int fill, FluidType type) {
|
||||
this.setFluidFill(fill, type);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public default int getFluidFillForReceive(FluidType type) {
|
||||
return this.getFluidFill(type);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public default int getMaxFluidFillForReceive(FluidType type) {
|
||||
return this.getMaxFluidFill(type);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public default void receiveFluid(int amount, FluidType type) {
|
||||
this.setFluidFill(this.getFluidFill(type) + amount, type);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.interfaces;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@Deprecated
|
||||
public interface IFluidContainer {
|
||||
|
||||
//Args: fill, what the fill should be set to; index, index for array if there are multiple tanks
|
||||
|
||||
@ -4,24 +4,28 @@ import java.util.List;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@Deprecated
|
||||
public interface IFluidSource extends IFluidContainer {
|
||||
|
||||
void fillFluidInit(FluidType type);
|
||||
@Deprecated void fillFluidInit(FluidType type);
|
||||
|
||||
void fillFluid(int x, int y, int z, boolean newTact, FluidType type);
|
||||
@Deprecated void fillFluid(int x, int y, int z, boolean newTact, FluidType type);
|
||||
|
||||
boolean getTact();
|
||||
List<IFluidAcceptor> getFluidList(FluidType type);
|
||||
void clearFluidList(FluidType type);
|
||||
|
||||
@Deprecated boolean getTact();
|
||||
@Deprecated List<IFluidAcceptor> getFluidList(FluidType type);
|
||||
@Deprecated void clearFluidList(FluidType type);
|
||||
|
||||
@Deprecated
|
||||
public default void setFluidFillForTransfer(int fill, FluidType type) {
|
||||
this.setFluidFill(fill, type);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public default int getFluidFillForTransfer(FluidType type) {
|
||||
return this.getFluidFill(type);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public default void transferFluid(int amount, FluidType type) {
|
||||
this.setFluidFillForTransfer(this.getFluidFillForTransfer(type) - amount, type);
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ import com.hbm.packet.PermaSyncPacket;
|
||||
import com.hbm.packet.PlayerInformPacket;
|
||||
import com.hbm.potion.HbmPotion;
|
||||
import com.hbm.saveddata.AuxSavedData;
|
||||
import com.hbm.tileentity.network.RTTYSystem;
|
||||
import com.hbm.util.ArmorUtil;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
import com.hbm.util.EnchantmentUtil;
|
||||
@ -1015,6 +1016,14 @@ public class ModEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event) {
|
||||
|
||||
if(event.phase == event.phase.START) {
|
||||
RTTYSystem.updateBroadcastQueue();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void enteringChunk(EnteringChunk evt) {
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -43,8 +44,23 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
this.updateConnections();
|
||||
if(worldObj.getTotalWorldTime() % 60 == 0) {
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
|
||||
for(FluidTank tank : inTanks()) {
|
||||
if(tank.getTankType() != Fluids.NONE) {
|
||||
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(DirPos pos : getConPos()) for(FluidTank tank : outTanks()) {
|
||||
if(tank.getTankType() != Fluids.NONE && tank.getFill() > 0) {
|
||||
this.sendFluid(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
this.speed = 100;
|
||||
@ -155,20 +171,27 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
|
||||
return 10_000_000;
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
protected List<DirPos> conPos;
|
||||
|
||||
protected List<DirPos> getConPos() {
|
||||
|
||||
if(conPos != null)
|
||||
return conPos;
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
|
||||
|
||||
for(int i = 0; i < 6; i++) {
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX * (3 - i) + rot.offsetX * 3, yCoord + 4, zCoord + dir.offsetZ * (3 - i) + rot.offsetZ * 3, Library.POS_Y);
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX * (3 - i) - rot.offsetX * 2, yCoord + 4, zCoord + dir.offsetZ * (3 - i) - rot.offsetZ * 2, Library.POS_Y);
|
||||
conPos.add(new DirPos(xCoord + dir.offsetX * (3 - i) + rot.offsetX * 3, yCoord + 4, zCoord + dir.offsetZ * (3 - i) + rot.offsetZ * 3, Library.POS_Y));
|
||||
conPos.add(new DirPos(xCoord + dir.offsetX * (3 - i) - rot.offsetX * 2, yCoord + 4, zCoord + dir.offsetZ * (3 - i) - rot.offsetZ * 2, Library.POS_Y));
|
||||
|
||||
for(int j = 0; j < 2; j++) {
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX * (3 - i) + rot.offsetX * 5, yCoord + 1 + j, zCoord + dir.offsetZ * (3 - i) + rot.offsetZ * 5, rot);
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX * (3 - i) - rot.offsetX * 4, yCoord + 1 + j, zCoord + dir.offsetZ * (3 - i) - rot.offsetZ * 4, rot.getOpposite());
|
||||
conPos.add(new DirPos(xCoord + dir.offsetX * (3 - i) + rot.offsetX * 5, yCoord + 1 + j, zCoord + dir.offsetZ * (3 - i) + rot.offsetZ * 5, rot));
|
||||
conPos.add(new DirPos(xCoord + dir.offsetX * (3 - i) - rot.offsetX * 4, yCoord + 1 + j, zCoord + dir.offsetZ * (3 - i) - rot.offsetZ * 4, rot.getOpposite()));
|
||||
}
|
||||
}
|
||||
|
||||
return conPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -17,6 +17,7 @@ import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -32,7 +33,7 @@ import net.minecraft.util.ChunkCoordinates;
|
||||
* Tanks follow the order R1(I1, I2, O1, O2), R2(I1, I2, O1, O2) ...
|
||||
* @author hbm
|
||||
*/
|
||||
public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor {
|
||||
public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor, IFluidUser {
|
||||
|
||||
public long power;
|
||||
public int[] progress;
|
||||
@ -515,6 +516,69 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
|
||||
|
||||
return outTanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, long fluid) {
|
||||
int amount = (int) fluid;
|
||||
|
||||
if(amount <= 0)
|
||||
return 0;
|
||||
|
||||
List<FluidTank> rec = new ArrayList();
|
||||
|
||||
for(FluidTank tank : inTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
rec.add(tank);
|
||||
}
|
||||
}
|
||||
|
||||
if(rec.size() == 0)
|
||||
return fluid;
|
||||
|
||||
int demand = 0;
|
||||
List<Integer> weight = new ArrayList();
|
||||
|
||||
for(FluidTank tank : rec) {
|
||||
int fillWeight = tank.getMaxFill() - tank.getFill();
|
||||
demand += fillWeight;
|
||||
weight.add(fillWeight);
|
||||
}
|
||||
|
||||
for(int i = 0; i < rec.size(); i++) {
|
||||
|
||||
if(demand <= 0)
|
||||
break;
|
||||
|
||||
FluidTank tank = rec.get(i);
|
||||
int fillWeight = weight.get(i);
|
||||
int part = (int) ((long)amount * (long)fillWeight / (long)demand);
|
||||
|
||||
tank.setFill(tank.getFill() + part);
|
||||
fluid -= part;
|
||||
}
|
||||
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type) {
|
||||
return getMaxFluidFill(type) - getFluidFillForTransfer(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalFluidForSend(FluidType type) {
|
||||
return getFluidFillForTransfer(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFluidForTransfer(FluidType type, long amount) {
|
||||
this.transferFluid((int) amount, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
51
src/main/java/com/hbm/tileentity/network/RTTYSystem.java
Normal file
51
src/main/java/com/hbm/tileentity/network/RTTYSystem.java
Normal file
@ -0,0 +1,51 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.util.Tuple.Pair;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class RTTYSystem {
|
||||
|
||||
/** Public frequency band for reading purposes, delayed by one tick */
|
||||
public static HashMap<Pair<World, String>, RTTYChannel> broadcast = new HashMap();
|
||||
/** New message queue for writing, gets written into readable Map later on */
|
||||
public static HashMap<Pair<World, String>, Object> newMessages = new HashMap();
|
||||
|
||||
/** Pushes a new signal to be used next tick. Only the last signal pushed will be used. */
|
||||
public static void broadcast(World world, String channelName, Object signal) {
|
||||
Pair identifier = new Pair(world, channelName);
|
||||
newMessages.put(identifier, signal);
|
||||
}
|
||||
|
||||
public static RTTYChannel listen(World world, String channelName) {
|
||||
RTTYChannel channel = broadcast.get(new Pair(world, channelName));
|
||||
return channel;
|
||||
}
|
||||
|
||||
public static void updateBroadcastQueue() {
|
||||
|
||||
for(Entry<Pair<World, String>, Object> worldEntry : newMessages.entrySet()) {
|
||||
Pair<World, String> identifier = worldEntry.getKey();
|
||||
Object lastSignal = worldEntry.getValue();
|
||||
|
||||
RTTYChannel channel = new RTTYChannel();
|
||||
channel.timeStamp = identifier.getKey().getTotalWorldTime();
|
||||
channel.signal = lastSignal;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RTTYChannel {
|
||||
long timeStamp = -1; //the totalWorldTime at the time of publishing, happens in the server tick event's PRE-phase. the publishing timestamp is that same number minus one
|
||||
Object signal; // a signal can be anything, a number, an encoded string, an entire blue whale, Steve from accounting, the concept of death, 7492 hot dogs, etc.
|
||||
}
|
||||
|
||||
/* Special objects for signifying specific signals to be used with RTTY machines (or telex) */
|
||||
public static enum RTTYSpecialSignal {
|
||||
BEGIN_TTY, //start a new message block
|
||||
STOP_TTY, //end the message block
|
||||
PRINT_BUFFER //print message, literally, it makes a paper printout
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user