Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
bunch of work on multiblock tanks
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 17, 2023
1 parent 073a43f commit 110087a
Show file tree
Hide file tree
Showing 39 changed files with 209 additions and 3 deletions.
51 changes: 51 additions & 0 deletions common/src/main/java/muramasa/gregtech/block/BlockColoredWall.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package muramasa.gregtech.block;

import muramasa.antimatter.Ref;
import muramasa.antimatter.block.BlockFakeTile;
import muramasa.antimatter.material.Material;
import muramasa.antimatter.registration.IColorHandler;
import muramasa.antimatter.texture.Texture;
import muramasa.gregtech.GTIRef;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

import static muramasa.antimatter.data.AntimatterMaterials.Wood;

public class BlockColoredWall extends BlockFakeTile implements IColorHandler {
final Material material;
public BlockColoredWall(String domain, Material material, Properties properties) {
super(domain, material.getId() + "_wall", properties);
this.material = material;
}

public BlockColoredWall(String domain, Material material){
this(domain, material, Block.Properties.of(net.minecraft.world.level.material.Material.METAL).strength(1.0f, 10.0f).sound(SoundType.METAL).requiresCorrectToolForDrops());
}

public Material getMaterial() {
return material;
}

@Override
public Texture[] getTextures() {
Texture side = material == Wood ? new Texture(GTIRef.ID, "block/casing/wall/wood") : new Texture(GTIRef.ID, "block/casing/wall/metal");
Texture overlay = new Texture(GTIRef.ID, "block/machine/empty");
Texture sideOverlay = material == Wood ? new Texture(GTIRef.ID, "block/casing/wall/wood_overlay_side") : overlay;
return new Texture[]{side, side, side, side, side, side, overlay, overlay, sideOverlay, sideOverlay, sideOverlay, sideOverlay};
}

@Override
public int getBlockColor(BlockState state, @Nullable BlockGetter world, @Nullable BlockPos pos, int i) {
return i == 0 ? material.getRGB() : -1;
}

@Override
public int getItemColor(ItemStack stack, @Nullable Block block, int i) {
return i == 0 ? material.getRGB() : -1;
}
}
4 changes: 4 additions & 0 deletions common/src/main/java/muramasa/gregtech/data/GregTechData.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ public Texture[] getTextures() {
public static final BlockCasing HULL_UV = new BlockCasing(GTIRef.ID, "hull_uv");
public static final BlockCasing HULL_UHV = new BlockCasing(GTIRef.ID, "hull_uhv");

public static final BlockColoredWall WOOD_WALL = new BlockColoredWall(GTIRef.ID, AntimatterMaterials.Wood, BlockBehaviour.Properties.of(net.minecraft.world.level.material.Material.WOOD, MaterialColor.WOOD).strength(2.0F, 3.0F).sound(SoundType.WOOD));
public static final BlockColoredWall STEEL_WALL = new BlockColoredWall(GTIRef.ID, Steel);
public static final BlockColoredWall INVAR_WALL = new BlockColoredWall(GTIRef.ID, Invar);
public static final BlockColoredWall STAINLESS_STEEL_WALL = new BlockColoredWall(GTIRef.ID, StainlessSteel);
public static final BlockFakeCasing CASING_FIRE_BRICK = new BlockFakeCasing(GTIRef.ID, "fire_bricks", BlockBehaviour.Properties.of(net.minecraft.world.level.material.Material.STONE, MaterialColor.DIRT).strength(1.0f, 10.0f).sound(SoundType.STONE));
public static final BlockCasing CASING_BRONZE = new BlockCasing(GTIRef.ID, "bronze_casing");
public static final BlockCasing CASING_BRICKED_BRONZE = new BlockSidedCasing(GTIRef.ID, "bricked_bronze_casing", "brick", "bronze");
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/java/muramasa/gregtech/data/Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public class Machines {
* Drums
*/
public static DrumMachine BRONZE_DRUM = GTUtilityData.createDrum(Materials.Bronze, 16000);
public static DrumMachine INVAR_DRUM = GTUtilityData.createDrum(Materials.Invar, 32000);
public static DrumMachine STEEL_DRUM = GTUtilityData.createDrum(Materials.Steel, 32000);
public static DrumMachine INVAR_DRUM = GTUtilityData.createDrum(Materials.Invar, 48000);
public static DrumMachine STAINLESS_DRUM = GTUtilityData.createDrum(Materials.StainlessSteel, 64000);
public static DrumMachine TITANIUM_DRUM = GTUtilityData.createDrum(Materials.Titanium, 128000);
public static DrumMachine NETHERRITE_DRUM = GTUtilityData.createDrum(AntimatterMaterials.Netherite, 128000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import muramasa.gregtech.GTIRef;
import muramasa.gregtech.block.BlockCasing;
import muramasa.gregtech.block.BlockCoil;
import muramasa.gregtech.block.BlockColoredWall;
import muramasa.gregtech.block.BlockFakeCasing;
import muramasa.gregtech.data.GregTechData;

import static muramasa.antimatter.data.AntimatterMaterials.Wood;

public class GregTechBlockTagProvider extends AntimatterBlockTagProvider {

public GregTechBlockTagProvider(String providerDomain, String providerName, boolean replace) {
Expand All @@ -21,6 +24,13 @@ public void processTags(String domain){
AntimatterAPI.all(BlockCasing.class, GTIRef.ID, cas -> {
this.tag(AntimatterDefaultTools.WRENCH.getToolType()).add(cas);
});
AntimatterAPI.all(BlockColoredWall.class, GTIRef.ID, cas -> {
if (cas.getMaterial() == Wood){
this.tag(AntimatterDefaultTools.AXE.getToolType()).add(cas);
} else {
this.tag(AntimatterDefaultTools.WRENCH.getToolType()).add(cas);
}
});
AntimatterAPI.all(BlockFakeCasing.class, GTIRef.ID, cas -> {
this.tag(AntimatterDefaultTools.PICKAXE.getToolType()).add(cas);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import muramasa.gregtech.GTIRef;
import muramasa.gregtech.block.BlockCasing;
import muramasa.gregtech.block.BlockCoil;
import muramasa.gregtech.block.BlockColoredWall;
import muramasa.gregtech.block.BlockFakeCasing;
import muramasa.gregtech.data.GregTechData;
import muramasa.gregtech.items.ItemIntCircuit;
Expand Down Expand Up @@ -54,6 +55,7 @@ protected void english(String domain, String locale) {
add(GregTechData.MINING_PIPE_THIN, "Mining Pipe");
add(GregTechData.BRITTLE_CHARCOAL, "Brittle Charcoal");
AntimatterAPI.all(BlockFakeCasing.class, domain).forEach(i -> add(i, lowerUnderscoreToUpperSpaced(i.getId())));
AntimatterAPI.all(BlockColoredWall.class, domain).forEach(i -> add(i, lowerUnderscoreToUpperSpaced(i.getId())));
AntimatterAPI.all(BlockCoil.class, domain).forEach(i -> add(i, lowerUnderscoreToUpperSpaced(i.getId())));
AntimatterAPI.all(ItemIntCircuit.class, domain).forEach(i -> add(i, "Integrated Circuit (" + i.circuitId + ")"));
AntimatterAPI.all(ItemBasic.class, domain).stream().filter(i -> i.getId().startsWith("circuit")).forEach(i -> override(i.getDescriptionId(), lowerUnderscoreToUpperSpacedRotated(i.getId())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import muramasa.antimatter.ore.CobbleStoneType;
import muramasa.gregtech.block.BlockCasing;
import muramasa.gregtech.block.BlockCoil;
import muramasa.gregtech.block.BlockColoredWall;
import muramasa.gregtech.block.BlockFakeCasing;
import muramasa.gregtech.data.GregTechData;
import muramasa.gregtech.data.Materials;
Expand Down Expand Up @@ -37,6 +38,7 @@ public GregtechBlockLootProvider(String providerDomain, String providerName) {
protected void loot() {
super.loot();
AntimatterAPI.all(BlockCasing.class,providerDomain, this::add);
AntimatterAPI.all(BlockColoredWall.class,providerDomain, this::add);
AntimatterAPI.all(BlockCoil.class,providerDomain, this::add);
AntimatterAPI.all(BlockFakeCasing.class, providerDomain, this::add);
this.add(GregTechData.MINING_PIPE_THIN);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package muramasa.gregtech.machine;

import com.gtnewhorizon.structurelib.structure.StructureUtility;
import io.github.gregtechintergalactical.gtutility.machine.MaterialBasicMultiMachine;
import muramasa.antimatter.material.Material;
import muramasa.antimatter.texture.Texture;
import muramasa.gregtech.GTIRef;
import muramasa.gregtech.tile.multi.TileEntityLargeTank;
import net.minecraft.world.level.block.Block;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static muramasa.antimatter.data.AntimatterMaterials.Wood;

public class MultiblockTankMachine extends MaterialBasicMultiMachine {
final int capacity;
public MultiblockTankMachine(String domain, Material material, boolean small, int capacity) {
super(domain, (small ? "small" : "large") + "_" + material.getId() + "_tank_main_valve", material);
if (small){
this.setStructure(TileEntityLargeTank.class, b -> b.part("main")
.of("CCC", "CCC", "CCC").of("C~C", "C-C", "CCC").of(0).build()
.atElement('C', StructureUtility.lazy(t -> ofBlock(t.getCasing()))).offset(1, 1, 0)
.build());
} else {
this.setStructure(TileEntityLargeTank.class, b -> b.part("main")
.of("CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC").of("CC~CC", "C---C", "C---C", "C---C", "CCCCC").of(0).build()
.atElement('C', StructureUtility.lazy(t -> ofBlock(t.getCasing()))).offset(1, 1, 0)
.build());
}
this.capacity = capacity;
String prefix = material == Wood ? "wood" : "metal";
baseTexture(new Texture(GTIRef.ID, "block/casing/wall/" + prefix));
overlayTexture((type, state, tier) -> {
Texture blank = new Texture(GTIRef.ID, "block/machine/empty");
return new Texture[]{blank, blank, blank, new Texture(GTIRef.ID, "block/casing/wall/" + prefix + "_tank_side_overlay"), blank, blank};
});
setAllowVerticalFacing(true);
}

public int getCapacity() {
return capacity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import muramasa.gregtech.GregTech;
import muramasa.gregtech.GTIRef;
import muramasa.gregtech.block.BlockCasing;
import muramasa.gregtech.block.BlockColoredWall;
import net.minecraft.client.renderer.RenderType;

import java.io.File;
Expand All @@ -17,6 +18,7 @@ public class ClientHandler {

public static void setup() {
AntimatterAPI.all(BlockCasing.class, t -> ModelUtils.setRenderLayer(t, RenderType.cutout()));
AntimatterAPI.all(BlockColoredWall.class, t -> ModelUtils.setRenderLayer(t, RenderType.cutout()));
copyProgrammerArtIfMissing();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package muramasa.gregtech.tile.multi;

import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.base.PlatformFluidHandler;
import io.github.gregtechintergalactical.gtutility.blockentity.BlockEntityMaterialBasicMultiMachine;
import io.github.gregtechintergalactical.gtutility.machine.MaterialBasicMultiMachine;
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.capability.fluid.FluidTank;
import muramasa.antimatter.capability.fluid.FluidTanks;
import muramasa.antimatter.capability.machine.MachineFluidHandler;
import muramasa.antimatter.util.Utils;
import muramasa.gregtech.GTIRef;
import muramasa.gregtech.machine.MultiblockTankMachine;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import tesseract.FluidPlatformUtils;
import tesseract.TesseractCapUtils;

import javax.annotation.Nullable;
import java.util.Optional;

import static muramasa.antimatter.data.AntimatterMaterials.Wood;
import static net.minecraft.core.Direction.DOWN;
import static net.minecraft.core.Direction.UP;

public class TileEntityLargeTank extends BlockEntityMaterialBasicMultiMachine<TileEntityLargeTank> {
public TileEntityLargeTank(MultiblockTankMachine type, BlockPos pos, BlockState state) {
super(type, pos, state);
this.fluidHandler.set(() -> new LargeTankFluidHandler(this, type.getCapacity(), 10000, 1, 0));
}

@Override
public boolean allowsFakeTiles() {
return true;
}

public Block getCasing(){
Block block = AntimatterAPI.get(Block.class, GTIRef.ID, material.getId() + "_wall");
if (block != null) return block;
return Blocks.BEDROCK;
}

public static class LargeTankFluidHandler extends MachineFluidHandler<TileEntityLargeTank> {

public LargeTankFluidHandler(TileEntityLargeTank tile, int capacity, int pressure, int inputCount, int outputCount) {
super(tile, capacity, pressure, inputCount, outputCount);
}

@Nullable
@Override
public FluidTanks getOutputTanks() {
return super.getInputTanks();
}

@Override
protected FluidTank getTank(int tank) {
return getInputTanks().getTank(tank);
}

@Override
public FluidTanks getTanks(int tank) {
return getInputTanks();
}

@Override
public void onUpdate() {
super.onUpdate();
if (tile.getLevel().getGameTime() % 20 == 0){
Direction dir = tile.getFacing();
if (getTank(0).getStoredFluid().getFluidAmount() > 0 && dir != UP){
BlockEntity adjacent = tile.getLevel().getBlockEntity(tile.getBlockPos().relative(dir));
if (adjacent != null){
Optional<PlatformFluidHandler> cap = TesseractCapUtils.getFluidHandler(tile.getLevel(), tile.getBlockPos().relative(dir), dir.getOpposite());
cap.ifPresent(other -> Utils.transferFluids(this.getOutputTanks(), other, 1000));
}
}
}
}

@Override
public long insertFluid(FluidHolder fluid, boolean simulate) {
if (tile.getMaterial() == Wood){

}
return super.insertFluid(fluid, simulate);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx5G
org.gradle.daemon=false
org.gradle.parallel=true

mod_version=0.2-alpha-45
mod_version=0.2-alpha-47
archive_base_name=gti
modid=gregtech

Expand All @@ -16,7 +16,7 @@ fabric_transfer_api_version=1.6.+
fabric_loader_version=0.14.6

gt_rubber_version=0.2.3-rc3
gt_utility_version=0.1-pre10
gt_utility_version=0.1-pre11
networkapi_version=0.1.1-rc2
jei_version=10.2.1.1004
crafttweaker_version=9.1.207
Expand Down

0 comments on commit 110087a

Please sign in to comment.