Skip to content

Commit

Permalink
Merge branch 'main' into pyrotech-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu authored Oct 6, 2024
2 parents 85afd65 + 00d0fb3 commit 7597cd6
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 24 deletions.
3 changes: 3 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ dependencies {
compileOnly rfg.deobf("curse.maven:bubbles-a-baubles-fork-995393:5719448")

compileOnly rfg.deobf("curse.maven:barrels-drums-storage-more-319404:2708193")

implementation rfg.deobf("curse.maven:pyrotech-306676:5351359")
implementation rfg.deobf("curse.maven:athenaeum-284350:4633750")
implementation rfg.deobf("curse.maven:dropt-284973:5405050")

api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
}
63 changes: 63 additions & 0 deletions src/main/java/supersymmetry/api/recipes/RecipeMapGroup.java
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);
}
}
9 changes: 9 additions & 0 deletions src/main/java/supersymmetry/common/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package supersymmetry.common;

import gregtech.api.block.VariantItemBlock;
import gregtech.api.modules.ModuleContainerRegistryEvent;
import gregtech.api.unification.material.event.MaterialEvent;
import gregtech.api.unification.material.event.PostMaterialEvent;
import gregtech.client.utils.TooltipHelper;
import gregtech.common.blocks.BlockWireCoil;
import gregtech.common.items.MetaItems;
import gregtech.modules.ModuleManager;
import net.minecraft.block.Block;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.monster.EntityZombie;
Expand Down Expand Up @@ -38,6 +40,7 @@
import supersymmetry.loaders.SuSyWorldLoader;
import supersymmetry.loaders.SusyOreDictionaryLoader;
import supersymmetry.loaders.recipes.SuSyRecipeLoader;
import supersymmetry.modules.SuSyModules;

import java.util.Objects;
import java.util.function.Function;
Expand Down Expand Up @@ -174,6 +177,12 @@ public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
SuSyRecipeLoader.init();
}

@SubscribeEvent
public static void registerModuleContainer(ModuleContainerRegistryEvent event) {
ModuleManager.getInstance().registerContainer(new SuSyModules());
}


