Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Sep 24, 2024
1 parent 1594f91 commit 8752541
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
* limitations under the License.
*/

package net.fabricmc.fabric.impl;
package net.fabricmc.fabric.api;

Check failure on line 17 in fabric-api-dev/src/main/java/net/fabricmc/fabric/api/FabricDevProperties.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Name 'net.fabricmc.fabric.api' must match pattern '^net\.fabricmc\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+([a-rt-z]|ss))+\.v[0-9]+|(impl|mixin|test)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+([a-rt-z]|ss))+(\.v[0-9]+)?|api\.(event|util|biomes\.v1|registry|client\.screen|container|block|entity|client\.itemgroup|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$'.

import java.util.function.Supplier;

import com.mojang.brigadier.ParseResults;

import net.minecraft.Bootstrap;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.dedicated.EulaReader;
import net.minecraft.util.collection.Weight;
import net.minecraft.world.Heightmap;

import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.ApiStatus;

Check failure on line 28 in fabric-api-dev/src/main/java/net/fabricmc/fabric/api/FabricDevProperties.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Wrong order for 'org.jetbrains.annotations.ApiStatus' import.

/** Mods should not directly use these fields; they only exist here as a reference of what Dev Properties exist */

Check failure on line 30 in fabric-api-dev/src/main/java/net/fabricmc/fabric/api/FabricDevProperties.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

