diff --git a/src/main/java/com/zorbatron/zbgt/ZBGTCore.java b/src/main/java/com/zorbatron/zbgt/ZBGTCore.java index c5e510c5..fe0fe717 100644 --- a/src/main/java/com/zorbatron/zbgt/ZBGTCore.java +++ b/src/main/java/com/zorbatron/zbgt/ZBGTCore.java @@ -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; @@ -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, @@ -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(); } } diff --git a/src/main/java/com/zorbatron/zbgt/api/ZBGTAPI.java b/src/main/java/com/zorbatron/zbgt/api/ZBGTAPI.java index a3bfde6f..26cf3322 100644 --- a/src/main/java/com/zorbatron/zbgt/api/ZBGTAPI.java +++ b/src/main/java/com/zorbatron/zbgt/api/ZBGTAPI.java @@ -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 CoAL_CASINGS = new Object2ObjectOpenHashMap<>(); + public static final Object2ObjectMap CoAL_CASINGS = new Object2ObjectOpenHashMap<>(); - public static final Object2ObjectMap PRECISE_CASINGS = new Object2ObjectOpenHashMap<>(); + public static final Object2ObjectMap PRECISE_CASINGS = new Object2ObjectOpenHashMap<>(); + + public static final Object2ObjectMap MACHINE_CASINGS = new Object2ObjectOpenHashMap<>(); } diff --git a/src/main/java/com/zorbatron/zbgt/api/block/ICoALTier.java b/src/main/java/com/zorbatron/zbgt/api/block/ICoALTier.java deleted file mode 100644 index c1ec951a..00000000 --- a/src/main/java/com/zorbatron/zbgt/api/block/ICoALTier.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.zorbatron.zbgt.api.block; - -public interface ICoALTier { - - int getTier(); -} diff --git a/src/main/java/com/zorbatron/zbgt/api/block/IPreciseTier.java b/src/main/java/com/zorbatron/zbgt/api/block/IPreciseTier.java deleted file mode 100644 index 3d0f2251..00000000 --- a/src/main/java/com/zorbatron/zbgt/api/block/IPreciseTier.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.zorbatron.zbgt.api.block; - -public interface IPreciseTier { - - int getTier(); -} diff --git a/src/main/java/com/zorbatron/zbgt/api/capability/ZBGTDataCodes.java b/src/main/java/com/zorbatron/zbgt/api/capability/ZBGTDataCodes.java index d3bd5276..d29f1237 100644 --- a/src/main/java/com/zorbatron/zbgt/api/capability/ZBGTDataCodes.java +++ b/src/main/java/com/zorbatron/zbgt/api/capability/ZBGTDataCodes.java @@ -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(); } diff --git a/src/main/java/com/zorbatron/zbgt/api/metatileentity/LaserCapableMultiMapMultiblockController.java b/src/main/java/com/zorbatron/zbgt/api/metatileentity/LaserCapableMultiMapMultiblockController.java new file mode 100644 index 00000000..91561c88 --- /dev/null +++ b/src/main/java/com/zorbatron/zbgt/api/metatileentity/LaserCapableMultiMapMultiblockController.java @@ -0,0 +1,82 @@ +package com.zorbatron.zbgt.api.metatileentity; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.minecraft.util.ResourceLocation; + +import com.zorbatron.zbgt.ZBGTConfig; + +import gregtech.api.capability.IEnergyContainer; +import gregtech.api.capability.impl.EnergyContainerList; +import gregtech.api.metatileentity.multiblock.MultiMapMultiblockController; +import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.pattern.TraceabilityPredicate; +import gregtech.api.recipes.RecipeMap; + +public abstract class LaserCapableMultiMapMultiblockController extends MultiMapMultiblockController { + + private final boolean allowSubstationHatches; + + public LaserCapableMultiMapMultiblockController(ResourceLocation metaTileEntityId, RecipeMap[] recipeMaps) { + this(metaTileEntityId, recipeMaps, true); + } + + public LaserCapableMultiMapMultiblockController(ResourceLocation metaTileEntityId, RecipeMap[] recipeMaps, + boolean allowSubstationHatches) { + super(metaTileEntityId, recipeMaps); + this.allowSubstationHatches = allowSubstationHatches; + } + + public boolean allowsSubstationHatches() { + return this.allowSubstationHatches && ZBGTConfig.multiblockSettings.allowSubstationHatches; + } + + @Override + protected void initializeAbilities() { + super.initializeAbilities(); + + List list = new ArrayList<>(); + list.addAll(getAbilities(MultiblockAbility.INPUT_ENERGY)); + list.addAll(getAbilities(MultiblockAbility.INPUT_LASER)); + if (allowsSubstationHatches()) { + list.addAll(getAbilities(MultiblockAbility.SUBSTATION_INPUT_ENERGY)); + } + + this.energyContainer = new EnergyContainerList(Collections.unmodifiableList(list)); + } + + @Override + public TraceabilityPredicate autoAbilities(boolean checkEnergyIn, boolean checkMaintenance, boolean checkItemIn, + boolean checkItemOut, boolean checkFluidIn, boolean checkFluidOut, + boolean checkMuffler) { + TraceabilityPredicate predicate = super.autoAbilities(false, checkMaintenance, checkItemIn, checkItemOut, + checkFluidIn, checkFluidOut, checkMuffler); + + if (checkEnergyIn) { + predicate = predicate.or(autoEnergyInputs()); + } + + return predicate; + } + + public TraceabilityPredicate autoEnergyInputs(int min, int max, int previewCount) { + if (allowsSubstationHatches()) { + return new TraceabilityPredicate(abilities(MultiblockAbility.INPUT_ENERGY, MultiblockAbility.INPUT_LASER, + MultiblockAbility.SUBSTATION_INPUT_ENERGY) + .setMinGlobalLimited(min).setMaxGlobalLimited(max).setPreviewCount(previewCount)); + } else { + return new TraceabilityPredicate(abilities(MultiblockAbility.INPUT_ENERGY, MultiblockAbility.INPUT_LASER) + .setMinGlobalLimited(min).setMaxGlobalLimited(max).setPreviewCount(previewCount)); + } + } + + public TraceabilityPredicate autoEnergyInputs(int min, int max) { + return autoEnergyInputs(min, max, 2); + } + + public TraceabilityPredicate autoEnergyInputs() { + return autoEnergyInputs(1, 3); + } +} diff --git a/src/main/java/com/zorbatron/zbgt/api/pattern/TraceabilityPredicates.java b/src/main/java/com/zorbatron/zbgt/api/pattern/TraceabilityPredicates.java index 7ef16af7..b72c9ae4 100644 --- a/src/main/java/com/zorbatron/zbgt/api/pattern/TraceabilityPredicates.java +++ b/src/main/java/com/zorbatron/zbgt/api/pattern/TraceabilityPredicates.java @@ -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; @@ -20,6 +20,7 @@ import gregtech.api.pattern.TraceabilityPredicate; import gregtech.api.recipes.RecipeMap; import gregtech.api.util.BlockInfo; +import gregtech.common.blocks.BlockMachineCasing; public class TraceabilityPredicates { @@ -27,23 +28,27 @@ public class TraceabilityPredicates { 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.component_al_tier")); + 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("gcyl.multiblock.pattern.error.component_al_casings"); + .addTooltips("zbgt.multiblock.pattern.error.casings"); public static TraceabilityPredicate coALCasings() { return CoAL_PREDICATE.get(); @@ -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("gcyl.multiblock.pattern.error.precise_casings"); + .toArray(BlockInfo[]::new)).addTooltips("zbgt.multiblock.pattern.error.casings"); public static TraceabilityPredicate preciseCasings() { return PRECISE_PREDICATE.get(); } + private static final Supplier 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(); diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/ITier.java b/src/main/java/com/zorbatron/zbgt/api/recipes/ITier.java deleted file mode 100644 index 2f932563..00000000 --- a/src/main/java/com/zorbatron/zbgt/api/recipes/ITier.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.zorbatron.zbgt.api.recipes; - -public interface ITier { - - int getTier(); -} diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/ZBGTRecipeMaps.java b/src/main/java/com/zorbatron/zbgt/api/recipes/ZBGTRecipeMaps.java index ddb21a04..fc065916 100644 --- a/src/main/java/com/zorbatron/zbgt/api/recipes/ZBGTRecipeMaps.java +++ b/src/main/java/com/zorbatron/zbgt/api/recipes/ZBGTRecipeMaps.java @@ -6,18 +6,23 @@ import java.util.List; import com.zorbatron.zbgt.api.recipes.builders.CoALRecipeBuilder; +import com.zorbatron.zbgt.api.recipes.builders.PreciseAssemblerRecipeBuilder; import com.zorbatron.zbgt.api.recipes.helpers.RecipeIOMod; +import com.zorbatron.zbgt.api.recipes.maps.RecipeMapCoAL; +import com.zorbatron.zbgt.api.recipes.maps.RecipeMapPreciseAssembler; import gregtech.api.recipes.RecipeMap; public final class ZBGTRecipeMaps { - private ZBGTRecipeMaps() {} - public static final RecipeMap CoAL_RECIPES = new RecipeMapCoAL<>( "coal_recipes", new CoALRecipeBuilder()); + public static final RecipeMap PRECISE_ASSEMBLER_RECIPES = new RecipeMapPreciseAssembler<>( + "precise_assembler_recipes", + new PreciseAssemblerRecipeBuilder()); + public static void modifyMaps() { List recipeModList = new ArrayList<>(); recipeModList.add(new RecipeIOMod(POLARIZER_RECIPES, 0, 0, 1, 1)); diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/builders/PreciseAssemblerRecipeBuilder.java b/src/main/java/com/zorbatron/zbgt/api/recipes/builders/PreciseAssemblerRecipeBuilder.java new file mode 100644 index 00000000..03918909 --- /dev/null +++ b/src/main/java/com/zorbatron/zbgt/api/recipes/builders/PreciseAssemblerRecipeBuilder.java @@ -0,0 +1,64 @@ +package com.zorbatron.zbgt.api.recipes.builders; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.jetbrains.annotations.NotNull; + +import com.zorbatron.zbgt.api.recipes.properties.PreciseAssemblerProperty; +import com.zorbatron.zbgt.api.util.ZBGTLog; + +import gregtech.api.recipes.Recipe; +import gregtech.api.recipes.RecipeBuilder; +import gregtech.api.recipes.RecipeMap; +import gregtech.api.util.EnumValidationResult; + +public class PreciseAssemblerRecipeBuilder extends RecipeBuilder { + + public PreciseAssemblerRecipeBuilder() {} + + public PreciseAssemblerRecipeBuilder(Recipe recipe, RecipeMap recipeMap) { + super(recipe, recipeMap); + } + + public PreciseAssemblerRecipeBuilder(RecipeBuilder recipeBuilder) { + super(recipeBuilder); + } + + @Override + public PreciseAssemblerRecipeBuilder copy() { + return new PreciseAssemblerRecipeBuilder(this); + } + + @Override + public boolean applyProperty(@NotNull String key, Object value) { + if (key.equals(PreciseAssemblerProperty.KEY)) { + this.CasingTier(((Number) value).intValue()); + return true; + } + + return super.applyProperty(key, value); + } + + public PreciseAssemblerRecipeBuilder CasingTier(int tier) { + if (tier < 0) { + ZBGTLog.logger.error("Casing tier cannot be less than 0!", new IllegalArgumentException()); + this.recipeStatus = EnumValidationResult.INVALID; + } + + this.applyProperty(PreciseAssemblerProperty.getInstance(), tier); + + return this; + } + + public int getCasingTier() { + return this.recipePropertyStorage == null ? 0 : + this.recipePropertyStorage.getRecipePropertyValue(PreciseAssemblerProperty.getInstance(), 0); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append(super.toString()) + .append(PreciseAssemblerProperty.getInstance().getKey(), getCasingTier()) + .toString(); + } +} diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/RecipeMapCoAL.java b/src/main/java/com/zorbatron/zbgt/api/recipes/maps/RecipeMapCoAL.java similarity index 97% rename from src/main/java/com/zorbatron/zbgt/api/recipes/RecipeMapCoAL.java rename to src/main/java/com/zorbatron/zbgt/api/recipes/maps/RecipeMapCoAL.java index 024944bf..2bab5597 100644 --- a/src/main/java/com/zorbatron/zbgt/api/recipes/RecipeMapCoAL.java +++ b/src/main/java/com/zorbatron/zbgt/api/recipes/maps/RecipeMapCoAL.java @@ -1,4 +1,4 @@ -package com.zorbatron.zbgt.api.recipes; +package com.zorbatron.zbgt.api.recipes.maps; import net.minecraftforge.items.IItemHandlerModifiable; @@ -26,7 +26,7 @@ public RecipeMapCoAL(@NotNull String unlocalizedName, @NotNull R defaultRecipeBu public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 176) - .widget(new ProgressWidget(100, 62, 0, 72, 20, ZBGTTextures.PROGRESS_BAR_COMPONENT_AL, + .widget(new ProgressWidget(100, 62, 0, 72, 20, ZBGTTextures.PROGRESS_BAR_CoAL, ProgressWidget.MoveType.HORIZONTAL)); this.addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); this.addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/maps/RecipeMapPreciseAssembler.java b/src/main/java/com/zorbatron/zbgt/api/recipes/maps/RecipeMapPreciseAssembler.java new file mode 100644 index 00000000..c512831b --- /dev/null +++ b/src/main/java/com/zorbatron/zbgt/api/recipes/maps/RecipeMapPreciseAssembler.java @@ -0,0 +1,44 @@ +package com.zorbatron.zbgt.api.recipes.maps; + +import net.minecraftforge.items.IItemHandlerModifiable; + +import org.jetbrains.annotations.NotNull; + +import gregtech.api.capability.impl.FluidTankList; +import gregtech.api.gui.GuiTextures; +import gregtech.api.gui.ModularUI; +import gregtech.api.gui.widgets.ProgressWidget; +import gregtech.api.recipes.RecipeBuilder; +import gregtech.api.recipes.RecipeMap; +import gregtech.core.sound.GTSoundEvents; + +public class RecipeMapPreciseAssembler> extends RecipeMap { + + public RecipeMapPreciseAssembler(@NotNull String unlocalizedName, @NotNull R defaultRecipeBuilder) { + super(unlocalizedName, 4, 1, 4, 0, defaultRecipeBuilder, false); + setSound(GTSoundEvents.ASSEMBLER); + } + + @Override + public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, + FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { + ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 176) + .widget(new ProgressWidget(100, 85, 30, 20, 20, GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, + ProgressWidget.MoveType.HORIZONTAL)); + + // :clueless: + addSlot(builder, 8, 14, 0, importItems, importFluids, false, false); + addSlot(builder, 8 + 18, 14, 1, importItems, importFluids, false, false); + addSlot(builder, 8 + 18 * 2, 14, 2, importItems, importFluids, false, false); + addSlot(builder, 8 + 18 * 3, 14, 3, importItems, importFluids, false, false); + + addSlot(builder, 8, 11 + 20 + 18, 0, importItems, importFluids, true, false); + addSlot(builder, 8 + 18, 11 + 20 + 18, 1, importItems, importFluids, true, false); + addSlot(builder, 8 + 18 * 2, 11 + 20 + 18, 2, importItems, importFluids, true, false); + addSlot(builder, 8 + 18 * 3, 11 + 20 + 18, 3, importItems, importFluids, true, false); + + addSlot(builder, 85 + 18 + 12, 31, 0, exportItems, exportFluids, false, true); + + return builder; + } +} diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/properties/CoALProperty.java b/src/main/java/com/zorbatron/zbgt/api/recipes/properties/CoALProperty.java index 6f87aed6..b4db2b8f 100644 --- a/src/main/java/com/zorbatron/zbgt/api/recipes/properties/CoALProperty.java +++ b/src/main/java/com/zorbatron/zbgt/api/recipes/properties/CoALProperty.java @@ -48,7 +48,7 @@ public static void registerCasingTier(int tier, String shortName) { @Override public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) { - minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.coal_casing_tier", + minecraft.fontRenderer.drawString(I18n.format("zbgt.recipe.coal_casing_tier", TextFormattingUtil.formatLongToCompactString(castValue(value))) + getCasingTier(castValue(value)), x, y, color); } diff --git a/src/main/java/com/zorbatron/zbgt/api/recipes/properties/PreciseAssemblerProperty.java b/src/main/java/com/zorbatron/zbgt/api/recipes/properties/PreciseAssemblerProperty.java new file mode 100644 index 00000000..6235fa19 --- /dev/null +++ b/src/main/java/com/zorbatron/zbgt/api/recipes/properties/PreciseAssemblerProperty.java @@ -0,0 +1,33 @@ +package com.zorbatron.zbgt.api.recipes.properties; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; + +import com.zorbatron.zbgt.common.block.blocks.PreciseCasing; + +import gregtech.api.recipes.recipeproperties.RecipeProperty; + +public class PreciseAssemblerProperty extends RecipeProperty { + + public static final String KEY = "precise_casing_tier"; + + public static PreciseAssemblerProperty INSTANCE; + + protected PreciseAssemblerProperty() { + super(KEY, Integer.class); + } + + public static PreciseAssemblerProperty getInstance() { + if (INSTANCE == null) { + INSTANCE = new PreciseAssemblerProperty(); + } + + return INSTANCE; + } + + @Override + public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) { + minecraft.fontRenderer.drawString(I18n.format("zbgt.machine.precise_assembler.precise_casing.tier", + I18n.format(PreciseCasing.CasingType.getUntranslatedShortNameByTier(castValue(value)))), x, y, color); + } +} diff --git a/src/main/java/com/zorbatron/zbgt/api/render/ZBGTTextures.java b/src/main/java/com/zorbatron/zbgt/api/render/ZBGTTextures.java index d085cfd8..88177ce3 100644 --- a/src/main/java/com/zorbatron/zbgt/api/render/ZBGTTextures.java +++ b/src/main/java/com/zorbatron/zbgt/api/render/ZBGTTextures.java @@ -14,7 +14,7 @@ public class ZBGTTextures { public static TextureArea ITEM_FLUID_OVERLAY; public static TextureArea AUTO_PULL; - public static final TextureArea PROGRESS_BAR_COMPONENT_AL = TextureArea + public static final TextureArea PROGRESS_BAR_CoAL = TextureArea .fullImage("textures/gui/progress_bar/progress_bar_component_al.png"); // Multiblock controller overlays @@ -46,4 +46,14 @@ public static void preInit() { IRIDIUM_CASING = new SimpleOverlayRenderer("casings/multiblocks/iridium"); } + + public static SimpleOverlayRenderer getPrassTextureByTier(int tier) { + return switch (tier) { + case (1) -> PRECISE_CASING_1; + case (2) -> PRECISE_CASING_2; + case (3) -> PRECISE_CASING_3; + case (4) -> PRECISE_CASING_4; + default -> PRECISE_CASING_0; + }; + } } diff --git a/src/main/java/com/zorbatron/zbgt/common/block/blocks/CoALCasing.java b/src/main/java/com/zorbatron/zbgt/common/block/blocks/CoALCasing.java index a884e809..b8e051e1 100644 --- a/src/main/java/com/zorbatron/zbgt/common/block/blocks/CoALCasing.java +++ b/src/main/java/com/zorbatron/zbgt/common/block/blocks/CoALCasing.java @@ -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 { @@ -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"), @@ -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; diff --git a/src/main/java/com/zorbatron/zbgt/common/block/blocks/PreciseCasing.java b/src/main/java/com/zorbatron/zbgt/common/block/blocks/PreciseCasing.java index b95d2255..94ec005f 100644 --- a/src/main/java/com/zorbatron/zbgt/common/block/blocks/PreciseCasing.java +++ b/src/main/java/com/zorbatron/zbgt/common/block/blocks/PreciseCasing.java @@ -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 { @@ -32,11 +30,13 @@ 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"), PRECISE_CASING_2("precise_2"), - PRECISE_CASING_3("precise_3"); + PRECISE_CASING_3("precise_3"), + PRECISE_CASING_4("precise_4"); private final String name; @@ -50,17 +50,22 @@ public String getName() { return this.name; } - @Override - public int getTier() { - return this.ordinal(); - } - - public CasingType getCasingByTier(int tier) { + 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; - default -> PRECISE_CASING_1; + default -> PRECISE_CASING_4; }; } + + public static String getUntranslatedNameByTier(int tier) { + return "tile.multiblock_casing." + getCasingByTier(tier).getName() + ".name"; + } + + public static String getUntranslatedShortNameByTier(int tier) { + return "tile.multiblock_casing." + getCasingByTier(tier).getName() + ".name.short"; + } } } diff --git a/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/MetaTileEntityCoAL.java b/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/MetaTileEntityCoAL.java index 4ad1d771..0b3392d2 100644 --- a/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/MetaTileEntityCoAL.java +++ b/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/MetaTileEntityCoAL.java @@ -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; @@ -50,7 +49,7 @@ import gregtech.common.blocks.*; public class MetaTileEntityCoAL extends LaserCapableRecipeMapMultiblockController - implements ITier, IOpticalComputationReceiver { + implements IOpticalComputationReceiver { private IOpticalComputationProvider computationProvider; private int tier; @@ -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 providers = getAbilities(MultiblockAbility.COMPUTATION_DATA_RECEPTION); - if (providers != null && providers.size() >= 1) { + if (providers != null && !providers.isEmpty()) { computationProvider = providers.get(0); } @@ -213,7 +212,6 @@ public void invalidateStructure() { this.tier = 0; } - @Override public int getTier() { return this.tier; } @@ -274,8 +272,7 @@ public CoALRecipeLogic(MetaTileEntityCoAL metaTileEntity) { @Override public boolean checkRecipe(@NotNull Recipe recipe) { - if (!super.checkRecipe(recipe)) - return false; + if (!super.checkRecipe(recipe)) return false; return recipe.getProperty(CoALProperty.getInstance(), 0) <= tier; } diff --git a/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/megamultis/MetaTileEntityPreciseAssembler.java b/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/megamultis/MetaTileEntityPreciseAssembler.java index 8532fbb1..c8180589 100644 --- a/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/megamultis/MetaTileEntityPreciseAssembler.java +++ b/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/megamultis/MetaTileEntityPreciseAssembler.java @@ -1,47 +1,65 @@ package com.zorbatron.zbgt.common.metatileentities.multi.electric.megamultis; +import static com.zorbatron.zbgt.api.capability.ZBGTDataCodes.MULTIBLOCK_TIER_CHANGE_1; +import static com.zorbatron.zbgt.api.capability.ZBGTDataCodes.MULTIBLOCK_TIER_CHANGE_2; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + import net.minecraft.block.state.IBlockState; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Blocks; import net.minecraft.network.PacketBuffer; +import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.jetbrains.annotations.NotNull; -import com.zorbatron.zbgt.api.block.IPreciseTier; -import com.zorbatron.zbgt.api.capability.ZBGTDataCodes; -import com.zorbatron.zbgt.api.metatileentity.LaserCapableMultiShapeGCYMMultiblockController; +import com.zorbatron.zbgt.api.ZBGTAPI; +import com.zorbatron.zbgt.api.metatileentity.LaserCapableMultiMapMultiblockController; import com.zorbatron.zbgt.api.pattern.TraceabilityPredicates; -import com.zorbatron.zbgt.api.recipes.ITier; +import com.zorbatron.zbgt.api.recipes.ZBGTRecipeMaps; +import com.zorbatron.zbgt.api.recipes.properties.PreciseAssemblerProperty; import com.zorbatron.zbgt.api.render.ZBGTTextures; +import com.zorbatron.zbgt.common.ZBGTMetaTileEntities; +import com.zorbatron.zbgt.common.block.ZBGTMetaBlocks; +import com.zorbatron.zbgt.common.block.blocks.PreciseCasing; -import gregicality.multiblocks.api.capability.impl.GCYMMultiblockRecipeLogic; -import gregtech.api.capability.IDataAccessHatch; +import gregtech.api.GTValues; +import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; -import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.pattern.BlockPattern; -import gregtech.api.pattern.FactoryBlockPattern; -import gregtech.api.pattern.PatternMatchContext; -import gregtech.api.pattern.TraceabilityPredicate; +import gregtech.api.metatileentity.multiblock.MultiblockDisplayText; +import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; +import gregtech.api.pattern.*; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMaps; +import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage; import gregtech.api.unification.material.Materials; +import gregtech.api.util.GTUtility; +import gregtech.api.util.TextComponentUtil; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; import gregtech.common.blocks.BlockGlassCasing; +import gregtech.common.blocks.BlockMachineCasing; import gregtech.common.blocks.MetaBlocks; +import gregtech.common.metatileentities.MetaTileEntities; -public class MetaTileEntityPreciseAssembler extends LaserCapableMultiShapeGCYMMultiblockController implements ITier { +public class MetaTileEntityPreciseAssembler extends LaserCapableMultiMapMultiblockController { - private int tier; + private int preciseCasingTier = -1; + private int machineCasingTier = -1; public MetaTileEntityPreciseAssembler(ResourceLocation metaTileEntityId) { super(metaTileEntityId, new gregtech.api.recipes.RecipeMap[] { RecipeMaps.ASSEMBLER_RECIPES, - RecipeMaps.ASSEMBLY_LINE_RECIPES, - RecipeMaps.CIRCUIT_ASSEMBLER_RECIPES }); - this.recipeMapWorkable = new GCYMMultiblockRecipeLogic(this); + ZBGTRecipeMaps.PRECISE_ASSEMBLER_RECIPES }); + this.recipeMapWorkable = new PreciseAssemblerRecipeLogic(this); } @Override @@ -50,62 +68,116 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { } @Override - protected @NotNull BlockPattern getStructurePattern(int index) { + protected @NotNull BlockPattern createStructurePattern() { return FactoryBlockPattern.start() .aisle("XXXXXXXXX", "F#######F", "F#######F", "F#######F", "XXXXXXXXX") - .aisle("XXXXXXXXX", "XGGGGGGGX", "XGGGGGGGX", "XGGGGGGGX", "XXXXXXXXX") - .aisle("XXXXXXXXX", "X#######X", "X#######X", "X#######X", "XXXXXXXXX") - .aisle("XXXXXXXXX", "XGGGGGGGX", "XGGGGGGGX", "XGGGGGGGX", "XXXXXXXXX") + .aisle("XHHHHHHHX", "XGGGGGGGX", "XGGGGGGGX", "XGGGGGGGX", "XXXXXXXXX") + .aisle("XHHHHHHHX", "X#######X", "X#######X", "X#######X", "XXXXXXXXX") + .aisle("XHHHHHHHX", "XGGGGGGGX", "XGGGGGGGX", "XGGGGGGGX", "XXXXXXXXX") .aisle("XXXXSXXXX", "F#######F", "F#######F", "F#######F", "XXXXXXXXX") .where('S', selfPredicate()) - .where('X', getCasingState() - .or(autoAbilities()) - .or(dataHatchPredicate(index == 1))) - // .where('H', metaTileEntities(MetaTileEntities.HULL)) + .where('H', getMachineHull()) + .where('X', getCasing().or(autoAbilities())) .where('F', frames(Materials.TungstenSteel)) .where('G', states(getGlassState())) .where('#', air()) .build(); } - protected TraceabilityPredicate getCasingState() { - return TraceabilityPredicates.preciseCasings(); - } + @Override + public List getMatchingShapes() { + ArrayList shapeInfo = new ArrayList<>(); - protected IBlockState getGlassState() { - return MetaBlocks.TRANSPARENT_CASING.getState(BlockGlassCasing.CasingType.TEMPERED_GLASS); - } + MultiblockShapeInfo.Builder builder = MultiblockShapeInfo.builder() + .aisle("XXXXXXXXX", "F#######F", "F#######F", "F#######F", "XXXXXXXXX") + .aisle("XHHHHHHHX", "XGGGGGGGX", "XGGGGGGGX", "XGGGGGGGX", "XXXXXXXXX") + .aisle("XHHHHHHHX", "X#######X", "X#######X", "X#######X", "XXXXXXXXX") + .aisle("XHHHHHHHX", "XGGGGGGGX", "XGGGGGGGX", "XGGGGGGGX", "XXXXXXXXX") + .aisle("XXXESMXXX", "F#######F", "F#######F", "F#######F", "XXXXXXXXX") + .where('S', ZBGTMetaTileEntities.PRASS, EnumFacing.SOUTH) + .where('G', MetaBlocks.TRANSPARENT_CASING.getState(BlockGlassCasing.CasingType.TEMPERED_GLASS)) + .where('F', MetaBlocks.FRAMES.get(Materials.TungstenSteel).getBlock(Materials.TungstenSteel)) + .where('E', MetaTileEntities.ENERGY_INPUT_HATCH[GTValues.LV], EnumFacing.SOUTH) + .where('M', MetaTileEntities.MAINTENANCE_HATCH, EnumFacing.SOUTH) + .where('#', Blocks.AIR.getDefaultState()); - protected TraceabilityPredicate dataHatchPredicate(boolean isAssemblyLine) { - // If set to assembly line, require a data hatch - if (isAssemblyLine) { - return abilities(MultiblockAbility.DATA_ACCESS_HATCH, MultiblockAbility.OPTICAL_DATA_RECEPTION) - .setExactLimit(1); - } + ZBGTAPI.MACHINE_CASINGS.entrySet().stream() + .sorted(Comparator.comparingInt(entry -> entry.getValue().ordinal())) + .forEach(entry -> shapeInfo.add(builder + .where('H', entry.getKey()) + .where('X', + ZBGTMetaBlocks.PRECISE_CASING.getState( + PreciseCasing.CasingType.getCasingByTier(entry.getValue().ordinal()))) + .build())); - return getCasingState(); + return shapeInfo; } @Override - public boolean checkRecipe(@NotNull Recipe recipe, boolean consumeIfSuccess) { - if (getRecipeMapIndex() == 1) { - return isRecipeAvailable(getAbilities(MultiblockAbility.DATA_ACCESS_HATCH), recipe) || - isRecipeAvailable(getAbilities(MultiblockAbility.OPTICAL_DATA_RECEPTION), recipe); - } else { - return true; - } + protected void addDisplayText(List textList) { + MultiblockDisplayText.builder(textList, isStructureFormed()) + .setWorkingStatus(recipeMapWorkable.isWorkingEnabled(), recipeMapWorkable.isActive()) + .addEnergyUsageLine(getEnergyContainer()) + .addEnergyTierLine(GTUtility.getTierByVoltage(recipeMapWorkable.getMaxVoltage())) + .addParallelsLine(recipeMapWorkable.getParallelLimit()) + .addCustom(tl -> { + if (isStructureFormed()) { + int preciseCasingTier = getPreciseCasingTier(); + ITextComponent preciseCasingText; + + if (preciseCasingTier == -1) { + preciseCasingText = TextComponentUtil.translationWithColor( + TextFormatting.GRAY, + "zbgt.machine.precise_assembler.precise_casing.tier.error"); + } else { + preciseCasingText = TextComponentUtil.translationWithColor( + TextFormatting.GRAY, + "zbgt.machine.precise_assembler.precise_casing.tier", + I18n.format(PreciseCasing.CasingType + .getUntranslatedShortNameByTier(preciseCasingTier))); + } + + ITextComponent preciseCasingHoverText = TextComponentUtil.translationWithColor( + TextFormatting.GRAY, + "zbgt.machine.precise_assembler.precise_casing.tier.hover"); + + tl.add(TextComponentUtil.setHover(preciseCasingText, preciseCasingHoverText)); + + int machineCasingTier = getMachineCasingTier(); + ITextComponent machineCasingText; + + if (machineCasingTier == -1) { + machineCasingText = TextComponentUtil.translationWithColor( + TextFormatting.GRAY, + "zbgt.machine.precise_assembler.machine_casing.tier.error"); + } else { + machineCasingText = TextComponentUtil.translationWithColor( + TextFormatting.GRAY, + "zbgt.machine.precise_assembler.machine_casing.tier", + GTValues.VNF[machineCasingTier]); + } + + ITextComponent machineCasingHoverText = TextComponentUtil.translationWithColor( + TextFormatting.GRAY, + "zbgt.machine.precise_assembler.machine_casing.tier.hover"); + + tl.add(TextComponentUtil.setHover(machineCasingText, machineCasingHoverText)); + } + }) + .addWorkingStatusLine() + .addProgressLine(recipeMapWorkable.getProgressPercent()); + } + + protected TraceabilityPredicate getCasing() { + return TraceabilityPredicates.preciseCasings(); } - private static boolean isRecipeAvailable(@NotNull Iterable hatches, - @NotNull Recipe recipe) { - for (IDataAccessHatch hatch : hatches) { - // creative hatches do not need to check, they always have the recipe - if (hatch.isCreative()) return true; + protected TraceabilityPredicate getMachineHull() { + return TraceabilityPredicates.machineCasings(); + } - // hatches need to have the recipe available - if (hatch.isRecipeAvailable(recipe)) return true; - } - return false; + protected IBlockState getGlassState() { + return MetaBlocks.TRANSPARENT_CASING.getState(BlockGlassCasing.CasingType.TEMPERED_GLASS); } @SideOnly(Side.CLIENT) @@ -117,11 +189,8 @@ protected ICubeRenderer getFrontOverlay() { @Override public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { - return switch (getTier()) { - case (2) -> ZBGTTextures.PRECISE_CASING_2; - case (3) -> ZBGTTextures.PRECISE_CASING_3; - default -> ZBGTTextures.PRECISE_CASING_1; - }; + return getPreciseCasingTier() == -1 ? ZBGTTextures.PRECISE_CASING_1 : + ZBGTTextures.getPrassTextureByTier(getPreciseCasingTier()); } @Override @@ -132,44 +201,102 @@ public boolean canBeDistinct() { @Override protected void formStructure(PatternMatchContext context) { super.formStructure(context); - Object type = context.get("PreciseTier"); - if (type instanceof IPreciseTier preciseTier) { - this.tier = preciseTier.getTier() + 1; + + Object preciseType = context.get("PreciseTier"); + if (preciseType instanceof PreciseCasing.CasingType preciseCasingType) { + this.preciseCasingTier = preciseCasingType.ordinal(); } else { - this.tier = 0; + this.preciseCasingTier = -1; } - writeCustomData(ZBGTDataCodes.MULTIBLOCK_TIER_CHANGE, packetBuffer -> packetBuffer.writeInt(this.tier)); + Object hullType = context.get("MachineCasingTier"); + if (hullType instanceof BlockMachineCasing.MachineCasingType machineCasingType) { + this.machineCasingTier = machineCasingType.ordinal(); + } + + writeCustomData(MULTIBLOCK_TIER_CHANGE_1, buf -> buf.writeInt(this.preciseCasingTier)); + writeCustomData(MULTIBLOCK_TIER_CHANGE_2, buf -> buf.writeInt(this.machineCasingTier)); } @Override public void invalidateStructure() { super.invalidateStructure(); - this.tier = 0; + this.preciseCasingTier = -1; + this.machineCasingTier = -1; } - @Override - public int getTier() { - return this.tier; + public int getPreciseCasingTier() { + return this.preciseCasingTier; + } + + public int getMachineCasingTier() { + return this.machineCasingTier; } @Override public void receiveCustomData(int dataId, PacketBuffer buf) { super.receiveCustomData(dataId, buf); - if (dataId == ZBGTDataCodes.MULTIBLOCK_TIER_CHANGE) { - this.tier = buf.readInt(); + if (dataId == MULTIBLOCK_TIER_CHANGE_1) { + this.preciseCasingTier = buf.readInt(); + } else if (dataId == MULTIBLOCK_TIER_CHANGE_2) { + this.machineCasingTier = buf.readInt(); } } @Override public void writeInitialSyncData(PacketBuffer buf) { super.writeInitialSyncData(buf); - buf.writeInt(this.tier); + buf.writeInt(this.preciseCasingTier); + buf.writeInt(this.machineCasingTier); } @Override public void receiveInitialSyncData(PacketBuffer buf) { super.receiveInitialSyncData(buf); - this.tier = buf.readInt(); + this.preciseCasingTier = buf.readInt(); + this.machineCasingTier = buf.readInt(); + } + + @Override + public boolean checkRecipe(@NotNull Recipe recipe, boolean consumeIfSuccess) { + int supposedRecipeMap = recipe.getRecipeCategory().getRecipeMap() == RecipeMaps.ASSEMBLER_RECIPES ? 0 : 1; + return getRecipeMapIndex() == supposedRecipeMap; + } + + protected class PreciseAssemblerRecipeLogic extends MultiblockRecipeLogic { + + public PreciseAssemblerRecipeLogic(RecipeMapMultiblockController tileEntity) { + super(tileEntity); + } + + @Override + protected void modifyOverclockPre(int @NotNull [] values, @NotNull IRecipePropertyStorage storage) { + if (getRecipeMapIndex() == 0) { + values[1] = (int) (values[1] * 0.5); + } + + super.modifyOverclockPre(values, storage); + } + + @Override + public int getParallelLimit() { + return (int) (16 * Math.pow(2, getPreciseCasingTier())); + } + + @Override + public boolean checkRecipe(@NotNull Recipe recipe) { + if (!super.checkRecipe(recipe)) return false; + + boolean meetsPreciseTier = recipe.getProperty(PreciseAssemblerProperty.getInstance(), 0) <= + getPreciseCasingTier(); + boolean meetsCasingTier = Math.min(GTUtility.getTierByVoltage(recipe.getEUt()), GTValues.UHV) <= + getMachineCasingTier(); + + if (getRecipeMapIndex() == 1) { + return meetsCasingTier && meetsPreciseTier; + } else { + return meetsCasingTier; + } + } } } diff --git a/src/main/java/com/zorbatron/zbgt/recipe/MiscRecipes.java b/src/main/java/com/zorbatron/zbgt/recipe/MiscRecipes.java index b1d24023..ebe19fbf 100644 --- a/src/main/java/com/zorbatron/zbgt/recipe/MiscRecipes.java +++ b/src/main/java/com/zorbatron/zbgt/recipe/MiscRecipes.java @@ -46,6 +46,7 @@ private static void sillyRecipes() { COMPRESSOR_RECIPES.recipeBuilder() .fluidInputs(Water.getFluid(Integer.MAX_VALUE)) .fluidOutputs(Neutronium.getFluid(1)) + .circuitMeta(1) .EUt(Integer.MAX_VALUE).duration(Integer.MAX_VALUE) .buildAndRegister(); } diff --git a/src/main/java/com/zorbatron/zbgt/recipe/ZBGTRecipes.java b/src/main/java/com/zorbatron/zbgt/recipe/ZBGTRecipes.java index fa996b1f..5260c485 100644 --- a/src/main/java/com/zorbatron/zbgt/recipe/ZBGTRecipes.java +++ b/src/main/java/com/zorbatron/zbgt/recipe/ZBGTRecipes.java @@ -1,5 +1,12 @@ package com.zorbatron.zbgt.recipe; +import net.minecraft.init.Blocks; + +import com.zorbatron.zbgt.api.recipes.ZBGTRecipeMaps; +import com.zorbatron.zbgt.common.block.blocks.PreciseCasing; + +import gregtech.api.GTValues; +import gregtech.api.unification.material.Materials; import gregtech.api.util.Mods; public class ZBGTRecipes { @@ -15,5 +22,13 @@ public static void init() { if (Mods.AppliedEnergistics2.isModLoaded()) { AE2Recipes.init(); } + + ZBGTRecipeMaps.PRECISE_ASSEMBLER_RECIPES.recipeBuilder() + .input(Blocks.DIRT, 64) + .fluidInputs(Materials.Water.getFluid(GTValues.L)) + .output(Blocks.DIAMOND_BLOCK) + .CasingTier(PreciseCasing.CasingType.PRECISE_CASING_1.ordinal()) + .EUt(GTValues.VA[GTValues.MV]).duration(20) + .buildAndRegister(); } } diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/3.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/ev.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/3.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/ev.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/2.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/hv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/2.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/hv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/4.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/iv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/4.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/iv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/5.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/luv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/5.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/luv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/0.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/lv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/0.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/lv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/13.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/max.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/13.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/max.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/1.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/mv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/1.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/mv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/12.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/opv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/12.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/opv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/9.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/uev.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/9.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/uev.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/8.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/uhv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/8.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/uhv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/10.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/uiv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/10.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/uiv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/ulv.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/ulv.png new file mode 100644 index 00000000..24ca2d49 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/ulv.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/7.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/uv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/7.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/uv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/11.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/uxv.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/11.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/uxv.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/casings/coal/6.png b/src/main/resources/assets/gregtech/textures/blocks/casings/coal/zpm.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/casings/coal/6.png rename to src/main/resources/assets/gregtech/textures/blocks/casings/coal/zpm.png diff --git a/src/main/resources/assets/zbgt/blockstates/coal_casing.json b/src/main/resources/assets/zbgt/blockstates/coal_casing.json index ff30efce..1d1f7688 100644 --- a/src/main/resources/assets/zbgt/blockstates/coal_casing.json +++ b/src/main/resources/assets/zbgt/blockstates/coal_casing.json @@ -8,74 +8,79 @@ }, "variants": { "variant": { + "ulv": { + "textures": { + "all": "gregtech:blocks/casings/coal/ulv" + } + }, "lv": { "textures": { - "all": "gregtech:blocks/casings/coal/0" + "all": "gregtech:blocks/casings/coal/lv" } }, "mv": { "textures": { - "all": "gregtech:blocks/casings/coal/1" + "all": "gregtech:blocks/casings/coal/mv" } }, "hv": { "textures": { - "all": "gregtech:blocks/casings/coal/2" + "all": "gregtech:blocks/casings/coal/hv" } }, "ev": { "textures": { - "all": "gregtech:blocks/casings/coal/3" + "all": "gregtech:blocks/casings/coal/ev" } }, "iv": { "textures": { - "all": "gregtech:blocks/casings/coal/4" + "all": "gregtech:blocks/casings/coal/iv" } }, "luv": { "textures": { - "all": "gregtech:blocks/casings/coal/5" + "all": "gregtech:blocks/casings/coal/luv" } }, "zpm": { "textures": { - "all": "gregtech:blocks/casings/coal/6" + "all": "gregtech:blocks/casings/coal/zpm" } }, "uv": { "textures": { - "all": "gregtech:blocks/casings/coal/7" + "all": "gregtech:blocks/casings/coal/uv" } }, "uhv": { "textures": { - "all": "gregtech:blocks/casings/coal/8" + "all": "gregtech:blocks/casings/coal/uhv" } }, "uev": { "textures": { - "all": "gregtech:blocks/casings/coal/9" + "all": "gregtech:blocks/casings/coal/uev" } }, "uiv": { "textures": { - "all": "gregtech:blocks/casings/coal/10" + "all": "gregtech:blocks/casings/coal/uiv" } }, "uxv": { "textures": { - "all": "gregtech:blocks/casings/coal/11" + "all": "gregtech:blocks/casings/coal/uxv" } }, "opv": { "textures": { - "all": "gregtech:blocks/casings/coal/12" + "all": "gregtech:blocks/casings/coal/opv" } }, "max": { "textures": { - "all": "gregtech:blocks/casings/coal/13" + "all": "gregtech:blocks/casings/coal/max" } } } diff --git a/src/main/resources/assets/zbgt/blockstates/precise_casing.json b/src/main/resources/assets/zbgt/blockstates/precise_casing.json index f8961428..2cdc494e 100644 --- a/src/main/resources/assets/zbgt/blockstates/precise_casing.json +++ b/src/main/resources/assets/zbgt/blockstates/precise_casing.json @@ -8,6 +8,11 @@ }, "variants": { "variant": { + "precise_0": { + "textures": { + "all": "gregtech:blocks/casings/multiblocks/precise_0" + } + }, "precise_1": { "textures": { "all": "gregtech:blocks/casings/multiblocks/precise_1" @@ -22,6 +27,11 @@ "textures": { "all": "gregtech:blocks/casings/multiblocks/precise_3" } + }, + "precise_4": { + "textures": { + "all": "gregtech:blocks/casings/multiblocks/precise_4" + } } } } diff --git a/src/main/resources/assets/zbgt/lang/en_us.lang b/src/main/resources/assets/zbgt/lang/en_us.lang index 39151969..b16d58f5 100644 --- a/src/main/resources/assets/zbgt/lang/en_us.lang +++ b/src/main/resources/assets/zbgt/lang/en_us.lang @@ -116,7 +116,11 @@ zbgt.machine.mega_abs.name=Mega Alloy Blast Smelter (mABS) zbgt.machine.mega_abs.tooltip=Mix and melt everything! zbgt.machine.precise_assembler.name=Precise Assembler (PRASS) -zbgt.machine.precise_assembler.tooltip=Very balanced multiblock ;) +zbgt.machine.precise_assembler.precise_casing.tier=Casing tier: %s +zbgt.machine.precise_assembler.precise_casing.tier.hover=Highest precise tier recipe that can be run +zbgt.machine.precise_assembler.machine_casing.tier=Machine casing tier: %s +zbgt.machine.precise_assembler.machine_casing.tier.hover=Recipes are limited to this voltage, regardless of the energy hatch +recipemap.precise_assembler_recipes.name=Precise Assembler zbgt.machine.quad_ebf.name=Quad EBF (qEBF) zbgt.machine.quad_ebf.tooltip=The same shape as a quad EBF, and thus has 4 innate parallels! @@ -128,16 +132,25 @@ zbgt.machine.coal.max_recipe_tier=Max Component Tier: %s zbgt.machine.coal.max_recipe_tier.hover=The highest component tier that can be assembled zbgt.machine.coal.computation_tier=Max Computation Available: %s zbgt.machine.coal.computation_tier.hover=Maximum amount of computation available for recipes -gregtech.recipe.coal_casing_tier=Casing Tier: +zbgt.recipe.coal_casing_tier=Casing Tier: recipemap.coal_recipes.name=Component Assembly Line # Multiblock Casings +tile.multiblock_casing.precise_0.name=Imprecise Electronic Unit Casing tile.multiblock_casing.precise_1.name=Precise Electronic Unit Casing MK-I tile.multiblock_casing.precise_2.name=Precise Electronic Unit Casing MK-II tile.multiblock_casing.precise_3.name=Precise Electronic Unit Casing MK-III +tile.multiblock_casing.precise_4.name=Precise Electronic Unit Casing MK-IV +tile.multiblock_casing.precise_0.name.short=Imprecise +tile.multiblock_casing.precise_1.name.short=MK-I +tile.multiblock_casing.precise_2.name.short=MK-II +tile.multiblock_casing.precise_3.name.short=MK-III +tile.multiblock_casing.precise_4.name.short=MK-IV + tile.multiblock_casing.iridium.name=Advanced Iridium Plated Machine Casing +tile.coal_casing.ulv.name=Component Assembly Line Casing (ULV) tile.coal_casing.lv.name=Component Assembly Line Casing (LV) tile.coal_casing.mv.name=Component Assembly Line Casing (MV) tile.coal_casing.hv.name=Component Assembly Line Casing (HV) @@ -153,6 +166,7 @@ tile.coal_casing.uxv.name=Component Assembly Line Casing (UXV) tile.coal_casing.opv.name=Component Assembly Line Casing (OpV) tile.coal_casing.max.name=Component Assembly Line Casing (MAX) +zbgt.multiblock.pattern.error.casings=§cAll casings must be the same tier§r # Random zbgt.laser_enabled.1=Can use