Skip to content

Commit

Permalink
[#486] Fixed that the player detector will not detect players in diff…
Browse files Browse the repository at this point in the history
…erent dimensions. But only if the max range is set to infinite(-1) while the config option `playerDetMultiDimensional` is set to true

Added a new checkstyle rule for singleline if statements
  • Loading branch information
SirEndii committed Aug 5, 2023
1 parent b968192 commit b65b81a
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 121 deletions.
26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -271,30 +271,30 @@ dependencies {

// Extended requirements
// We don't use the api since we need a specific class from mekanism
implementation fg.deobf("mekanism:Mekanism:${mekanism_version}")
compileOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")

// Applied Energistics 2
implementation fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
compileOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
// Curios
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")

// Refined Storage
implementation fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") {
compileOnly fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") {
transitive false
}

// AE2 Things
compileOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources")
runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources")
//runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources")

// AE2 Additions
compileOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}")
runtimeOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}")
//runtimeOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}")

implementation 'thedarkcolour:kotlinforforge:3.12.0'

// Botania
implementation fg.deobf("vazkii.botania:Botania:${botania_version}")
compileOnly fg.deobf("vazkii.botania:Botania:${botania_version}")

// Minecolonies
// Change to compileOnly when running `runData`
Expand All @@ -305,20 +305,20 @@ dependencies {
compileOnly fg.deobf("com.ldtteam:blockui:${blockui_version}")

//Patchouli
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")
compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")

// Create
implementation fg.deobf("com.simibubi.create:create-${minecraft_version}:${create_version}:all")
compileOnly fg.deobf("com.simibubi.create:create-${minecraft_version}:${create_version}:all")

//Removed until fully ported
//testImplementation fg.deobf("site.siredvin.ttoolkit:ttoolkit-${minecraft_version}:${ttoolkit_version}")

//Powah
implementation fg.deobf("curse.maven:powah-633483:${powah_version}")
implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:8.2.88")
implementation fg.deobf("dev.architectury:architectury-forge:6.2.43")
compileOnly fg.deobf("curse.maven:powah-633483:${powah_version}")
compileOnly fg.deobf("me.shedaniel.cloth:cloth-config-forge:8.2.88")
compileOnly fg.deobf("dev.architectury:architectury-forge:6.2.43")

implementation fg.deobf("curse.maven:crash-utilities-371813:4406293")
compileOnly fg.deobf("curse.maven:crash-utilities-371813:4406293")

testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}"
Expand Down
4 changes: 4 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA,SEMI" />
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="if \(.*\) \S+;"/>
<property name="message" value="Single-line if statements without braces must have a newline after the condition."/>
</module>
<module name="WhitespaceAround">
<property name="ignoreEnhancedForColon" value="false" />
<!-- Allow empty functions -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ public static HudOverlayHandler getInstance() {
}

public static void updateCanvas(List<ARRenderAction> actions) {
if (instance == null) return;
if (instance == null)
return;
instance.canvas.clear();
instance.canvas.addAll(actions);
}

public static void clearCanvas() {
if (instance == null) return;
if (instance == null)
return;
instance.canvas.clear();
}

