more fluid net stuff, sulfuric acid bucket fix

This commit is contained in:
Boblet 2022-04-13 16:43:17 +02:00
parent db259a9fdc
commit f62695bab1
11 changed files with 109 additions and 17 deletions

View File

@ -53,6 +53,13 @@ public interface IFluidUser extends IFluidConnector {
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x + world.rand.nextDouble(), y + world.rand.nextDouble(), z + world.rand.nextDouble()), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 25));
}
}
public default void sendFluidToAll(FluidType type, TileEntity te) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
sendFluid(type, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
}
}
public default long getTotalFluidForSend(FluidType type) { return 0; }
public default void removeFluidForTransfer(FluidType type, long amount) { }

View File

@ -29,7 +29,6 @@ import cpw.mods.fml.relauncher.SideOnly;
public class MachineCoal extends BlockContainer {
private final Random field_149933_a = new Random();
private Random rand;
private final boolean isActive;
private static boolean keepInventory;
@ -38,7 +37,6 @@ public class MachineCoal extends BlockContainer {
public MachineCoal(boolean blockState) {
super(Material.iron);
rand = new Random();
isActive = blockState;
}

View File

@ -162,6 +162,7 @@ public class OreDictManager {
/** LEAD */
public static final DictFrame PB = new DictFrame("Lead");
//public static final DictFrame BI = new DictFrame("Bismuth");
public static final DictFrame AS = new DictFrame("Arsenic");
/** TANTALUM */
public static final DictFrame TA = new DictFrame("Tantalum");
public static final DictFrame COLTAN = new DictFrame("Coltan");
@ -327,6 +328,7 @@ public class OreDictManager {
TCALLOY .ingot(ingot_tcalloy) .dust(powder_tcalloy);
PB .nugget(nugget_lead) .ingot(ingot_lead) .dust(powder_lead) .plate(plate_lead) .block(block_lead) .ore(ore_lead, ore_meteor_lead);
//BI .nugget(nugget_bismuth) .ingot(ingot_bismuth); THAT'S WHAT YOU THOUGHT!
AS .nugget(nugget_arsenic) .ingot(ingot_arsenic);
TA .nugget(nugget_tantalium) .gem(gem_tantalium) .ingot(ingot_tantalium) .dust(powder_tantalium) .block(block_tantalium);
COLTAN .ingot(fragment_coltan) .dust(powder_coltan_ore) .block(block_coltan) .ore(ore_coltan);
NB .nugget(fragment_niobium) .ingot(ingot_niobium) .dustSmall(powder_niobium_tiny) .dust(powder_niobium) .block(block_niobium);

View File

@ -286,7 +286,7 @@ public class AnvilRecipes {
pullFromAssembler(new ComparableStack(ModItems.plate_mixed, 4), 3);
constructionRecipes.add(new AnvilConstructionRecipe(
new AStack[] {new ComparableStack(ModItems.ingot_arsenic), new OreDictStack(REDSTONE.dust(), 4), new OreDictStack(ASBESTOS.ingot(), 2)},
new AStack[] {new OreDictStack(AS.ingot()), new OreDictStack(REDSTONE.dust(), 4), new OreDictStack(ASBESTOS.ingot(), 2)},
new AnvilOutput(new ItemStack(ModItems.circuit_arsenic_raw))).setTier(5));
constructionRecipes.add(new AnvilConstructionRecipe(new ComparableStack(ModItems.ingot_u233, 1), new AnvilOutput(new ItemStack(ModItems.plate_fuel_u233))).setTier(4));

View File

@ -5631,6 +5631,7 @@ public class ModItems {
FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.acid_fluid, 1000), new ItemStack(ModItems.bucket_acid));
FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.toxic_fluid, 1000), new ItemStack(ModItems.bucket_toxic));
FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.schrabidic_fluid, 1000), new ItemStack(ModItems.bucket_schrabidic_acid));
FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.sulfuric_acid_fluid, 1000), new ItemStack(ModItems.bucket_sulfuric_acid));
BucketHandler.INSTANCE.buckets.put(ModBlocks.mud_block, ModItems.bucket_mud);
BucketHandler.INSTANCE.buckets.put(ModBlocks.acid_block, ModItems.bucket_acid);
BucketHandler.INSTANCE.buckets.put(ModBlocks.toxic_block, ModItems.bucket_toxic);

View File

