aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities/machines/basic
diff options
context:
space:
mode:
authorLéa Gris <lea.gris@noiraude.net>2022-07-23 13:21:54 +0200
committerGitHub <noreply@github.com>2022-07-23 13:21:54 +0200
commit74464417fd78c389b9d84173a7f9aeb4443ae0b6 (patch)
tree84170a821c75e6198801438e7d5da71df48b2beb /src/main/java/gregtech/common/tileentities/machines/basic
parent4f4a5e495e5a71467fb22ae5694f508193bc5f13 (diff)
downloadGT5-Unofficial-74464417fd78c389b9d84173a7f9aeb4443ae0b6.tar.gz
GT5-Unofficial-74464417fd78c389b9d84173a7f9aeb4443ae0b6.tar.bz2
GT5-Unofficial-74464417fd78c389b9d84173a7f9aeb4443ae0b6.zip
add(api/enums): particle and sound effect enumerations (#1154)
* add(api/enums): particle and sound effect enumerations - Adds new GregTech API enumerations: - `ParticleFX`: Enumerates known EntityFX particles. - `SoundResource`: Enumerates known sounds with, id and ResourceLocation. - Refactors code to use the new enumerations instead of string literals. - Uses `ParticleFX` and `onRandomDisplayTick` to improve or implement new particle effects for these machines: - BBF: Adds random flames in front of the firebox. - Steam machines: Changes pressure-exhaust particles to white vapour, rather than dark smoke. - Magic Energy Absorber: Adds random effect, of absorbed magical purple particles, by the EnderDragon Egg siphon. - Forge Hammer: Adds sparse random sparks, ejected from the main face.
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines/basic')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java113
1 files changed, 56 insertions, 57 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
index 1573c951eb..4bc9a56e2f 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
@@ -1,14 +1,12 @@
package gregtech.common.tileentities.machines.basic;
-import cpw.mods.fml.common.FMLCommonHandler;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import gregtech.GT_Mod;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.SoundResource;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
@@ -16,7 +14,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin
import gregtech.api.objects.ItemData;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_AssemblyLineUtils;
-import gregtech.api.util.GT_Assemblyline_Server;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
@@ -24,11 +21,13 @@ import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.behaviors.Behaviour_DataOrb;
import net.minecraft.init.Items;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.nbt.NBTTagString;
+import java.util.Objects;
+
+import static gregtech.api.enums.GT_Values.*;
import static gregtech.api.enums.Textures.BlockIcons.*;
import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes;
@@ -36,30 +35,30 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
public GT_MetaTileEntity_Scanner(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 1, "Scans Crops and other things.", 1, 1, "Scanner.png", "",
- TextureFactory.of(
- TextureFactory.of(OVERLAY_SIDE_SCANNER_ACTIVE),
- TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_ACTIVE_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_SIDE_SCANNER),
- TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_FRONT_SCANNER_ACTIVE),
- TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_ACTIVE_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_FRONT_SCANNER),
- TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_TOP_SCANNER_ACTIVE),
- TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_ACTIVE_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_TOP_SCANNER),
- TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_BOTTOM_SCANNER_ACTIVE),
- TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_ACTIVE_GLOW).glow().build()),
- TextureFactory.of(
- TextureFactory.of(OVERLAY_BOTTOM_SCANNER),
- TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_GLOW).glow().build()));
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_SIDE_SCANNER_ACTIVE),
+ TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_ACTIVE_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_SIDE_SCANNER),
+ TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_FRONT_SCANNER_ACTIVE),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_ACTIVE_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_FRONT_SCANNER),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_TOP_SCANNER_ACTIVE),
+ TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_ACTIVE_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_TOP_SCANNER),
+ TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_BOTTOM_SCANNER_ACTIVE),
+ TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_ACTIVE_GLOW).glow().build()),
+ TextureFactory.of(
+ TextureFactory.of(OVERLAY_BOTTOM_SCANNER),
+ TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_GLOW).glow().build()));
}
public GT_MetaTileEntity_Scanner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) {
@@ -105,7 +104,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
return 2;
}
} catch (Throwable e) {
- if (GT_Values.D1) {
+ if (D1) {
e.printStackTrace(GT_Log.err);
}
}
@@ -127,6 +126,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
}
aStack.stackSize -= 1;
this.mOutputItems[0] = GT_Utility.copyAmount(1L, aStack);
+ assert this.mOutputItems[0] != null;
this.mOutputItems[0].setTagCompound(tNBT);
return 2;
}
@@ -170,6 +170,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
aStack.stackSize -= 1;
this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot());
+ assert this.mOutputItems[0] != null;
this.mOutputItems[0].setTagCompound(aStack.getTagCompound());
calculateOverclockedNess(30, 128);
//In case recipe is too OP for that machine
@@ -182,6 +183,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
aStack.stackSize -= 1;
this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot());
+ assert this.mOutputItems[0] != null;
this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "map_id", (short) aStack.getItemDamage()));
calculateOverclockedNess(30, 128);
//In case recipe is too OP for that machine
@@ -195,27 +197,32 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
String sTier = "";
- if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem())) {
- if (aStack.getItemDamage() == 0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).copy().toString()))
+ int stackItemID = Item.getIdFromItem(aStack.getItem());
+ int stackItemDamage = aStack.getItemDamage();
+ if (stackItemID == Item.getIdFromItem(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_CORE, "item.schematic", 1L, 0)).getItem())) {
+ if (stackItemDamage == 0 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_CORE, "item.schematic", 1L, 0)).copy().toString()))
sTier = "100";
- else if (aStack.getItemDamage() == 1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 1).copy().toString()))
+ else if (stackItemDamage == 1 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_CORE, "item.schematic", 1L, 1)).copy().toString()))
sTier = "2";
- } else if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem())) {
- if (aStack.getItemDamage() == 0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).copy().toString()))
- sTier = "3";
- else if (aStack.getItemDamage() == 1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 1).copy().toString()))
- sTier = "101";
- else if (aStack.getItemDamage() == 2 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 2).copy().toString()))
- sTier = "102";
- } else if (aStack.getUnlocalizedName().matches(".*\\d+.*"))
- sTier = aStack.getUnlocalizedName().split("(?<=\\D)(?=\\d)")[1].substring(0, 1);
- else
- sTier = "1";
+ } else {
+ if (stackItemID == Item.getIdFromItem(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 0)).getItem())) {
+ if (stackItemDamage == 0 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 0)).copy().toString()))
+ sTier = "3";
+ else if (stackItemDamage == 1 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 1)).copy().toString()))
+ sTier = "101";
+ else if (stackItemDamage == 2 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 2)).copy().toString()))
+ sTier = "102";
+ } else if (aStack.getUnlocalizedName().matches(".*\\d+.*"))
+ sTier = aStack.getUnlocalizedName().split("(?<=\\D)(?=\\d)")[1].substring(0, 1);
+ else
+ sTier = "1";
+ }
getSpecialSlot().stackSize -= 1;
aStack.stackSize -= 1;
this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot());
+ assert this.mOutputItems[0] != null;
this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "rocket_tier", Short.parseShort(sTier)));
calculateOverclockedNess(480, 36000);
@@ -241,7 +248,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
}
}
- if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true) && aStack != null) {
+ if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true)) {
for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) {
if (GT_Utility.areStacksEqual(tRecipe.mResearchItem, aStack, true)) {
boolean failScanner = true;
@@ -254,20 +261,12 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
if (failScanner) {
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
}
-
- String s = tRecipe.mOutput.getDisplayName();
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName());
- if (s == null)
- s = tRecipe.mOutput.getDisplayName();
- }
this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot());
-
// Use Assline Utils
if (GT_AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(this.mOutputItems[0], tRecipe)) {
- aStack.stackSize -= 1;
+ aStack.stackSize -= 1;
calculateOverclockedNess(30, tRecipe.mResearchTime);
//In case recipe is too OP for that machine
if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
@@ -275,7 +274,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
getSpecialSlot().stackSize -= 1;
return 2;
}
-
+
}
}
}
@@ -314,7 +313,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
super.startSoundLoop(aIndex, aX, aY, aZ);
if (aIndex == 1) {
- GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ);
+ GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_MAGNETIZER_LOOP, 10, 1.0F, aX, aY, aZ);
}
}