more misc fluid work, gonna leave most of this untill we have an offical or new api
This commit is contained in:
parent
0742abb840
commit
6a93c3fd46
28 changed files with 147 additions and 404 deletions
|
@ -10,7 +10,7 @@ import net.minecraft.client.render.model.UnbakedModel;
|
|||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.util.Identifier;
|
||||
import techreborn.client.render.DyamicCellBakedModel;
|
||||
import techreborn.client.render.DynamicCellBakedModel;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
@ -46,7 +46,7 @@ public class TechRebornClient implements ClientModInitializer {
|
|||
@Nullable
|
||||
@Override
|
||||
public BakedModel bake(ModelLoader modelLoader, Function<Identifier, Sprite> function, ModelBakeSettings modelBakeSettings) {
|
||||
return new DyamicCellBakedModel();
|
||||
return new DynamicCellBakedModel();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISubItemRetriever {
|
||||
|
||||
ItemStack getCellByName(String name);
|
||||
|
||||
ItemStack getCellByName(String name, int count);
|
||||
|
||||
ItemStack getDustByName(String name);
|
||||
|
||||
ItemStack getDustByName(String name, int count);
|
||||
|
||||
ItemStack getSmallDustByName(String name);
|
||||
|
||||
ItemStack getSmallDustByName(String name, int count);
|
||||
|
||||
ItemStack getGemByName(String name);
|
||||
|
||||
ItemStack getGemByName(String name, int count);
|
||||
|
||||
ItemStack getIngotByName(String name);
|
||||
|
||||
ItemStack getIngotByName(String name, int count);
|
||||
|
||||
ItemStack getNuggetByName(String name);
|
||||
|
||||
ItemStack getNuggetByName(String name, int count);
|
||||
|
||||
ItemStack getPartByName(String name);
|
||||
|
||||
ItemStack getPartByName(String name, int count);
|
||||
|
||||
ItemStack getPlateByName(String name);
|
||||
|
||||
ItemStack getPlateByName(String name, int count);
|
||||
|
||||
ItemStack getUpgradeByName(String name);
|
||||
|
||||
ItemStack getUpgradeByName(String name, int count);
|
||||
|
||||
ItemStack getOreByName(String name);
|
||||
|
||||
ItemStack getOreByName(String name, int count);
|
||||
|
||||
ItemStack getStorageBlockByName(String name);
|
||||
|
||||
ItemStack getStorageBlockByName(String name, int count);
|
||||
|
||||
}
|
|
@ -35,8 +35,6 @@ public final class TechRebornAPI {
|
|||
*/
|
||||
public static IRecipeCompact recipeCompact;
|
||||
|
||||
public static ISubItemRetriever subItemRetriever;
|
||||
|
||||
public static IC2Helper ic2Helper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,7 +117,7 @@ public class FluidReplicatorRecipe implements Cloneable {
|
|||
if (!FluidUtils.fluidEquals(fluid, output)) {
|
||||
return false;
|
||||
}
|
||||
final Fluid tankFluid = blockEntity.tank.getFluidType();
|
||||
final Fluid tankFluid = blockEntity.tank.getFluid();
|
||||
if (tankFluid != null && !FluidUtils.fluidEquals(tankFluid, fluid)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class IndustrialGrinderRecipe extends RebornRecipe {
|
|||
return false;
|
||||
}
|
||||
final FluidInstance recipeFluid = fluidStack;
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluid();
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluidInstance();
|
||||
if (fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class IndustrialGrinderRecipe extends RebornRecipe {
|
|||
public boolean onCraft(final BlockEntity be) {
|
||||
IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be;
|
||||
final FluidInstance recipeFluid = fluidStack;
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluid();
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluidInstance();
|
||||
if (fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class IndustrialSawmillRecipe extends RebornRecipe {
|
|||
return false;
|
||||
}
|
||||
final FluidInstance recipeFluid = fluidStack;
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluid();
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluidInstance();
|
||||
if (fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class IndustrialSawmillRecipe extends RebornRecipe {
|
|||
public boolean onCraft(BlockEntity be) {
|
||||
IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be;
|
||||
final FluidInstance recipeFluid = fluidStack;
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluid();
|
||||
final FluidInstance tankFluid = blockEntity.tank.getFluidInstance();
|
||||
if (fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -82,17 +82,15 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
|||
if (ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(0).isEmpty()) {
|
||||
FluidUtils.drainContainers(tank, inventory, 0, 1);
|
||||
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType());
|
||||
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
|
||||
}
|
||||
tank.setBlockEntity(this);
|
||||
tank.compareAndUpdate();
|
||||
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
|
||||
if (tank.getFluidAmount() > 0) {
|
||||
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluidType()))
|
||||
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluidType()).orElse(null);
|
||||
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluid()))
|
||||
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null);
|
||||
|
||||
if (currentRecipe != null) {
|
||||
final Integer euPerBucket = currentRecipe.getEnergyPerMb() * 1000;
|
||||
|
|
|
@ -92,7 +92,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
|||
// Check cells input slot 2 time per second
|
||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 2, tank.getFluidType());
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 2, tank.getFluid());
|
||||
}
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
|||
super.tick();
|
||||
}
|
||||
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +143,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
|||
public BuiltContainer createContainer(int syncID, PlayerEntity player) {
|
||||
return new ContainerBuilder("fluidreplicator").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isItemEqualIgnoreDamage(TRContent.Parts.UU_MATTER.getStack()))
|
||||
.outputSlot(2, 124, 55).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||
.outputSlot(2, 124, 55).energySlot(3, 8, 72).sync(tank).syncEnergyValue().syncCrafterValue().addInventory()
|
||||
.create(this, syncID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
|||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
FluidUtils.drainContainers(tank, inventory, 1, 6);
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 6, tank.getFluidType());
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 6, tank.getFluid());
|
||||
}
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
|
@ -116,8 +116,6 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
|||
if (!world.isClient && getMultiBlock()) {
|
||||
super.tick();
|
||||
}
|
||||
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,7 +145,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
|||
return new ContainerBuilder("industrialgrinder").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).fluidSlot(1, 34, 35).slot(0, 84, 43).outputSlot(2, 126, 18).outputSlot(3, 126, 36)
|
||||
.outputSlot(4, 126, 54).outputSlot(5, 126, 72).outputSlot(6, 34, 55).energySlot(7, 8, 72)
|
||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
.sync(tank).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
}
|
|
@ -98,7 +98,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
|||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
FluidUtils.drainContainers(tank, inventory, 1, 5);
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 5, tank.getFluidType());
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 5, tank.getFluidInstance().getFluid());
|
||||
}
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
|
@ -107,7 +107,6 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
|||
super.tick();
|
||||
}
|
||||
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
|
@ -147,7 +146,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
|||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("industrialsawmill").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).fluidSlot(1, 34, 35).slot(0, 84, 43).outputSlot(2, 126, 25).outputSlot(3, 126, 43)
|
||||
.outputSlot(4, 126, 61).outputSlot(5, 34, 55).energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue()
|
||||
.outputSlot(4, 126, 61).outputSlot(5, 34, 55).energySlot(6, 8, 72).sync(tank).syncEnergyValue().syncCrafterValue()
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import reborncore.common.util.Tank;
|
|||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
@ -89,14 +90,12 @@ public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
|||
public void tick() {
|
||||
super.tick();
|
||||
if (!world.isClient) {
|
||||
// TODO: Fix in 1.13
|
||||
// if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|
||||
// || FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType())) {
|
||||
// this.syncWithAll();
|
||||
// }
|
||||
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|
||||
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
|
||||
this.syncWithAll();
|
||||
}
|
||||
|
||||
}
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,8 +132,8 @@ public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
|||
@Override
|
||||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||
if (isReal | hasData) {
|
||||
if (this.tank.getFluid() != null) {
|
||||
info.add(new LiteralText(this.tank.getFluidAmount() + " of " + this.tank.getFluidType()));
|
||||
if (!this.tank.getFluidInstance().isEmpty()) {
|
||||
info.add(new LiteralText(this.tank.getFluidAmount() + " of " + this.tank.getFluid()));
|
||||
} else {
|
||||
info.add(new LiteralText("Empty"));
|
||||
}
|
||||
|
@ -146,8 +145,8 @@ public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
|||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("quantumtank").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53).addInventory()
|
||||
.create(this, syncID);
|
||||
.addInventory().blockEntity(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53)
|
||||
.sync(tank).addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -58,7 +58,7 @@ public class GuiDieselGenerator extends GuiBase {
|
|||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(this, 130, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class GuiFluidReplicator extends GuiBase {
|
|||
super.drawForeground(mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
builder.drawTank(this, 99, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 99, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class GuiGasTurbine extends GuiBase {
|
|||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(this, 130, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class GuiIndustrialGrinder extends GuiBase {
|
|||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawTank(this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class GuiIndustrialSawmill extends GuiBase {
|
|||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawTank(this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
if (blockEntity.getMutliBlock()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
|
|
|
@ -67,7 +67,7 @@ public class GuiPlasmaGenerator extends GuiBase {
|
|||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(this, 130, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class GuiQuantumTank extends GuiBase {
|
|||
protected void drawForeground(final int mouseX, final int mouseY) {
|
||||
super.drawForeground(mouseX, mouseY);
|
||||
|
||||
FluidInstance fluid = quantumTank.tank.getFluid();
|
||||
FluidInstance fluid = quantumTank.tank.getFluidInstance();
|
||||
if(fluid != null){
|
||||
font.draw( "Fluid Type:", 10, 20, 4210752);
|
||||
font.draw(FluidUtil.getFluidName(fluid) + "", 10, 30, 4210752);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class GuiSemifluidGenerator extends GuiBase {
|
|||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(this, 130, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class GuiThermalGenerator extends GuiBase {
|
|||
|
||||
builder.drawProgressBar(this, blockEntity.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(this, 130, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluid(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawTank(this, 44, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package techreborn.client.render;
|
||||
|
||||
import io.github.prospector.silk.fluid.FluidInstance;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
||||
import net.fabricmc.fabric.api.renderer.v1.Renderer;
|
||||
|
@ -20,6 +21,7 @@ import net.minecraft.client.render.model.json.ModelTransformation;
|
|||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -27,6 +29,7 @@ import net.minecraft.util.math.Direction;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.ExtendedBlockView;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.fluid.container.GenericFluidContainer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
|
@ -34,11 +37,11 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DyamicCellBakedModel implements BakedModel, FabricBakedModel {
|
||||
public class DynamicCellBakedModel implements BakedModel, FabricBakedModel {
|
||||
|
||||
Sprite base;
|
||||
|
||||
public DyamicCellBakedModel() {
|
||||
public DynamicCellBakedModel() {
|
||||
base = MinecraftClient.getInstance().getSpriteAtlas().getSprite(new Identifier("techreborn:item/cell_base"));
|
||||
}
|
||||
|
||||
|
@ -49,12 +52,14 @@ public class DyamicCellBakedModel implements BakedModel, FabricBakedModel {
|
|||
|
||||
@Override
|
||||
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
|
||||
|
||||
Fluid fluid = null;
|
||||
if(stack.hasTag() && stack.getTag().containsKey("fluid")){
|
||||
fluid = Registry.FLUID.get(new Identifier(stack.getTag().getString("fluid")));
|
||||
GenericFluidContainer<ItemStack> fluidContainer = GenericFluidContainer.fromStack(stack);
|
||||
Fluid fluid = Fluids.EMPTY;
|
||||
if(fluidContainer != null){
|
||||
FluidInstance fluidInstance = fluidContainer.getFluidInstance(stack);
|
||||
if(!fluidInstance.isEmpty()){
|
||||
fluid = fluidContainer.getFluidInstance(stack).getFluid();
|
||||
}
|
||||
}
|
||||
|
||||
context.meshConsumer().accept(getMesh(fluid));
|
||||
}
|
||||
|
||||
|
@ -77,7 +82,7 @@ public class DyamicCellBakedModel implements BakedModel, FabricBakedModel {
|
|||
.spriteColor(0, -1, -1, -1, -1)
|
||||
.spriteBake(0, base, MutableQuadView.BAKE_LOCK_UV).emit();
|
||||
|
||||
if(fluid != null){
|
||||
if(fluid != Fluids.EMPTY){
|
||||
FluidRenderHandler fluidRenderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
|
||||
if(fluidRenderHandler != null){
|
||||
Sprite fluidSprite = fluidRenderHandler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
|
||||
|
@ -129,7 +134,7 @@ public class DyamicCellBakedModel implements BakedModel, FabricBakedModel {
|
|||
|
||||
@Override
|
||||
public BakedModel apply(BakedModel bakedModel, ItemStack itemStack, World world, LivingEntity livingEntity) {
|
||||
return DyamicCellBakedModel.this;
|
||||
return DynamicCellBakedModel.this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.init;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.api.ISubItemRetriever;
|
||||
import techreborn.items.ItemCells;
|
||||
/**
|
||||
* Created by Mark on 03/04/2016.
|
||||
*/
|
||||
public class SubItemRetriever implements ISubItemRetriever {
|
||||
@Override
|
||||
public ItemStack getCellByName(String name) {
|
||||
return ItemCells.getCellByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCellByName(String name, int count) {
|
||||
return ItemCells.getCellByName(name, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDustByName(String name) {
|
||||
// return ItemDusts.getDustByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDustByName(String name, int count) {
|
||||
// return ItemDusts.getDustByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSmallDustByName(String name) {
|
||||
// return ItemDustsSmall.getSmallDustByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSmallDustByName(String name, int count) {
|
||||
// return ItemDustsSmall.getSmallDustByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getGemByName(String name) {
|
||||
// TODO: Fix recipe
|
||||
//return ItemGems.getGemByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getGemByName(String name, int count) {
|
||||
// TODO: Fix recipe
|
||||
//return ItemGems.getGemByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIngotByName(String name) {
|
||||
//return ItemIngots.getIngotByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIngotByName(String name, int count) {
|
||||
//return ItemIngots.getIngotByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getNuggetByName(String name) {
|
||||
// TODO: fix recipe
|
||||
// return ItemNuggets.getNuggetByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getNuggetByName(String name, int count) {
|
||||
// TODO: fix recipe
|
||||
// return ItemNuggets.getNuggetByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPartByName(String name) {
|
||||
// return ItemParts.getPartByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPartByName(String name, int count) {
|
||||
// return ItemParts.getPartByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPlateByName(String name) {
|
||||
// TODO: fix recipe
|
||||
// return ItemPlates.getPlateByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPlateByName(String name, int count) {
|
||||
// TODO: fix recipe
|
||||
// return ItemPlates.getPlateByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getUpgradeByName(String name) {
|
||||
// return ItemUpgrades.getUpgradeByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getUpgradeByName(String name, int count) {
|
||||
// return ItemUpgrades.getUpgradeByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOreByName(String name) {
|
||||
// return BlockOre.getOreByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOreByName(String name, int count) {
|
||||
// return BlockOre.getOreByName(name, count);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStorageBlockByName(String name) {
|
||||
// return BlockStorage.getStorageBlockByName(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStorageBlockByName(String name, int count) {
|
||||
// return BlockStorage.getStorageBlockByName(name, count);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -25,8 +25,9 @@
|
|||
package techreborn.init.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.init.ModFluids;
|
||||
import techreborn.items.ItemDynamicCell;
|
||||
import techreborn.items.ItemCells;
|
||||
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
|
@ -37,7 +38,7 @@ import java.security.InvalidParameterException;
|
|||
public class DistillationTowerRecipes extends RecipeMethods {
|
||||
|
||||
public static void init() {
|
||||
register(ItemCells.getCellByName("oil", 16), 1400, 13, getMaterial("diesel", 16, Type.CELL), getMaterial("sulfuricAcid", 16, Type.CELL), getMaterial("glyceryl", Type.CELL));
|
||||
register(ItemDynamicCell.getCellWithFluid(ModFluids.OIL.getFluid(), 16), 1400, 13, getMaterial("diesel", 16, Type.CELL), getMaterial("sulfuricAcid", 16, Type.CELL), getMaterial("glyceryl", Type.CELL));
|
||||
}
|
||||
|
||||
static void register(ItemStack input, int ticks, int euPerTick, boolean oreDict, ItemStack... outputs) {
|
||||
|
|
|
@ -24,23 +24,18 @@
|
|||
|
||||
package techreborn.init.recipes;
|
||||
|
||||
import techreborn.api.reactor.FusionReactorRecipe;
|
||||
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.items.ItemCells;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public class FusionReactorRecipes extends RecipeMethods {
|
||||
public static void init() {
|
||||
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("helium3"),
|
||||
ItemCells.getCellByName("deuterium"), ItemCells.getCellByName("heliumplasma"), 40000000, 32768, 1024));
|
||||
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("tritium"),
|
||||
ItemCells.getCellByName("deuterium"), ItemCells.getCellByName("helium3"), 60000000, 16384, 2048));
|
||||
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("wolframium"),
|
||||
ItemCells.getCellByName("Berylium"), TRContent.Dusts.PLATINUM.getStack(), 80000000, -2048, 1024));
|
||||
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("helium3"),
|
||||
// ItemCells.getCellByName("deuterium"), ItemCells.getCellByName("heliumplasma"), 40000000, 32768, 1024));
|
||||
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("tritium"),
|
||||
// ItemCells.getCellByName("deuterium"), ItemCells.getCellByName("helium3"), 60000000, 16384, 2048));
|
||||
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("wolframium"),
|
||||
// ItemCells.getCellByName("Berylium"), TRContent.Dusts.PLATINUM.getStack(), 80000000, -2048, 1024));
|
||||
// TODO: Fix recipe
|
||||
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("wolframium"),
|
||||
// ItemCells.getCellByName("lithium"), BlockOre.getOreByName("iridium"), 90000000, -2048, 1024));
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.items.ItemCells;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
|
@ -50,8 +49,8 @@ public abstract class RecipeMethods {
|
|||
// } else if (type == Type.NUGGET) {
|
||||
// return ItemNuggets.getNuggetByName(name, count);
|
||||
// } else
|
||||
if (type == Type.CELL) {
|
||||
return ItemCells.getCellByName(name, count);
|
||||
// if (type == Type.CELL) {
|
||||
// return ItemCells.getCellByName(name, count);
|
||||
// } else if (type == Type.PART) {
|
||||
// return ItemParts.getPartByName(name, count);
|
||||
// } else if (type == Type.CABLE) {
|
||||
|
@ -64,7 +63,7 @@ public abstract class RecipeMethods {
|
|||
// return ItemUpgrades.getUpgradeByName(name, count);
|
||||
// } else if (type == Type.ORE) {
|
||||
// return BlockOre.getOreByName(name, count);
|
||||
}
|
||||
// }
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
public class ItemCells {
|
||||
public static ItemStack getCellByName(String name, int count) {
|
||||
if (name.equalsIgnoreCase("empty") || name.equalsIgnoreCase("cell")) {
|
||||
return ItemDynamicCell.getEmptyCell(count).copy();
|
||||
}
|
||||
Fluid fluid = FluidUtils.getFluid("fluid" + name.toLowerCase());
|
||||
if (fluid == null) {
|
||||
fluid = FluidUtils.getFluid(name.toLowerCase());
|
||||
if (fluid == null) {
|
||||
fluid = FluidUtils.getFluid(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
Validate.notNull(fluid, "The fluid " + name + " could not be found");
|
||||
return ItemDynamicCell.getCellWithFluid(fluid, count);
|
||||
}
|
||||
|
||||
public static ItemStack getCellByName(String name) {
|
||||
return getCellByName(name, 1);
|
||||
}
|
||||
|
||||
public static boolean isCellEqual(ItemStack stack1, ItemStack stack2){
|
||||
if(stack1 == null || stack2 == null){
|
||||
return false;
|
||||
}
|
||||
if(stack1.isEmpty() || stack2.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
if(stack1.getTag() == null || stack2.getTag() == null){
|
||||
return false;
|
||||
}
|
||||
return stack1.getTag().equals(stack2.getTag());
|
||||
}
|
||||
|
||||
}
|
|
@ -24,17 +24,17 @@
|
|||
|
||||
package techreborn.items;
|
||||
|
||||
import io.github.prospector.silk.fluid.FluidInstance;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import reborncore.common.fluid.container.GenericFluidContainer;
|
||||
import reborncore.common.util.ItemNBTHelper;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
|
@ -43,12 +43,12 @@ import techreborn.utils.FluidUtils;
|
|||
/**
|
||||
* Created by modmuss50 on 17/05/2016.
|
||||
*/
|
||||
public class ItemDynamicCell extends Item {
|
||||
public class ItemDynamicCell extends Item implements GenericFluidContainer<ItemStack> {
|
||||
|
||||
public static final int CAPACITY = 1000;
|
||||
|
||||
public ItemDynamicCell() {
|
||||
super(new Item.Settings().group(TechReborn.ITEMGROUP));
|
||||
super(new Item.Settings().maxCount(1).group(TechReborn.ITEMGROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,8 +66,6 @@ public class ItemDynamicCell extends Item {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> subItems) {
|
||||
if (!isIn(tab)) {
|
||||
|
@ -81,22 +79,18 @@ public class ItemDynamicCell extends Item {
|
|||
|
||||
// @Override
|
||||
// public String getTranslationKey(ItemStack stack) {
|
||||
// FluidStack fluidStack = getFluidHandler(stack).getFluid();
|
||||
// FluidStack fluidStack = getFluidHandler(stack).getFluidInstance();
|
||||
// if (fluidStack == null)
|
||||
// return super.getTranslationKey(stack);
|
||||
// return StringUtils.t("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) {
|
||||
// return getFluidHandler(stack);
|
||||
// }
|
||||
//
|
||||
|
||||
public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) {
|
||||
Validate.notNull(fluid);
|
||||
ItemStack stack = new ItemStack(TRContent.CELL);
|
||||
ItemNBTHelper.getNBT(stack).putString("fluid", Registry.FLUID.getId(fluid).toString());
|
||||
GenericFluidContainer<ItemStack> fluidContainer = GenericFluidContainer.fromStack(stack);
|
||||
Validate.notNull(fluidContainer);
|
||||
fluidContainer.setFluid(stack, new FluidInstance(fluid, fluidContainer.getCapacity(stack)));
|
||||
stack.setCount(stackSize);
|
||||
return stack;
|
||||
}
|
||||
|
@ -110,4 +104,27 @@ public class ItemDynamicCell extends Item {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setFluid(ItemStack type, FluidInstance instance) {
|
||||
Validate.notNull(type, "ItemStack cannot be null!");
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
instance.toTag(compoundTag);
|
||||
ItemNBTHelper.getNBT(type).put("fluid", compoundTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidInstance getFluidInstance(ItemStack type) {
|
||||
Validate.notNull(type, "ItemStack cannot be null!");
|
||||
if(ItemNBTHelper.getNBT(type).containsKey("fluid")){
|
||||
CompoundTag compoundTag = ItemNBTHelper.getNBT(type).getCompound("fluid");
|
||||
return new FluidInstance(compoundTag);
|
||||
}
|
||||
return new FluidInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack type) {
|
||||
Validate.notNull(type, "ItemStack cannot be null!");
|
||||
return CAPACITY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,18 @@ package techreborn.utils;
|
|||
|
||||
import io.github.prospector.silk.fluid.FluidInstance;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.common.fluid.container.GenericFluidContainer;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import reborncore.mixin.extensions.FluidBlockExtensions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -38,24 +45,62 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class FluidUtils {
|
||||
|
||||
public static Fluid fluidFromBlock(Block bLock){
|
||||
throw new UnsupportedOperationException("needs coding");
|
||||
public static Fluid fluidFromBlock(Block block){
|
||||
if(block instanceof FluidBlockExtensions){
|
||||
return ((FluidBlockExtensions) block).getFluid();
|
||||
}
|
||||
return Fluids.EMPTY;
|
||||
}
|
||||
|
||||
public static List<Fluid> getAllFluids() {
|
||||
return Registry.FLUID.stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Fluid getFluid(String name){
|
||||
return null;
|
||||
public static boolean drainContainers(GenericFluidContainer<Direction> target, Inventory inventory, int inputSlot, int outputSlot) {
|
||||
ItemStack inputStack = inventory.getInvStack(inputSlot);
|
||||
ItemStack outputStack = inventory.getInvStack(outputSlot);
|
||||
|
||||
if (inputStack.isEmpty()) return false;
|
||||
|
||||
if(inputStack.getCount() > 1){
|
||||
System.out.println("TODO make this support more than 1 item");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void drainContainers(Tank tank, RebornInventory<?> inventory, int i, int i1) {
|
||||
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
|
||||
|
||||
GenericFluidContainer<ItemStack> source = GenericFluidContainer.fromStack(inputStack);
|
||||
if(source == null || source.getFluidInstance(inputStack).isEmpty()){
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void fillContainers(Tank tank, RebornInventory<?> inventory, int i, int i1, Fluid fluidType) {
|
||||
Fluid fluidType = source.getFluidInstance(inputStack).getFluid();
|
||||
FluidInstance contained = target.getFluidInstance(null);
|
||||
|
||||
if(!contained.isEmpty()){
|
||||
//Check that the fluid we are trying to insert into is the same
|
||||
if(contained.getFluid() != fluidType){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int transferAmount = 10;
|
||||
|
||||
if(source.canExtractFluid(inputStack, fluidType, transferAmount) && target.canInsertFluid(null, fluidType, transferAmount)){
|
||||
target.insertFluid(null, fluidType, transferAmount);
|
||||
source.extractFluid(inputStack, fluidType, transferAmount);
|
||||
if(source.getCurrentFluidAmount(inputStack) < 1){
|
||||
inventory.setInvStack(outputSlot, inputStack);
|
||||
inventory.setInvStack(inputSlot, ItemStack.EMPTY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean fillContainers(GenericFluidContainer<Direction> source, Inventory inventory, int inputSlot, int outputSlot, Fluid fluidToFill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean fluidEquals(Fluid fluid, Fluid fluid1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue