Skip to content

Commit

Permalink
fix: some sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Nov 3, 2023
1 parent 4313ca5 commit f447ecd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
record NetworkReceiverKey(GlobalPos pos) {
int getDistance(final BlockPos from) {
return (int) Math.sqrt(
Math.pow(from.getX() - pos.pos().getX(), 2)
+ Math.pow(from.getY() - pos.pos().getY(), 2)
+ Math.pow(from.getZ() - pos.pos().getZ(), 2)
Math.pow(from.getX() - (double) pos.pos().getX(), 2)
+ Math.pow(from.getY() - (double) pos.pos().getY(), 2)
+ Math.pow(from.getZ() - (double) pos.pos().getZ(), 2)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier;

public class BlockModelProvider extends net.minecraftforge.client.model.generators.BlockModelProvider {
private static final ResourceLocation EMISSIVE_ALL_CUTOUT = createIdentifier("block/emissive_all_cutout");
private static final ResourceLocation EMISSIVE_NORTH_CUTOUT = createIdentifier("block/emissive_north_cutout");
private static final ResourceLocation NORTH_CUTOUT = createIdentifier("block/north_cutout");
private static final ResourceLocation ALL_CUTOUT = createIdentifier("block/all_cutout");

public BlockModelProvider(final PackOutput output, final ExistingFileHelper existingFileHelper) {
super(output, MOD_ID, existingFileHelper);
}
Expand Down Expand Up @@ -43,12 +48,11 @@ private void registerCables() {
}

private void registerControllers() {
final ResourceLocation base = createIdentifier("block/emissive_all_cutout");
final ResourceLocation off = createIdentifier("block/controller/off");
final ResourceLocation on = createIdentifier("block/controller/on");
Blocks.INSTANCE.getController().forEach((color, id, controller) -> {
final ResourceLocation cutout = createIdentifier("block/controller/cutouts/" + color.getName());
withExistingParent("block/controller/" + color.getName(), base)
withExistingParent("block/controller/" + color.getName(), EMISSIVE_ALL_CUTOUT)
.texture("particle", off)
.texture("all", on)
.texture("cutout", cutout);
Expand All @@ -61,7 +65,7 @@ private void registerGrids(final BlockColorMap<? extends AbstractGridBlock<?>> b
registerEmissiveGrids(name, color.getName(), cutout);
});
final ResourceLocation inactiveCutout = createIdentifier("block/" + name + "/cutouts/inactive");
registerGrids(name, "inactive", inactiveCutout, createIdentifier("block/north_cutout"));
registerGrids(name, "inactive", inactiveCutout, NORTH_CUTOUT);
}

private void registerGrids(final String name,
Expand All @@ -86,7 +90,7 @@ private void registerGrids(final String name,
}

private void registerEmissiveGrids(final String name, final String variantName, final ResourceLocation cutout) {
registerGrids(name, variantName, cutout, createIdentifier("block/emissive_north_cutout"));
registerGrids(name, variantName, cutout, EMISSIVE_NORTH_CUTOUT);
}

private void registerDetectors() {
Expand Down Expand Up @@ -114,36 +118,34 @@ private void registerWirelessTransmitters() {
}

private void registerNetworkReceivers() {
final ResourceLocation emissiveBase = createIdentifier("block/emissive_all_cutout");
final ResourceLocation baseTexture = createIdentifier("block/network_receiver/base");
Blocks.INSTANCE.getNetworkReceiver().forEach((color, id, receiver) -> {
final ResourceLocation cutout = createIdentifier("block/network_receiver/cutouts/" + color.getName());
withExistingParent("block/network_receiver/" + color.getName(), emissiveBase)
withExistingParent("block/network_receiver/" + color.getName(), EMISSIVE_ALL_CUTOUT)
.texture("particle", baseTexture)
.texture("all", baseTexture)
.texture("cutout", cutout);
});
withExistingParent("block/network_receiver/inactive", createIdentifier("block/all_cutout"))
withExistingParent("block/network_receiver/inactive", ALL_CUTOUT)
.texture("particle", baseTexture)
.texture("all", baseTexture)
.texture("cutout", createIdentifier("block/network_receiver/cutouts/inactive"));
}

private void registerNetworkTransmitters() {
final ResourceLocation emissiveBase = createIdentifier("block/emissive_all_cutout");
final ResourceLocation baseTexture = createIdentifier("block/network_transmitter/base");
Blocks.INSTANCE.getNetworkTransmitter().forEach((color, id, receiver) -> {
final ResourceLocation cutout = createIdentifier("block/network_transmitter/cutouts/" + color.getName());
withExistingParent("block/network_transmitter/" + color.getName(), emissiveBase)
withExistingParent("block/network_transmitter/" + color.getName(), EMISSIVE_ALL_CUTOUT)
.texture("particle", baseTexture)
.texture("all", baseTexture)
.texture("cutout", cutout);
});
withExistingParent("block/network_transmitter/inactive", createIdentifier("block/all_cutout"))
withExistingParent("block/network_transmitter/inactive", ALL_CUTOUT)
.texture("particle", baseTexture)
.texture("all", baseTexture)
.texture("cutout", createIdentifier("block/network_transmitter/cutouts/inactive"));
withExistingParent("block/network_transmitter/error", emissiveBase)
withExistingParent("block/network_transmitter/error", EMISSIVE_ALL_CUTOUT)
.texture("particle", baseTexture)
.texture("all", baseTexture)
.texture("cutout", createIdentifier("block/network_transmitter/cutouts/error"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier;

public class ItemModelProvider extends net.minecraftforge.client.model.generators.ItemModelProvider {
private static final String CUTOUT_TEXTURE_KEY = "cutout";
private static final String CABLE_TEXTURE_KEY = "cable";

public ItemModelProvider(final PackOutput output, final ExistingFileHelper existingFileHelper) {
super(output, MOD_ID, existingFileHelper);
}
Expand Down Expand Up @@ -54,7 +57,7 @@ private void registerCables() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cable",
CABLE_TEXTURE_KEY,
createIdentifier("block/cable/" + color.getName()))
);
}
Expand All @@ -65,7 +68,7 @@ private void registerExporters() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cable",
CABLE_TEXTURE_KEY,
createIdentifier("block/cable/" + color.getName())
));
}
Expand All @@ -76,7 +79,7 @@ private void registerImporters() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cable",
CABLE_TEXTURE_KEY,
createIdentifier("block/cable/" + color.getName())
));
}
Expand All @@ -87,7 +90,7 @@ private void registerExternalStorages() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cable",
CABLE_TEXTURE_KEY,
createIdentifier("block/cable/" + color.getName())
));
}
Expand Down Expand Up @@ -158,7 +161,7 @@ private void registerConstructors() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cable",
CABLE_TEXTURE_KEY,
createIdentifier("block/cable/" + color.getName())
));
}
Expand All @@ -169,7 +172,7 @@ private void registerDestructors() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cable",
CABLE_TEXTURE_KEY,
createIdentifier("block/cable/" + color.getName())
));
}
Expand All @@ -180,7 +183,7 @@ private void registerWirelessTransmitters() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cutout",
CUTOUT_TEXTURE_KEY,
createIdentifier("block/wireless_transmitter/cutouts/" + color.getName())
));
}
Expand All @@ -191,7 +194,7 @@ private void registerNetworkReceivers() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cutout",
CUTOUT_TEXTURE_KEY,
createIdentifier("block/network_receiver/cutouts/" + color.getName())
));
}
Expand All @@ -202,7 +205,7 @@ private void registerNetworkTransmitters() {
blocks.forEach((color, id, block) -> singleTexture(
id.getPath(),
base,
"cutout",
CUTOUT_TEXTURE_KEY,
createIdentifier("block/network_transmitter/cutouts/" + color.getName())
));
}
Expand Down

0 comments on commit f447ecd

Please sign in to comment.