aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2022-03-04 20:21:11 +0100
committerGitHub <noreply@github.com>2022-03-04 20:21:11 +0100
commitdbab3423566f64c354977acc362ccdd3335bb865 (patch)
tree53a709121414cede7d6146abfcfaf29beeaaef22
parentc8d78c16f0aefb288975338778eda53af147b714 (diff)
downloadGT5-Unofficial-dbab3423566f64c354977acc362ccdd3335bb865.tar.gz
GT5-Unofficial-dbab3423566f64c354977acc362ccdd3335bb865.tar.bz2
GT5-Unofficial-dbab3423566f64c354977acc362ccdd3335bb865.zip
StructureLib integration (#99)
* Implement StructureLib to Mega Vacuum Freezer * Remove unused translation * EIC StructureLib integration Electric Implosion Compressor * Bacterial Vat StructureLib integration * Remove unused translations * Change air block to isAir * Block rotation of EIC * Add recipe map to MVF * Manual Trafo StructureLib integration * Windmill StructureLib integration * Block Windmill rotation Former-commit-id: 43331bd8d46203a87bdadd234295c2e75ac82621
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java178
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java220
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java427
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java183
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java147
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java2
-rw-r--r--src/main/resources/assets/bartworks/lang/de_DE.lang3
-rw-r--r--src/main/resources/assets/bartworks/lang/en_US.lang4
-rw-r--r--src/main/resources/assets/bartworks/lang/fr_FR.lang4
-rw-r--r--src/main/resources/assets/bartworks/lang/zh_CN.lang10
10 files changed, 663 insertions, 515 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java
index 9d1a054cb0..993099521d 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java
@@ -30,22 +30,27 @@ import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader;
import com.github.bartimaeusnek.bartworks.common.net.RendererPacket;
import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch;
import com.github.bartimaeusnek.bartworks.util.*;
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.util.ForgeDirection;
@@ -56,11 +61,16 @@ import net.minecraftforge.fluids.FluidStack;
import java.util.*;
import java.util.stream.Collectors;
-public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
+import static gregtech.api.enums.Textures.BlockIcons.*;
+import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+
+public class GT_TileEntity_BioVat extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_TileEntity_BioVat> {
public static final HashMap<Coords, Integer> staticColorMap = new HashMap<>();
- private static final byte MCASING_INDEX = 49;
private static final byte TIMERDIVIDER = 20;
private final HashSet<EntityPlayerMP> playerMPHashSet = new HashSet<>();
@@ -74,6 +84,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
private byte mGlassTier;
private int mSievert;
private int mNeededSievert;
+ private int mCasing = 0;
public GT_TileEntity_BioVat(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -83,6 +94,88 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
super(aName);
}
+ private static final int CASING_INDEX = 49;
+ private static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final IStructureDefinition<GT_TileEntity_BioVat> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_BioVat>builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
+ {"ccccc", "ccccc", "ccccc", "ccccc", "ccccc"},
+ {"ggggg", "gaaag", "gaaag", "gaaag", "ggggg"},
+ {"ggggg", "gaaag", "gaaag", "gaaag", "ggggg"},
+ {"cc~cc", "ccccc", "ccccc", "ccccc", "ccccc"},
+ }))
+ .addElement('c', ofChain(
+ ofHatchAdder(GT_TileEntity_BioVat::addMaintenanceToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_BioVat::addOutputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_BioVat::addInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_BioVat::addRadiationInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_BioVat::addEnergyInputToMachineList, CASING_INDEX, 1),
+ onElementPass(e -> e.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1))
+ ))
+ .addElement('a', ofChain(
+ isAir(),
+ ofBlockAnyMeta(FluidLoader.bioFluidBlock)
+ ))
+ .addElement('g', new IStructureElement<GT_TileEntity_BioVat>(){
+
+ @Override
+ public boolean check(GT_TileEntity_BioVat te, World world, int x, int y, int z) {
+ byte glasstier = BW_Util.calculateGlassTier(world.getBlock(x, y, z), (byte)world.getBlockMetadata(x, y, z));
+ if(glasstier == 0)
+ return false;
+ if(te.mGlassTier == 0)
+ te.mGlassTier = glasstier;
+ return te.mGlassTier == glasstier;
+ }
+
+ @Override
+ public boolean spawnHint(GT_TileEntity_BioVat te, World world, int x, int y, int z, ItemStack itemStack) {
+ StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 1 /* aDots: 2 */);
+ return true;
+ }
+
+ @Override
+ public boolean placeBlock(GT_TileEntity_BioVat te, World world, int x, int y, int z, ItemStack itemStack) {
+ world.setBlock(x, y, z, Blocks.glass, 0, 2);
+ return true;
+ }
+ })
+ .build();
+
+ @Override
+ public IStructureDefinition<GT_TileEntity_BioVat> getStructureDefinition() {
+ return STRUCTURE_DEFINITION;
+ }
+
+ @Override
+ protected IAlignmentLimits getInitialAlignmentLimits() {
+ return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped();
+ }
+
+ @Override
+ protected GT_Multiblock_Tooltip_Builder createTooltip() {
+ GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.
+ addMachineType("Bacterial Vat").
+ addInfo("Controller block for the Bacterial Vat").
+ addInfo("For maximum efficiency boost keep the Output Hatch always half filled!").
+ addSeparator().
+ beginStructureBlock(5, 4, 5, false).
+ addController("Front bottom center").
+ addCasingInfo("Clean Stainless Steel Casings", 19).
+ addOtherStructurePart("Glass", "Hollow two middle layers", 2).
+ addStructureInfo("The glass can be any glass, i.e. Tinkers Construct Clear Glass").
+ addStructureInfo("Some Recipes need more advanced Glass Types").
+ addMaintenanceHatch("Any casing", 1).
+ addOtherStructurePart("Radio Hatch", "Any casing", 1).
+ addInputBus("Any casing", 1).
+ addOutputBus("Any casing", 1).
+ addInputHatch("Any casing", 1).
+ addOutputHatch("Any casing", 1).
+ addEnergyHatch("Any casing", 1).
+ toolTipFinisher("Bartworks");
+ return tt;
+ }
+
public static int[] specialValueUnpack(int aSpecialValue) {
int[] ret = new int[4];
ret[0] = aSpecialValue & 0xF; // = glass tier
@@ -259,7 +352,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
return this.mOutputHatches.stream().map(GT_MetaTileEntity_Hatch_Output::getFluid).filter(Objects::nonNull).collect(Collectors.toSet());
}
- private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity) {
+ private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity, int CasingIndex) {
if (aTileEntity == null) {
return false;
} else {
@@ -267,7 +360,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
if (aMetaTileEntity == null) {
return false;
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch) {
- ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(GT_TileEntity_BioVat.MCASING_INDEX);
+ ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(CasingIndex);
return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity);
} else {
return false;
@@ -277,49 +370,19 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) {
- int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2;
- int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2;
- int blockcounter = 0;
this.mRadHatches.clear();
+ this.mGlassTier = 0;
+ this.mCasing = 0;
- for (int x = -2; x <= 2; x++)
- for (int z = -2; z <= 2; z++)
- for (int y = 0; y < 4; y++) {
- IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z);
- if (y == 0 || y == 3) {
- //controller
- if (y == 0 && xDir + x == 0 && zDir + z == 0)
- continue;
- if (!(this.addOutputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addRadiationInputToMachineList(tileEntity) || this.addInputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addMaintenanceToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addEnergyInputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX))) {
- if (BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, GregTech_API.sBlockCasings4, 1)) {
- ++blockcounter;
- continue;
- }
- return false;
- }
- } else {
- if (Math.abs(x) < 2 && Math.abs(z) != 2) {
- if (!(BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, Blocks.air) || (BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, FluidLoader.bioFluidBlock)))) {
- return false;
- }
- } else {
- if (x == -2 && z == -2 && y == 1)
- this.mGlassTier = BW_Util.calculateGlassTier(aBaseMetaTileEntity.getBlockOffset(xDir + -2, y, zDir + z), aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z));
- if (0 == this.mGlassTier || this.mGlassTier != BW_Util.calculateGlassTier(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z), aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z))) {
- return false;
- }
- }
- }
- }
-
- if (blockcounter > 18 &&
- this.mRadHatches.size() < 2 &&
- this.mOutputHatches.size() == 1 &&
- this.mMaintenanceHatches.size() == 1 &&
- this.mInputHatches.size() > 0)
- return this.mEnergyHatches.size() > 0;
+ if(!checkPiece(STRUCTURE_PIECE_MAIN, 2, 3, 0))
+ return false;
- return false;
+ return this.mCasing >= 19 &&
+ this.mRadHatches.size() <= 1 &&
+ this.mOutputHatches.size() == 1 &&
+ this.mMaintenanceHatches.size() == 1 &&
+ this.mInputHatches.size() > 0 &&
+ this.mEnergyHatches.size() > 0;
}
@Override
@@ -567,18 +630,23 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
}
@Override
- public String[] getDescription() {
- String[] dsc = StatCollector.translateToLocal("tooltip.tile.bvat.0.name").split(";");
- String[] fdsc = new String[dsc.length + 1];
- for (int i = 0; i < dsc.length; i++) {
- fdsc[i] = dsc[i];
- fdsc[dsc.length] = BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get();
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing) {
+ if (aActive)
+ return new ITexture[]{
+ Textures.BlockIcons.getCasingTextureForId(CASING_INDEX),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE).extFacing().build(),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW).extFacing().glow().build()};
+ return new ITexture[]{
+ Textures.BlockIcons.getCasingTextureForId(CASING_INDEX),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER).extFacing().build(),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW).extFacing().glow().build()};
}
- return fdsc;
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)};
}
@Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_BioVat.MCASING_INDEX), TextureFactory.of(aActive ? TextureFactory.of(TextureFactory.of(Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW).glow().build()) : TextureFactory.of(TextureFactory.of(Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW).glow().build()))} : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_BioVat.MCASING_INDEX)};
+ public void construct(ItemStack itemStack, boolean b) {
+ buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 3, 0);
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java
index f761543f56..b9c3d36c0e 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java
@@ -22,28 +22,39 @@
package com.github.bartimaeusnek.bartworks.common.tileentities.multis;
-import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.Materials;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
-import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ImplosionCompressor;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
-import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import static com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry.BW_BLOCKS;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
-public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity_ImplosionCompressor {
+public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_TileEntity_ElectricImplosionCompressor> {
public static GT_Recipe.GT_Recipe_Map eicMap;
- private Boolean piston = null;
+ private Boolean piston = true;
public GT_TileEntity_ElectricImplosionCompressor(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -53,6 +64,98 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity
super(aName);
}
+ private static final int CASING_INDEX = 16;
+ private static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final IStructureDefinition<GT_TileEntity_ElectricImplosionCompressor> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_ElectricImplosionCompressor>builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
+ {"ccc", "cec", "ccc"},
+ {"ttt", "tft", "ttt"},
+ {"ttt", "tft", "ttt"},
+ {"nnn", "nnn", "nnn"},
+ {"nNn", "NNN", "nNn"},
+ {"nnn", "nnn", "nnn"},
+ {"t~t", "tft", "ttt"},
+ {"ttt", "tft", "ttt"},
+ {"CCC", "CeC", "CCC"},
+ }))
+ .addElement('c', ofChain(
+ ofBlock(GregTech_API.sBlockCasings2, 0),
+ ofBlock(GregTech_API.sBlockCasings3, 4)
+ ))
+ .addElement('t', ofBlock(BW_BLOCKS[2], 1))
+ .addElement('f', ofBlock(BW_BLOCKS[2], 0))
+ .addElement('n', ofBlock(GregTech_API.sBlockMetal5, 2))
+ .addElement('C', ofChain(
+ ofHatchAdder(GT_TileEntity_ElectricImplosionCompressor::addInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_ElectricImplosionCompressor::addOutputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_ElectricImplosionCompressor::addMaintenanceToMachineList, CASING_INDEX, 1),
+ ofBlock(GregTech_API.sBlockCasings2, 0),
+ ofBlock(GregTech_API.sBlockCasings3, 4)
+ ))
+ .addElement('e', ofHatchAdder(GT_TileEntity_ElectricImplosionCompressor::addEnergyInputToMachineList, CASING_INDEX, 2))
+ .addElement('N', new IStructureElement<GT_TileEntity_ElectricImplosionCompressor>(){
+
+ @Override
+ public boolean check(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z) {
+ if(!te.piston && !world.isAirBlock(x, y, z))
+ return false;
+ if(te.piston && !(world.getBlock(x, y, z) == GregTech_API.sBlockMetal5 && world.getBlockMetadata(x, y, z) == 2))
+ return false;
+ return true;
+ }
+
+ @Override
+ public boolean spawnHint(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z, ItemStack itemStack) {
+ if(te.piston)
+ StructureLibAPI.hintParticle(world, x, y, z, GregTech_API.sBlockMetal5, 2);
+ return true;
+ }
+
+ @Override
+ public boolean placeBlock(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z, ItemStack itemStack) {
+ if(te.piston)
+ world.setBlock(x, y, z, GregTech_API.sBlockMetal5, 2, 3);
+ else
+ world.setBlockToAir(x, y, z);
+ return true;
+ }
+ })
+ .build();
+
+ @Override
+ public IStructureDefinition<GT_TileEntity_ElectricImplosionCompressor> getStructureDefinition() {
+ return STRUCTURE_DEFINITION;
+ }
+
+ @Override
+ protected IAlignmentLimits getInitialAlignmentLimits() {
+ return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped();
+ }
+
+ @Override
+ protected GT_Multiblock_Tooltip_Builder createTooltip() {
+ GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.
+ addMachineType("Implosion Compressor").
+ addInfo("Explosions are fun").
+ addInfo("Controller block for the Electric Implosion Compressor").
+ addInfo("Uses electricity instead of Explosives").
+ addSeparator().
+ beginStructureBlock(3, 9, 3, false).
+ addController("Front 3rd layer center").
+ addCasingInfo("Solid Steel Machine Casing", 8).
+ addStructureInfo("Casings can be replaced with Explosion Warning Signs").
+ addOtherStructurePart("Transformer-Winding Blocks", "Outer layer 2,3,7,8").
+ addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Inner layer 2,3,7,8").
+ addOtherStructurePart("Neutronium Blocks", "Layer 4,5,6").
+ addMaintenanceHatch("Any bottom casing", 1).
+ addInputBus("Any bottom casing", 1).
+ addOutputBus("Any bottom casing", 1).
+ addEnergyHatch("Bottom and top middle", 2).
+ toolTipFinisher("Bartworks");
+ return tt;
+ }
+
@Override
public boolean checkRecipe(ItemStack aStack) {
@@ -94,7 +197,7 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity
return false;
}
-
+
@Override
public boolean drainEnergyInput(long aEU) {
if (aEU <= 0) return true;
@@ -103,7 +206,7 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity
if(!h1.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU/2, false) || !h2.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU/2, false)) return false;
return true;
}
-
+
@Override
public boolean onRunningTick(ItemStack aStack) {
if (this.mRuntime % 10 == 0)
@@ -111,17 +214,16 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity
return super.onRunningTick(aStack);
}
+ @Override
+ public boolean isCorrectMachinePart(ItemStack itemStack) {
+ return true;
+ }
+
public void stopMachine() {
this.resetPiston();
super.stopMachine();
}
- @Override
- public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
- if (this.piston == null)
- this.piston = true;
- }
-
private void resetPiston() {
if (this.getBaseMetaTileEntity().getWorld().isRemote)
return;
@@ -174,75 +276,27 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity
@Override
public void saveNBTData(NBTTagCompound aNBT) {
- aNBT.setBoolean("piston", this.piston);
super.saveNBTData(aNBT);
+ aNBT.setBoolean("piston", this.piston);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
- this.piston = aNBT.getBoolean("piston");
super.loadNBTData(aNBT);
+ this.piston = aNBT.getBoolean("piston");
}
@Override
- @SuppressWarnings("ALL")
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) {
- int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
- int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
-
- for (int x = -1; x <= 1; x++) {
- for (int y = -2; y < 7; y++) {
- for (int z = -1; z <= 1; z++) {
- IGregTechTileEntity te = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, z + zDir);
- if (y == -2 || y == 6) {
- if (!(x == 0 && z == 0)) {
- if (!this.addMaintenanceToMachineList(te, 16) && !this.addInputToMachineList(te, 16) && !this.addOutputToMachineList(te, 16)) {
- Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z);
- byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z);
- if ((tBlock != GregTech_API.sBlockCasings2 || tMeta != 0) && (tBlock != GregTech_API.sBlockCasings3 || tMeta != 4)) {
- return false;
- }
- }
- } else if (x == 0 && z == 0) {
- if (y == -2)
- if (!this.addEnergyInputToMachineList(te, 16))
- return false;
- if (y == 6)
- if (!this.addEnergyInputToMachineList(te, 16))
- return false;
- }
- } else if ((y > -2 && y < 1) || (y > 3 && y < 6)) {
- if (y == 0 && xDir + x == 0 && zDir + z == 0)
- continue;
- Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z);
- byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z);
- if (x == 0 && z == 0) {
- if (tBlock != BW_BLOCKS[2] || tMeta != 0)
- return false;
- } else {
- if (tBlock != BW_BLOCKS[2] || tMeta != 1)
- return false;
- }
+ if(!checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0))
+ return false;
+ return this.mMaintenanceHatches.size() == 1 &&
+ this.mEnergyHatches.size() == 2;
+ }
- } else if (y == 1) {
- if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 1, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 1, zDir + z)), Materials.Neutronium.getBlocks(1)))
- return false;
- } else if (y == 2) {
- if (!this.piston) {
- if (Math.abs(x) == 1 && Math.abs(z) == 1) {
- if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 2, zDir + z)), Materials.Neutronium.getBlocks(1)))
- return false;
- }
- } else if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1)))
- return false;
- } else if (y == 3) {
- if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 3, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 3, zDir + z)), Materials.Neutronium.getBlocks(1)))
- return false;
- }
- }
- }
- }
- return true;
+ @Override
+ public int getMaxEfficiency(ItemStack itemStack) {
+ return 10000;
}
@@ -252,12 +306,30 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity
}
@Override
+ public int getDamageToComponent(ItemStack itemStack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack itemStack) {
+ return false;
+ }
+
+ @Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) {
return new GT_TileEntity_ElectricImplosionCompressor(this.mName);
}
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing) {
+ return aActive ? new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16], TextureFactory.builder().addIcon(new IIconContainer[]{Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE}).extFacing().build(), TextureFactory.builder().addIcon(new IIconContainer[]{Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE_GLOW}).extFacing().glow().build()} : new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16], TextureFactory.builder().addIcon(new IIconContainer[]{Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR}).extFacing().build(), TextureFactory.builder().addIcon(new IIconContainer[]{Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_GLOW}).extFacing().glow().build()};
+ } else {
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16]};
+ }
+ }
+
@Override
- public String[] getDescription() {
- return BW_Tooltip_Reference.getTranslatedBrandedTooltip("tooltip.tile.eic.0.name");
+ public void construct(ItemStack itemStack, boolean b) {
+ buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 1, 6, 0);
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java
index e3b3e64753..a4fab93440 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java
@@ -22,34 +22,35 @@
package com.github.bartimaeusnek.bartworks.common.tileentities.multis;
-import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
-import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.metatileentity.implementations.*;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import static com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry.BW_BLOCKS;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.Textures.BlockIcons.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional;
-public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase {
+public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_TileEntity_ManualTrafo> {
- private static final byte SINGLE_UPSTEP = 0;
- private static final byte SINGLE_DOWNSTEP = 1;
- private static final byte MULTI_UPSTEP = 2;
- private static final byte MULTI_DOWNSTEP = 3;
private byte mode;
- private byte texid = 2;
- private long mCoilWicks;
+ private int mTiers;
private boolean upstep = true;
public GT_TileEntity_ManualTrafo(int aID, String aName, String aNameRegional) {
@@ -60,6 +61,96 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase
super(aName);
}
+ private static final int CASING_INDEX = 2;
+ private static final String STRUCTURE_PIECE_BASE = "base";
+ private static final String STRUCTURE_PIECE_LAYER = "layer";
+ private static final String STRUCTURE_PIECE_TOP = "top";
+ private static final String STRUCTURE_PIECE_TAP_LAYER = "taplayer";
+ private static final IStructureDefinition<GT_TileEntity_ManualTrafo> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_ManualTrafo>builder()
+ .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{
+ {"b~b", "bbb", "bbb"}
+ }))
+ .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{
+ {"ttt", "tft", "ttt"}
+ }))
+ .addShape(STRUCTURE_PIECE_TOP, transpose(new String[][]{
+ {"ooo", "ooo", "ooo"}
+ }))
+ .addShape(STRUCTURE_PIECE_TAP_LAYER, transpose(new String[][]{
+ {" TTT ", "TtttT", "TtftT", "TtttT", " TTT "}
+ }))
+ .addElement('b', ofChain(
+ ofHatchAdder(GT_TileEntity_ManualTrafo::addEnergyInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_ManualTrafo::addMaintenanceToMachineList, CASING_INDEX, 1),
+ ofBlock(GregTech_API.sBlockCasings1, 2)
+ ))
+ .addElement('o', ofHatchAdderOptional(GT_TileEntity_ManualTrafo::addDynamoToMachineList, CASING_INDEX, 2, GregTech_API.sBlockCasings1, 2))
+ .addElement('t', ofBlock(BW_BLOCKS[2], 1))
+ .addElement('f', ofBlock(BW_BLOCKS[2], 0))
+ .addElement('T', new IStructureElementNoPlacement<GT_TileEntity_ManualTrafo>() {
+ @Override
+ public boolean check(GT_TileEntity_ManualTrafo te, World world, int x, int y, int z) {
+ if(world.isAirBlock(x, y, z))
+ return true;
+ TileEntity tileEntity = world.getTileEntity(x, y, z);
+ if(tileEntity == null)
+ return true;
+ if(!(tileEntity instanceof IGregTechTileEntity))
+ return true;
+ IMetaTileEntity mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity();
+ if(mte instanceof GT_MetaTileEntity_Hatch_Dynamo || mte instanceof GT_MetaTileEntity_Hatch_Energy) {
+ int intier = te.mEnergyHatches.get(0).mTier;
+ if(((GT_MetaTileEntity_TieredMachineBlock) mte).mTier == intier + (te.upstep ? te.mTiers : -te.mTiers)){
+ te.addToMachineList((IGregTechTileEntity)tileEntity, CASING_INDEX);
+ return true;
+ }
+ else
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean spawnHint(GT_TileEntity_ManualTrafo te, World world, int x, int y, int z, ItemStack itemStack) {
+ StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 2 /* aDots: 3 */);
+ return true;
+ }
+ }
+ )
+ .build();
+
+ @Override
+ public IStructureDefinition<GT_TileEntity_ManualTrafo> getStructureDefinition() {
+ return STRUCTURE_DEFINITION;