Skip to content

Commit

Permalink
Minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Jan 28, 2024
1 parent e78b4ca commit a70d940
Show file tree
Hide file tree
Showing 64 changed files with 258 additions and 289 deletions.
2 changes: 1 addition & 1 deletion src/api/java/mods/railcraft/api/charge/ChargeStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ default int getAvailableCharge() {
}

default float getEfficiency() {
return 1.0F;
return 1;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/mods/railcraft/api/track/TrackUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static boolean placeRailAt(ItemStack stack, ServerLevel level,
var soundType = railBlock.getSoundType(blockState, level, pos, null);
level.playSound(null, pos,
soundType.getPlaceSound(),
SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F,
SoundSource.BLOCKS, (soundType.getVolume() + 1) / 2,
soundType.getPitch() * 0.8F);
}
return success;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mods/railcraft/charge/ChargeNetworkImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public Iterator<ChargeNode> iterator() {
protected void destroy(boolean touchNodes) {
logger.debug("Destroying grid: {}", this);
invalid = true;
totalLosses = 0.0F;
totalLosses = 0;
if (touchNodes) {
forEach(n -> n.chargeGrid = NULL_GRID);
}
Expand Down Expand Up @@ -401,13 +401,13 @@ public float getAverageUsagePerTick() {

public float getUtilization() {
if (this.isInfinite()) {
return 0.0F;
return 0;
}
var potentialDraw = this.getPotentialDraw();
if (potentialDraw <= 0.0F) {
return 1.0F;
if (potentialDraw <= 0) {
return 1;
}
return Math.min(this.averageUsagePerTick / potentialDraw, 1.0F);
return Math.min(this.averageUsagePerTick / potentialDraw, 1);
}

public boolean isInfinite() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.client.Minecraft;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.Vec3;

public class TuningAuraHandlerImpl implements TuningAuraHandler {

Expand Down Expand Up @@ -40,7 +39,7 @@ public void spawnTuningAura(BlockEntity start, BlockEntity dest) {
int color = colorProfile.getColor(start, start.getBlockPos(), dest.getBlockPos());

level.addParticle(
new TuningAuraParticleOptions(Vec3.atCenterOf(dest.getBlockPos()), color),
new TuningAuraParticleOptions(dest.getBlockPos().getCenter(), color),
px, py, pz, 0.0D, 0.0D, 0.0D);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
this.windowWidth, this.windowHeight);
var poseStack = guiGraphics.pose();
poseStack.pushPose();
poseStack.translate(centredX, centredY, 0.0F);
poseStack.translate(centredX, centredY, 0);
GuiUtil.drawCenteredString(guiGraphics, this.font, this.title, this.windowWidth, this.font.lineHeight);
this.renderContent(guiGraphics, mouseX, mouseY, partialTicks);
poseStack.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
var left = this.leftPos;
var top = this.topPos;

RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderColor(1, 1, 1, 1);

if (this.menu.getCarried().isEmpty()) {
for (var renderer : this.widgetRenderers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

public class FluidGaugeRenderer extends WidgetRenderer<FluidGaugeWidget> {

Expand Down Expand Up @@ -54,7 +55,7 @@ public void render(ResourceLocation widgetLocation, GuiGraphics guiGraphics, int
}
}

var mask = (int) Math.floor(this.widget.h * scale);
var mask = Mth.floor(this.widget.h * scale);
if (mask == 0 && fluidStack.getAmount() > 0) {
mask = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected int getYImage(boolean hovered) {
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
var font = Minecraft.getInstance().font;
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
RenderSystem.setShaderColor(1, 1, 1, this.alpha);
int i = this.getYImage(this.isHoveredOrFocused());
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;

/**
Expand All @@ -32,28 +33,28 @@ public static LayerDefinition createBodyLayer(CubeDeformation cubeDeformation) {
partdefinition.addOrReplaceChild("bottom",
CubeListBuilder.create()
.texOffs(0, 10)
.addBox(-10.0F, -8.0F, -1.0F, 20.0F, 16.0F, 2.0F, cubeDeformation),
PartPose.offsetAndRotation(0.0F, 4.0F, 0.0F, ((float) Math.PI / 2F), 0.0F, 0.0F));
.addBox(-10, -8, -1, 20, 16, 2, cubeDeformation),
PartPose.offsetAndRotation(0, 4, 0, Mth.HALF_PI, 0, 0));
partdefinition.addOrReplaceChild("front",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-8.0F, -9.0F, -1.0F, 16.0F, 8.0F, 2.0F, cubeDeformation),
PartPose.offsetAndRotation(-9.0F, 4.0F, 0.0F, 0.0F, ((float) Math.PI * 1.5F), 0.0F));
.addBox(-8, -9, -1, 16, 8, 2, cubeDeformation),
PartPose.offsetAndRotation(-9, 4, 0, 0, Mth.PI * 1.5F, 0));
partdefinition.addOrReplaceChild("back",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-8.0F, -9.0F, -1.0F, 16.0F, 8.0F, 2.0F, cubeDeformation),
PartPose.offsetAndRotation(9.0F, 4.0F, 0.0F, 0.0F, ((float) Math.PI / 2F), 0.0F));
.addBox(-8, -9, -1, 16, 8, 2, cubeDeformation),
PartPose.offsetAndRotation(9, 4, 0, 0, Mth.HALF_PI, 0));
partdefinition.addOrReplaceChild("left",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-8.0F, -9.0F, -1.0F, 16.0F, 8.0F, 2.0F, cubeDeformation),
PartPose.offsetAndRotation(0.0F, 4.0F, -7.0F, 0.0F, (float) Math.PI, 0.0F));
.addBox(-8, -9, -1, 16, 8, 2, cubeDeformation),
PartPose.offsetAndRotation(0, 4, -7, 0, Mth.PI, 0));
partdefinition.addOrReplaceChild("right",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-8.0F, -9.0F, -1.0F, 16.0F, 8.0F, 2.0F, cubeDeformation),
PartPose.offset(0.0F, 4.0F, 7.0F));
.addBox(-8, -9, -1, 16, 8, 2, cubeDeformation),
PartPose.offset(0, 4, 7));
return LayerDefinition.create(meshdefinition, 64, 32);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ public static LayerDefinition createBodyLayer(CubeDeformation deformation) {
root.addOrReplaceChild("wheels",
CubeListBuilder.create()
.texOffs(1, 25)
.addBox(-20F, -5F, -16F, 23, 2, 16, deformation),
PartPose.offset(8.0F, 8.0F, 8.0F));
.addBox(-20, -5, -16, 23, 2, 16, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("frame",
CubeListBuilder.create()
.texOffs(1, 1)
.addBox(-21F, -10F, -17F, 25, 5, 18, deformation),
PartPose.offset(8.0F, 8.0F, 8.0F));
.addBox(-21, -10, -17, 25, 5, 18, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("engine",
CubeListBuilder.create()
.texOffs(67, 37)
.addBox(-15F, -19F, -16F, 13, 9, 16, deformation),
PartPose.offset(8.0F, 8.0F, 8.0F));
.addBox(-15, -19, -16, 13, 9, 16, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("sideA",
CubeListBuilder.create()
.texOffs(35, 45)
.addBox(-20F, -17F, -13F, 5, 7, 10, deformation),
PartPose.offset(8.0F, 8.0F, 8.0F));
.addBox(-20, -17, -13, 5, 7, 10, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("sideB",
CubeListBuilder.create()
.texOffs(35, 45)
.addBox(-2F, -17F, -13F, 5, 7, 10, deformation),
PartPose.offset(8.0F, 8.0F, 8.0F));
.addBox(-2, -17, -13, 5, 7, 10, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("light",
CubeListBuilder.create()
.texOffs(1, 55)
.addBox(-21F, -18F, -10F, 6, 4, 4, deformation),
PartPose.offset(8.0F, 8.0F, 8.0F));
.addBox(-21, -18, -10, 6, 4, 4, deformation),
PartPose.offset(8, 8, 8));

return LayerDefinition.create(mesh, 128, 64);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;

public class LowSidesMinecartModel<T extends Entity> extends HierarchicalModel<T> {
Expand All @@ -23,39 +24,38 @@ public LowSidesMinecartModel(ModelPart root) {
public static LayerDefinition createBodyLayer(CubeDeformation deformation) {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
int length = 20;
float length = 20;
int heightEnds = 8;
int heightSides = 6;
int width = 16;
float width = 16;
int yOffset = 4;
root.addOrReplaceChild("bottom",
CubeListBuilder.create()
.texOffs(0, 10)
.addBox(-length / 2.0F, -width / 2.0F, -1.0F, length, width, 2.0F, deformation),
PartPose.offsetAndRotation(0.0F, yOffset, 0.0F, ((float) Math.PI / 2F), 0.0F, 0.0F));
.addBox(-length / 2, -width / 2, -1, length, width, 2, deformation),
PartPose.offsetAndRotation(0, yOffset, 0, Mth.HALF_PI, 0, 0));
root.addOrReplaceChild("front",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-width / 2.0F, (-length / 2.0F) + 1, -1.0F, width, heightEnds, 2.0F,
.addBox(-width / 2, (-length / 2) + 1, -1, width, heightEnds, 2,
deformation),
PartPose.offsetAndRotation(-9.0F, yOffset, 0.0F, 0.0F, ((float) Math.PI * 1.5F), 0.0F));
PartPose.offsetAndRotation(-9, yOffset, 0, 0, Mth.PI * 1.5F, 0));
root.addOrReplaceChild("back",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-width / 2.0F, (-length / 2.0F) + 1, -1.0F, width, heightEnds, 2.0F,
.addBox(-width / 2, (-length / 2) + 1, -1, width, heightEnds, 2,
deformation),
PartPose.offsetAndRotation((length / 2.0F) - 1, yOffset, 0.0F, 0.0F, ((float) Math.PI / 2F),
0.0F));
PartPose.offsetAndRotation((length / 2) - 1, yOffset, 0, 0, Mth.HALF_PI, 0));
root.addOrReplaceChild("left",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-width / 2.0F, -heightSides - 1, -1.0F, width, heightSides, 2.0F, deformation),
PartPose.offsetAndRotation(0.0F, yOffset, -7.0F, 0.0F, (float) Math.PI, 0.0F));
.addBox(-width / 2, -heightSides - 1, -1, width, heightSides, 2, deformation),
PartPose.offsetAndRotation(0, yOffset, -7, 0, Mth.PI, 0));
root.addOrReplaceChild("right",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-width / 2.0F, -heightSides - 1, -1.0F, width, heightSides, 2.0F, deformation),
PartPose.offset(0.0F, yOffset, 7.0F));
.addBox(-width / 2, -heightSides - 1, -1, width, heightSides, 2, deformation),
PartPose.offset(0, yOffset, 7));
return LayerDefinition.create(mesh, 64, 32);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static LayerDefinition createBodyLayer() {
CubeListBuilder.create()
.texOffs(0, 1)
.addBox(-2, 10.75F, -2, 4, 4, 4),
PartPose.offset(8.0F, 6.0F, 8.0F));
PartPose.offset(8, 6, 8));
return LayerDefinition.create(mesh, 16, 16);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public static LayerDefinition createBodyLayer() {
CubeListBuilder.create()
.texOffs(0, 1)
.addBox(-8, -8, -8, 16, 16, 16),
PartPose.offset(8.0F, 8.0F, 8.0F));
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("bracket",
CubeListBuilder.create()
.texOffs(1, 35)
.addBox(-3, 8, -3, 6, 1, 6),
PartPose.offset(8.0F, 8.0F, 8.0F));
PartPose.offset(8, 8, 8));
return LayerDefinition.create(mesh, 64, 64);
}
}
28 changes: 14 additions & 14 deletions src/main/java/mods/railcraft/client/model/SteamLocomotiveModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@ public static LayerDefinition createBodyLayer(CubeDeformation deformation) {
root.addOrReplaceChild("wheels",
CubeListBuilder.create()
.texOffs(1, 23)
.addBox(-20F, -5F, -16F, 23, 2, 16, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-20, -5, -16, 23, 2, 16, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("frame",
CubeListBuilder.create()
.texOffs(1, 1)
.addBox(-21F, -7F, -17F, 25, 2, 18, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-21, -7, -17, 25, 2, 18, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("boiler",
CubeListBuilder.create()
.texOffs(67, 38)
.addBox(-20F, -18F, -15F, 16, 11, 14, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-20, -18, -15, 16, 11, 14, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("cab",
CubeListBuilder.create()
.texOffs(81, 8)
.addBox(-4F, -19F, -16F, 7, 12, 16, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-4, -19, -16, 7, 12, 16, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("cowcatcher",
CubeListBuilder.create()
.texOffs(1, 43)
.addBox(-22F, -8F, -14F, 3, 5, 12, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-22, -8, -14, 3, 5, 12, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("stack",
CubeListBuilder.create()
.texOffs(49, 43)
.addBox(-17F, -24F, -10F, 4, 6, 4, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-17, -24, -10, 4, 6, 4, deformation),
PartPose.offset(8, 8, 8));
root.addOrReplaceChild("dome",
CubeListBuilder.create()
.texOffs(23, 43)
.addBox(-11F, -20F, -11F, 6, 2, 6, deformation),
PartPose.offset(8F, 8F, 8F));
.addBox(-11, -20, -11, 6, 2, 6, deformation),
PartPose.offset(8, 8, 8));
return LayerDefinition.create(mesh, 128, 64);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected BaseShrinkingSmokeParticle(ClientLevel level, double x, double y, doub
@Override
public float getQuadSize(float partialTicks) {
return this.quadSize * Mth.clamp(
(this.age + partialTicks) / this.lifetime * 32.0F, 0.0F, 1.0F);
(this.age + partialTicks) / this.lifetime * 32.0F, 0, 1.0F);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public abstract class BaseSmokeParticle extends DimmableParticle {
public static final float SMOKE_GRAVITY = -0.1F;

protected BaseSmokeParticle(ClientLevel level, double x, double y, double z) {
this(level, x, y, z, 0.0D, 0.0D, 0.0D, 3.0F);
this(level, x, y, z, 0, 0, 0, 3.0F);
}

protected BaseSmokeParticle(ClientLevel level, double x, double y, double z, double dx, double dy,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mods.railcraft.client.particle;

import mods.railcraft.client.util.RenderUtil;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.level.material.MapColor;
Expand All @@ -19,11 +20,11 @@ public ChimneyParticle(ClientLevel level, double x, double y, double z, double d
super(level, x, y, z, dx, dy, dz, scale);
this.gravity = SMOKE_GRAVITY;
this.rCol =
Mth.clamp((this.random.nextFloat() * 0.1f - 0.05f) + ((color >> 16) & 0xFF) / 255f, 0f, 1f);
Mth.clamp((this.random.nextFloat() * 0.1f - 0.05f) + RenderUtil.getRed(color), 0, 1);
this.gCol =
Mth.clamp((this.random.nextFloat() * 0.1f - 0.05f) + ((color >> 8) & 0xFF) / 255f, 0f, 1f);
Mth.clamp((this.random.nextFloat() * 0.1f - 0.05f) + RenderUtil.getGreen(color), 0, 1);
this.bCol =
Mth.clamp((this.random.nextFloat() * 0.1f - 0.05f) + ((color) & 0xFF) / 255f, 0f, 1f);
Mth.clamp((this.random.nextFloat() * 0.1f - 0.05f) + RenderUtil.getBlue(color), 0, 1);
this.lifetime = (int) ((24.0F / (this.random.nextFloat() * 0.5F + 0.2F)) * scale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ protected DimmableParticle(
@Override
public int getLightColor(float partialTicks) {
int lightColor = super.getLightColor(partialTicks);
float progress = (float) this.age / (float) this.lifetime;
progress *= progress;
progress *= progress;
double progress = Math.pow((double) this.age / this.lifetime, 3);
int var4 = lightColor & 255;
int var5 = lightColor >> 16 & 255;
var5 += (int) (progress * 15.0F * 16.0F);
var5 += (int) (progress * 15 * 16);

if (var5 > 240) {
var5 = 240;
Expand Down

0 comments on commit a70d940

Please sign in to comment.