@ -85,6 +85,11 @@ public class ItemFluidIdentifier extends Item implements IItemFluidIdentifier {
return Fluids.fromID(stack.getItemDamage());
}
@Override
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) {
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f1, float f2, float f3) {
TileEntity te = world.getTileEntity(x, y, z);
@ -139,7 +144,7 @@ public class ItemFluidIdentifier extends Item implements IItemFluidIdentifier {
if (te instanceof TileEntityFluidDuctSimple && ((TileEntityFluidDuctSimple) te).getType() == oldType) {
TileEntityFluidDuctSimple nextDuct = (TileEntityFluidDuctSimple) te;
long connectionsCount = Arrays.stream(nextDuct.connections).filter(Objects::nonNull).count();
long connectionsCount = Arrays.stream(nextDuct.connections).filter(Objects::nonNull).count(); // (o -> Objects.nonNull(o))
if (connectionsCount > 1) {
markDuctsRecursively(world, nextX, nextY, nextZ, type, maxRecursion - currentRecursion);

View File

@ -1,8 +1,6 @@
package com.hbm.tileentity.machine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.interfaces.IFluidContainer;
@ -18,11 +16,12 @@ import com.hbm.tileentity.TileEntityMachineBase;
import api.hbm.energy.IBatteryItem;
import api.hbm.energy.IEnergyGenerator;
import api.hbm.fluid.IFluidStandardReceiver;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineDiesel extends TileEntityMachineBase implements IEnergyGenerator, IFluidContainer, IFluidAcceptor {
public class TileEntityMachineDiesel extends TileEntityMachineBase implements IEnergyGenerator, IFluidContainer, IFluidAcceptor, IFluidStandardReceiver {
public long power;
public int soundCycle = 0;
@ -102,6 +101,8 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
this.updateStandardPipes(Fluids.WATER, worldObj, xCoord, yCoord, zCoord);
//Tank Management
tank.setType(3, 4, slots);
@ -229,4 +230,9 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
if(type == tank.getTankType())
tank.setFill(i);
}
@Override
public FluidTank[] getReceivingTanks() {
return new FluidTank[] {tank};
}
}

View File

@ -14,14 +14,13 @@ import com.hbm.lib.Library;
import com.hbm.main.ModEventHandler;
import com.hbm.tileentity.TileEntityMachineBase;
import api.hbm.fluid.IFluidStandardSender;
import api.hbm.fluid.IFluidUser;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.EnumSkyBlock;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcceptor, IFluidSource, IFluidStandardSender {
public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcceptor, IFluidSource, IFluidUser {
public FluidTank tank;
public short mode = 0;
@ -54,7 +53,13 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
tank.unloadTank(4, 5, slots);
tank.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
this.sendFluid(tank.getTankType(), worldObj, xCoord, yCoord - 1, zCoord, ForgeDirection.DOWN);
if(this.mode == 1 || this.mode == 2) {
this.sendFluidToAll(tank.getTankType(), this);
}
/*
* TODO: these don't work as receivers yet, don't forget how the subscription system works
*/
age++;
if(age >= 20)
@ -206,7 +211,18 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
}
@Override
public FluidTank[] getSendingTanks() {
return new FluidTank[] {tank};
public long transferFluid(FluidType type, long fluid) {
long toTransfer = Math.min(getDemand(type), fluid);
tank.setFill(tank.getFill() + (int) toTransfer);
return fluid - toTransfer;
}
@Override
public long getDemand(FluidType type) {
if(this.mode == 2 || this.mode == 3)
return 0;
return type == tank.getTankType() ? tank.getMaxFill() - tank.getFill() : 0;
}
}

View File

@ -1,9 +1,11 @@
package com.hbm.tileentity.machine.storage;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.lib.Library;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
public class TileEntityMachineBAT9000 extends TileEntityBarrel {
@ -38,6 +40,17 @@ public class TileEntityMachineBAT9000 extends TileEntityBarrel {
fillFluid(this.xCoord - 3, this.yCoord, this.zCoord - 1, getTact(), type);
}
public void sendFluidToAll(FluidType type, TileEntity te) {
sendFluid(type, worldObj, xCoord + 1, yCoord, zCoord + 3, Library.POS_Z);
sendFluid(type, worldObj, xCoord - 1, yCoord, zCoord + 3, Library.POS_Z);
sendFluid(type, worldObj, xCoord + 1, yCoord, zCoord - 3, Library.NEG_Z);
sendFluid(type, worldObj, xCoord - 1, yCoord, zCoord - 3, Library.NEG_Z);
sendFluid(type, worldObj, xCoord + 3, yCoord, zCoord + 1, Library.POS_X);
sendFluid(type, worldObj, xCoord - 3, yCoord, zCoord + 1, Library.POS_X);
sendFluid(type, worldObj, xCoord + 3, yCoord, zCoord - 1, Library.NEG_X);
sendFluid(type, worldObj, xCoord - 3, yCoord, zCoord - 1, Library.NEG_X);
}
AxisAlignedBB bb = null;
@Override

View File

@ -14,13 +14,14 @@ import com.hbm.inventory.fluid.Fluids;
import com.hbm.lib.Library;
import com.hbm.tileentity.TileEntityMachineBase;
import api.hbm.fluid.IFluidUser;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements IFluidContainer, IFluidSource, IFluidAcceptor {
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements IFluidContainer, IFluidSource, IFluidAcceptor, IFluidUser {
public FluidTank tank;
public short mode = 0;
@ -49,6 +50,18 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
if(age >= 20)
age = 0;
if(this.mode == 1 || this.mode == 2) {
FluidType type = tank.getTankType();
sendFluid(type, worldObj, xCoord + 2, yCoord, zCoord - 1, Library.POS_X);
sendFluid(type, worldObj, xCoord + 2, yCoord, zCoord + 1, Library.POS_X);
sendFluid(type, worldObj, xCoord - 2, yCoord, zCoord - 1, Library.NEG_X);
sendFluid(type, worldObj, xCoord - 2, yCoord, zCoord + 1, Library.NEG_X);
sendFluid(type, worldObj, xCoord - 1, yCoord, zCoord + 2, Library.POS_Z);
sendFluid(type, worldObj, xCoord + 1, yCoord, zCoord + 2, Library.POS_Z);
sendFluid(type, worldObj, xCoord - 1, yCoord, zCoord - 2, Library.NEG_Z);
sendFluid(type, worldObj, xCoord + 1, yCoord, zCoord - 2, Library.NEG_Z);
}
if((mode == 1 || mode == 2) && (age == 9 || age == 19))
fillFluidInit(tank.getTankType());
@ -179,4 +192,20 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
nbt.setShort("mode", mode);
tank.writeToNBT(nbt, "tank");
}
@Override
public long transferFluid(FluidType type, long fluid) {
long toTransfer = Math.min(getDemand(type), fluid);
tank.setFill(tank.getFill() + (int) toTransfer);
return fluid - toTransfer;
}
@Override
public long getDemand(FluidType type) {
if(this.mode == 2 || this.mode == 3)
return 0;
return type == tank.getTankType() ? tank.getMaxFill() - tank.getFill() : 0;
}
}

View File

@ -5,6 +5,7 @@ import com.hbm.inventory.fluid.FluidType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
@ -26,13 +27,27 @@ public class TileEntityMachineOrbus extends TileEntityBarrel {
public void fillFluidInit(FluidType type) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
ForgeDirection d2 = dir.getRotation(ForgeDirection.DOWN);
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
for(int i = -1; i < 7; i += 7) {
this.fillFluid(xCoord, yCoord + i, zCoord, this.getTact(), this.tank.getTankType());
this.fillFluid(xCoord + dir.offsetX, yCoord + i, zCoord + dir.offsetZ, this.getTact(), this.tank.getTankType());
this.fillFluid(xCoord + d2.offsetX, yCoord + i, zCoord + d2.offsetZ, this.getTact(), this.tank.getTankType());
this.fillFluid(xCoord + dir.offsetX + d2.offsetX, yCoord + i, zCoord + dir.offsetZ + d2.offsetZ, this.getTact(), this.tank.getTankType());
this.fillFluid(xCoord + rot.offsetX, yCoord + i, zCoord + rot.offsetZ, this.getTact(), this.tank.getTankType());
this.fillFluid(xCoord + dir.offsetX + rot.offsetX, yCoord + i, zCoord + dir.offsetZ + rot.offsetZ, this.getTact(), this.tank.getTankType());
}
}
public void sendFluidToAll(FluidType type, TileEntity te) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
for(int i = -1; i < 7; i += 7) {
ForgeDirection out = i == -1 ? ForgeDirection.DOWN : ForgeDirection.UP;
sendFluid(type, worldObj, xCoord, yCoord + i, zCoord, out);
sendFluid(type, worldObj, xCoord + dir.offsetX, yCoord + i, zCoord + dir.offsetZ, out);
sendFluid(type, worldObj, xCoord + rot.offsetX, yCoord + i, zCoord + rot.offsetZ, out);
sendFluid(type, worldObj, xCoord + dir.offsetX + rot.offsetX, yCoord + i, zCoord + dir.offsetZ + rot.offsetZ, out);
}
}