Skip to content

Commit

Permalink
Merge pull request #395 from littlecube8152/pcb-multis
Browse files Browse the repository at this point in the history
PCB Multiblocks
  • Loading branch information
MCTian-mi authored Mar 6, 2025
2 parents a85f206 + 86878e5 commit b81b51f
Show file tree
Hide file tree
Showing 32 changed files with 634 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public ItemStack getItemVariant(T variant, int amount) {
return new ItemStack(this, amount, variant.ordinal() * 4);
}

public IBlockState getState(T variant, EnumFacing facing) {
return getDefaultState().withProperty(VARIANT, variant).withProperty(FACING, facing);
}


@Nonnull
@Override
public BlockStateContainer createBlockState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
import gregtech.api.pattern.PatternStringError;
import gregtech.api.pattern.TraceabilityPredicate;
import gregtech.api.util.BlockInfo;
import gregtech.api.util.RelativeDirection;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraftforge.fml.common.Loader;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import supersymmetry.SuSyValues;
import supersymmetry.common.blocks.BlockConveyor;
import supersymmetry.common.blocks.BlockCoolingCoil;
import supersymmetry.common.blocks.BlockSinteringBrick;
import supersymmetry.common.blocks.SuSyBlocks;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;

/**
* Class containing global predicates
Expand Down Expand Up @@ -59,7 +64,7 @@ public class SuSyPredicates {
);

private static final Supplier<TraceabilityPredicate> RAILS = () -> new TraceabilityPredicate(blockWorldState -> {
if(!Loader.isModLoaded(SuSyValues.MODID_IMMERSIVERAILROADING)) return true;
if (!Loader.isModLoaded(SuSyValues.MODID_IMMERSIVERAILROADING)) return true;

IBlockState state = blockWorldState.getBlockState();

Expand All @@ -68,6 +73,31 @@ public class SuSyPredicates {
return block == IRBlocks.BLOCK_RAIL.internal || block == IRBlocks.BLOCK_RAIL_GAG.internal;
});

// Allow all conveyor belts, and require them to have the same type.
// This will create a list of Pair<BlockPos, RelativeDirection> allowing the multiblock to reorient the facing.
private static final Map<RelativeDirection, Supplier<TraceabilityPredicate>> CONVEYOR_BELT =
Arrays.stream(RelativeDirection.values()).collect(Collectors.toMap(facing -> facing,
facing -> () -> new TraceabilityPredicate(blockWorldState -> {
IBlockState state = blockWorldState.getBlockState();
if (state.getBlock() instanceof BlockConveyor) {
// Check conveyor type
BlockConveyor.ConveyorType type = ((BlockConveyor) state.getBlock()).getState(state);
Object currentConveyor = blockWorldState.getMatchContext().getOrPut("ConveyorType", type);
if (!currentConveyor.equals(type)) {
blockWorldState.setError(new PatternStringError("gregtech.multiblock.pattern.error.conveyor"));
return false;
}
// Adds the position of the conveyor (and target facing) to the match context
blockWorldState.getMatchContext().getOrPut("ConveyorBelt", new LinkedList<>())
.add(Pair.of(blockWorldState.getPos(), facing));
return true;
}
return false;
}, () -> Arrays.stream(BlockConveyor.ConveyorType.values())
.map(entry -> new BlockInfo(SuSyBlocks.CONVEYOR_BELT.getState(entry), null))
.toArray(BlockInfo[]::new)
).addTooltips("gregtech.multiblock.pattern.error.conveyor")));

@NotNull
public static TraceabilityPredicate coolingCoils() {
return COOLING_COILS.get();
Expand All @@ -82,4 +112,9 @@ public static TraceabilityPredicate sinteringBricks() {
public static TraceabilityPredicate rails() {
return RAILS.get();
}

@NotNull
public static TraceabilityPredicate conveyorBelts(RelativeDirection facing) {
return CONVEYOR_BELT.get(facing).get();
}
}
7 changes: 7 additions & 0 deletions src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ public class SuSyRecipeMaps {
.setSound(GTSoundEvents.TURBINE)
.allowEmptyOutput();

public static final RecipeMap<SimpleRecipeBuilder> CURTAIN_COATER = new RecipeMap<>("curtain_coater", 1, 1, 1, 0, new SimpleRecipeBuilder().EUt(VA[LV]), false)
.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, ProgressWidget.MoveType.HORIZONTAL)
.setSound(GTSoundEvents.BATH);

public static final RecipeMap<SimpleRecipeBuilder> MILLING_RECIPES = new RecipeMap<>("milling", 2, 1, 0, 0, new SimpleRecipeBuilder().EUt(VA[LV]), false)
.setSound(GTSoundEvents.CUT);

public static void init(){
RecipeMaps.SIFTER_RECIPES.setMaxFluidInputs(1);
RecipeMaps.SIFTER_RECIPES.setMaxFluidOutputs(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public SusyTextures(){
public static final OrientedOverlayRenderer SINTERING_OVERLAY = new OrientedOverlayRenderer("machines/multiblocks/sintering");
public static final OrientedOverlayRenderer SMOKE_STACK_OVERLAY = new OrientedOverlayRenderer("machines/multiblocks/smoke_stack");
public static final OrientedOverlayRenderer PRIMITIVE_SMELTER_OVERLAY = new OrientedOverlayRenderer("machines/multiblocks/primitive_smelter");
public static final OrientedOverlayRenderer MILLING_OVERLAY = new OrientedOverlayRenderer("machines/multiblocks/milling");

public static final SimpleOverlayRenderer SILICON_CARBIDE_CASING = new SimpleOverlayRenderer("multiblock_casing/silicon_carbide_casing");
public static final SimpleOverlayRenderer ULV_STRUCTURAL_CASING = new SimpleOverlayRenderer("multiblock_casing/ulv_structural_casing");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/supersymmetry/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static void registerBlocks(@NotNull RegistryEvent.Register<Block> event)
registry.register(SuSyBlocks.STRUCTURAL_BLOCK);
registry.register(SuSyBlocks.STRUCTURAL_BLOCK_1);
registry.register(SuSyBlocks.DRILL_HEAD);
registry.register(SuSyBlocks.DRILL_BIT);
registry.register(SuSyBlocks.DEPOSIT_BLOCK);
registry.register(SuSyBlocks.RESOURCE_BLOCK);
registry.register(SuSyBlocks.RESOURCE_BLOCK_1);
Expand All @@ -88,6 +89,7 @@ public static void registerBlocks(@NotNull RegistryEvent.Register<Block> event)
registry.register(SuSyBlocks.SERPENTINE);
registry.register(SuSyBlocks.HARDBLOCKS);
registry.register(SuSyBlocks.CUSTOMSHEETS);
registry.register(SuSyBlocks.CONVEYOR_BELT);

SHEETED_FRAMES.values().stream().distinct().forEach(registry::register);
}
Expand All @@ -104,6 +106,7 @@ public static void registerItems(@NotNull RegistryEvent.Register<Item> event) {
registry.register(createItemBlock(block, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.ALTERNATOR_COIL, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.DRILL_HEAD, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.DRILL_BIT, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.TURBINE_ROTOR, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.SEPARATOR_ROTOR, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.STRUCTURAL_BLOCK, VariantItemBlock::new));
Expand All @@ -119,6 +122,7 @@ public static void registerItems(@NotNull RegistryEvent.Register<Item> event) {
registry.register(createItemBlock(SuSyBlocks.SERPENTINE, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.HARDBLOCKS, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.CUSTOMSHEETS, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.CONVEYOR_BELT, VariantItemBlock::new));

SHEETED_FRAMES.values()
.stream().distinct()
Expand Down
110 changes: 110 additions & 0 deletions src/main/java/supersymmetry/common/blocks/BlockConveyor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package supersymmetry.common.blocks;

import gregtech.api.cover.CoverRayTracer;
import gregtech.common.items.tool.rotation.CustomBlockRotations;
import gregtech.common.items.tool.rotation.ICustomRotationBehavior;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import supersymmetry.api.blocks.VariantHorizontalRotatableBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import org.jetbrains.annotations.NotNull;

import static net.minecraft.block.material.Material.IRON;

public class BlockConveyor extends VariantHorizontalRotatableBlock<BlockConveyor.ConveyorType> {

static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.25D, 1.0D);

public static final ICustomRotationBehavior BLOCK_FLAT_HORIZONTAL_BEHAVIOR = new ICustomRotationBehavior() {

@Override
public boolean customRotate(IBlockState state, World world, BlockPos pos, RayTraceResult hitResult) {
// Prohibit rotate other than up/down faces, as base GT does not support non-square faces
if (hitResult.sideHit != EnumFacing.UP && hitResult.sideHit != EnumFacing.DOWN)
return false;
// The rest is the same with BLOCK_HORIZONTAL_BEHAVIOR
EnumFacing gridSide = CoverRayTracer.determineGridSideHit(hitResult);
if (gridSide == null) return false;
if (gridSide.getAxis() == EnumFacing.Axis.Y) return false;

if (gridSide != state.getValue(BlockHorizontal.FACING)) {
state = state.withProperty(BlockHorizontal.FACING, gridSide);
world.setBlockState(pos, state);
return true;
}
return false;
}

@Override
public boolean showGrid() {
return false;
}
};

public BlockConveyor() {
super(IRON);
CustomBlockRotations.registerCustomRotation(this, BLOCK_FLAT_HORIZONTAL_BEHAVIOR);
setTranslationKey("conveyor_belt");
setHardness(5.0f);
setResistance(10.0f);
setSoundType(SoundType.METAL);
setHarvestLevel("wrench", 2);
setDefaultState(getState(ConveyorType.LV_CONVEYOR));
}

@Override
public boolean canCreatureSpawn(@NotNull IBlockState state, @NotNull IBlockAccess world, @NotNull BlockPos pos,
@NotNull EntityLiving.SpawnPlacementType type) {
return false;
}

@Override
@NotNull
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
return AABB_BOTTOM_HALF;
}

@Override
@SuppressWarnings("deprecation")
public boolean isFullCube(@NotNull IBlockState state) {
return false;
}

@Override
@SuppressWarnings("deprecation")
public boolean isOpaqueCube(@NotNull IBlockState state) {
return false;
}

public enum ConveyorType implements IStringSerializable {
LV_CONVEYOR("lv");

public final String name;

ConveyorType(String name) {
this.name = name;
}

@NotNull
@Override
public String getName() {
return this.name;
}

@NotNull
@Override
public String toString() {
return getName();
}
}
}
63 changes: 63 additions & 0 deletions src/main/java/supersymmetry/common/blocks/BlockDrillBit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package supersymmetry.common.blocks;

import gregtech.api.block.IStateHarvestLevel;
import gregtech.api.block.VariantBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;

public class BlockDrillBit extends VariantBlock<BlockDrillBit.DrillBitType> {
public BlockDrillBit(){
super(net.minecraft.block.material.Material.IRON);
setTranslationKey("drill_bit");
setHardness(5.0f);
setResistance(10.0f);
setSoundType(SoundType.METAL);
setHarvestLevel("wrench", 2);
setDefaultState(getState(DrillBitType.STEEL));
}

@Override
public boolean canCreatureSpawn(@NotNull IBlockState state, @NotNull IBlockAccess world, @NotNull BlockPos pos,
@NotNull EntityLiving.SpawnPlacementType type) {
return false;
}

@NotNull
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.SOLID;
}

public enum DrillBitType implements IStringSerializable, IStateHarvestLevel {
STEEL("steel", 3);

private final String name;
private final int harvestLevel;

DrillBitType(String name, int harvestLevel) {
this.name = name;
this.harvestLevel = harvestLevel;
}

@Nonnull
public String getName() {
return this.name;
}

public int getHarvestLevel(IBlockState state) {
return this.harvestLevel;
}

public String getHarvestTool(IBlockState state) {
return "wrench";
}
}
}
10 changes: 10 additions & 0 deletions src/main/java/supersymmetry/common/blocks/SuSyBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class SuSyBlocks {
public static BlockTurbineRotor TURBINE_ROTOR;
public static BlockSeparatorRotor SEPARATOR_ROTOR;
public static BlockDrillHead DRILL_HEAD;
public static BlockDrillBit DRILL_BIT;
public static BlockStructural STRUCTURAL_BLOCK;
public static BlockStructural1 STRUCTURAL_BLOCK_1;
public static BlockDeposit DEPOSIT_BLOCK;
Expand All @@ -42,6 +43,7 @@ public class SuSyBlocks {
public static BlockSerpentine SERPENTINE;
public static BlocksHardened HARDBLOCKS;
public static BlocksCustomSheets CUSTOMSHEETS;
public static BlockConveyor CONVEYOR_BELT;

public static void init() {
COOLING_COIL = new BlockCoolingCoil();
Expand All @@ -53,6 +55,9 @@ public static void init() {
DRILL_HEAD = new BlockDrillHead();
DRILL_HEAD.setRegistryName("drill_head");

DRILL_BIT = new BlockDrillBit();
DRILL_BIT.setRegistryName("drill_bit");

COAGULATION_TANK_WALL = new BlockCoagulationTankWall();
COAGULATION_TANK_WALL.setRegistryName("coagulation_tank_wall");

Expand Down Expand Up @@ -108,6 +113,9 @@ public static void init() {

CUSTOMSHEETS = new BlocksCustomSheets();
CUSTOMSHEETS.setRegistryName("custom_sheets");

CONVEYOR_BELT = new BlockConveyor();
CONVEYOR_BELT.setRegistryName("conveyor_belt");
}

@SideOnly(Side.CLIENT)
Expand All @@ -119,6 +127,7 @@ public static void registerItemModels() {
registerItemModel(block);
registerItemModel(ALTERNATOR_COIL);
registerItemModel(DRILL_HEAD);
registerItemModel(DRILL_BIT);
registerItemModel(TURBINE_ROTOR);
registerItemModel(SEPARATOR_ROTOR);
registerItemModel(STRUCTURAL_BLOCK);
Expand All @@ -134,6 +143,7 @@ public static void registerItemModels() {
SERPENTINE.onModelRegister();
registerItemModel(HARDBLOCKS);
registerItemModel(CUSTOMSHEETS);
registerItemModel(CONVEYOR_BELT);
}

@SideOnly(Side.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ public class SuSyMetaTileEntities {

public static MetaTileEntitySieveDistillationTower SIEVE_DISTILLATION_TOWER;

public static MetaTileEntityCurtainCoater CURTAIN_COATER;
public static MetaTileEntityPreciseMillingMachine MILLING;

public static MetaTileEntityBridge INV_BRIDGE;
public static MetaTileEntityBridge TANK_BRIDGE;
public static MetaTileEntityBridge INV_TANK_BRIDGE;
Expand Down Expand Up @@ -277,6 +280,9 @@ public static void init() {
registerSimpleMTE(CVD, 12, 14653, "cvd", SuSyRecipeMaps.CVD_RECIPES, SusyTextures.CVD_OVERLAY, true, GTUtility.defaultTankSizeFunction);
registerSimpleMTE(ION_IMPLANTER, 12, 14666, "ion_implanter", SuSyRecipeMaps.ION_IMPLANTATION_RECIPES, SusyTextures.ION_IMPLANTER_OVERLAY, true, GTUtility.defaultTankSizeFunction);

CURTAIN_COATER = registerMetaTileEntity(14513, new MetaTileEntityCurtainCoater(susyId("curtain_coater")));
MILLING = registerMetaTileEntity(14514, new MetaTileEntityPreciseMillingMachine(susyId("milling")));

ArrayList<Integer> ids = new ArrayList<>();
for (int id = 14500; id < 15000; id++) {
if (GregTechAPI.MTE_REGISTRY.getObjectById(id) == null) ids.add(id);
Expand Down
Loading

0 comments on commit b81b51f

Please sign in to comment.