private static <T extends Block> ItemBlock createItemBlock(T block, Function<T, ItemBlock> producer) {
ItemBlock itemBlock = producer.apply(block);
itemBlock.setRegistryName(Objects.requireNonNull(block.getRegistryName()));
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/supersymmetry/common/EventHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ public class EventHandlers {
@SubscribeEvent
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {

if (event.player.isCreative()) return;

NBTTagCompound playerData = event.player.getEntityData();
NBTTagCompound data = playerData.hasKey(EntityPlayer.PERSISTED_NBT_TAG) ? playerData.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG) : new NBTTagCompound();

if(!event.player.getEntityWorld().isRemote && !data.getBoolean(FIRST_SPAWN)) {

data.setBoolean(FIRST_SPAWN, true);
playerData.setTag(EntityPlayer.PERSISTED_NBT_TAG, data);
if (event.player.isCreative()) return;

EntityDropPod dropPod = new EntityDropPod(event.player.getEntityWorld(), event.player.posX, event.player.posY + 256, event.player.posZ);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package supersymmetry.integration.bubbles;
package supersymmetry.integration.baubles;

import baubles.api.BaubleType;
import gregtech.api.GTValues;
import gregtech.api.modules.GregTechModule;
import gregtech.common.items.MetaItems;
import gregtech.integration.IntegrationSubmodule;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.jetbrains.annotations.NotNull;
import supersymmetry.Supersymmetry;
import supersymmetry.api.SusyLog;
import supersymmetry.common.item.behavior.ArmorBaubleBehavior;
import supersymmetry.modules.SuSyModules;

import java.util.Collections;
import java.util.List;

@GregTechModule(
moduleID = SuSyModules.MODULE_BUBBLES,
containerID = GTValues.MODID,
moduleID = SuSyModules.MODULE_BAUBLES,
containerID = Supersymmetry.MODID,
modDependencies = "baubles",
name = "SuSy Baubles Integration",
description = "Baubles Integration Module")
description = "SuSy Baubles Integration Module")
public class BaublesModule extends IntegrationSubmodule {

@SubscribeEvent(priority = EventPriority.LOW)
Expand All @@ -36,4 +38,9 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
public List<Class<?>> getEventBusSubscribers() {
return Collections.singletonList(BaublesModule.class);
}

@Override
public void init(FMLInitializationEvent event) {
SusyLog.logger.info("Baubles found. Enabling integration...");
}
}
21 changes: 6 additions & 15 deletions src/main/java/supersymmetry/integration/bdsandm/BDSAndMModule.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package supersymmetry.integration.bdsandm;

import funwayguy.bdsandm.blocks.tiles.TileEntityBarrel;
import funwayguy.bdsandm.core.BDSM;
import gregtech.api.GTValues;
import gregtech.api.cover.CoverRayTracer;
import gregtech.api.modules.GregTechModule;
import gregtech.common.items.tool.rotation.CustomBlockRotations;
import gregtech.common.items.tool.rotation.ICustomRotationBehavior;
import gregtech.integration.IntegrationSubmodule;
import net.minecraft.block.BlockDirectional;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import supersymmetry.Supersymmetry;
import supersymmetry.api.SusyLog;
import supersymmetry.modules.SuSyModules;

import java.util.Objects;

@GregTechModule(
moduleID = SuSyModules.MODULE_BDSAndM,
containerID = GTValues.MODID,
containerID = Supersymmetry.MODID,
modDependencies = "bdsandm",
name = "SuSy BDSAndM Integration",
description = "BDSAndM Integration Module")
Expand All @@ -29,21 +26,15 @@ public class BDSAndMModule extends IntegrationSubmodule {
if (gridSide == null) return false;
gridSide = gridSide.getOpposite(); // IDK what's happening here, blame the original author
if (gridSide != state.getValue(BlockDirectional.FACING)) {
TileEntityBarrel barrel = ((TileEntityBarrel) world.getTileEntity(pos));
if (barrel != null) {
state = state.withProperty(BlockDirectional.FACING, gridSide);
NBTTagCompound tagCompound = barrel.writeToNBT(new NBTTagCompound());
world.setBlockState(pos, state);
Objects.requireNonNull(world.getTileEntity(pos)).readFromNBT(tagCompound);
return true;
}
world.setBlockState(pos, state.withProperty(BlockDirectional.FACING, gridSide));
return true;
}
return false;
};

@Override
public void init(FMLInitializationEvent event) {
getLogger().info("BDSAndM found. Enabling integration...");
SusyLog.logger.info("BDSAndM found. Enabling integration...");
CustomBlockRotations.registerCustomRotation(BDSM.blockMetalBarrel, BDSAndM_BARREL_BEHAVIOR);
CustomBlockRotations.registerCustomRotation(BDSM.blockWoodBarrel, BDSAndM_BARREL_BEHAVIOR);
}
Expand Down
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();
}
}
22 changes: 22 additions & 0 deletions src/main/java/supersymmetry/modules/SuSyCoreModule.java
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;
}
}
5 changes: 4 additions & 1 deletion src/main/java/supersymmetry/modules/SuSyModules.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package supersymmetry.modules;

import gregtech.api.modules.IModuleContainer;
import gregtech.api.modules.ModuleContainer;
import supersymmetry.Supersymmetry;

@ModuleContainer
public class SuSyModules implements IModuleContainer {

public static final String MODULE_CORE = "susy_core";
public static final String MODULE_BDSAndM = "bdsandm_integration";
public static final String MODULE_BUBBLES = "baubles_integration";
public static final String MODULE_BAUBLES = "baubles_integration";

@Override
public String getID() {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/mixins.susy.bdsandm.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"compatibilityLevel" : "JAVA_8",
"mixins" : [
"BlockBarrelBaseMixin",
"ItemBarrelMixin"
"ItemBarrelMixin",
"TileEntityBarrelMixin"
]
}

0 comments on commit 7597cd6

Please sign in to comment.