Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CleaningMaintenanceHatch #2307

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1030,17 +1030,16 @@ public static BiConsumer<ItemStack, List<Component>> createTankTooltips(String n
.register();

public static final MachineDefinition CLEANING_MAINTENANCE_HATCH = REGISTRATE
.machine("cleaning_maintenance_hatch", CleaningMaintenanceHatchPartMachine::new)
.machine("cleaning_maintenance_hatch",
holder -> new CleaningMaintenanceHatchPartMachine(holder, CleanroomType.CLEANROOM))
.rotationState(RotationState.ALL)
.abilities(PartAbility.MAINTENANCE)
.tooltips(Component.translatable("gtceu.universal.disabled"),
Component.translatable("gtceu.machine.maintenance_hatch_cleanroom_auto.tooltip.0"),
Component.translatable("gtceu.machine.maintenance_hatch_cleanroom_auto.tooltip.1"))
.tooltipBuilder((stack, tooltips) -> {
for (CleanroomType type : CleaningMaintenanceHatchPartMachine.getCleanroomTypes()) {
tooltips.add(Component.literal(String.format(" %s%s", ChatFormatting.GREEN,
Component.translatable(type.getTranslationKey()).getString())));
}
tooltips.add(Component.literal(" ").append(Component
.translatable(CleanroomType.CLEANROOM.getTranslationKey()).withStyle(ChatFormatting.GREEN)));
})
.renderer(() -> new MaintenanceHatchPartRenderer(3, GTCEu.id("block/machine/part/maintenance.cleaning")))
.compassNodeSelf()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.gregtechceu.gtceu.common.machine.multiblock.part;

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.capability.ICleanroomReceiver;
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
import com.gregtechceu.gtceu.api.machine.feature.ICleanroomProvider;
Expand All @@ -10,29 +9,29 @@

import net.minecraft.MethodsReturnNonnullByDefault;

import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.NotNull;
import lombok.Getter;

import java.util.Set;
import java.util.Collections;

import javax.annotation.ParametersAreNonnullByDefault;

import static com.gregtechceu.gtceu.api.GTValues.UHV;
import static com.gregtechceu.gtceu.api.GTValues.UV;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class CleaningMaintenanceHatchPartMachine extends AutoMaintenanceHatchPartMachine {

protected static final Set<CleanroomType> CLEANED_TYPES = new ObjectOpenHashSet<>();

static {
CLEANED_TYPES.add(CleanroomType.CLEANROOM);
}

// must come after the static block
private static final ICleanroomProvider DUMMY_CLEANROOM = DummyCleanroom.createForTypes(CLEANED_TYPES);
private final ICleanroomProvider DUMMY_CLEANROOM;

@Getter
private final CleanroomType cleanroomType;

public CleaningMaintenanceHatchPartMachine(IMachineBlockEntity metaTileEntityId) {
public CleaningMaintenanceHatchPartMachine(IMachineBlockEntity metaTileEntityId, CleanroomType cleanroomType) {
super(metaTileEntityId);
this.cleanroomType = cleanroomType;
DUMMY_CLEANROOM = DummyCleanroom.createForTypes(Collections.singletonList(cleanroomType));
}

@Override
Expand All @@ -53,24 +52,6 @@ public void removedFromController(IMultiController controller) {

@Override
public int getTier() {
return GTValues.UV;
}

/**
* Add an {@link CleanroomType} that is provided to multiblocks with this hatch
*
* @param type the type to add
*/
@SuppressWarnings("unused")
public static void addCleanroomType(@NotNull CleanroomType type) {
CLEANED_TYPES.add(type);
}

/**
* @return the {@link CleanroomType}s this hatch provides to multiblocks
*/
@SuppressWarnings("unused")
public static ImmutableSet<CleanroomType> getCleanroomTypes() {
return ImmutableSet.copyOf(CLEANED_TYPES);
return cleanroomType == CleanroomType.CLEANROOM ? UV : UHV;
}
}
Loading