-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathMetaTileEntityCleaningMaintenanceHatch.java
More file actions
113 lines (96 loc) · 4.22 KB
/
Copy pathMetaTileEntityCleaningMaintenanceHatch.java
File metadata and controls
113 lines (96 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package gregtech.common.metatileentities.multi.multiblockpart;
import gregtech.api.GTValues;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.metatileentity.multiblock.*;
import gregtech.api.util.GTUtility;
import gregtech.client.renderer.ICubeRenderer;
import gregtech.client.renderer.texture.Textures;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.ColourMultiplier;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Matrix4;
import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Set;
public class MetaTileEntityCleaningMaintenanceHatch extends MetaTileEntityAutoMaintenanceHatch {
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);
public MetaTileEntityCleaningMaintenanceHatch(ResourceLocation metaTileEntityId) {
super(metaTileEntityId);
}
@Override
public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
return new MetaTileEntityCleaningMaintenanceHatch(metaTileEntityId);
}
@Override
public void addToMultiBlock(MultiblockControllerBase controllerBase) {
super.addToMultiBlock(controllerBase);
if (controllerBase instanceof ICleanroomReceiver cleanroomReceiver) {
cleanroomReceiver.setCleanroom(DUMMY_CLEANROOM);
}
}
@Override
public int getTier() {
return GTValues.UV;
}
@Override
public ICubeRenderer getBaseTexture() {
MultiblockControllerBase controller = getController();
if (controller != null) {
return this.hatchTexture = controller.getBaseTexture(this);
} else if (this.hatchTexture != null) {
if (hatchTexture != Textures.getInactiveTexture(hatchTexture)) {
return this.hatchTexture = Textures.getInactiveTexture(hatchTexture);
}
return this.hatchTexture;
} else {
return Textures.VOLTAGE_CASINGS[getTier()];
}
}
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
getBaseTexture().render(renderState, translation, ArrayUtils.add(pipeline,
new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering()))));
if (shouldRenderOverlay())
Textures.MAINTENANCE_OVERLAY_CLEANING.renderSided(getFrontFacing(), renderState, translation, pipeline);
}
@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(I18n.format("gregtech.machine.maintenance_hatch_cleanroom_auto.tooltip.1"));
tooltip.add(I18n.format("gregtech.machine.maintenance_hatch.cleanroom_auto.tooltip.2"));
for (CleanroomType type : CLEANED_TYPES) {
tooltip.add(String.format(" %s%s", TextFormatting.GREEN, I18n.format(type.getTranslationKey())));
}
}
/**
* 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);
}
}