Skip to content

Commit

Permalink
Merge branch 'GregTechCEu:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
marisathewitch authored Jul 10, 2024
2 parents 11aab6c + 7799009 commit 0192d9d
Show file tree
Hide file tree
Showing 18 changed files with 380 additions and 181 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/format_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ on:
push:
branches:
- master
paths: ['src/main/java/**', 'src/test/**']
pull_request:
paths: ['src/main/java/**', 'src/test/**']

concurrency:
group: formatting-${{ github.head_ref || github.ref }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
branches:
- master
pull_request:
branches:
- '*'

concurrency:
group: tests-${{ github.head_ref || github.ref }}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/validate_gradle_wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:
paths:
- 'gradle/**'
pull_request:
branches:
- '*'
paths:
- 'gradle/**'

Expand All @@ -26,4 +24,4 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation
uses: gradle/actions/wrapper-validation@v3
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ dependencies {
// Published dependencies
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:modularui:2.4.3") { transitive = false }
api("com.cleanroommc:groovyscript:1.1.0") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.698")
api("com.cleanroommc:groovyscript:1.1.1") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
api("appeng:ae2-uel:v0.56.4") { transitive = false }
api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
19 changes: 10 additions & 9 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
22 changes: 22 additions & 0 deletions src/main/java/gregtech/api/capability/IDistillationTower.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gregtech.api.capability;

import gregtech.api.metatileentity.multiblock.IMultiblockPart;

import net.minecraft.util.math.BlockPos;

import java.util.List;

/**
* intended for use in conjunction with {@link gregtech.api.capability.impl.DistillationTowerLogicHandler}
* use with distillation tower type multiblocks
*/
public interface IDistillationTower {

List<IMultiblockPart> getMultiblockParts();

BlockPos getPos();

void invalidateStructure();

boolean allowSameFluidFillForOutputs();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package gregtech.api.capability.impl;

import gregtech.api.capability.IDistillationTower;
import gregtech.api.capability.IMultipleTankHandler;
import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart;
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
import gregtech.api.pattern.BlockPattern;
import gregtech.api.util.GTLog;
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart;

import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.FluidTankProperties;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.stream.Collectors;

/**
* Allows hatchscan behavior to be used on fluid outputs. Not a child of {@link AbstractRecipeLogic}
* for compatibility with other children.
*/
public class DistillationTowerLogicHandler {

protected final IDistillationTower tower;

private int layerCount;
private List<IFluidHandler> orderedFluidOutputs;
private IMultipleTankHandler fluidTanks;

public DistillationTowerLogicHandler(IDistillationTower tower) {
this.tower = tower;
}

/**
* Applies fluids to outputs on a sorted one fluid -> one hatch basis
*
* @param fluids the fluids to output. Will be automatically trimmed if there are not enough output hatches.
* @param doFill whether the application should be simulated or not.
* @return whether the fluids were successfully applied to the outputs or not.
*/
public boolean applyFluidToOutputs(List<FluidStack> fluids, boolean doFill) {
boolean valid = true;
for (int i = 0; i < Math.min(fluids.size(), this.getOrderedFluidOutputs().size()); i++) {
IFluidHandler handler = this.getOrderedFluidOutputs().get(i);
int accepted = handler.fill(fluids.get(i), doFill);
if (accepted != fluids.get(i).amount) valid = false;
if (!doFill && !valid) break;
}
return valid;
}

/**
* Called on structure formation to determine the number of layers in the distillation tower. <br>
* <br>
* Needs to be overriden for multiblocks that have different assemblies than the standard distillation tower.
*
* @param structurePattern the structure pattern
*/
public void determineLayerCount(@NotNull BlockPattern structurePattern) {
this.setLayerCount(structurePattern.formedRepetitionCount[1] + 1);
}

/**
* Called on structure formation to determine the ordered list of fluid handlers in the distillation tower. <br>
* <br>
* Needs to be overriden for multiblocks that have different assemblies than the standard distillation tower.
*/
public void determineOrderedFluidOutputs() {
// noinspection SimplifyStreamApiCallChains
List<MetaTileEntityMultiblockPart> fluidExportParts = tower.getMultiblockParts().stream()
.filter(iMultiblockPart -> iMultiblockPart instanceof IMultiblockAbilityPart<?>abilityPart &&
abilityPart.getAbility() == MultiblockAbility.EXPORT_FLUIDS &&
abilityPart instanceof MetaTileEntityMultiblockPart)
.map(iMultiblockPart -> (MetaTileEntityMultiblockPart) iMultiblockPart)
.collect(Collectors.toList());
// the fluidExportParts should come sorted in smallest Y first, largest Y last.
List<IFluidHandler> orderedHandlerList = new ObjectArrayList<>();
List<IFluidTank> tankList = new ObjectArrayList<>();
int firstY = tower.getPos().getY() + 1;
int exportIndex = 0;
for (int y = firstY; y < firstY + this.getLayerCount(); y++) {
if (fluidExportParts.size() <= exportIndex) {
orderedHandlerList.add(FakeTank.INSTANCE);
tankList.add(FakeTank.INSTANCE);
continue;
}
MetaTileEntityMultiblockPart part = fluidExportParts.get(exportIndex);
if (part.getPos().getY() == y) {
List<IFluidTank> hatchTanks = new ObjectArrayList<>();
// noinspection unchecked
((IMultiblockAbilityPart<IFluidTank>) part).registerAbilities(hatchTanks);
orderedHandlerList.add(new FluidTankList(false, hatchTanks));
tankList.addAll(hatchTanks);
exportIndex++;
} else if (part.getPos().getY() > y) {
orderedHandlerList.add(FakeTank.INSTANCE);
tankList.add(FakeTank.INSTANCE);
} else {
GTLog.logger.error(
"The Distillation Tower at {} had a fluid export hatch with an unexpected Y position.",
tower.getPos());
tower.invalidateStructure();
this.setOrderedFluidOutputs(new ObjectArrayList<>());
this.setFluidTanks(new FluidTankList(false));
}
}
this.setOrderedFluidOutputs(orderedHandlerList);
this.setFluidTanks(new FluidTankList(tower.allowSameFluidFillForOutputs(), tankList));
}

/**
* Should be called on structure invalidation.
*/
public void invalidate() {
this.setLayerCount(0);
this.setOrderedFluidOutputs(null);
}

protected void setLayerCount(int layerCount) {
this.layerCount = layerCount;
}

public int getLayerCount() {
return layerCount;
}

protected void setOrderedFluidOutputs(List<IFluidHandler> orderedFluidOutputs) {
this.orderedFluidOutputs = orderedFluidOutputs;
}

public List<IFluidHandler> getOrderedFluidOutputs() {
return orderedFluidOutputs;
}

protected void setFluidTanks(IMultipleTankHandler fluidTanks) {
this.fluidTanks = fluidTanks;
}

public IMultipleTankHandler getFluidTanks() {
return fluidTanks;
}

// an endless void devouring any fluid sent to it
protected static class FakeTank implements IFluidHandler, IFluidTank {

protected static final FakeTank INSTANCE = new FakeTank();
public static final FluidTankInfo FAKE_TANK_INFO = new FluidTankInfo(null, Integer.MAX_VALUE);
public static final IFluidTankProperties FAKE_TANK_PROPERTIES = new FluidTankProperties(null, Integer.MAX_VALUE,
true, false);
public static final IFluidTankProperties[] FAKE_TANK_PROPERTIES_ARRAY = new IFluidTankProperties[] {
FAKE_TANK_PROPERTIES };

@Override
public IFluidTankProperties[] getTankProperties() {
return FAKE_TANK_PROPERTIES_ARRAY;
}

@Override
public FluidStack getFluid() {
return null;
}

@Override
public int getFluidAmount() {
return 0;
}

@Override
public int getCapacity() {
return Integer.MAX_VALUE;
}

@Override
public FluidTankInfo getInfo() {
return FAKE_TANK_INFO;
}

@Override
public int fill(FluidStack resource, boolean doFill) {
return resource.amount;
}

@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
return null;
}

@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ public void performMining() {
// drill a hole beneath the miner and extend the pipe downwards by one
WorldServer world = (WorldServer) metaTileEntity.getWorld();
if (mineY.get() < pipeY.get()) {
world.destroyBlock(
new BlockPos(metaTileEntity.getPos().getX(), pipeY.get(), metaTileEntity.getPos().getZ()), false);
var pipePos = new BlockPos(metaTileEntity.getPos().getX(), pipeY.get(), metaTileEntity.getPos().getZ());
if (world.getTileEntity(pipePos) == null &&
world.getBlockState(pipePos).getBlockHardness(world, pipePos) >= 0)
world.destroyBlock(pipePos, false);
pipeY.decrementAndGet();
incrementPipeLength();
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/gregtech/api/unification/OreDictUnifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,13 @@ public static boolean hasOreDictionary(@NotNull ItemStack itemStack, @NotNull St
return wildcardNames != null && wildcardNames != names && wildcardNames.contains(oreDictName);
}

public static List<ItemStack> getAllWithOreDictionaryName(String oreDictionaryName) {
return oreDictNameStacks.get(oreDictionaryName).stream()
public static @NotNull List<@NotNull ItemStack> getAllWithOreDictionaryName(@NotNull String oreDictionaryName) {
var stacks = oreDictNameStacks.get(oreDictionaryName);
if (stacks == null) {
return Collections.emptyList();
}

return stacks.stream()
.map(ItemStack::copy)
.collect(Collectors.toList());
}
Expand Down
Loading

0 comments on commit 0192d9d

Please sign in to comment.