Cleanup usages of static imports and build script so that our build doesn't spam useless error like messages.

So that it is easier to see real errors.
Add compatibility checking to standard testing tasks.
This commit is contained in:
LexManos committed 2023-07-17 17:26:28 -07:00
1 parent e6bb7eecbd
commit ebb316a15c
28 files changed
+202 -258

No files matched your search

@@ -14,8 +14,7 @@ import net.minecraftforge.eventbus.api.Event;
import java.util.Locale;
import java.util.Map;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Preconditions;
/**
* Fired for registering structure conversions for pre-1.18.2 worlds. This is used by {@link StructuresBecomeConfiguredFix}
@@ -92,11 +91,11 @@ public class RegisterStructureConversionsEvent extends Event
*/
public void register(String oldStructureID, StructuresBecomeConfiguredFix.Conversion conversion)
{
checkNotNull(oldStructureID, "Original structure ID must not be null");
checkArgument(oldStructureID.toLowerCase(Locale.ROOT).equals(oldStructureID),
Preconditions.checkNotNull(oldStructureID, "Original structure ID must not be null");
Preconditions.checkArgument(oldStructureID.toLowerCase(Locale.ROOT).equals(oldStructureID),
"Original structure ID should be in all lowercase");
checkNotNull(conversion, "Structure conversion must not be null");
checkNotNull(conversion.fallback(), "Fallback structure ID in structure conversion must not be null");
Preconditions.checkNotNull(conversion, "Structure conversion must not be null");
Preconditions.checkNotNull(conversion.fallback(), "Fallback structure ID in structure conversion must not be null");
if (map.putIfAbsent(oldStructureID.toLowerCase(Locale.ROOT), conversion) != null)
{
throw new IllegalArgumentException("Conversion has already been registered for structure " + oldStructureID);
@@ -26,9 +26,6 @@ import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import static net.minecraftforge.eventbus.api.Event.Result.DEFAULT;
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
@@ -141,8 +138,8 @@ public class PlayerInteractEvent extends PlayerEvent
@Cancelable
public static class RightClickBlock extends PlayerInteractEvent
{
private Result useBlock = DEFAULT;
private Result useItem = DEFAULT;
private Result useBlock = Result.DEFAULT;
private Result useItem = Result.DEFAULT;
private BlockHitResult hitVec;
public RightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) {
@@ -201,8 +198,8 @@ public class PlayerInteractEvent extends PlayerEvent
super.setCanceled(canceled);
if (canceled)
{
useBlock = DENY;
useItem = DENY;
useBlock = Result.DENY;
useItem = Result.DENY;
}
}
}
@@ -254,8 +251,8 @@ public class PlayerInteractEvent extends PlayerEvent
@Cancelable
public static class LeftClickBlock extends PlayerInteractEvent
{
private Result useBlock = DEFAULT;
private Result useItem = DEFAULT;
private Result useBlock = Result.DEFAULT;
private Result useItem = Result.DEFAULT;
private final Action action;
@Deprecated(since = "1.20.1", forRemoval = true)
@@ -292,7 +289,7 @@ public class PlayerInteractEvent extends PlayerEvent
*/
@NotNull
public Action getAction() {
return this.action;
return this.action;
}
public void setUseBlock(Result triggerBlock)
@@ -311,38 +308,38 @@ public class PlayerInteractEvent extends PlayerEvent
super.setCanceled(canceled);
if (canceled)
{
useBlock = DENY;
useItem = DENY;
useBlock = Result.DENY;
useItem = Result.DENY;
}
}
public static enum Action {
/**
* When the player first left clicks a block
*/
START,
/**
* When the player stops left clicking a block by completely breaking it
*/
STOP,
/**
* When the player stops left clicking a block by releasing the button, or no longer targeting the same block before it breaks.
*/
ABORT,
/**
* When the player is actively mining a block on the client side
* Warning: The event is fired every tick on the client
*/
CLIENT_HOLD;
/**
* When the player first left clicks a block
*/
START,
/**
* When the player stops left clicking a block by completely breaking it
*/
STOP,
/**
* When the player stops left clicking a block by releasing the button, or no longer targeting the same block before it breaks.
*/
ABORT,
/**
* When the player is actively mining a block on the client side
* Warning: The event is fired every tick on the client
*/
CLIENT_HOLD;
public static Action convert(ServerboundPlayerActionPacket.Action action) {
return switch (action) {
default -> START;
case START_DESTROY_BLOCK -> START;
case STOP_DESTROY_BLOCK -> STOP;
case ABORT_DESTROY_BLOCK -> ABORT;
};
}
public static Action convert(ServerboundPlayerActionPacket.Action action) {
return switch (action) {
default -> START;
case START_DESTROY_BLOCK -> START;
case STOP_DESTROY_BLOCK -> STOP;
case ABORT_DESTROY_BLOCK -> ABORT;
};
}
}
}