Skip to content

Commit ae1f62d

Browse files
committed
chore: 🔧 spotless / pmd setup and a bit of cleanup
1 parent 6ad7700 commit ae1f62d

266 files changed

Lines changed: 2857 additions & 3983 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ plugins {
33
id 'idea'
44
id 'maven-publish'
55
id 'net.neoforged.moddev' version '1.0.14'
6-
id "org.sonarqube" version "5.0.0.4638"
76
id "net.darkhax.curseforgegradle" version "1.1.15"
87
id "com.modrinth.minotaur" version "2.+"
98
id "com.diffplug.spotless" version "7.0.4"
9+
id "org.openrewrite.rewrite" version "7.35.0"
1010
}
1111

1212
idea {
@@ -24,7 +24,7 @@ spotless {
2424
target spotlessFiles == null ? "src/*/java/**/*.java" : spotlessFiles.toString().split(/\s*,\s*/).findAll { it.endsWith(".java") }
2525

2626
eclipse().configFile "$projectDir/codeformat/eclipse-java-format.xml"
27-
importOrder "", "javax", "java"
27+
importOrder "", "javax", "java", "\\#"
2828
removeUnusedImports()
2929
trimTrailingWhitespace()
3030
endWithNewline()
@@ -256,9 +256,5 @@ tasks.modrinth {
256256
onlyIf { !project.ext.changelog.isEmpty() }
257257
}
258258

259-
sonar {
260-
properties {
261-
property "sonar.projectKey", "xreliquary:Reliquary"
262-
property "sonar.organization", "p3pp3rf1y-github"
263-
}
264-
}
259+
def sharedCodeQualityScript = file('../gradle/code-quality.gradle')
260+
apply from: sharedCodeQualityScript.exists() ? sharedCodeQualityScript : 'https://raw.githubusercontent.com/P3pp3rF1y/MultiWorkspace/1.21.x/gradle/code-quality.gradle'

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ pluginManagement {
88

99
plugins {
1010
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
11-
}
11+
}

src/main/java/reliquary/Reliquary.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public class Reliquary {
2929
public static final String MOD_ID = "reliquary";
3030
private static String networkProtocolVersion;
3131

32-
33-
@SuppressWarnings("java:S1118") //needs to be public for mod to work
32+
@SuppressWarnings("java:S1118") // needs to be public for mod to work
3433
public Reliquary(IEventBus modBus, Dist dist, ModContainer container) {
3534
networkProtocolVersion = container.getModInfo().getVersion().toString();
3635
NeoForgeMod.enableMilkFluid();

src/main/java/reliquary/api/IPedestal.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
99

1010
import javax.annotation.Nullable;
11+
1112
import java.util.List;
1213
import java.util.Optional;
1314

src/main/java/reliquary/api/client/package-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Auto generated package-info by MCP
22

3-
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
3+
@ParametersAreNonnullByDefault
4+
@MethodsReturnNonnullByDefault
45
package reliquary.api.client;
56

67
import net.minecraft.MethodsReturnNonnullByDefault;

src/main/java/reliquary/api/package-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
// Auto generated package-info by MCP
33

4-
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
4+
@ParametersAreNonnullByDefault
5+
@MethodsReturnNonnullByDefault
56
package reliquary.api;
67

78
import net.minecraft.MethodsReturnNonnullByDefault;

src/main/java/reliquary/block/AlkahestryAltarBlock.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import reliquary.util.BlockEntityHelper;
3434

3535
import javax.annotation.Nullable;
36+
3637
import java.util.function.Consumer;
3738

3839
public class AlkahestryAltarBlock extends Block implements EntityBlock, ICreativeTabItemGenerator {
@@ -80,14 +81,17 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, Block
8081

8182
@Override
8283
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rand) {
83-
if (Boolean.FALSE.equals(state.getValue(ACTIVE)) || level.getDayTime() >= 12000 || !level.canSeeSkyFromBelowWater(pos.above()) || rand.nextInt(3) != 0) {
84+
if (Boolean.FALSE.equals(state.getValue(ACTIVE)) || level.getDayTime() >= 12000 || !level.canSeeSkyFromBelowWater(pos.above())
85+
|| rand.nextInt(3) != 0) {
8486
return;
8587
}
86-
level.addParticle(ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, 0.9F, 0.9F, 0.0F), pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 1.1D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0D, 0D, 0D);
88+
level.addParticle(ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, 0.9F, 0.9F, 0.0F), pos.getX() + 0.5D + rand.nextGaussian() / 8,
89+
pos.getY() + 1.1D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0D, 0D, 0D);
8790
}
8891

8992
@Override
90-
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult p_316140_) {
93+
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
94+
BlockHitResult p_316140_) {
9195
if (Boolean.TRUE.equals(state.getValue(ACTIVE))) {
9296
return ItemInteractionResult.CONSUME;
9397
}
@@ -118,9 +122,11 @@ protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state,
118122
}
119123

120124
private void playSoundAndSpawnParticles(Level level, BlockPos pos, AlkahestryAltarBlockEntity altar) {
121-
level.playSound(null, pos, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3F, 0.5F + 0.5F * altar.getRedstoneCount() + (float) (level.random.nextGaussian() / 8));
125+
level.playSound(null, pos, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3F,
126+
0.5F + 0.5F * altar.getRedstoneCount() + (float) (level.random.nextGaussian() / 8));
122127
for (int particles = level.random.nextInt(3); particles < 3 + altar.getRedstoneCount() * 4 + altar.getRedstoneCount(); particles++) {
123-
level.addParticle(DustParticleOptions.REDSTONE, pos.getX() + 0.5D + level.random.nextGaussian() / 5, pos.getY() + 1.2D, pos.getZ() + 0.5D + level.random.nextGaussian() / 5, 1D, 0D, 0D);
128+
level.addParticle(DustParticleOptions.REDSTONE, pos.getX() + 0.5D + level.random.nextGaussian() / 5, pos.getY() + 1.2D,
129+
pos.getZ() + 0.5D + level.random.nextGaussian() / 5, 1D, 0D, 0D);
124130
}
125131
}
126132

src/main/java/reliquary/block/ApothecaryCauldronBlock.java

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,18 @@
3131
import reliquary.util.WorldHelper;
3232

3333
import javax.annotation.Nullable;
34+
3435
import java.util.function.Consumer;
3536
import java.util.stream.Stream;
3637

3738
public class ApothecaryCauldronBlock extends Block implements EntityBlock, ICreativeTabItemGenerator {
3839

3940
public static final IntegerProperty LEVEL = IntegerProperty.create("level", 0, 3);
4041
private static final VoxelShape INSIDE = box(2.0D, 4.0D, 2.0D, 14.0D, 16.0D, 14.0D);
41-
private static final VoxelShape SHAPE = Stream.of(
42-
Block.box(1, 1, 1, 15, 2, 15),
43-
Block.box(2, 0, 2, 4, 1, 4),
44-
Block.box(12, 0, 2, 14, 1, 4),
45-
Block.box(12, 0, 12, 14, 1, 14),
46-
Block.box(2, 0, 12, 4, 1, 14),
47-
Block.box(0, 2, 0, 16, 13, 2),
48-
Block.box(0, 2, 14, 16, 13, 16),
49-
Block.box(14, 2, 2, 16, 13, 14),
50-
Block.box(0, 2, 2, 2, 13, 14),
51-
Block.box(1, 13, 2, 2, 14, 14),
52-
Block.box(1, 13, 1, 15, 14, 2),
53-
Block.box(1, 13, 14, 15, 14, 15),
54-
Block.box(14, 13, 2, 15, 14, 14),
55-
Block.box(0, 14, 2, 2, 16, 14),
56-
Block.box(0, 14, 0, 16, 16, 2),
57-
Block.box(14, 14, 2, 16, 16, 14),
58-
Block.box(0, 14, 14, 16, 16, 16)
59-
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
42+
private static final VoxelShape SHAPE = Stream.of(box(1, 1, 1, 15, 2, 15), box(2, 0, 2, 4, 1, 4), box(12, 0, 2, 14, 1, 4), box(12, 0, 12, 14, 1, 14),
43+
box(2, 0, 12, 4, 1, 14), box(0, 2, 0, 16, 13, 2), box(0, 2, 14, 16, 13, 16), box(14, 2, 2, 16, 13, 14), box(0, 2, 2, 2, 13, 14),
44+
box(1, 13, 2, 2, 14, 14), box(1, 13, 1, 15, 14, 2), box(1, 13, 14, 15, 14, 15), box(14, 13, 2, 15, 14, 14), box(0, 14, 2, 2, 16, 14),
45+
box(0, 14, 0, 16, 16, 2), box(14, 14, 2, 16, 16, 14), box(0, 14, 14, 16, 16, 16)).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
6046

6147
public ApothecaryCauldronBlock() {
6248
super(Properties.of().mapColor(MapColor.METAL).strength(1.5F, 5.0F).noOcclusion());
@@ -97,7 +83,8 @@ public void entityInside(BlockState state, Level level, BlockPos pos, Entity ent
9783
}
9884

9985
@Override
100-
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
86+
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
87+
BlockHitResult hitResult) {
10188
if (level.isClientSide) {
10289
return !heldItem.isEmpty() ? ItemInteractionResult.SUCCESS : ItemInteractionResult.CONSUME;
10390
} else {
@@ -122,18 +109,16 @@ public void handlePrecipitation(BlockState state, Level level, BlockPos pos, Bio
122109
}
123110

124111
/**
125-
* If this returns true, then comparators facing away from this block will
126-
* use the value from getComparatorInputOverride instead of the actual
127-
* redstone signal strength.
112+
* If this returns true, then comparators facing away from this block will use the value from getComparatorInputOverride instead of the actual redstone
113+
* signal strength.
128114
*/
129115
@Override
130116
public boolean hasAnalogOutputSignal(BlockState state) {
131117
return true;
132118
}
133119

134120
/**
135-
* If hasComparatorInputOverride returns true, the return value from this is
136-
* used instead of the redstone signal strength when this block inputs to a
121+
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal strength when this block inputs to a
137122
* comparator.
138123
*/
139124
@Override

src/main/java/reliquary/block/ApothecaryMortarBlock.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,15 @@
3232
import reliquary.util.WorldHelper;
3333

3434
import javax.annotation.Nullable;
35+
3536
import java.util.function.Consumer;
3637
import java.util.stream.Stream;
3738

3839
public class ApothecaryMortarBlock extends Block implements EntityBlock, ICreativeTabItemGenerator {
3940
public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.Plane.HORIZONTAL);
40-
private static final VoxelShape MORTAR_SHAPE = Stream.of(
41-
Block.box(6, 1.5, 6, 10, 2.5, 10),
42-
Block.box(5, 2.5, 5, 11, 3.5, 11),
43-
Block.box(5, 0, 5, 11, 1.5, 11),
44-
Block.box(4, 3.5, 5, 5, 6.5, 11),
45-
Block.box(11, 3.5, 5, 12, 6.5, 11),
46-
Block.box(5, 3.5, 11, 11, 6.5, 12),
47-
Block.box(5, 3.5, 4, 11, 6.5, 5)
48-
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
41+
private static final VoxelShape MORTAR_SHAPE = Stream.of(box(6, 1.5, 6, 10, 2.5, 10), box(5, 2.5, 5, 11, 3.5, 11), box(5, 0, 5, 11, 1.5, 11),
42+
box(4, 3.5, 5, 5, 6.5, 11), box(11, 3.5, 5, 12, 6.5, 11), box(5, 3.5, 11, 11, 6.5, 12), box(5, 3.5, 4, 11, 6.5, 5))
43+
.reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
4944

5045
public ApothecaryMortarBlock() {
5146
super(Properties.of().mapColor(MapColor.STONE).strength(1.5F, 2.0F));
@@ -80,7 +75,8 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
8075
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
8176
return level.getBlockEntity(pos, ModBlocks.APOTHECARY_MORTAR_TILE_TYPE.get()).map(mortar -> {
8277
if (player.isCrouching()) {
83-
InventoryHelper.executeOnItemHandlerAt(level, pos, state, mortar, itemHandler -> InventoryHelper.tryRemovingLastStack(itemHandler, level, mortar.getBlockPos()));
78+
InventoryHelper.executeOnItemHandlerAt(level, pos, state, mortar,
79+
itemHandler -> InventoryHelper.tryRemovingLastStack(itemHandler, level, mortar.getBlockPos()));
8480
return InteractionResult.SUCCESS;
8581
}
8682

@@ -94,9 +90,10 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockP
9490
}
9591

9692
@Override
97-
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
93+
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
94+
BlockHitResult hitResult) {
9895
return level.getBlockEntity(pos, ModBlocks.APOTHECARY_MORTAR_TILE_TYPE.get()).map(mortar -> {
99-
//if we're in cooldown prevent player from insta inserting essence that they just got from mortar
96+
// if we're in cooldown prevent player from insta inserting essence that they just got from mortar
10097
if (mortar.isInCooldown(level) && heldItem.getItem() == ModItems.POTION_ESSENCE.get()) {
10198
return ItemInteractionResult.FAIL;
10299
}
@@ -114,7 +111,8 @@ protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state,
114111

115112
if (!putItemInSlot) {
116113
if (mortar.usePestle(level)) {
117-
level.playSound(null, pos, soundType.getStepSound(), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
114+
level.playSound(null, pos, soundType.getStepSound(), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F,
115+
soundType.getPitch() * 0.8F);
118116
return ItemInteractionResult.CONSUME;
119117
} else {
120118
return ItemInteractionResult.FAIL;

src/main/java/reliquary/block/FertileLilyPadBlock.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class FertileLilyPadBlock extends BushBlock implements ICreativeTabItemGe
3535
public static final MapCodec<FertileLilyPadBlock> CODEC = simpleCodec(FertileLilyPadBlock::new);
3636
private static final Map<ResourceKey<Level>, Long> currentDimensionTicks = new HashMap<>();
3737
private static final Map<ResourceKey<Level>, Set<BlockPos>> dimensionPositionsTicked = new HashMap<>();
38-
private static final VoxelShape AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 1.5D, 15.0D);
38+
private static final VoxelShape AABB = box(1.0D, 0.0D, 1.0D, 15.0D, 1.5D, 15.0D);
3939

4040
public FertileLilyPadBlock() {
4141
super(Properties.of().mapColor(MapColor.PLANT));
@@ -74,7 +74,8 @@ public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource
7474

7575
@Override
7676
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rand) {
77-
level.addParticle(ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, 0.0F, 0.9F, 0.5F), pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY(), pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0D, 0D, 0D);
77+
level.addParticle(ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, 0.0F, 0.9F, 0.5F), pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY(),
78+
pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0D, 0D, 0D);
7879
}
7980

8081
private int secondsBetweenGrowthTicks() {
@@ -123,7 +124,8 @@ private boolean isGrowable(Block cropBlock) {
123124
return true;
124125
}
125126

126-
return cropBlock instanceof SpecialPlantable || cropBlock instanceof BonemealableBlock || cropBlock.asItem().builtInRegistryHolder().is(Tags.Items.CROPS);
127+
return cropBlock instanceof SpecialPlantable || cropBlock instanceof BonemealableBlock
128+
|| cropBlock.asItem().builtInRegistryHolder().is(Tags.Items.CROPS);
127129
}
128130

129131
private int getNumberOfPotencySteps() {

0 commit comments

Comments
 (0)