//TODO: Use the forge Overlay System instead
/*@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRender(RenderGuiEvent.Post event) {
if (event.getWindow() == null) return;
if (event.getWindow() == null)
return;
Minecraft mc = Minecraft.getInstance();
PoseStack matrixStack = event.getMatrixStack();
for (ARRenderAction action : canvas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,16 @@ public static long getTotalItemStorage(IGridNode node) {

while (iterator.hasNext()) {
DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class);
if (entity == null) continue;
if (entity == null)
continue;

InternalInventory inventory = entity.getInternalInventory();

for (int i = 0; i < inventory.size(); i++) {
ItemStack stack = inventory.getStackInSlot(i);

if (stack.isEmpty()) continue;
if (stack.isEmpty())
continue;

if (stack.getItem() instanceof BasicStorageCell cell) {
if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.items().getClass())) {
Expand Down Expand Up @@ -328,14 +330,16 @@ public static long getTotalFluidStorage(IGridNode node) {

while (iterator.hasNext()) {
DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class);
if (entity == null) continue;
if (entity == null)
continue;

InternalInventory inventory = entity.getInternalInventory();

for (int i = 0; i < inventory.size(); i++) {
ItemStack stack = inventory.getStackInSlot(i);

if (stack.isEmpty()) continue;
if (stack.isEmpty())
continue;

if (stack.getItem() instanceof BasicStorageCell cell) {
if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.fluids().getClass())) {
Expand Down Expand Up @@ -374,33 +378,38 @@ public static long getUsedItemStorage(IGridNode node) {

while (iterator.hasNext()) {
DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class);
if (entity == null) continue;
if (entity == null)
continue;

InternalInventory inventory = entity.getInternalInventory();

for (int i = 0; i < inventory.size(); i++) {
ItemStack stack = inventory.getStackInSlot(i);

if (stack.isEmpty()) continue;
if (stack.isEmpty())
continue;

if (stack.getItem() instanceof BasicStorageCell cell) {
int bytesPerType = cell.getBytesPerType(null);

if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.items().getClass())) {
if (stack.getTag() == null) continue;
if (stack.getTag() == null)
continue;
int numOfType = stack.getTag().getLongArray("amts").length;
long numItemsInCell = stack.getTag().getLong("ic");

used += ((int) Math.ceil(((double) numItemsInCell) / 8)) + ((long) bytesPerType * numOfType);
}
} else if (APAddons.aeThingsLoaded && stack.getItem() instanceof DISKDrive disk) {
if (disk.getKeyType().toString().equals("ae2:i")) {
if (stack.getTag() == null) continue;
if (stack.getTag() == null)
continue;
long numBytesInCell = stack.getTag().getLong("ic");
used += numBytesInCell;
}
} else if (APAddons.aeAdditionsLoaded && stack.getItem() instanceof SuperStorageCell) {
if (stack.getTag() == null) continue;
if (stack.getTag() == null)
continue;
long numItemsInCell = stack.getTag().getLong("ic");

used += numItemsInCell;
Expand Down Expand Up @@ -431,7 +440,8 @@ public static long getUsedFluidStorage(IGridNode node) {

while (iterator.hasNext()) {
DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class);
if (entity == null) continue;
if (entity == null)
continue;

InternalInventory inventory = entity.getInternalInventory();

Expand All @@ -442,14 +452,16 @@ public static long getUsedFluidStorage(IGridNode node) {
int bytesPerType = cell.getBytesPerType(null);

if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.fluids().getClass())) {
if (stack.getTag() == null) continue;
if (stack.getTag() == null)
continue;
int numOfType = stack.getTag().getLongArray("amts").length;
long numBucketsInCell = stack.getTag().getLong("ic") / 1000;

used += ((int) Math.ceil(((double) numBucketsInCell) / 8)) + ((long) bytesPerType * numOfType);
}
} else if (APAddons.aeAdditionsLoaded && stack.getItem() instanceof SuperStorageCell superStorageCell) {
if (stack.getTag() == null) continue;
if (stack.getTag() == null)
continue;
long numItemsInCell = stack.getTag().getLong("ic");

used += numItemsInCell;
Expand Down Expand Up @@ -489,14 +501,16 @@ public static List<Object> listCells(IGridNode node) {
if (!iterator.hasNext()) return items;
while (iterator.hasNext()) {
DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class);
if (entity == null) continue;
if (entity == null)
continue;

InternalInventory inventory = entity.getInternalInventory();

for (int i = 0; i < inventory.size(); i++) {
ItemStack stack = inventory.getStackInSlot(i);

if (stack.isEmpty()) continue;
if (stack.isEmpty())
continue;

if (stack.getItem() instanceof BasicStorageCell cell) {
items.add(getObjectFromCell(cell, stack));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void startCrafting() {
}

public void maybeCraft() {
if (startedCrafting || futureJob == null || !futureJob.isDone()) return;
if (startedCrafting || futureJob == null || !futureJob.isDone())
return;
ICraftingPlan job;
try {
job = futureJob.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public void registerOperation(@NotNull IPeripheralOperation<?> operation) {
cooldown = fuelAbility.reduceCooldownAccordingToConsumptionRate(cooldown);
}
MethodResult result = method.apply(context);
if (successCallback != null) successCallback.accept(context);
if (successCallback != null)
successCallback.accept(context);
setCooldown(operation, cooldown);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th
for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) {
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range))
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage);
}
return MethodResult.of(true);
Expand All @@ -139,7 +139,7 @@ public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaE
for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) {
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range))
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage);
}
return MethodResult.of(true);
Expand Down Expand Up @@ -170,7 +170,7 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension)
return MethodResult.of(false, "NOT_SAME_DIMENSION");

if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range))
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage);
return MethodResult.of(true);
});
Expand All @@ -196,7 +196,7 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension)
return MethodResult.of(false, "NOT_SAME_DIMENSION");

if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range))
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage, false);
return MethodResult.of(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public final Object getVisitors() throws LuaException {

List<Object> list = new ArrayList<>();
for (ICivilianData civilian : colony.getVisitorManager().getCivilianDataMap().values()) {
if (!(civilian instanceof IVisitorData visitorData)) continue;
if (!(civilian instanceof IVisitorData visitorData))
continue;
list.add(MineColonies.visitorToObject(visitorData));
}
return list;
Expand Down Expand Up @@ -257,7 +258,8 @@ public final Object getRequests() throws LuaException {
List<IRequest<?>> requests = new ArrayList<>();
for (IToken<?> token : tokens) {
IRequest<?> request = requestManager.getRequestForToken(token);
if (request.getRequest() instanceof IDeliverable) requests.add(request);
if (request.getRequest() instanceof IDeliverable)
requests.add(request);
}

List<Object> result = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public final boolean isWearing(int index) throws LuaException {
public final int getEmptySpace() throws LuaException {
int i = 0;
for (ItemStack stack : getOwnerPlayer().getInventory().items) {
if (stack.isEmpty()) i++;
if (stack.isEmpty())
i++;
}
return i;
}
Expand Down
Loading

0 comments on commit b65b81a

Please sign in to comment.