Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
added progress sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 2, 2024
1 parent 32d14d2 commit 250a74a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -91,6 +90,7 @@ public static void loadRecipes(Consumer<FinishedRecipe> 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");
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 250a74a

Please sign in to comment.