goodbye arrays of float arrays...

This commit is contained in:
Flanks255 2022-07-06 12:14:19 -05:00
parent 26dfa7cb75
commit 70b0131f88
12 changed files with 33 additions and 54 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -32,21 +32,6 @@ public final class LensRecipeHandler {
// ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer);
}
//
// @Deprecated //Use lens-checking method below.
// public static List<LensConversionRecipe> getRecipesFor(ItemStack input) {
// List<LensConversionRecipe> 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));
// }

View file

@ -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() {

View file

@ -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 {

View file

@ -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) {

View file

@ -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)