Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
M-W-K committed Sep 4, 2024
1 parent 8a210b3 commit 65d0051
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public List<BakedQuad> getQuads(ColorData data) {
existing.add(quad.withColor(data));
}
cache.put(data, existing);
// if (cache.size() > 20) cache.removeLast();
// if (cache.size() > 20) cache.removeLast();
}
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@Desugar
@SideOnly(Side.CLIENT)
public record ColorData(int... colorsARGB) {

@Override
public boolean equals(Object obj) {
if (obj == this) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public final class QuadHelper {
private QuadHelper() {}

public static @NotNull RecolorableBakedQuad buildQuad(EnumFacing normal, Pair<Vector3f, Vector3f> box,
@NotNull UVMapper uv, @NotNull SpriteInformation targetSprite) {
@NotNull UVMapper uv,
@NotNull SpriteInformation targetSprite) {
BlockPartFace face = new BlockPartFace(null, -1, targetSprite.sprite().getIconName(), uv.map(normal, box));
BakedQuad quad = BAKERY.makeBakedQuad(box.getLeft(), box.getRight(), face, targetSprite.sprite(), normal,
ModelRotation.X0_Y0, null, false, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package gregtech.client.renderer.pipe.quad;

import gregtech.api.util.reference.WeakHashSet;
import gregtech.client.renderer.pipe.util.SpriteInformation;

import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.jetbrains.annotations.NotNull;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

@SideOnly(Side.CLIENT)
public class RecolorableBakedQuad extends BakedQuad {
Expand All @@ -25,15 +16,17 @@ public class RecolorableBakedQuad extends BakedQuad {

/**
* Create a new recolorable quad based off of a baked quad prototype.
* @param prototype the prototype.
*
* @param prototype the prototype.
* @param spriteInformation the sprite information of this baked quad.
*/
public RecolorableBakedQuad(BakedQuad prototype, SpriteInformation spriteInformation) {
this(prototype, prototype.getTintIndex(), spriteInformation, new Int2ObjectOpenHashMap<>());
}

protected RecolorableBakedQuad(BakedQuad prototype, int tintIndex,
SpriteInformation spriteInformation, Int2ObjectOpenHashMap<RecolorableBakedQuad> cache) {
SpriteInformation spriteInformation,
Int2ObjectOpenHashMap<RecolorableBakedQuad> cache) {
super(prototype.vertexData, tintIndex, prototype.getFace(), spriteInformation.sprite(),
prototype.shouldApplyDiffuseLighting(), prototype.getFormat());
this.spriteInformation = spriteInformation;
Expand All @@ -42,12 +35,14 @@ protected RecolorableBakedQuad(BakedQuad prototype, int tintIndex,

/**
* Get a recolorable quad based off of this quad but aligned with the given color data.
*
* @param data the color data.
* @return a quad colored based on the color data.
*/
public RecolorableBakedQuad withColor(ColorData data) {
if (!spriteInformation.colorable()) return this;
int argb = data.colorsARGB()[spriteInformation.colorID()];
return cache.computeIfAbsent(argb, (c) -> new RecolorableBakedQuad(this, c, this.spriteInformation, this.cache));
return cache.computeIfAbsent(argb,
(c) -> new RecolorableBakedQuad(this, c, this.spriteInformation, this.cache));
}
}
3 changes: 0 additions & 3 deletions src/main/java/gregtech/common/blocks/MetaBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import gregtech.api.GregTechAPI;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.graphnet.pipenet.physical.PipeStructureRegistry;
import gregtech.api.graphnet.pipenet.physical.block.PipeMaterialBlock;
import gregtech.api.graphnet.pipenet.physical.tile.PipeActivableTileEntity;
import gregtech.api.graphnet.pipenet.physical.tile.PipeMaterialTileEntity;
import gregtech.api.graphnet.pipenet.physical.tile.PipeTileEntity;
Expand All @@ -26,7 +25,6 @@
import gregtech.client.model.modelfactories.BakedModelHandler;
import gregtech.client.renderer.handler.MetaTileEntityRenderer;
import gregtech.client.renderer.handler.MetaTileEntityTESR;
import gregtech.client.renderer.pipe.AbstractPipeModel;
import gregtech.common.ConfigHolder;
import gregtech.common.blocks.explosive.BlockITNT;
import gregtech.common.blocks.explosive.BlockPowderbarrel;
Expand Down Expand Up @@ -80,7 +78,6 @@
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
Expand Down

0 comments on commit 65d0051

Please sign in to comment.