From 250a74a513bce89c2d489e2d40ac4ee843bb726f Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:25:50 -0400 Subject: [PATCH] added progress sensor --- .../cover/redstone/CoverProgressSensor.java | 49 ++++++++++++++++++ .../gregtech/data/GregTechCovers.java | 4 ++ .../gregtech/data/GregTechMaterialEvents.java | 2 +- .../gregtech/loader/crafting/Parts.java | 4 +- .../textures/block/cover/progress_sensor.png | Bin 0 -> 303 bytes .../textures/item/basic/progress_sensor.png | Bin 0 -> 4434 bytes 6 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/muramasa/gregtech/cover/redstone/CoverProgressSensor.java create mode 100644 common/src/main/resources/assets/gti/textures/block/cover/progress_sensor.png create mode 100644 common/src/main/resources/assets/gti/textures/item/basic/progress_sensor.png diff --git a/common/src/main/java/muramasa/gregtech/cover/redstone/CoverProgressSensor.java b/common/src/main/java/muramasa/gregtech/cover/redstone/CoverProgressSensor.java new file mode 100644 index 000000000..74351f6c8 --- /dev/null +++ b/common/src/main/java/muramasa/gregtech/cover/redstone/CoverProgressSensor.java @@ -0,0 +1,49 @@ +package muramasa.gregtech.cover.redstone; + +import earth.terrarium.botarium.common.fluid.base.FluidContainer; +import earth.terrarium.botarium.common.fluid.base.FluidHolder; +import muramasa.antimatter.blockentity.BlockEntityMachine; +import muramasa.antimatter.blockentity.pipe.BlockEntityFluidPipe; +import muramasa.antimatter.capability.ICoverHandler; +import muramasa.antimatter.capability.machine.MachineRecipeHandler; +import muramasa.antimatter.cover.CoverFactory; +import muramasa.antimatter.machine.Tier; +import muramasa.gregtech.cover.base.CoverBasicRedstoneOutput; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.stream.IntStream; + +public class CoverProgressSensor extends CoverBasicRedstoneOutput { + public CoverProgressSensor(@NotNull ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { + super(source, tier, side, factory); + } + + @Override + public boolean canPlace() { + return handler.getTile() instanceof BlockEntityMachine machine && machine.recipeHandler.side(side).isPresent(); + } + + @Override + public ResourceLocation getModel(String type, Direction dir) { + if (type.equals("pipe")) return PIPE_COVER_MODEL; + return getBasicModel(); + } + + @Override + public void onUpdate() { + if (handler.getTile().getLevel() == null || handler.getTile().getLevel().isClientSide) return; + MachineRecipeHandler recipeHandler = handler.getTile() instanceof BlockEntityMachine machine ? machine.recipeHandler.side(side).orElse(null) : null; + if (recipeHandler != null){ + long scale = recipeHandler.getMaxProgress() > 0 ? recipeHandler.getMaxProgress() / 15L : 0; + long currentProgress = recipeHandler.getCurrentProgress(); + if (scale > 0){ + setOutputRedstone(inverted ? (int) (15L - currentProgress / scale) : (int) (currentProgress / scale)); + } else { + setOutputRedstone(inverted ? 15 : 0); + } + } + } +} diff --git a/common/src/main/java/muramasa/gregtech/data/GregTechCovers.java b/common/src/main/java/muramasa/gregtech/data/GregTechCovers.java index c529b4e64..2a6c4f849 100644 --- a/common/src/main/java/muramasa/gregtech/data/GregTechCovers.java +++ b/common/src/main/java/muramasa/gregtech/data/GregTechCovers.java @@ -10,6 +10,7 @@ import muramasa.gregtech.GTIRef; import muramasa.gregtech.cover.*; import muramasa.gregtech.cover.redstone.CoverNeedsMaintenance; +import muramasa.gregtech.cover.redstone.CoverProgressSensor; import muramasa.gregtech.cover.redstone.CoverRedstoneMachineController; import muramasa.gregtech.items.ItemCoverCustomTooltip; import net.minecraft.nbt.CompoundTag; @@ -83,6 +84,9 @@ public class GregTechCovers { public static final CoverFactory COVER_NEEDS_MAINTENANCE_COVER = CoverFactory.builder(CoverNeedsMaintenance::new).item((a, b) -> { return new ItemCover(GTIRef.ID, "needs_maintenance_cover"); }).addTextures(new Texture(GTIRef.ID, "block/cover/needs_maintenance_cover")).build(GTIRef.ID, "needs_maintenance_cover"); + public static final CoverFactory COVER_PROGRESS_SENSOR = CoverFactory.builder(CoverProgressSensor::new).item((a, b) -> { + return new ItemCover(GTIRef.ID, "progress_sensor"); + }).addTextures(new Texture(GTIRef.ID, "block/cover/progress_sensor")).build(GTIRef.ID, "progress_sensor"); public static final CoverFactory COVER_ENERGY_DETECTOR = CoverFactory.builder(CoverEnergyDetector::new).item((a, b) -> { return new ItemCover(GTIRef.ID, "energy_detector"); }).addTextures(new Texture(GTIRef.ID, "block/cover/energy_detector")).build(GTIRef.ID, "energy_detector"); diff --git a/common/src/main/java/muramasa/gregtech/data/GregTechMaterialEvents.java b/common/src/main/java/muramasa/gregtech/data/GregTechMaterialEvents.java index 6b756109e..b58aa81e2 100644 --- a/common/src/main/java/muramasa/gregtech/data/GregTechMaterialEvents.java +++ b/common/src/main/java/muramasa/gregtech/data/GregTechMaterialEvents.java @@ -134,7 +134,7 @@ public static void onMaterialEvent(GregTechMaterialEvent event){ event.setMaterial(BlackBronze).asMetal(2000, FRAME); event.setMaterial(BlackSteel).asMetal(1200, 1200, FRAME, PLATE).forceBF(false); event.setMaterial(BlueSteel).asMetal(1400, 1400, FRAME).forceBF(false); - event.setMaterial(Brass).asMetal(1170, FRAME, ROD_LONG, PLATE); + event.setMaterial(Brass).asMetal(1170, FRAME, ROD_LONG, PLATE, GEAR_SMALL); event.setMaterial(Bronze).asMetal(1125, GEAR, FRAME, ROTOR); event.setMaterial(CdInAGAlloy).asMetal(752, ROD); event.setMaterial(CobaltBrass).asMetal(1500, GEAR); diff --git a/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java b/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java index dc6e49e8b..08aa4e0c5 100644 --- a/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java +++ b/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java @@ -32,8 +32,7 @@ import static com.google.common.collect.ImmutableMap.of; import static io.github.gregtechintergalactical.gtcore.data.GTCoreItems.*; -import static io.github.gregtechintergalactical.gtcore.data.GTCoreTags.CIRCUITS_ADVANCED; -import static io.github.gregtechintergalactical.gtcore.data.GTCoreTags.PLATES_IRON_ALUMINIUM; +import static io.github.gregtechintergalactical.gtcore.data.GTCoreTags.*; import static muramasa.antimatter.data.AntimatterMaterials.*; import static muramasa.antimatter.data.AntimatterMaterialTypes.*; import static muramasa.antimatter.data.AntimatterDefaultTools.*; @@ -91,6 +90,7 @@ public static void loadRecipes(Consumer output, AntimatterRecipe provider.shapeless(output, GTIRef.ID, "data_stick_clearing", "data_sticks", new ItemStack(GregTechItems.DataStick), GregTechItems.DataStick); provider.shapeless(output, GTIRef.ID, "fluid_filter_reset", "filters", GregTechCovers.COVER_FLUID_FILTER.getItem(), GregTechCovers.COVER_FLUID_FILTER.getItem().getItem()); provider.shapeless(output, GTIRef.ID, "item_filter_reset", "filters", GregTechCovers.COVER_ITEM_FILTER.getItem(), GregTechCovers.COVER_ITEM_FILTER.getItem().getItem()); + provider.addItemRecipe(output, "covers", GregTechCovers.COVER_PROGRESS_SENSOR.getItem().getItem(), of('W', CABLE_GETTER.apply(PipeSize.VTINY, LV, false), 'A', PLATE.getMaterialTag(Aluminium), 'G', GEAR_SMALL.getMaterialTag(Brass), 'C', CIRCUITS_GOOD), "WAW", "GCG"); provider.addItemRecipe(output, "misc", DiamondGrindHead, of('D', DUST.getMaterialTag(Diamond), 'G', GEM.getMaterialTag(Diamond), 'S', PLATE.getMaterialTag(Steel)), "DSD", "SGS", "DSD"); provider.addItemRecipe(output, "misc", TungstenGrindHead, of('D', PLATE.getMaterialTag(Tungsten), 'G', GEM.getMaterialTag(Diamond), 'S', PLATE.getMaterialTag(Steel)), "DSD", "SGS", "DSD"); provider.addItemRecipe(output, "hazmat", UniversalHazardSuitMask, of('L', PLATE.getMaterialTag(Lead), 'A', PLATE.getMaterialTag(Aluminium), 'C', Items.CHAINMAIL_HELMET, 'G', Items.GLASS_PANE), "ALA", "LCL", "AGA"); diff --git a/common/src/main/resources/assets/gti/textures/block/cover/progress_sensor.png b/common/src/main/resources/assets/gti/textures/block/cover/progress_sensor.png new file mode 100644 index 0000000000000000000000000000000000000000..72e8b2d9b762073bc243647171498cdbc30062e2 GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GGLLkg|>2BR0pdfpR zr>`sf11@HMWefSFzV$#Mwj^(N7l!{JxM1({$v}}ko-U3d7QM+kD*tmb@2q&(X3LXs zY@u_zgxHz*0|C*|rwf!PFzPt+7- szi{Eh{;sZ5^@fIqZ}b`rPaI|7`?hYwDqAIapg$NqUHx3vIVCg!0LFH5DF6Tf literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/gti/textures/item/basic/progress_sensor.png b/common/src/main/resources/assets/gti/textures/item/basic/progress_sensor.png new file mode 100644 index 0000000000000000000000000000000000000000..6f5da33f498280d07abd6e9fde518ffcd57007bd GIT binary patch literal 4434 zcmeHKe^3l)EHfkn1)YQgIOB<6(VrDd^isCe>L2WW^n0A^*V`^lk30TO4S_u8_-tlXi znGQ3}e=PHOZ@=&J{k-q{yzl$Mc6dGOGc$5CFbvCdRXVGo&(d1@0{ERbG|of!2UO<@ zxLk!;I=leVFds8$7-)uR<9UV@ECp=4pe=^6hS6HCAyx06hVhEz_#li|B{7;0ZJ38; zLf;9Ef$>u4e+^CAomlHEjI}3S|LI5t6ueFJ>s@Xy&X{P*WM*N8Vk{iRaukg-G)GY! zL&N%ppHD@kF{wMl&_O2E@&%8f) z;*}rGAKAYA)8CE`jMb0*@VtM`ng={o&&dwklR;}}$56@EgNM+ekhp$6 zDzgAlV`oF=M4mh-L1aCWw*XJ6y5UtjbXz()f@X)T)UQ){oO|fnx1dj zeMb5Bm!1dDkxH|!&nDdR4zvmZZTO*6j2eAni*qB23{N$16;LpU6KOc9L5G!jc_E{ z($ZpTF`MLQkfiN)J4rDl!w`TVl-97y$B3|!uTdm8oJbL(Qbd*HFs^a(ez{3?7>zKG zPsA6BxZRWVVI`>o=t0K#2uYhLG87`Gdnjr}Gms<$`dSaAwl#vtYNW_bQ2|vnq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