From 70b0131f88461e2f890f8dd020ecc8407774ac4b Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:14:19 -0500 Subject: [PATCH] goodbye arrays of float arrays... --- .../actuallyadditions/api/lens/Lens.java | 2 +- .../api/lens/LensConversion.java | 4 +-- .../mod/items/lens/LensColor.java | 31 ++++++++++--------- .../mod/items/lens/LensDeath.java | 4 +-- .../mod/items/lens/LensDetonation.java | 4 +-- .../mod/items/lens/LensDisenchanting.java | 4 +-- .../mod/items/lens/LensMining.java | 4 +-- .../mod/items/lens/LensRecipeHandler.java | 15 --------- .../mod/network/PacketHandler.java | 2 +- .../mod/tile/TileEntityLeafGenerator.java | 2 +- .../mod/tile/TileEntityVerticalDigger.java | 2 +- .../actuallyadditions/mod/util/AssetUtil.java | 13 ++------ 12 files changed, 33 insertions(+), 54 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java index 4bad400c4..9337f3272 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java @@ -33,7 +33,7 @@ public abstract class Lens { /** * Returns the color in an array of 3 float values that are r, g, b */ - public abstract float[] getColor(); + public abstract int getColor(); /** * Gets the maximum distance the beam goes with this lens diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java index e6da708b3..b77f4587b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java @@ -30,8 +30,8 @@ public class LensConversion extends Lens { } @Override - public float[] getColor() { - return new float[]{27F / 255F, 109F / 255F, 1F}; + public int getColor() { + return 0x1B6FFF; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java index d9807bd29..0ed189bd8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java @@ -31,20 +31,22 @@ import java.util.Random; public class LensColor extends Lens { + //1k to fire, 200 per item public static final int ENERGY_USE = 200; //Thanks to xdjackiexd for this, as I couldn't be bothered - public static final float[][] POSSIBLE_COLORS = {{158F, 43F, 39F}, //Red - {234F, 126F, 53F}, //Orange - {194F, 181F, 28F}, //Yellow - {57F, 186F, 46F}, //Lime Green - {54F, 75F, 24F}, //Green - {99F, 135F, 210F}, //Light Blue - {38F, 113F, 145F}, //Cyan - {37F, 49F, 147F}, //Blue - {126F, 52F, 191F}, //Purple - {190F, 73F, 201F}, //Magenta - {217F, 129F, 153F}, //Pink - {86F, 51F, 28F}, //Brown + public static final int[] POSSIBLE_COLORS = new int[]{ + 0x9E2B27, //Red + 0xEA7E35, //Orange + 0xC2B41C, //Yellow + 0x39BA2E, //Lime Green + 0x364B18, //Green + 0x6387D2, //Light Blue + 0x267191, //Cyan + 0x253293, //Blue + 0x7E34BF, //Purple + 0xBE49C9, //Magenta + 0xD98199, //Pink + 0x56331C, //Brown }; private final Random rand = new Random(); @@ -96,9 +98,8 @@ public class LensColor extends Lens { } @Override - public float[] getColor() { - float[] colors = POSSIBLE_COLORS[this.rand.nextInt(POSSIBLE_COLORS.length)]; - return new float[]{colors[0] / 255F, colors[1] / 255F, colors[2] / 255F}; + public int getColor() { + return POSSIBLE_COLORS[this.rand.nextInt(POSSIBLE_COLORS.length)]; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java index db18bec61..af7e07a96 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java @@ -46,8 +46,8 @@ public class LensDeath extends Lens { } @Override - public float[] getColor() { - return new float[]{188F / 255F, 222F / 255F, 1F}; + public int getColor() { + return 0xBCDEFF; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java index 628ac4b82..044db3344 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java @@ -34,8 +34,8 @@ public class LensDetonation extends Lens { } @Override - public float[] getColor() { - return new float[]{158F / 255F, 43F / 255F, 39F / 255F}; + public int getColor() { + return 0x9E2B27; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java index 610e8e644..b4d5ad260 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java @@ -104,8 +104,8 @@ public class LensDisenchanting extends Lens { } @Override - public float[] getColor() { - return new float[]{234F / 255F, 173F / 255F, 1.0f}; + public int getColor() { + return 0xEBADFF; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java index 931236f3b..419cccd00 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java @@ -171,8 +171,8 @@ public class LensMining extends Lens { } @Override - public float[] getColor() { - return new float[]{76F / 255F, 76F / 255F, 76F / 255F}; + public int getColor() { + return 0x4C4C4C; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java index e0ff9bff8..63589f7c4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java @@ -32,21 +32,6 @@ public final class LensRecipeHandler { // ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer); } // - // @Deprecated //Use lens-checking method below. - // public static List getRecipesFor(ItemStack input) { - // List possibleRecipes = new ArrayList<>(); - // for (LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES) - // if (recipe.getInput().apply(input)) possibleRecipes.add(recipe); - // return possibleRecipes; - // } - // - // @Nullable - // public static LensConversionRecipe findMatchingRecipe(ItemStack input, Lens lens) { - // for (LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES) - // if (recipe.matches(input, lens)) return recipe; - // return null; - // } - // // private static Ingredient fromBlock(Block b) { // return Ingredient.fromItems(Item.getItemFromBlock(b)); // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index 4156ff8c7..2e68f2d2c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -53,7 +53,7 @@ public final class PacketHandler { @Override @OnlyIn(Dist.CLIENT) public void handleData(CompoundNBT compound, NetworkEvent.Context context) { - AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); + AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInt("Color"), compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); } }; public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java index 5298efbdf..ca28c4e4a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java @@ -88,7 +88,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE this.storage.receiveEnergyInternal(energyProduced, false); - AssetUtil.spawnLaserWithTimeServer(this.level, this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F / 255F, 163F / 255F, 74F / 255F}, 25, 0, 0.075F, 0.8F); + AssetUtil.spawnLaserWithTimeServer(this.level, this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), 0x3EA34A, 25, 0, 0.075F, 0.8F); } } } else { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java index ed83a9dbf..29e1678a7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java @@ -197,7 +197,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements } private void shootParticles(int endX, int endY, int endZ) { - AssetUtil.spawnLaserWithTimeServer(this.level, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), endX, endY, endZ, new float[]{65F / 255F, 150F / 255F, 2F / 255F}, 10, 120, 0.1F, 0.8F); + AssetUtil.spawnLaserWithTimeServer(this.level, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), endX, endY, endZ, 0x429602, 10, 120, 0.1F, 0.8F); } private boolean isBlacklisted(Block block) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index bb5dcbd68..62fc1f407 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -17,12 +17,10 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.render.RenderTypes; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; -import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.LightTexture; @@ -30,7 +28,6 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.IParticleData; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; @@ -41,8 +38,6 @@ import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.network.NetworkRegistry; -import net.minecraftforge.fml.network.PacketDispatcher; import net.minecraftforge.fml.network.PacketDistributor; public final class AssetUtil { @@ -212,7 +207,7 @@ public final class AssetUtil { // GlStateManager._popMatrix(); // } - public static void spawnLaserWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) { + public static void spawnLaserWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, int color, int maxAge, double rotationTime, float size, float alpha) { if (!world.isClientSide) { CompoundNBT data = new CompoundNBT(); data.putDouble("StartX", startX); @@ -221,9 +216,7 @@ public final class AssetUtil { data.putDouble("EndX", endX); data.putDouble("EndY", endY); data.putDouble("EndZ", endZ); - data.putFloat("Color1", color[0]); - data.putFloat("Color2", color[1]); - data.putFloat("Color3", color[2]); + data.putInt("Color", color); data.putDouble("RotationTime", rotationTime); data.putFloat("Size", size); data.putInt("MaxAge", maxAge); @@ -233,7 +226,7 @@ public final class AssetUtil { } @OnlyIn(Dist.CLIENT) - public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) { + public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, int color, int maxAge, double rotationTime, float size, float alpha) { Minecraft mc = Minecraft.getInstance(); TileEntity tile = mc.level.getBlockEntity(new BlockPos(startX, startY, startZ)); if(tile instanceof TileEntityAtomicReconstructor)