Skip to content

Commit

Permalink
clean redundant casts
Browse files Browse the repository at this point in the history
  • Loading branch information
aurilisdev committed Jan 28, 2025
1 parent 38c4830 commit 6b1d275
Show file tree
Hide file tree
Showing 21 changed files with 54 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/main/java/electrodynamics/api/gas/GasStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public int getVolumeChangeFromHeating(int deltaTemp) {
throw new UnsupportedOperationException("The temperature cannot drop below absolute zero");
}

double change = (deltaTemp + (double) temperature) / (double) temperature;
double change = (deltaTemp + (double) temperature) / temperature;

return (int) Math.ceil(amount * change);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public SWBFClientExtensions(SimpleWaterBasedFluidType fluidType) {
this.fluidType = fluidType;
}

@Override
public ResourceLocation getStillTexture() {
return fluidType.texture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ParticleFluidDrop(ClientLevel level, double x, double y, double z, double
setSpriteFromAge(sprites);
setColor(options.r, options.g, options.b);
int i = (int)(8.0 / (this.random.nextDouble() * 0.8 + 0.2));
this.lifetime = (int)Math.max((float)i * options.scale, 1.0F);
this.lifetime = (int)Math.max(i * options.scale, 1.0F);
}

@Override
Expand All @@ -35,7 +35,7 @@ public ParticleRenderType getRenderType() {

@Override
public float getQuadSize(float scaleFactor) {
return this.quadSize * Mth.clamp(((float)this.age + scaleFactor) / (float)this.lifetime * 32.0F, 0.0F, 1.0F);
return this.quadSize * Mth.clamp((this.age + scaleFactor) / this.lifetime * 32.0F, 0.0F, 1.0F);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public int getLightColor(float partialTick) {

@Override
public float getQuadSize(float scaleFactor) {
float f = ((float) this.age + scaleFactor) / (float) this.lifetime;
float f = (this.age + scaleFactor) / this.lifetime;
return this.quadSize * (1.0F - f * f);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ScreenSeismicScanner(ContainerSeismicScanner container, Inventory inv, Co
graphics.renderComponentTooltip(getFontRenderer(), tooltips, xAxis, yAxis);
}).setOnPress(but -> {

ScreenComponentButton<?> button = (ScreenComponentButton<?>) but;
ScreenComponentButton<?> button = but;

componentsToHide.forEach(component -> {
component.setActive(button.isPressed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public ScreenElectrolosisChamber(ContainerElectrolosisChamber container, Invento
int width = getFontRenderer().width(text);
float scale = 1;
if(width > 70) {
scale = 70.0F / (float) width;
scale = 70.0F / width;
width = 70;
}
int diff = 70 - width;
int half = diff / 2;
int x = (int) Math.ceil((float) (52 + half) / scale) + 1;
int x = (int) Math.ceil((52 + half) / scale) + 1;
int y = (int) Math.ceil(52.0F / scale);
graphics.pose().pushPose();
graphics.pose().scale(scale, scale, scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public boolean isItem() {
return false;
}

@Override
public boolean isPlayerStorable() {
return this == quarry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void registerColoredBlocks(RegisterColorHandlersEvent.Item event)

double maxHeat = item.getMaxTemp();

double amtPerTier = maxHeat / (double) HEAT_COLORS.length;
double amtPerTier = maxHeat / HEAT_COLORS.length;

int threshhold = (int) (currHeat / amtPerTier);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public TileMultiSubnode(BlockPos worldPosition, BlockState blockState) {
addComponent(new ComponentPacketHandler(this));
}

@Override
@Nullable
public ICapabilityElectrodynamic getElectrodynamicCapability(@Nullable Direction side) {
if (level.getBlockEntity(parentPos.get()) instanceof IMultiblockParentTile node) {
Expand All @@ -45,6 +46,7 @@ public ICapabilityElectrodynamic getElectrodynamicCapability(@Nullable Direction
return null;
}

@Override
@Nullable
public IFluidHandler getFluidHandlerCapability(@Nullable Direction side) {
if (level.getBlockEntity(parentPos.get()) instanceof IMultiblockParentTile node) {
Expand All @@ -53,6 +55,7 @@ public IFluidHandler getFluidHandlerCapability(@Nullable Direction side) {
return null;
}

@Override
@Nullable
public IGasHandler getGasHandlerCapability(@Nullable Direction side) {
if (level.getBlockEntity(parentPos.get()) instanceof IMultiblockParentTile node) {
Expand All @@ -61,6 +64,7 @@ public IGasHandler getGasHandlerCapability(@Nullable Direction side) {
return null;
}

@Override
@Nullable
public IItemHandler getItemHandlerCapability(@Nullable Direction side) {
if (level.getBlockEntity(parentPos.get()) instanceof IMultiblockParentTile node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public void writeConnection(Direction dir, EnumConnectType connection) {
connections.set(masked | (connection.ordinal() << (dir.ordinal() * 4)));
}

@Override
public EnumConnectType[] readConnections() {
EnumConnectType[] connections = new EnumConnectType[6];
for (Direction dir : Direction.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public BiConsumer<GasTank, GenericTile> getCondensedHandler() {

tankGas.bringPressureTo(Gas.PRESSURE_AT_SEA_LEVEL);

FluidStack fluidStack = new FluidStack(fluid, (int) tankGas.getAmount());
FluidStack fluidStack = new FluidStack(fluid, tankGas.getAmount());

outputTank.fill(fluidStack, IFluidHandler.FluidAction.EXECUTE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public void updateAddonTanks(int count, boolean isLeft) {
ComponentGasHandlerMulti handler = getComponent(IComponentType.GasHandler);
ComponentFluidHandlerMulti multi = getComponent(IComponentType.FluidHandler);
if (isLeft) {
multi.getInputTanks()[0].setCapacity((int) (Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * count));
multi.getInputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * count);
handler.getInputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * count);
} else {
multi.getOutputTanks()[0].setCapacity((int) (Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * count));
multi.getOutputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * count);
handler.getOutputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * count);
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public void updateLit(boolean isHeating, Direction facing) {

@Override
public IComponentFluidHandler getFluidHandler() {
return new ComponentFluidHandlerMulti.ComponentFluidHandlerMultiBiDirec(this).setInputDirections(BlockEntityUtils.MachineDirection.BOTTOM).setInputTanks(1, arr((int) Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY)).setOutputDirections(BlockEntityUtils.MachineDirection.BOTTOM).setOutputTanks(1, arr((int) Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY));
return new ComponentFluidHandlerMulti.ComponentFluidHandlerMultiBiDirec(this).setInputDirections(BlockEntityUtils.MachineDirection.BOTTOM).setInputTanks(1, arr(Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY)).setOutputDirections(BlockEntityUtils.MachineDirection.BOTTOM).setOutputTanks(1, arr(Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void updateLit(boolean isHeating, Direction facing) {

@Override
public IComponentFluidHandler getFluidHandler() {
return new ComponentFluidHandlerMulti(this).setInputTanks(1, (int) Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY).setInputDirections(BlockEntityUtils.MachineDirection.BACK).setOutputTanks(1, (int) Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY).setOutputDirections(BlockEntityUtils.MachineDirection.FRONT);
return new ComponentFluidHandlerMulti(this).setInputTanks(1, Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY).setInputDirections(BlockEntityUtils.MachineDirection.BACK).setOutputTanks(1, Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY).setOutputDirections(BlockEntityUtils.MachineDirection.FRONT);
}

@Override
Expand Down Expand Up @@ -97,9 +97,9 @@ public void updateTankCount() {
}
ComponentGasHandlerMulti handler = getComponent(IComponentType.GasHandler);
ComponentFluidHandlerMulti multi = getComponent(IComponentType.FluidHandler);
multi.getInputTanks()[0].setCapacity((int) (Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * tankCount));
multi.getInputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * tankCount);
handler.getInputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_INPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * tankCount);
multi.getOutputTanks()[0].setCapacity((int) (Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * tankCount));
multi.getOutputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * tankCount);
handler.getOutputTanks()[0].setCapacity(Constants.GAS_TRANSFORMER_BASE_OUTPUT_CAPCITY + Constants.GAS_TRANSFORMER_ADDON_TANK_CAPCITY * tankCount);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public List<GasStack> getGasOutputs(ChemicalReactorRecipe recipe) {
return outputs;
}

@Override
public void setItemInputs(List<List<ItemStack>> inputs, IRecipeLayoutBuilder builder) {
SlotDataWrapper wrapper;
for (int i = 0; i < inputSlotWrappers.length; i++) {
Expand All @@ -214,6 +215,7 @@ public void setItemInputs(List<List<ItemStack>> inputs, IRecipeLayoutBuilder bui
}
}

@Override
public void setItemOutputs(List<ItemStack> outputs, IRecipeLayoutBuilder builder) {
SlotDataWrapper wrapper;
for (int i = 0; i < outputSlotWrappers.length; i++) {
Expand All @@ -228,6 +230,7 @@ public void setItemOutputs(List<ItemStack> outputs, IRecipeLayoutBuilder builder
}
}

@Override
public void setFluidInputs(List<List<FluidStack>> inputs, IRecipeLayoutBuilder builder) {
AbstractFluidGaugeObject wrapper;
RecipeIngredientRole role = RecipeIngredientRole.INPUT;
Expand Down Expand Up @@ -270,6 +273,7 @@ public void setFluidInputs(List<List<FluidStack>> inputs, IRecipeLayoutBuilder b
}
}

@Override
public void setFluidOutputs(List<FluidStack> outputs, IRecipeLayoutBuilder builder) {
AbstractFluidGaugeObject wrapper;
RecipeIngredientRole role = RecipeIngredientRole.OUTPUT;
Expand Down Expand Up @@ -301,6 +305,7 @@ public void setFluidOutputs(List<FluidStack> outputs, IRecipeLayoutBuilder build
}
}

@Override
public void setGasInputs(List<List<GasStack>> inputs, IRecipeLayoutBuilder builder) {

AbstractGasGaugeObject wrapper;
Expand Down Expand Up @@ -339,11 +344,12 @@ public void setGasInputs(List<List<GasStack>> inputs, IRecipeLayoutBuilder build

int oneMinusHeight = wrapper.getHeight() - height;

builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredients(ElectrodynamicsJeiTypes.GAS_STACK, stacks).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack((int) maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredients(ElectrodynamicsJeiTypes.GAS_STACK, stacks).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack(maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
}

}

@Override
public void setGasOutputs(List<GasStack> outputs, IRecipeLayoutBuilder builder) {

AbstractGasGaugeObject wrapper;
Expand Down Expand Up @@ -376,7 +382,7 @@ public void setGasOutputs(List<GasStack> outputs, IRecipeLayoutBuilder builder)

int oneMinusHeight = wrapper.getHeight() - height;

builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredient(ElectrodynamicsJeiTypes.GAS_STACK, stack).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack((int) maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredient(ElectrodynamicsJeiTypes.GAS_STACK, stack).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack(maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void setGasInputs(List<List<GasStack>> inputs, IRecipeLayoutBuilder build

int oneMinusHeight = wrapper.getHeight() - height;

builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredients(ElectrodynamicsJeiTypes.GAS_STACK, stacks).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack((int) maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredients(ElectrodynamicsJeiTypes.GAS_STACK, stacks).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack(maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
}

}
Expand Down Expand Up @@ -362,7 +362,7 @@ public void setGasOutputs(List<GasStack> outputs, IRecipeLayoutBuilder builder)

int oneMinusHeight = wrapper.getHeight() - height;

builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredient(ElectrodynamicsJeiTypes.GAS_STACK, stack).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack((int) maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
builder.addSlot(role, wrapper.getX() + 1, wrapper.getY() + wrapper.getHeight() - height).addIngredient(ElectrodynamicsJeiTypes.GAS_STACK, stack).setCustomRenderer(ElectrodynamicsJeiTypes.GAS_STACK, new IngredientRendererGasStack(maxGaugeCap, -oneMinusHeight + 1, height, wrapper.getBarsTexture()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void render(GuiGraphics graphics, GasStack ingredient) {

stack.pushPose();

float amt = (float) ingredient.getAmount();
float amt = ingredient.getAmount();

if (amt < tankAmount / 50) {
double amtPowTen = Math.pow(10, Math.round(Math.log10(amt) - Math.log10(5.5) + 0.5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public ScreenComponentVerticalSlider setClickConsumer(Consumer<Integer> responde
return this;
}

@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
if (isValidClick(button)) {
this.onMouseDrag(mouseX, mouseY, dragX, dragY);
Expand Down Expand Up @@ -75,7 +76,7 @@ public void renderBackground(GuiGraphics graphics, int xAxis, int yAxis, int gui

graphics.blit(bg.getLocation(), guiWidth + xLocation - 1, guiHeight + yLocation, width, 1, bg.textureU(), bg.textureV(), bg.textureWidth(), 1, bg.imageWidth(), bg.imageHeight());

int permutations = (int) ((double) (height - 2) / 28.0D);
int permutations = (int) ((height - 2) / 28.0D);

int remainder = height - permutations * 28 - 2;

Expand Down Expand Up @@ -148,31 +149,38 @@ private VerticalSliderTextures(int textureWidth, int textureHeight, int textureU
this.loc = loc;
}

public ResourceLocation getLocation() {
@Override
public ResourceLocation getLocation() {
return this.loc;
}

public int imageHeight() {
@Override
public int imageHeight() {
return this.imageHeight;
}

public int imageWidth() {
@Override
public int imageWidth() {
return this.imageWidth;
}

public int textureHeight() {
@Override
public int textureHeight() {
return this.textureHeight;
}

public int textureU() {
@Override
public int textureU() {
return this.textureU;
}

public int textureV() {
@Override
public int textureV() {
return this.textureV;
}

public int textureWidth() {
@Override
public int textureWidth() {
return this.textureWidth;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public IComponentType getType() {
return IComponentType.FluidHandler;
}

@Override
public IFluidHandler getCapability(@Nullable Direction side, CapabilityInputType inputType) {
if (side == null || !isSided) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public boolean writeConnection(Direction dir, EnumConnectType connection) {
return this.connections.isDirty();
}

@Override
public EnumConnectType[] readConnections() {
return connectionsArr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public BiConsumer<GasTank, GenericTile> getCondensedHandler() {

int room = Math.max(0, MAX_CONDENSED_AMOUNT - currentCondensate.getAmount());

int taken = Math.min(room, (int) tankGas.getAmount());
int taken = Math.min(room, tankGas.getAmount());

currentCondensate.setAmount(currentCondensate.getAmount() + taken);

condensedFluidFromGas.set(currentCondensate);

} else {

FluidStack newFluid = new FluidStack(condensedFluid, Math.min((int) tankGas.getAmount(), MAX_CONDENSED_AMOUNT));
FluidStack newFluid = new FluidStack(condensedFluid, Math.min(tankGas.getAmount(), MAX_CONDENSED_AMOUNT));

condensedFluidFromGas.set(newFluid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void updateNetwork(Direction[] dirs) {
continue;
}

adjacentNetworks.add((NETWORK) wire.conductor().getNetwork());
adjacentNetworks.add(wire.conductor().getNetwork());

}

Expand Down

0 comments on commit 6b1d275

Please sign in to comment.