Skip to content

Commit

Permalink
Merge branch 'master' into deprecations-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Dec 27, 2024
2 parents 5571123 + e4a885a commit bcb382d
Show file tree
Hide file tree
Showing 32 changed files with 591 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ public boolean check(MTEWindmill t, World world, int x, int y, int z) {
return t.setRotorBlock(tileEntity);
}

@Override
public boolean couldBeValid(MTEWindmill mteWindmill, World world, int x, int y, int z, ItemStack trigger) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
return tileEntity instanceof TileEntityRotorBlock;
}

@Override
public boolean spawnHint(MTEWindmill t, World world, int x, int y, int z, ItemStack trigger) {
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public boolean check(T o, World world, int x, int y, int z) {
return world.isAirBlock(x, y, z);
}

@Override
public boolean couldBeValid(T o, World world, int x, int y, int z, ItemStack trigger) {
return check(o, world, x, y, z);
}

@Override
public boolean spawnHint(T o, World world, int x, int y, int z, ItemStack trigger) {
if (world.blockExists(x, y, z) && !world.isAirBlock(x, y, z))
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/bartworks/util/BWUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,18 @@ public boolean check(T te, World world, int x, int y, int z) {
return getter.apply(te) == glassTier;
}

@Override
public boolean couldBeValid(T te, World world, int x, int y, int z, ItemStack trigger) {
if (world.isAirBlock(x, y, z)) return false;
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);

int glassTier = GlassTier.getGlassTier(block, meta);

// If it is not a glass, the tier will be 0.
return glassTier != 0 && glassTier != notset && glassTier >= mintier && glassTier <= maxtier;
}

@Override
public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemStack) {
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), aDots - 1);
Expand Down Expand Up @@ -340,6 +352,11 @@ public boolean check(T te, World world, int x, int y, int z) {
return glassTier >= mintier && glassTier <= maxtier;
}

@Override
public boolean couldBeValid(T te, World world, int x, int y, int z, ItemStack trigger) {
return check(te, world, x, y, z);
}

@Override
public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemStack) {
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), aDots - 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
package goodgenerator.blocks.tileEntity;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.ITierConverter;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import com.gtnewhorizon.structurelib.structure.StructureUtility;

import goodgenerator.api.recipe.GoodGeneratorRecipeMaps;
import goodgenerator.blocks.tileEntity.base.MTETooltipMultiBlockBaseEM;
Expand All @@ -49,7 +48,6 @@ public class MTEFuelRefineFactory extends MTETooltipMultiBlockBaseEM implements

private IStructureDefinition<MTEFuelRefineFactory> multiDefinition = null;
private int Tier = -1;
private final int[] cnt = new int[] { 0, 0, 0, 0 };
private static final Block[] coils = new Block[] { Loaders.FRF_Coil_1, Loaders.FRF_Coil_2, Loaders.FRF_Coil_3,
Loaders.FRF_Coil_4 };

Expand Down Expand Up @@ -112,64 +110,42 @@ public IStructureDefinition<MTEFuelRefineFactory> getStructure_EM() {
.addElement('G', ofBlock(Loaders.fieldRestrictingGlass, 0))
.addElement(
'F',
ofChain(
onElementPass(x -> ++x.cnt[0], ofFieldCoil(0)),
onElementPass(x -> ++x.cnt[1], ofFieldCoil(1)),
onElementPass(x -> ++x.cnt[2], ofFieldCoil(2)),
onElementPass(x -> ++x.cnt[3], ofFieldCoil(3))))
ofBlocksTiered(
fieldCoilTierConverter(),
getAllFieldCoilTiers(),
-1,
MTEFuelRefineFactory::setCoilTier,
MTEFuelRefineFactory::getCoilTier))
.build();
}
return multiDefinition;
}

public static <T> IStructureElement<T> ofFieldCoil(int aIndex) {
return new IStructureElement<>() {

@Override
public boolean check(T t, World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block.equals(coils[aIndex]);
}

@Override
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
StructureLibAPI.hintParticle(world, x, y, z, coils[getIndex(trigger)], 0);
return true;
}

private int getIndex(ItemStack trigger) {
int s = trigger.stackSize;
if (s > 4 || s <= 0) s = 4;
return s - 1;
public static ITierConverter<Integer> fieldCoilTierConverter() {
return (block, meta) -> {
for (int i = 0; i < coils.length; i++) {
if (block.equals(coils[i])) {
return i + 1;
}
}
return null;
};
}

@Override
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
return world.setBlock(x, y, z, coils[getIndex(trigger)], 0, 3);
}
public static List<Pair<Block, Integer>> getAllFieldCoilTiers() {
ArrayList<Pair<Block, Integer>> tiers = new ArrayList<>();
for (Block coil : coils) {
tiers.add(Pair.of(coil, 0));
}
return tiers;
}

@Override
public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger,
AutoPlaceEnvironment env) {
return BlocksToPlace.create(coils[getIndex(trigger)], 0);
}
private void setCoilTier(int tier) {
this.Tier = tier;
}

@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
coils[getIndex(trigger)],
0,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
private int getCoilTier() {
return this.Tier;
}

@Override
Expand Down Expand Up @@ -210,22 +186,8 @@ public String[] getStructureDescription(ItemStack itemStack) {

@Override
public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
cnt[0] = 0;
cnt[1] = 0;
cnt[2] = 0;
cnt[3] = 0;
return structureCheck_EM(mName, 7, 12, 1) && getTier() != -1;
}

public int getTier() {
for (int i = 0; i < 4; i++) {
if (cnt[i] == 32) {
Tier = i + 1;
return i;
}
}
Tier = -1;
return -1;
return structureCheck_EM(mName, 7, 12, 1);
}

@Override
Expand Down
115 changes: 0 additions & 115 deletions src/main/java/goodgenerator/util/StructureHelper.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/enums/MetaTileEntityIDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,8 @@ public enum MetaTileEntityIDs {
SOLAR_PANEL_LuV(2736),
SOLAR_PANEL_ZPM(2737),
SOLAR_PANEL_UV(2738),
MATTER_MANIPULATOR_UPLINK(2750),
HATCH_MATTER_MANIPULATOR_UPLINK_ME(2751),
INDUSTRIAL_LASER_ENGRAVER_CONTROLLER(3004),
INDUSTRIAL_COMPRESSOR_CONTROLLER(3005),
HIP_COMPRESSOR_CONTROLLER(3006),
Expand Down
Loading

0 comments on commit bcb382d

Please sign in to comment.