Skip to content

Commit

Permalink
Merge pull request #319 from MCTian-mi/better-handling-bdsandm
Browse files Browse the repository at this point in the history
Better handling bdsandm drum rotation & Fix susy modules
  • Loading branch information
bruberu authored Oct 2, 2024
2 parents 7e709b4 + f7078e4 commit 4fa8f6b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 22 deletions.
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 @@ -172,6 +175,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
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 4fa8f6b

Please sign in to comment.