Skip to content

Commit 960712f

Browse files
jude123412Dream-MasterUltraProdigyNikolay-Sitnikov
authored
Add Vis-Regulated Maintenance Hatch (#6022)
Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: UltraProdigy <187078471+UltraProdigy@users.noreply.github.com> Co-authored-by: Nikolay S. <nicksitnikov@gmail.com>
1 parent 6331cc3 commit 960712f

File tree

8 files changed

+257
-0
lines changed

8 files changed

+257
-0
lines changed

dependencies.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ dependencies {
135135
// For testing
136136
//runtimeOnlyNonPublishable('com.github.GTNewHorizons:TCNEIAdditions:1.5.13:dev')
137137

138+
// For Magical Maintenance Hatch Testing
139+
// runtimeOnlyNonPublishable("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") { transitive = false }
140+
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:Electro-Magic-Tools:1.7.17:dev") { transitive = false }
141+
138142
// For testing ctm
139143
runtimeOnlyNonPublishable('com.github.GTNewHorizons:Angelica:2.0.0-alpha17:dev') { transitive = false }
140144

src/main/java/gregtech/api/enums/GTValues.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,48 @@ public static final class NBT {
680680
EnumChatFormatting.RED + BOLD,
681681
EnumChatFormatting.YELLOW + BOLD));
682682

683+
public static final Supplier<String> AuthorJude = chain(
684+
createJudeOuterText(
685+
"x",
686+
EnumChatFormatting.DARK_PURPLE,
687+
EnumChatFormatting.LIGHT_PURPLE,
688+
EnumChatFormatting.DARK_PURPLE),
689+
createJudeOuterText(
690+
"X",
691+
EnumChatFormatting.LIGHT_PURPLE,
692+
EnumChatFormatting.DARK_PURPLE,
693+
EnumChatFormatting.DARK_PURPLE),
694+
createJudeCenterText("jude", EnumChatFormatting.DARK_BLUE, EnumChatFormatting.BLUE),
695+
createJudeOuterText(
696+
"X",
697+
EnumChatFormatting.LIGHT_PURPLE,
698+
EnumChatFormatting.DARK_PURPLE,
699+
EnumChatFormatting.DARK_PURPLE),
700+
createJudeOuterText(
701+
"x",
702+
EnumChatFormatting.DARK_PURPLE,
703+
EnumChatFormatting.LIGHT_PURPLE,
704+
EnumChatFormatting.DARK_PURPLE));
705+
706+
private static Supplier<String> createJudeOuterText(String text, EnumChatFormatting colorA,
707+
EnumChatFormatting colorB, EnumChatFormatting colorC) {
708+
return animatedText(text, 0, 200, colorA + BOLD, colorB + BOLD, colorC + BOLD);
709+
}
710+
711+
private static Supplier<String> createJudeCenterText(String text, EnumChatFormatting colorA,
712+
EnumChatFormatting colorB) {
713+
return animatedText(
714+
text,
715+
0,
716+
200,
717+
colorA + BOLD,
718+
colorA + BOLD,
719+
colorA + BOLD,
720+
colorB + OBFUSCATED + BOLD,
721+
colorB + BOLD,
722+
colorB + OBFUSCATED + BOLD);
723+
}
724+
683725
private static Supplier<String> createChromLetter(String letter, String... injectedUnicode) {
684726

685727
XSTR random = XSTR.XSTR_INSTANCE;

src/main/java/gregtech/api/enums/ItemList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,7 @@ public enum ItemList implements IItemContainer {
21802180
EntropicProcessor,
21812181
DecayWarehouse,
21822182
LATEX,
2183+
MagicalMaintenanceHatch,
21832184
AcceleratorLV,
21842185
AcceleratorMV,
21852186
AcceleratorHV,

src/main/java/gregtech/api/enums/MetaTileEntityIDs.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,7 @@ public enum MetaTileEntityIDs {
18011801
ENTROPIC_PROCESSOR(15750),
18021802
DECAY_WAREHOUSE(15751),
18031803
LATEX(15752),
1804+
MagicalMaintenanceHatch(15753),
18041805
BasicTeslaTransceiver1by1(16000),
18051806
AdvancedTeslaTransceiver1by1(16001),
18061807
EpycTeslaTransceiver1by1(16002),
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
package gregtech.api.metatileentity.implementations;
2+
3+
import static net.minecraft.util.StatCollector.translateToLocal;
4+
5+
import net.minecraft.client.renderer.texture.IIconRegister;
6+
import net.minecraft.entity.player.EntityPlayer;
7+
import net.minecraft.item.ItemStack;
8+
import net.minecraft.nbt.NBTTagCompound;
9+
import net.minecraft.util.ResourceLocation;
10+
import net.minecraftforge.common.util.ForgeDirection;
11+
12+
import cpw.mods.fml.relauncher.Side;
13+
import cpw.mods.fml.relauncher.SideOnly;
14+
import gregtech.api.enums.Textures;
15+
import gregtech.api.interfaces.ITexture;
16+
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
17+
import gregtech.api.metatileentity.MetaTileEntity;
18+
import gregtech.api.render.TextureFactory;
19+
import thaumcraft.api.aspects.Aspect;
20+
import thaumcraft.api.visnet.VisNetHandler;
21+
22+
public class MTEMagicalMaintenanceHatch extends MTEHatchMaintenance {
23+
24+
private static Textures.BlockIcons.CustomIcon face;
25+
26+
private int airBuffer = 0;
27+
private int earthBuffer = 0;
28+
private int fireBuffer = 0;
29+
private int waterBuffer = 0;
30+
private int orderBuffer = 0;
31+
private int entropyBuffer = 0;
32+
33+
private static final int centiVisCap = 5000;
34+
private static final int centiVisCost = 2500;
35+
36+
private static final ResourceLocation focusMaintenanceSound = new ResourceLocation(
37+
"emt",
38+
"maintenance.MaintenanceWandFocus");
39+
40+
public MTEMagicalMaintenanceHatch(int aID, String aName, String aNameRegional, int aTier) {
41+
super(aID, aName, aNameRegional, aTier);
42+
}
43+
44+
public MTEMagicalMaintenanceHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
45+
super(aName, aTier, aDescription, aTextures, false);
46+
}
47+
48+
@Override
49+
public String[] getDescription() {
50+
return new String[] { translateToLocal("gt.blockmachines.magical.maintenance.desc.0"),
51+
translateToLocal("gt.blockmachines.magical.maintenance.desc.1"),
52+
translateToLocal("gt.blockmachines.magical.maintenance.desc.2") };
53+
}
54+
55+
@Override
56+
@SideOnly(Side.CLIENT)
57+
public void registerIcons(IIconRegister aBlockIconRegister) {
58+
super.registerIcons(aBlockIconRegister);
59+
face = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_MAGICALMAINTENANCE");
60+
}
61+
62+
@Override
63+
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
64+
return new ITexture[] { aBaseTexture, TextureFactory.of(face) };
65+
}
66+
67+
@Override
68+
public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
69+
return new ITexture[] { aBaseTexture, TextureFactory.of(face) };
70+
}
71+
72+
@Override
73+
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
74+
return new MTEMagicalMaintenanceHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures);
75+
}
76+
77+
@Override
78+
public void saveNBTData(NBTTagCompound nbt) {
79+
super.saveNBTData(nbt);
80+
nbt.setInteger("airBuffer", this.airBuffer);
81+
nbt.setInteger("earthBuffer", this.earthBuffer);
82+
nbt.setInteger("fireBuffer", this.fireBuffer);
83+
nbt.setInteger("waterBuffer", this.waterBuffer);
84+
nbt.setInteger("orderBuffer", this.orderBuffer);
85+
nbt.setInteger("entropyBuffer", this.entropyBuffer);
86+
87+
nbt.setBoolean("wrench", this.mWrench);
88+
nbt.setBoolean("screwdriver", this.mScrewdriver);
89+
nbt.setBoolean("softMallet", this.mSoftMallet);
90+
nbt.setBoolean("hardHammer", this.mHardHammer);
91+
nbt.setBoolean("solderingTool", this.mSolderingTool);
92+
nbt.setBoolean("crowbar", this.mCrowbar);
93+
}
94+
95+
@Override
96+
public void loadNBTData(NBTTagCompound nbt) {
97+
super.loadNBTData(nbt);
98+
this.airBuffer = nbt.getInteger("airBuffer");
99+
this.earthBuffer = nbt.getInteger("earthBuffer");
100+
this.fireBuffer = nbt.getInteger("fireBuffer");
101+
this.waterBuffer = nbt.getInteger("waterBuffer");
102+
this.orderBuffer = nbt.getInteger("orderBuffer");
103+
this.entropyBuffer = nbt.getInteger("entropyBuffer");
104+
105+
this.mWrench = nbt.getBoolean("wrench");
106+
this.mScrewdriver = nbt.getBoolean("screwdriver");
107+
this.mSoftMallet = nbt.getBoolean("softMallet");
108+
this.mHardHammer = nbt.getBoolean("hardHammer");
109+
this.mSolderingTool = nbt.getBoolean("solderingTool");
110+
this.mCrowbar = nbt.getBoolean("crowbar");
111+
}
112+
113+
@Override
114+
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
115+
super.onPostTick(aBaseMetaTileEntity, aTick);
116+
if (aBaseMetaTileEntity.isServerSide()) {
117+
performMaintenance();
118+
}
119+
}
120+
121+
private void performMaintenance() {
122+
// Internal Buffer, Caps at 5000 vis
123+
airBuffer = fillIfBelowCap(airBuffer, Aspect.AIR);
124+
earthBuffer = fillIfBelowCap(earthBuffer, Aspect.EARTH);
125+
fireBuffer = fillIfBelowCap(fireBuffer, Aspect.FIRE);
126+
waterBuffer = fillIfBelowCap(waterBuffer, Aspect.WATER);
127+
orderBuffer = fillIfBelowCap(orderBuffer, Aspect.ORDER);
128+
entropyBuffer = fillIfBelowCap(entropyBuffer, Aspect.ENTROPY);
129+
130+
boolean shouldRepair = !this.mWrench || !this.mScrewdriver
131+
|| !this.mSolderingTool
132+
|| !this.mCrowbar
133+
|| !this.mSoftMallet
134+
|| !this.mHardHammer;
135+
136+
boolean canRepair = airBuffer >= centiVisCost && earthBuffer >= centiVisCost
137+
&& fireBuffer >= centiVisCost
138+
&& waterBuffer >= centiVisCost
139+
&& orderBuffer >= centiVisCost
140+
&& entropyBuffer >= centiVisCost;
141+
142+
// Repair if needed + Drain
143+
if (canRepair && shouldRepair) {
144+
this.mWrench = this.mScrewdriver = this.mSolderingTool = this.mCrowbar = this.mSoftMallet = this.mHardHammer = true;
145+
airBuffer -= centiVisCost;
146+
earthBuffer -= centiVisCost;
147+
fireBuffer -= centiVisCost;
148+
waterBuffer -= centiVisCost;
149+
orderBuffer -= centiVisCost;
150+
entropyBuffer -= centiVisCost;
151+
}
152+
}
153+
154+
private int fillIfBelowCap(int buffer, Aspect aspect) {
155+
if (buffer >= centiVisCap) return buffer;
156+
157+
int space = centiVisCap - buffer;
158+
int drained = VisNetHandler.drainVis(
159+
getBaseMetaTileEntity().getWorld(),
160+
getBaseMetaTileEntity().getXCoord(),
161+
getBaseMetaTileEntity().getYCoord(),
162+
getBaseMetaTileEntity().getZCoord(),
163+
aspect,
164+
Math.min(space, 5));
165+
166+
return buffer + drained;
167+
}
168+
169+
@Override
170+
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side,
171+
float aX, float aY, float aZ) {
172+
return false;
173+
}
174+
175+
@Override
176+
public void onMaintenancePerformed(MTEMultiBlockBase aMaintenanceTarget) {
177+
setMaintenanceSound(focusMaintenanceSound, 1.0F, 1.0F);
178+
super.onMaintenancePerformed(aMaintenanceTarget);
179+
}
180+
181+
@Override
182+
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side,
183+
ItemStack aStack) {
184+
return false;
185+
}
186+
187+
@Override
188+
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side,
189+
ItemStack aStack) {
190+
return false;
191+
}
192+
}

