Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dev Module #4087

Open
wants to merge 19 commits into
base: 1.21.1
Choose a base branch
from
1 change: 1 addition & 0 deletions fabric-api-dev/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = getSubprojectVersion(project)
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.impl;

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Name 'net.fabricmc.fabric.impl' 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;

@SuppressWarnings("JavadocReference")
public class FabricDevProperties {
/**

Check failure on line 33 in fabric-api-dev/src/main/java/net/fabricmc/fabric/impl/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 weight is set to zero</br>

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Javadoc comment at column 48 has parse error. It is forbidden to close singleton HTML tags. Tag: br.

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Javadoc comment at column 48 has parse error. It is forbidden to close singleton HTML tags. Tag: br.

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Extra HTML tag found: </br>
IThundxr marked this conversation as resolved.
Show resolved Hide resolved
* Property: <code>fabric.dev.zeroWeightWarning</code></br>

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Extra HTML tag found: </br>
* Default value: true</br>

Check failure on line 36 in fabric-api-dev/src/main/java/net/fabricmc/fabric/impl/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);

/**

Check failure on line 41 in fabric-api-dev/src/main/java/net/fabricmc/fabric/impl/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>

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Javadoc comment at column 49 has parse error. It is forbidden to close singleton HTML tags. Tag: br.

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

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Javadoc comment at column 49 has parse error. It is forbidden to close singleton HTML tags. Tag: 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);

/**
* 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);
IThundxr marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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);
IThundxr marked this conversation as resolved.
Show resolved Hide resolved

/**
* Registers Minecraft's debug commands
* (TestCommand, RaidCommand, DebugPathCommand, DebugMobSpawningCommand,
* WardenSpawnTrackerCommand, SpawnArmorTrimsCommand, ServerPackCommand),
* and if on the server DebugConfigCommand</br>
* Property: <code>fabric.dev.registerDebugCommands</code></br>
* Default value: true</br>
* {@link CommandManager#CommandManager}
*/
public static final boolean REGISTER_DEBUG_COMMANDS = getProperty("registerDebugCommands", true);

/**
* 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these should be named such as fabric.dev.command.logging.exception (with all of the others following the same pattern?


/**
* 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);

/**
* 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);

/**
* 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);

/**
* 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);

/**
* Invokes a method in which you should have a breakpoint to debug errors
* thrown with Util#error and exceptions thrown with Util#throwOrPause</br>
* Property: <code>fabric.dev.enableExceptionIdePausing</code></br>
* Default value: true</br>
* {@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);
IThundxr marked this conversation as resolved.
Show resolved Hide resolved

private static final boolean IS_DEVELOPMENT_ENV = FabricLoader.getInstance().isDevelopmentEnvironment();

private static boolean getProperty(String name, boolean defaultValue) {
IThundxr marked this conversation as resolved.
Show resolved Hide resolved
String propertyValue = System.getProperty("fabric.dev" + name);
IThundxr marked this conversation as resolved.
Show resolved Hide resolved
if (propertyValue == null || propertyValue.isEmpty())
return IS_DEVELOPMENT_ENV && defaultValue;
return "true".equalsIgnoreCase(propertyValue);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.dev;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.block.Block;
import net.minecraft.item.Item;

import net.fabricmc.fabric.impl.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) {
IThundxr marked this conversation as resolved.
Show resolved Hide resolved
return original || FabricDevProperties.LOG_CONVENTION_ISSUES;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.dev;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.util.math.BlockBox;

import net.fabricmc.fabric.impl.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) {
return original || FabricDevProperties.THROW_ON_INVALID_BLOCK_BOXES;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.dev;

import java.util.Set;
import java.util.function.Consumer;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.Bootstrap;

import net.fabricmc.fabric.impl.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) {
return original || FabricDevProperties.LOG_MISSING_TRANSLATIONS || FabricDevProperties.ENABLE_COMMAND_ARGUMENT_LOGGING;
}

@WrapWithCondition(method = "logMissing", at = @At(value = "INVOKE", target = "Ljava/util/Set;forEach(Ljava/util/function/Consumer;)V"))
private static boolean wrapWithConditionTranslationWarnings(Set<String> instance, Consumer<String> consumer) {
return FabricDevProperties.LOG_MISSING_TRANSLATIONS;
}

@WrapWithCondition(method = "logMissing", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/command/CommandManager;checkMissing()V"))
private static boolean wrapWithConditionCommandArgumentWarnings() {
return FabricDevProperties.ENABLE_COMMAND_ARGUMENT_LOGGING;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.dev;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.world.chunk.Chunk;

import net.fabricmc.fabric.impl.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) {
return original || FabricDevProperties.ENABLE_UNPRIMED_HEIGHTMAP_LOGGING;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.dev;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.server.command.CommandManager;

import net.fabricmc.fabric.impl.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) {
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) {
return original || FabricDevProperties.ENABLE_COMMAND_EXCEPTION_LOGGING;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.dev;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.server.dedicated.EulaReader;

import net.fabricmc.fabric.impl.FabricDevProperties;

@Mixin(EulaReader.class)
public class EulaReaderMixin {
@ModifyExpressionValue(method = {"<init>", "createEulaFile"}, at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private boolean mevIsDevelopmentForDevModule(boolean original) {
return original || FabricDevProperties.ALWAYS_AGREE_TO_EULA;
}
}
Loading
Loading