Fixed ARC FluidTanks + book work
Fixed the ARC so that it could actually accept FluidStacks via capabilities. Also added several entries to the book regarding the Blood Altar and its runes.
This commit is contained in:
parent
4ada12dd5e
commit
797963ff04
26 changed files with 419 additions and 40 deletions
|
@ -389,8 +389,7 @@ public class BloodAltar// implements IFluidHandler
|
|||
{
|
||||
ItemStack contained = tileAltar.getStackInSlot(0);
|
||||
|
||||
if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb)
|
||||
|| !(contained.getItem() instanceof IBindable))
|
||||
if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb) || !(contained.getItem() instanceof IBindable))
|
||||
return;
|
||||
|
||||
BloodOrb orb = ((IBloodOrb) contained.getItem()).getOrb(contained);
|
||||
|
@ -404,10 +403,8 @@ public class BloodAltar// implements IFluidHandler
|
|||
// int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2
|
||||
// ? orb.getFillRate() * (1 + consumptionMultiplier)
|
||||
// : orb.getFillRate()), fluid.getAmount());
|
||||
int liquidDrained = Math.min((int) (orb.getFillRate()
|
||||
* (1 + consumptionMultiplier)), fluid.getAmount());
|
||||
int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity()
|
||||
* this.orbCapacityMultiplier));
|
||||
int liquidDrained = Math.min((int) (orb.getFillRate() * (1 + consumptionMultiplier)), fluid.getAmount());
|
||||
int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
|
||||
fluid.setAmount(fluid.getAmount() - drain);
|
||||
|
||||
if (drain > 0 && internalCounter % 4 == 0 && world instanceof ServerWorld)
|
||||
|
@ -456,15 +453,12 @@ public class BloodAltar// implements IFluidHandler
|
|||
this.efficiencyMultiplier = (float) Math.pow(0.85, upgrade.getLevel(BloodRuneType.EFFICIENCY));
|
||||
this.sacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getLevel(BloodRuneType.SACRIFICE));
|
||||
this.selfSacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getLevel(BloodRuneType.SELF_SACRIFICE));
|
||||
this.capacityMultiplier = (float) ((1
|
||||
* Math.pow(1.10, upgrade.getLevel(BloodRuneType.AUGMENTED_CAPACITY))) + 0.20
|
||||
* upgrade.getLevel(BloodRuneType.CAPACITY));
|
||||
this.capacityMultiplier = (float) ((1 + 0.20 * upgrade.getLevel(BloodRuneType.CAPACITY) * Math.pow(1.075, upgrade.getLevel(BloodRuneType.AUGMENTED_CAPACITY))));
|
||||
this.dislocationMultiplier = (float) (Math.pow(1.2, upgrade.getLevel(BloodRuneType.DISPLACEMENT)));
|
||||
this.orbCapacityMultiplier = (float) (1 + 0.02 * upgrade.getLevel(BloodRuneType.ORB));
|
||||
this.chargingFrequency = Math.max(20 - accelerationUpgrades, 1);
|
||||
this.chargingRate = (int) (10 * upgrade.getLevel(BloodRuneType.CHARGING) * (1 + consumptionMultiplier / 2));
|
||||
this.maxCharge = (int) (FluidAttributes.BUCKET_VOLUME * Math.max(0.5 * capacityMultiplier, 1)
|
||||
* upgrade.getLevel(BloodRuneType.CHARGING));
|
||||
this.maxCharge = (int) (FluidAttributes.BUCKET_VOLUME * Math.max(0.5 * capacityMultiplier, 1) * upgrade.getLevel(BloodRuneType.CHARGING));
|
||||
}
|
||||
|
||||
this.capacity = (int) (FluidAttributes.BUCKET_VOLUME * 10 * capacityMultiplier);
|
||||
|
|
|
@ -44,8 +44,7 @@ public class RenderResizableCuboid
|
|||
{
|
||||
return new Vector3f(vector.getX(), vector.getY(), value);
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = " + vector + ")");
|
||||
}
|
||||
|
||||
public static double getValue(Vector3d vector, Axis axis)
|
||||
|
@ -60,8 +59,7 @@ public class RenderResizableCuboid
|
|||
{
|
||||
return vector.z;
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = " + vector + ")");
|
||||
}
|
||||
|
||||
public void renderCube(Model3D cube, MatrixStack matrix, IVertexBuilder buffer, int argb, int light, int overlay)
|
||||
|
@ -108,8 +106,7 @@ public class RenderResizableCuboid
|
|||
// to see the texture artifacts
|
||||
for (int uIndex = 0; uIndex < sizeU; uIndex++)
|
||||
{
|
||||
float[] baseUV = new float[]
|
||||
{ minU, maxU, minV, maxV };
|
||||
float[] baseUV = new float[] { minU, maxU, minV, maxV };
|
||||
double addU = 1;
|
||||
// If the size of the texture is greater than the cuboid goes on for then make
|
||||
// sure the texture positions are lowered
|
||||
|
@ -127,8 +124,8 @@ public class RenderResizableCuboid
|
|||
addV = sizeV - vIndex;
|
||||
uv[V_MAX] = uv[V_MIN] + (uv[V_MAX] - uv[V_MIN]) * (float) addV;
|
||||
}
|
||||
float[] xyz = new float[]
|
||||
{ uIndex, (float) (uIndex + addU), vIndex, (float) (vIndex + addV) };
|
||||
float[] xyz = new float[] { uIndex, (float) (uIndex + addU), vIndex,
|
||||
(float) (vIndex + addV) };
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
|
@ -147,9 +144,7 @@ public class RenderResizableCuboid
|
|||
matrix.pop();
|
||||
}
|
||||
|
||||
private void renderPoint(Matrix4f matrix4f, Matrix3f normal, IVertexBuilder buffer, Direction face, Axis u, Axis v,
|
||||
float other, float[] uv, float[] xyz, boolean minU, boolean minV, float red, float green, float blue,
|
||||
float alpha, int light, int overlay)
|
||||
private void renderPoint(Matrix4f matrix4f, Matrix3f normal, IVertexBuilder buffer, Direction face, Axis u, Axis v, float other, float[] uv, float[] xyz, boolean minU, boolean minV, float red, float green, float blue, float alpha, int light, int overlay)
|
||||
{
|
||||
int U_ARRAY = minU ? U_MIN : U_MAX;
|
||||
int V_ARRAY = minV ? V_MIN : V_MAX;
|
||||
|
@ -160,8 +155,7 @@ public class RenderResizableCuboid
|
|||
// TODO: Figure out how and why this works, it gives about the same brightness
|
||||
// as we used to have but I don't understand why/how
|
||||
float adjustment = 2.5F;
|
||||
Vector3f norm = new Vector3f(normalForFace.getX() + adjustment, normalForFace.getY()
|
||||
+ adjustment, normalForFace.getZ() + adjustment);
|
||||
Vector3f norm = new Vector3f(normalForFace.getX() + adjustment, normalForFace.getY() + adjustment, normalForFace.getZ() + adjustment);
|
||||
norm.normalize();
|
||||
buffer.pos(matrix4f, vertex.getX(), vertex.getY(), vertex.getZ()).color(red, green, blue, alpha).tex(uv[U_ARRAY], uv[V_ARRAY]).overlay(overlay).lightmap(light).normal(normal, norm.getX(), norm.getY(), norm.getZ()).endVertex();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package wayoftime.bloodmagic.network;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
||||
|
||||
public class ARCTanksPacket
|
||||
{
|
||||
private BlockPos pos;
|
||||
private CompoundNBT inputNBT;
|
||||
private CompoundNBT outputNBT;
|
||||
|
||||
public ARCTanksPacket()
|
||||
{
|
||||
pos = BlockPos.ZERO;
|
||||
inputNBT = new CompoundNBT();
|
||||
outputNBT = new CompoundNBT();
|
||||
}
|
||||
|
||||
public ARCTanksPacket(TileAlchemicalReactionChamber tile)
|
||||
{
|
||||
this(tile.getPos(), tile.inputTank.writeToNBT(new CompoundNBT()), tile.outputTank.writeToNBT(new CompoundNBT()));
|
||||
}
|
||||
|
||||
public ARCTanksPacket(BlockPos pos, CompoundNBT inputNBT, CompoundNBT outputNBT)
|
||||
{
|
||||
this.pos = pos;
|
||||
this.inputNBT = inputNBT;
|
||||
this.outputNBT = outputNBT;
|
||||
}
|
||||
|
||||
public static void encode(ARCTanksPacket pkt, PacketBuffer buf)
|
||||
{
|
||||
buf.writeBlockPos(pkt.pos);
|
||||
buf.writeCompoundTag(pkt.inputNBT);
|
||||
buf.writeCompoundTag(pkt.outputNBT);
|
||||
}
|
||||
|
||||
public static ARCTanksPacket decode(PacketBuffer buf)
|
||||
{
|
||||
ARCTanksPacket pkt = new ARCTanksPacket(buf.readBlockPos(), buf.readCompoundTag(), buf.readCompoundTag());
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
public static void handle(ARCTanksPacket message, Supplier<Context> context)
|
||||
{
|
||||
context.get().enqueueWork(() -> updateTanks(message.pos, message.inputNBT, message.outputNBT));
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void updateTanks(BlockPos pos, CompoundNBT inputNBT, CompoundNBT outputNBT)
|
||||
{
|
||||
World world = Minecraft.getInstance().world;
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAlchemicalReactionChamber)
|
||||
{
|
||||
((TileAlchemicalReactionChamber) tile).inputTank.readFromNBT(inputNBT);
|
||||
((TileAlchemicalReactionChamber) tile).outputTank.readFromNBT(outputNBT);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ public class BloodMagicPacketHandler extends BasePacketHandler
|
|||
public void initialize()
|
||||
{
|
||||
registerServerToClient(ChatUtil.PacketNoSpamChat.class, ChatUtil.PacketNoSpamChat::encode, ChatUtil.PacketNoSpamChat::decode, ChatUtil.PacketNoSpamChat::handle);
|
||||
registerServerToClient(ARCTanksPacket.class, ARCTanksPacket::encode, ARCTanksPacket::decode, ARCTanksPacket::handle);
|
||||
// INSTANCE.registerMessage(id, messageType, encoder, decoder, messageConsumer);
|
||||
// INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT);
|
||||
// INSTANCE.registerMessage(ItemRouterButtonPacketProcessor.class, ItemRouterButtonPacketProcessor.class, 1, Side.SERVER);
|
||||
|
|
|
@ -112,7 +112,8 @@ public class RitualManager
|
|||
|
||||
public Ritual getRitual(String id)
|
||||
{
|
||||
return rituals.get(id).getNewCopy();
|
||||
Ritual ritual = rituals.get(id);
|
||||
return ritual == null ? null : ritual.getNewCopy();
|
||||
}
|
||||
|
||||
public String getId(Ritual ritual)
|
||||
|
|
|
@ -90,8 +90,7 @@ public class RitualLava extends Ritual
|
|||
AreaDescriptor lavaRange = masterRitualStone.getBlockRange(LAVA_RANGE);
|
||||
|
||||
int maxLavaVolume = getMaxVolumeForRange(LAVA_RANGE, willConfig, holder);
|
||||
if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder))
|
||||
|| (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume))
|
||||
if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder)) || (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -202,8 +201,7 @@ public class RitualLava extends Ritual
|
|||
{
|
||||
break;
|
||||
}
|
||||
if (!entity.isPotionActive(Effects.FIRE_RESISTANCE)
|
||||
|| (entity.getActivePotionEffect(Effects.FIRE_RESISTANCE).getDuration() < 2))
|
||||
if (!entity.isPotionActive(Effects.FIRE_RESISTANCE) || (entity.getActivePotionEffect(Effects.FIRE_RESISTANCE).getDuration() < 2))
|
||||
{
|
||||
entity.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, 100, 0));
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -18,26 +21,30 @@ import net.minecraft.tileentity.TileEntityType;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.event.recipes.FluidStackIngredient;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
|
||||
import wayoftime.bloodmagic.common.item.IARCTool;
|
||||
import wayoftime.bloodmagic.common.item.inventory.InventoryWrapper;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
import wayoftime.bloodmagic.network.ARCTanksPacket;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.MultiSlotItemHandler;
|
||||
|
||||
public class TileAlchemicalReactionChamber extends TileInventory implements ITickableTileEntity, INamedContainerProvider, ISidedInventory
|
||||
public class TileAlchemicalReactionChamber extends TileInventory implements ITickableTileEntity, INamedContainerProvider, ISidedInventory, IFluidHandler
|
||||
{
|
||||
@ObjectHolder("bloodmagic:alchemicalreactionchamber")
|
||||
public static TileEntityType<TileAlchemicalReactionChamber> TYPE;
|
||||
|
@ -389,9 +396,7 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
{
|
||||
Optional<FluidStack> fluidStackOptional = FluidUtil.getFluidContained(itemStack);
|
||||
|
||||
return fluidStackOptional.isPresent()
|
||||
&& ((index == OUTPUT_BUCKET_SLOT && !fluidStackOptional.get().isEmpty())
|
||||
|| (index == INPUT_BUCKET_SLOT && fluidStackOptional.get().isEmpty()));
|
||||
return fluidStackOptional.isPresent() && ((index == OUTPUT_BUCKET_SLOT && !fluidStackOptional.get().isEmpty()) || (index == INPUT_BUCKET_SLOT && fluidStackOptional.get().isEmpty()));
|
||||
}
|
||||
|
||||
if (index >= OUTPUT_SLOT && index < OUTPUT_SLOT + NUM_OUTPUTS)
|
||||
|
@ -412,4 +417,94 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
{
|
||||
return index >= OUTPUT_SLOT && index < OUTPUT_SLOT + NUM_OUTPUTS;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
||||
{
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
{
|
||||
return LazyOptional.of(() -> this).cast();
|
||||
}
|
||||
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanks()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank)
|
||||
{
|
||||
switch (tank)
|
||||
{
|
||||
case 0:
|
||||
return inputTank.getFluid();
|
||||
default:
|
||||
return outputTank.getFluid();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank)
|
||||
{
|
||||
switch (tank)
|
||||
{
|
||||
case 0:
|
||||
return inputTank.getCapacity();
|
||||
default:
|
||||
return outputTank.getCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, FluidStack stack)
|
||||
{
|
||||
switch (tank)
|
||||
{
|
||||
case 0:
|
||||
return inputTank.isFluidValid(stack);
|
||||
default:
|
||||
return outputTank.isFluidValid(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
{
|
||||
int fillAmount = inputTank.fill(resource, action);
|
||||
if (fillAmount > 0 && !world.isRemote)
|
||||
{
|
||||
BloodMagic.packetHandler.sendToAllTracking(new ARCTanksPacket(this), this);
|
||||
// this.world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 3);
|
||||
}
|
||||
return fillAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
FluidStack drainedStack = outputTank.drain(resource, action);
|
||||
if (!drainedStack.isEmpty() && !world.isRemote)
|
||||
{
|
||||
BloodMagic.packetHandler.sendToAllTracking(new ARCTanksPacket(this), this);
|
||||
// this.world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 3);
|
||||
}
|
||||
return drainedStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
FluidStack drainedStack = outputTank.drain(maxDrain, action);
|
||||
if (!drainedStack.isEmpty() && !world.isRemote)
|
||||
{
|
||||
BloodMagic.packetHandler.sendToAllTracking(new ARCTanksPacket(this), this);
|
||||
// this.world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 3);
|
||||
}
|
||||
return drainedStack;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue