|
1 | 1 | package gregtech.common.metatileentities.multi.multiblockpart;
|
2 | 2 |
|
3 | 3 | import gregtech.api.capability.IControllable;
|
| 4 | +import gregtech.api.capability.ICoolantHandler; |
4 | 5 | import gregtech.api.capability.impl.FilteredItemHandler;
|
| 6 | +import gregtech.api.capability.impl.LockableFluidTank; |
5 | 7 | import gregtech.api.capability.impl.NotifiableFluidTank;
|
6 | 8 | import gregtech.api.gui.GuiTextures;
|
7 | 9 | import gregtech.api.gui.ModularUI;
|
|
14 | 16 | import gregtech.api.metatileentity.multiblock.IFissionReactorHatch;
|
15 | 17 | import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart;
|
16 | 18 | import gregtech.api.metatileentity.multiblock.MultiblockAbility;
|
| 19 | +import gregtech.api.unification.material.Material; |
| 20 | +import gregtech.api.unification.material.properties.PropertyKey; |
17 | 21 | import gregtech.client.renderer.texture.Textures;
|
18 | 22 | import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;
|
19 | 23 |
|
|
32 | 36 |
|
33 | 37 | import java.util.List;
|
34 | 38 |
|
35 |
| -public class MetaTileEntityCoolantExportHatch extends MetaTileEntityMultiblockNotifiablePart implements |
36 |
| - IMultiblockAbilityPart<IFluidTank>, IControllable, IFissionReactorHatch { |
| 39 | +import static gregtech.api.capability.GregtechDataCodes.LOCK_UPDATE; |
| 40 | + |
| 41 | +public class MetaTileEntityCoolantExportHatch extends MetaTileEntityMultiblockNotifiablePart |
| 42 | + implements IMultiblockAbilityPart<ICoolantHandler>, ICoolantHandler, |
| 43 | + IControllable, IFissionReactorHatch { |
37 | 44 |
|
38 | 45 | private boolean workingEnabled;
|
39 | 46 | private boolean valid;
|
40 |
| - private final FluidTank fluidTank; |
| 47 | + private LockableFluidTank fluidTank; |
| 48 | + private Material coolant; |
41 | 49 |
|
42 | 50 | public MetaTileEntityCoolantExportHatch(ResourceLocation metaTileEntityId) {
|
43 | 51 | super(metaTileEntityId, 4, true);
|
44 |
| - this.fluidTank = new NotifiableFluidTank(16000, this, true); |
45 | 52 | this.frontFacing = EnumFacing.DOWN;
|
46 | 53 | }
|
47 | 54 |
|
@@ -105,19 +112,49 @@ public boolean checkValidity(int depth) {
|
105 | 112 | return true;
|
106 | 113 | }
|
107 | 114 |
|
| 115 | + @Override |
| 116 | + public void setLock(boolean isLocked) { |
| 117 | + fluidTank.setLock(isLocked); |
| 118 | + writeCustomData(LOCK_UPDATE, (packetBuffer -> packetBuffer.writeBoolean(isLocked))); |
| 119 | + } |
| 120 | + |
| 121 | + @Override |
| 122 | + public boolean isLocked() { |
| 123 | + return fluidTank.isLocked(); |
| 124 | + } |
| 125 | + |
| 126 | + @Override |
| 127 | + public Material getCoolant() { |
| 128 | + return this.coolant; |
| 129 | + } |
| 130 | + |
| 131 | + @Override |
| 132 | + public void setCoolant(Material material) { |
| 133 | + if (!material.hasProperty(PropertyKey.COOLANT)) { |
| 134 | + throw new IllegalStateException( |
| 135 | + "Can't use material " + material.getName() + " as a coolant without a coolant property"); |
| 136 | + } |
| 137 | + this.coolant = material; |
| 138 | + } |
| 139 | + |
| 140 | + @Override |
| 141 | + public LockableFluidTank getFluidTank() { |
| 142 | + return this.fluidTank; |
| 143 | + } |
| 144 | + |
108 | 145 | @Override
|
109 | 146 | public void setValid(boolean valid) {
|
110 | 147 | this.valid = valid;
|
111 | 148 | }
|
112 | 149 |
|
113 | 150 | @Override
|
114 |
| - public MultiblockAbility<IFluidTank> getAbility() { |
| 151 | + public MultiblockAbility<ICoolantHandler> getAbility() { |
115 | 152 | return MultiblockAbility.EXPORT_COOLANT;
|
116 | 153 | }
|
117 | 154 |
|
118 | 155 | @Override
|
119 |
| - public void registerAbilities(List<IFluidTank> abilityList) { |
120 |
| - abilityList.add(fluidTank); |
| 156 | + public void registerAbilities(List<ICoolantHandler> abilityList) { |
| 157 | + abilityList.add(this); |
121 | 158 | }
|
122 | 159 |
|
123 | 160 | @Override
|
|
0 commit comments