Skip to content

Commit

Permalink
Erm, add ULV casings to the CoAL
Browse files Browse the repository at this point in the history
Remove some stuff I don't think I need
Make the PRASS use machine casings and have a tier based on them
  • Loading branch information
Zorbatron committed Sep 9, 2024
1 parent 58d1c0f commit 027c605
Show file tree
Hide file tree
Showing 28 changed files with 155 additions and 148 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/zorbatron/zbgt/ZBGTCore.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.zorbatron.zbgt;

import static com.zorbatron.zbgt.api.ZBGTAPI.CoAL_CASINGS;
import static com.zorbatron.zbgt.api.ZBGTAPI.PRECISE_CASINGS;
import static com.zorbatron.zbgt.api.ZBGTAPI.*;
import static com.zorbatron.zbgt.common.block.ZBGTMetaBlocks.CoAL_CASING;
import static com.zorbatron.zbgt.common.block.ZBGTMetaBlocks.PRECISE_CASING;

Expand All @@ -19,6 +18,8 @@
import com.zorbatron.zbgt.common.block.blocks.PreciseCasing;

import gregtech.GTInternalTags;
import gregtech.common.blocks.BlockMachineCasing;
import gregtech.common.blocks.MetaBlocks;

@Mod(modid = ZBGTCore.MODID,
version = ZBGTCore.VERSION,
Expand Down Expand Up @@ -56,6 +57,10 @@ public void preInit(FMLPreInitializationEvent event) {
PRECISE_CASINGS.put(PRECISE_CASING.getState(type), type);
}

for (BlockMachineCasing.MachineCasingType type : BlockMachineCasing.MachineCasingType.values()) {
MACHINE_CASINGS.put(MetaBlocks.MACHINE_CASING.getState(type), type);
}

proxy.preInit();
}
}
11 changes: 7 additions & 4 deletions src/main/java/com/zorbatron/zbgt/api/ZBGTAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import net.minecraft.block.state.IBlockState;

import com.zorbatron.zbgt.api.block.ICoALTier;
import com.zorbatron.zbgt.api.block.IPreciseTier;
import com.zorbatron.zbgt.common.block.blocks.CoALCasing;
import com.zorbatron.zbgt.common.block.blocks.PreciseCasing;

import gregtech.common.blocks.BlockMachineCasing;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

public class ZBGTAPI {

public static final Object2ObjectMap<IBlockState, ICoALTier> CoAL_CASINGS = new Object2ObjectOpenHashMap<>();
public static final Object2ObjectMap<IBlockState, CoALCasing.CasingType> CoAL_CASINGS = new Object2ObjectOpenHashMap<>();

public static final Object2ObjectMap<IBlockState, IPreciseTier> PRECISE_CASINGS = new Object2ObjectOpenHashMap<>();
public static final Object2ObjectMap<IBlockState, PreciseCasing.CasingType> PRECISE_CASINGS = new Object2ObjectOpenHashMap<>();

public static final Object2ObjectMap<IBlockState, BlockMachineCasing.MachineCasingType> MACHINE_CASINGS = new Object2ObjectOpenHashMap<>();
}
6 changes: 0 additions & 6 deletions src/main/java/com/zorbatron/zbgt/api/block/ICoALTier.java

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/com/zorbatron/zbgt/api/block/IPreciseTier.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

