Skip to content

Commit

Permalink
Subatomic Particles
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueHero233 committed Sep 28, 2024
1 parent 1d0e871 commit e1315b7
Show file tree
Hide file tree
Showing 38 changed files with 18 additions and 30 deletions.
35 changes: 14 additions & 21 deletions src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import gregtech.api.enums.Materials;
import gtPlusPlus.core.item.base.misc.BaseItemParticle;
import gtPlusPlus.core.material.MaterialsElements;
import gtPlusPlus.core.util.Utils;

public class IonParticles extends BaseItemParticle {
Expand All @@ -24,16 +23,17 @@ public class IonParticles extends BaseItemParticle {
public static HashMap<Integer, String> MetaToNameMap = new HashMap<>();

public IonParticles() {
super("Ion", MaterialsElements.NAMES.length, EnumRarity.rare);
super("Ion", ions.length, EnumRarity.rare);
}

public static IIcon[] overlays = new IIcon[MaterialsElements.NAMES.length];
public static IIcon baseTexture;
public static final String[] ions = new String[] { "Hydrogen", "Helium" };

public IIcon[] texture = new IIcon[ions.length];

static {
// Generate Ions
int key = 0;
for (String s : MaterialsElements.NAMES) {
for (String s : ions) {
// Map names to Meta
NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key);
MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase()));
Expand All @@ -60,7 +60,7 @@ public String getUnlocalizedName() {

@Override
public String getUnlocalizedName(final ItemStack itemStack) {
return "item.particle.ion" + "." + MaterialsElements.NAMES[itemStack.getItemDamage()];
return "item.particle.ion." + ions[itemStack.getItemDamage()];
}

private static boolean createNBT(ItemStack rStack) {
Expand All @@ -72,7 +72,7 @@ private static boolean createNBT(ItemStack rStack) {
return true;
}

public static final long getChargeState(final ItemStack aStack) {
public static long getChargeState(final ItemStack aStack) {
NBTTagCompound aNBT = aStack.getTagCompound();
if (aNBT != null) {
aNBT = aNBT.getCompoundTag("Ion");
Expand All @@ -85,7 +85,7 @@ public static final long getChargeState(final ItemStack aStack) {
return 0L;
}

public static final boolean setChargeState(final ItemStack aStack, final long aCharge) {
public static boolean setChargeState(final ItemStack aStack, final long aCharge) {
NBTTagCompound aNBT = aStack.getTagCompound();
if (aNBT != null) {
aNBT = aNBT.getCompoundTag("Ion");
Expand All @@ -102,8 +102,7 @@ public double getDurabilityForDisplay(ItemStack stack) {
if (stack.getTagCompound() == null) {
createNBT(stack);
}
double chargeState = getChargeState(stack);
return chargeState;
return (double) getChargeState(stack);
}

@Override
Expand Down Expand Up @@ -131,23 +130,21 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool
+ " Ion with a "
+ aState
+ " charge state of "
+ aCharge
+ "");
+ aCharge);
}
super.addInformation(stack, player, list, bool);
}

@Override
public void registerIcons(IIconRegister reg) {
for (int i = 0; i < IonParticles.overlays.length; i++) {
IonParticles.overlays[i] = reg.registerIcon(GTPlusPlus.ID + ":" + "ion/" + i);
for (int i = 0; i < this.texture.length; i++) {
this.texture[i] = reg.registerIcon(GTPlusPlus.ID + ":ion" + i);
}
IonParticles.baseTexture = reg.registerIcon(GTPlusPlus.ID + ":" + "ion/IonBase");
}

@Override
public IIcon getIconFromDamage(int meta) {
return IonParticles.overlays[meta];
return this.texture[meta];
}

@Override
Expand All @@ -157,11 +154,7 @@ public boolean requiresMultipleRenderPasses() {

@Override
public IIcon getIconFromDamageForRenderPass(int aMeta, int aPass) {
if (aPass == 0) {
return IonParticles.baseTexture;
} else {
return IonParticles.overlays[aMeta];
}
return this.texture[aMeta];
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public StandardBaseParticles() {
MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase()));
for (Particle o : Particle.aMap) {
int aColour = 0;
if (o.mParticleName.toLowerCase()
.equals(s.toLowerCase())) {
if (o.mParticleName.equalsIgnoreCase(s)) {
if (o.mParticleType == ElementaryGroup.BARYON) {
aColour = Utils.rgbtoHexValue(174, 226, 156);
aColourMap.put(key++, aColour);
Expand Down Expand Up @@ -109,7 +108,6 @@ public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
Particle aCharge = getParticle(stack);
EnumChatFormatting aColour = EnumChatFormatting.GRAY;
String aState = aColour + "Unknown" + EnumChatFormatting.RESET;
if (aCharge != null) {
String aGroup = aCharge.mParticleType.name()
.toLowerCase();
Expand All @@ -130,13 +128,11 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool
} else if (aGroup.toLowerCase()
.contains("meson")) {
aColour = EnumChatFormatting.WHITE;
} else {
aColour = EnumChatFormatting.GRAY;
}
String aFirstLet = aGroup.substring(0, 1)
.toUpperCase();
aGroup = aGroup.replaceFirst(aGroup.substring(0, 1), aFirstLet);
aState = aColour + aGroup + EnumChatFormatting.RESET;
String aState = aColour + aGroup + EnumChatFormatting.RESET;
list.add(EnumChatFormatting.GRAY + "Type: " + aState);
}
super.addInformation(stack, player, list, bool);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/gtPlusPlus/core/material/MaterialsElements.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

public final class MaterialsElements {

public static final String[] NAMES = new String[] { "Hydrogen", "Helium" };

// First 50 Elements
public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen);
public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gtPlusPlus/core/material/Particle.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class Particle {
UNKNOWN = new Particle(ElementaryGroup.UNKNOWN, "Unknown");
}

public static enum ElementaryGroup {
public enum ElementaryGroup {
QUARK,
LEPTON,
BOSON,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "animation": { "interpolate": true, "frametime": 4 } }
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/24.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/3.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/4.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/5.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/6.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/7.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/8.png
Binary file modified src/main/resources/assets/miscutils/textures/items/particle/9.png

0 comments on commit e1315b7

Please sign in to comment.