First sentence should end with a period.
@ApiStatus.Internal
@SuppressWarnings("JavadocReference")
public class FabricDevProperties {
/**

Check failure on line 34 in fabric-api-dev/src/main/java/net/fabricmc/fabric/api/FabricDevProperties.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

First sentence should end with a period.
Expand All @@ -36,33 +37,24 @@ public class FabricDevProperties {
* Default value: true</br>

Check failure on line 37 in fabric-api-dev/src/main/java/net/fabricmc/fabric/api/FabricDevProperties.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Extra HTML tag found: </br>
* {@link Weight#validate(int)}
*/
public static final boolean ZERO_WEIGHT_WARNING = getProperty("zeroWeightWarning", true);
public static final boolean ZERO_WEIGHT_WARNING = getProperty("zeroWeightWarning");

/**

Check failure on line 42 in fabric-api-dev/src/main/java/net/fabricmc/fabric/api/FabricDevProperties.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

First sentence should end with a period.
* Logs an error when a translation is missing</br>
* Property: <code>fabric.dev.logMissingTranslations</code></br>
* Default value: true</br>
* {@link Bootstrap#logMissing()}
*/
public static final boolean LOG_MISSING_TRANSLATIONS = getProperty("logMissingTranslations", true);
public static final boolean LOG_MISSING_TRANSLATIONS = getProperty("logMissingTranslations");

/**
* Logs an error if Block classes don't end with Block and if Item classes don't end with Item</br>
* Logs an error if Block classes don't end with "Block" and if Item classes don't end with "Item"</br>
* Property: <code>fabric.dev.logConventionIssues</code></br>
* Default value: true</br>
* {@link net.minecraft.block.Block#Block} and {@link net.minecraft.item.Item#Item}
*/
public static final boolean LOG_CONVENTION_ISSUES = getProperty("logConventionIssues", true);

/**
* Skips creating the eula.txt file and always agrees to the EULA</br>
* <strong>Note: By enabling this, you declare that you have agreed to the EULA.</strong></br>
* Property: <code>fabric.dev.alwaysAgreeToEula</code></br>
* Default value: false</br>
* {@link net.minecraft.server.dedicated.EulaReader#EulaReader} and {@link EulaReader#createEulaFile()}
*/
public static final boolean ALWAYS_AGREE_TO_EULA = getProperty("alwaysAgreeToEula", false);

public static final boolean LOG_BLOCK_AND_ITEM_CONVENTION_ISSUES = getProperty("logBlockAndItemConventionIssues");

/**
* Registers Minecraft's debug commands
* (TestCommand, RaidCommand, DebugPathCommand, DebugMobSpawningCommand,
Expand All @@ -72,47 +64,47 @@ public class FabricDevProperties {
* Default value: true</br>
* {@link CommandManager#CommandManager}
*/
public static final boolean REGISTER_DEBUG_COMMANDS = getProperty("registerDebugCommands", true);
public static final boolean REGISTER_DEBUG_COMMANDS = getProperty("registerDebugCommands");

/**
* Logs an error if a command threw an exception</br>
* Property: <code>fabric.dev.enableCommandExceptionLogging</code></br>
* Default value: true</br>
* {@link CommandManager#execute(ParseResults, String)}
*/
public static final boolean ENABLE_COMMAND_EXCEPTION_LOGGING = getProperty("enableCommandExceptionLogging", true);
public static final boolean ENABLE_COMMAND_EXCEPTION_LOGGING = getProperty("enableCommandExceptionLogging");

/**
* Logs an error regarding argument ambiguity and throws an exception if an argument type is not registered</br>
* Property: <code>fabric.dev.enableCommandArgumentLogging</code></br>
* Default value: true</br>
* {@link CommandManager#checkMissing()}
*/
public static final boolean ENABLE_COMMAND_ARGUMENT_LOGGING = getProperty("enableCommandArgumentLogging", true);
public static final boolean ENABLE_COMMAND_ARGUMENT_LOGGING = getProperty("enableCommandArgumentLogging");

/**
* Throw's an exception if a bounding box is invalid</br>
* Property: <code>fabric.dev.throwOnInvalidBlockBoxes</code></br>
* Default value: true</br>
* {@link net.minecraft.util.math.BlockBox#BlockBox(int, int, int, int, int, int)}
*/
public static final boolean THROW_ON_INVALID_BLOCK_BOXES = getProperty("throwOnInvalidBlockBoxes", true);
public static final boolean THROW_ON_INVALID_BLOCK_BOXES = getProperty("throwOnInvalidBlockBoxes");

/**
* Logs an error if the heightmap is null</br>
* Property: <code>fabric.dev.enableUnprimedHeightmapLogging</code></br>
* Default value: true</br>
* {@link net.minecraft.world.chunk.Chunk#sampleHeightmap(Heightmap.Type, int, int)}
*/
public static final boolean ENABLE_UNPRIMED_HEIGHTMAP_LOGGING = getProperty("enableUnprimedHeightmapLogging", true);
public static final boolean ENABLE_UNPRIMED_HEIGHTMAP_LOGGING = getProperty("enableUnprimedHeightmapLogging");

/**
* Set's the current thread's name to the activeThreadName if debugRunnable or debugSupplier is called</br>
* Property: <code>fabric.dev.enableSupplierAndRunnableDebugging</code></br>
* Default value: false</br>
* {@link net.minecraft.util.Util#debugRunnable(String, Runnable)} and {@link net.minecraft.util.Util#debugSupplier(String, Supplier)}
*/
public static final boolean ENABLE_SUPPLIER_AND_RUNNABLE_DEBUGGING = getProperty("enableSupplierAndRunnableDebugging", false);
public static final boolean ENABLE_SUPPLIER_AND_RUNNABLE_DEBUGGING = getProperty("enableSupplierAndRunnableDebugging");

/**
* Invokes a method in which you should have a breakpoint to debug errors
Expand All @@ -122,14 +114,9 @@ public class FabricDevProperties {
* {@link net.minecraft.util.Util#error(String)}, {@link net.minecraft.util.Util#error(String, Throwable)}
* and {@link net.minecraft.util.Util#throwOrPause(Throwable)}
*/
public static final boolean ENABLE_EXCEPTION_IDE_PAUSING = getProperty("enableExceptionIdePausing", true);

private static final boolean IS_DEVELOPMENT_ENV = FabricLoader.getInstance().isDevelopmentEnvironment();
public static final boolean ENABLE_EXCEPTION_IDE_PAUSING = getProperty("enableExceptionIdePausing");

private static boolean getProperty(String name, boolean defaultValue) {
String propertyValue = System.getProperty("fabric.dev" + name);
if (propertyValue == null || propertyValue.isEmpty())
return IS_DEVELOPMENT_ENV && defaultValue;
return "true".equalsIgnoreCase(propertyValue);
private static boolean getProperty(String name) {
return Boolean.getBoolean("fabric.dev." + name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import net.minecraft.block.Block;
import net.minecraft.item.Item;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin({Block.class, Item.class})
public class BlockAndItemMixin {
@ModifyExpressionValue(method = {
"<init>(Lnet/minecraft/block/AbstractBlock$Settings;)V",
"<init>(Lnet/minecraft/item/Item$Settings;)V"
}, at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private boolean mevIsDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.LOG_CONVENTION_ISSUES;
private boolean isDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.LOG_BLOCK_AND_ITEM_CONVENTION_ISSUES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

import net.minecraft.util.math.BlockBox;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin(BlockBox.class)
public class BlockBoxMixin {
@ModifyExpressionValue(method = "<init>(IIIIII)V", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private boolean mevIsDevelopmentForDevModule(boolean original) {
private boolean isDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.THROW_ON_INVALID_BLOCK_BOXES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

import net.minecraft.Bootstrap;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin(Bootstrap.class)
public class BootstrapMixin {
@ModifyExpressionValue(method = "logMissing", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private static boolean mevIsDevelopmentForDevModule(boolean original) {
private static boolean isDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.LOG_MISSING_TRANSLATIONS || FabricDevProperties.ENABLE_COMMAND_ARGUMENT_LOGGING;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

import net.minecraft.world.chunk.Chunk;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin(Chunk.class)
public class ChunkMixin {
@ModifyExpressionValue(method = "sampleHeightmap", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private boolean mevIsDevelopmentForDevModule(boolean original) {
private boolean isDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.ENABLE_UNPRIMED_HEIGHTMAP_LOGGING;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@

import net.minecraft.server.command.CommandManager;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin(CommandManager.class)
public class CommandManagerMixin {
@ModifyExpressionValue(method = "<init>", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private static boolean mevIsDevelopmentForDevModule(boolean original) {
private static boolean isDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.REGISTER_DEBUG_COMMANDS;
}

@ModifyExpressionValue(method = "execute", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private static boolean mevIsDevelopmentForDevModule2(boolean original) {
private static boolean isDevelopmentForDevModule2(boolean original) {
return original || FabricDevProperties.ENABLE_COMMAND_EXCEPTION_LOGGING;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@

import net.minecraft.util.Util;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin(Util.class)
public class UtilMixin {
@ModifyExpressionValue(method = {
"debugRunnable(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
"debugSupplier(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;"
}, at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private static boolean mevIsDevelopmentForDevModule2(boolean original) {
private static boolean isDevelopmentForDevModule2(boolean original) {
return original || FabricDevProperties.ENABLE_SUPPLIER_AND_RUNNABLE_DEBUGGING;
}

@ModifyExpressionValue(method = {"error(Ljava/lang/String;)V", "error(Ljava/lang/String;Ljava/lang/Throwable;)V", "throwOrPause"}, at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private static boolean mevIsDevelopmentForDevModule3(boolean original) {
private static boolean isDevelopmentForDevModule3(boolean original) {
return original || FabricDevProperties.ENABLE_EXCEPTION_IDE_PAUSING;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

import net.minecraft.util.collection.Weight;

import net.fabricmc.fabric.impl.FabricDevProperties;
import net.fabricmc.fabric.api.FabricDevProperties;

@Mixin(Weight.class)
public class WeightMixin {
@ModifyExpressionValue(method = "validate", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private static boolean mevIsDevelopmentForDevModule(boolean original) {
private static boolean isDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.ZERO_WEIGHT_WARNING;
}
}
3 changes: 1 addition & 2 deletions fabric-api-dev/src/main/resources/fabric-api-dev.mixins.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"required": true,
"package": "net.fabricmc.fabric.mixin.dev",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
"BlockAndItemMixin",
"BlockBoxMixin",
"BootstrapMixin",
"ChunkMixin",
"CommandManagerMixin",
"EulaReaderMixin",
"UtilMixin",
"WeightMixin"
],
Expand Down
2 changes: 1 addition & 1 deletion fabric-api-dev/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "fabric-api-dev",
"name": "Fabric API Dev Utilities",
"name": "Fabric API Dev Tools",
"version": "${version}",
"environment": "*",
"license": "Apache-2.0",
Expand Down

0 comments on commit 8752541

Please sign in to comment.