public class ZBGTDataCodes {

public static final int MULTIBLOCK_TIER_CHANGE = GregtechDataCodes.assignId();
public static final int MULTIBLOCK_TIER_CHANGE_1 = GregtechDataCodes.assignId();
public static final int MULTIBLOCK_TIER_CHANGE_2 = GregtechDataCodes.assignId();
public static final int MULTIBLOCK_TIER_CHANGE_3 = GregtechDataCodes.assignId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import net.minecraft.block.state.IBlockState;

import com.zorbatron.zbgt.api.ZBGTAPI;
import com.zorbatron.zbgt.api.block.ICoALTier;
import com.zorbatron.zbgt.api.block.IPreciseTier;
import com.zorbatron.zbgt.common.block.blocks.CoALCasing;
import com.zorbatron.zbgt.common.block.blocks.PreciseCasing;

import gregicality.multiblocks.api.capability.IParallelMultiblock;
import gregicality.multiblocks.api.metatileentity.GCYMMultiblockAbility;
Expand All @@ -20,27 +20,32 @@
import gregtech.api.pattern.TraceabilityPredicate;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.BlockInfo;
import gregtech.common.blocks.BlockMachineCasing;

public class TraceabilityPredicates {

private static final Supplier<TraceabilityPredicate> CoAL_PREDICATE = () -> new TraceabilityPredicate(
blockWorldState -> {
IBlockState blockState = blockWorldState.getBlockState();
if (ZBGTAPI.CoAL_CASINGS.containsKey(blockState)) {
ICoALTier tier = ZBGTAPI.CoAL_CASINGS.get(blockState);
CoALCasing.CasingType tier = ZBGTAPI.CoAL_CASINGS.get(blockState);
Object casing = blockWorldState.getMatchContext().getOrPut("CoALTier", tier);

if (!casing.equals(tier)) {
blockWorldState.setError(
new PatternStringError("gregtech.multiblock.pattern.error.coal_tier"));
return false;
}

blockWorldState.getMatchContext().getOrPut("VBlock", new LinkedList<>())
.add(blockWorldState.getPos());

return true;
}

return false;
}, () -> ZBGTAPI.CoAL_CASINGS.entrySet().stream()
.sorted(Comparator.comparingInt(entry -> entry.getValue().getTier()))
.sorted(Comparator.comparingInt(entry -> entry.getValue().ordinal()))
.map(entry -> new BlockInfo(entry.getKey(), null))
.toArray(BlockInfo[]::new))
.addTooltips("zbgt.multiblock.pattern.error.casings");
Expand All @@ -53,27 +58,60 @@ public static TraceabilityPredicate coALCasings() {
blockWorldState -> {
IBlockState blockState = blockWorldState.getBlockState();
if (ZBGTAPI.PRECISE_CASINGS.containsKey(blockState)) {
IPreciseTier tier = ZBGTAPI.PRECISE_CASINGS.get(blockState);
PreciseCasing.CasingType tier = ZBGTAPI.PRECISE_CASINGS.get(blockState);
Object casing = blockWorldState.getMatchContext().getOrPut("PreciseTier", tier);

if (!casing.equals(tier)) {
blockWorldState.setError(
new PatternStringError("gregtech.multiblock.pattern.error.precise_tier"));
return false;
}

blockWorldState.getMatchContext().getOrPut("VBlock", new LinkedList<>())
.add(blockWorldState.getPos());

return true;
}

return false;
}, () -> ZBGTAPI.PRECISE_CASINGS.entrySet().stream()
.sorted(Comparator.comparingInt(entry -> entry.getValue().getTier()))
.sorted(Comparator.comparingInt(entry -> entry.getValue().ordinal()))
.map(entry -> new BlockInfo(entry.getKey(), null))
.toArray(BlockInfo[]::new)).addTooltips("zbgt.multiblock.pattern.error.casings");

public static TraceabilityPredicate preciseCasings() {
return PRECISE_PREDICATE.get();
}

private static final Supplier<TraceabilityPredicate> MACHINE_CASING_PREDICATE = () -> new TraceabilityPredicate(
blockWorldState -> {
IBlockState blockState = blockWorldState.getBlockState();
if (ZBGTAPI.MACHINE_CASINGS.containsKey(blockState)) {
BlockMachineCasing.MachineCasingType tier = ZBGTAPI.MACHINE_CASINGS.get(blockState);
Object casing = blockWorldState.getMatchContext().getOrPut("MachineCasingTier", tier);

if (!casing.equals(tier)) {
blockWorldState.setError(
new PatternStringError("gregtech.multiblock.pattern.error.machine_casing_tier"));
return false;
}

blockWorldState.getMatchContext().getOrPut("VBlock", new LinkedList<>())
.add(blockWorldState.getPos());

return true;
}

return false;
}, () -> ZBGTAPI.MACHINE_CASINGS.entrySet().stream()
.sorted(Comparator.comparingInt(entry -> entry.getValue().ordinal()))
.map(entry -> new BlockInfo(entry.getKey(), null))
.toArray(BlockInfo[]::new)).addTooltip("zbgt.multiblock.pattern.error.machine_casings");

public static TraceabilityPredicate machineCasings() {
return MACHINE_CASING_PREDICATE.get();
}

public static TraceabilityPredicate autoBusesAndHatches(RecipeMap<?>[] recipeMaps) {
boolean checkedItemIn = false, checkedItemOut = false, checkedFluidIn = false, checkedFluidOut = false;
TraceabilityPredicate predicate = new TraceabilityPredicate();
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/com/zorbatron/zbgt/api/recipes/ITier.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import org.jetbrains.annotations.NotNull;

import com.zorbatron.zbgt.api.block.ICoALTier;

import gregtech.api.block.VariantBlock;

public class CoALCasing extends VariantBlock<CoALCasing.CasingType> {
Expand All @@ -36,8 +34,9 @@ public boolean canCreatureSpawn(@Nonnull IBlockState state, @Nonnull IBlockAcces
return false;
}

public enum CasingType implements IStringSerializable, ICoALTier {
public enum CasingType implements IStringSerializable {

CASING_ULV("ulv"),
CASING_LV("lv"),
CASING_MV("mv"),
CASING_HV("hv"),
Expand Down Expand Up @@ -65,11 +64,6 @@ public String getName() {
return this.name;
}

@Override
public int getTier() {
return this.ordinal();
}

public static CasingType getCasingByTier(int tier) {
return switch (tier) {
case (MV) -> CASING_MV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import org.jetbrains.annotations.NotNull;

import com.zorbatron.zbgt.api.block.IPreciseTier;

import gregtech.api.block.VariantBlock;

public class PreciseCasing extends VariantBlock<PreciseCasing.CasingType> {
Expand All @@ -32,7 +30,7 @@ public boolean canCreatureSpawn(@NotNull IBlockState state, @NotNull IBlockAcces
return false;
}

public enum CasingType implements IStringSerializable, IPreciseTier {
public enum CasingType implements IStringSerializable {

PRECISE_CASING_0("precise_0"),
PRECISE_CASING_1("precise_1"),
Expand All @@ -52,18 +50,13 @@ public String getName() {
return this.name;
}

@Override
public int getTier() {
return this.ordinal();
}

public static CasingType getCasingByTier(int tier) {
return switch (tier) {
case (0) -> PRECISE_CASING_0;
case (1) -> PRECISE_CASING_1;
case (2) -> PRECISE_CASING_2;
case (3) -> PRECISE_CASING_3;
case (4) -> PRECISE_CASING_4;
default -> PRECISE_CASING_0;
default -> PRECISE_CASING_4;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@

import org.jetbrains.annotations.NotNull;

import com.zorbatron.zbgt.api.block.ICoALTier;
import com.zorbatron.zbgt.api.metatileentity.LaserCapableRecipeMapMultiblockController;
import com.zorbatron.zbgt.api.recipes.ITier;
import com.zorbatron.zbgt.api.recipes.properties.CoALProperty;
import com.zorbatron.zbgt.api.render.ZBGTTextures;
import com.zorbatron.zbgt.common.block.ZBGTMetaBlocks;
import com.zorbatron.zbgt.common.block.blocks.CoALCasing;
import com.zorbatron.zbgt.common.block.blocks.ZBGTBlockMultiblockCasing;

import gregtech.api.GTValues;
Expand All @@ -50,7 +49,7 @@
import gregtech.common.blocks.*;

public class MetaTileEntityCoAL extends LaserCapableRecipeMapMultiblockController
implements ITier, IOpticalComputationReceiver {
implements IOpticalComputationReceiver {

private IOpticalComputationProvider computationProvider;
private int tier;
Expand Down Expand Up @@ -187,13 +186,13 @@ public ICubeRenderer getBaseTexture(IMultiblockPart iMultiblockPart) {
protected void formStructure(PatternMatchContext context) {
super.formStructure(context);
Object type = context.get("CoALTier");
if (type instanceof ICoALTier) {
this.tier = ((ICoALTier) type).getTier() + 1;
if (type instanceof CoALCasing.CasingType coalTier) {
this.tier = coalTier.ordinal();
} else
this.tier = 0;
this.tier = -1;

List<IOpticalComputationHatch> providers = getAbilities(MultiblockAbility.COMPUTATION_DATA_RECEPTION);
if (providers != null && providers.size() >= 1) {
if (providers != null && !providers.isEmpty()) {
computationProvider = providers.get(0);
}

Expand All @@ -213,7 +212,6 @@ public void invalidateStructure() {
this.tier = 0;
}

@Override
public int getTier() {
return this.tier;
}
Expand Down
Loading

0 comments on commit 027c605

Please sign in to comment.