src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.addItemTooltip;
44
import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.chain;
55
import static gregtech.api.enums.MetaTileEntityIDs.*;
6+
import static gregtech.api.enums.Mods.ElectroMagicTools;
67
import static gregtech.api.enums.Mods.Forestry;
78
import static gregtech.api.enums.Mods.StorageDrawers;
89
import static gregtech.api.enums.Mods.Thaumcraft;
@@ -76,6 +77,7 @@
7677
import gregtech.api.metatileentity.implementations.MTEHatchQuadrupleHumongous;
7778
import gregtech.api.metatileentity.implementations.MTEHatchVoid;
7879
import gregtech.api.metatileentity.implementations.MTEHatchVoidBus;
80+
import gregtech.api.metatileentity.implementations.MTEMagicalMaintenanceHatch;
7981
import gregtech.api.metatileentity.implementations.MTETransformer;
8082
import gregtech.api.metatileentity.implementations.MTEWetTransformer;
8183
import gregtech.api.metatileentity.implementations.MTEWirelessEnergy;
@@ -662,6 +664,16 @@ private static void registerMultiblockControllers() {
662664
ItemList.LATEX.set(new MTELatex(LATEX.ID, "multimachine.latex", "L.A.T.E.X.").getStackForm(1));
663665
addItemTooltip(ItemList.LATEX.get(1), chain(() -> "Author: ", GTValues.AuthorThree));
664666

667+
if (Thaumcraft.isModLoaded() && ElectroMagicTools.isModLoaded()) {
668+
ItemList.MagicalMaintenanceHatch.set(
669+
new MTEMagicalMaintenanceHatch(
670+
MagicalMaintenanceHatch.ID,
671+
"hatch.maintenance.magic",
672+
"Vis-Regulated Maintenance Hatch",
673+
5).getStackForm(1));
674+
addItemTooltip(ItemList.MagicalMaintenanceHatch.get(1), chain(() -> "Author: ", GTValues.AuthorJude));
675+
}
676+
665677
ItemList.Machine_Multi_NanochipAssemblyComplex.set(
666678
new MTENanochipAssemblyComplex(
667679
NANOCHIP_ASSEMBLY_CONTROLLER.ID,

src/main/resources/assets/gregtech/lang/en_US.lang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,11 @@ achievement.gt.blockcasings5.12.desc=Pickup this item to see the recipe in NEI
30003000
achievement.gt.blockcasings5.13=Eternal Coil
30013001
achievement.gt.blockcasings5.13.desc=Pickup this item to see the recipe in NEI
30023002

3003+
# Magical Maintenance Hatch
3004+
gt.blockmachines.magical.maintenance.desc.0=For magically maintaining Multiblocks with Centi-Vis.
3005+
gt.blockmachines.magical.maintenance.desc.1=Consumes §b25 §7Primal Vis of each type to fix maintenance issues.
3006+
gt.blockmachines.magical.maintenance.desc.2=§eAer§7, §aTerra§7, §cIgnis§7, §9Aqua§7, §fOrdo§7, §8Perditio
3007+
30033008
# Exo-Foundry
30043009
gt.blockmachines.multimachine.foundry.basemodule=When used in the Exo-Foundry:
30053010
gt.blockmachines.multimachine.foundry.modulelimit=- Limit of §f1 §7per §6Foundry
733 Bytes
Loading

0 commit comments

Comments
 (0)