-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pyrotech-integration
- Loading branch information
Showing
10 changed files
with
140 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/supersymmetry/api/recipes/RecipeMapGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package supersymmetry.api.recipes; | ||
|
||
import gregtech.api.recipes.Recipe; | ||
import gregtech.api.recipes.RecipeBuilder; | ||
import gregtech.api.recipes.RecipeMap; | ||
import gregtech.api.recipes.builders.SimpleRecipeBuilder; | ||
import gregtech.api.recipes.category.GTRecipeCategory; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
public class RecipeMapGroup<R extends RecipeBuilder<R>> extends RecipeMap<R> { | ||
|
||
protected final RecipeMap<?>[] recipeMaps; | ||
|
||
protected RecipeMapGroup(@NotNull String unlocalizedName, int maxInputs, int maxOutputs, int maxFluidInputs, int maxFluidOutputs, @NotNull R defaultRecipeBuilder, boolean isHidden, @NotNull RecipeMap<?>[] recipeMaps) { | ||
super(unlocalizedName, maxInputs, maxOutputs, maxFluidInputs, maxFluidOutputs, defaultRecipeBuilder, isHidden); | ||
this.recipeMaps = recipeMaps; | ||
} | ||
|
||
@Nonnull | ||
public static RecipeMapGroup<SimpleRecipeBuilder> create(@NotNull String unlocalizedName, @NotNull RecipeMap<?>... recipeMaps) { | ||
int maxInputs = 0, maxOutputs = 0, maxFluidInputs = 0, maxFluidOutputs = 0; | ||
for (RecipeMap<?> recipeMap : recipeMaps) { | ||
maxInputs = Math.max(maxInputs, recipeMap.getMaxInputs()); | ||
maxOutputs = Math.max(maxOutputs, recipeMap.getMaxOutputs()); | ||
maxFluidInputs = Math.max(maxFluidInputs, recipeMap.getMaxFluidInputs()); | ||
maxFluidOutputs = Math.max(maxFluidOutputs, recipeMap.getMaxFluidOutputs()); | ||
} | ||
return new RecipeMapGroup<>(unlocalizedName, maxInputs, maxOutputs, maxFluidInputs, maxFluidOutputs, new SimpleRecipeBuilder(), true, recipeMaps); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Recipe findRecipe(long voltage, List<ItemStack> inputs, List<FluidStack> fluidInputs, boolean exactVoltage) { | ||
AtomicReference<Recipe> recipe = new AtomicReference<>(); | ||
Arrays.stream(recipeMaps) | ||
.parallel() | ||
.map(recipeMap -> recipeMap.findRecipe(voltage, inputs, fluidInputs, exactVoltage)) | ||
.filter(java.util.Objects::nonNull) | ||
.findFirst().ifPresent(recipe::set); | ||
return recipe.get(); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Map<GTRecipeCategory, List<Recipe>> getRecipesByCategory() { | ||
Map<GTRecipeCategory, List<Recipe>> res = new Object2ObjectOpenHashMap<>(); | ||
for (RecipeMap<?> recipeMap : recipeMaps) { | ||
res.putAll(recipeMap.getRecipesByCategory()); | ||
} | ||
return Collections.unmodifiableMap(res); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/supersymmetry/mixins/bdsandm/TileEntityBarrelMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package supersymmetry.mixins.bdsandm; | ||
|
||
import funwayguy.bdsandm.blocks.tiles.TileEntityBarrel; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(TileEntityBarrel.class) | ||
public abstract class TileEntityBarrelMixin extends TileEntity { | ||
|
||
@Override | ||
public boolean shouldRefresh(@NotNull World world, @NotNull BlockPos pos, @NotNull IBlockState oldState, @NotNull IBlockState newSate) { | ||
return oldState.getBlock() != newSate.getBlock(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package supersymmetry.modules; | ||
|
||
import gregtech.api.modules.GregTechModule; | ||
import gregtech.api.modules.IGregTechModule; | ||
import org.apache.logging.log4j.Logger; | ||
import org.jetbrains.annotations.NotNull; | ||
import supersymmetry.Supersymmetry; | ||
import supersymmetry.api.SusyLog; | ||
|
||
@GregTechModule( | ||
moduleID = SuSyModules.MODULE_CORE, | ||
containerID = Supersymmetry.MODID, | ||
name = "SuSy Core", | ||
description = "Core module of SuSy Core, so this should call SuSy Core Core ngl.", | ||
coreModule = true) | ||
public class SuSyCoreModule implements IGregTechModule { | ||
|
||
@Override | ||
public @NotNull Logger getLogger() { | ||
return SusyLog.logger; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters