Compare commits

...

7 commits

Author SHA1 Message Date
a8e579b07f pull from upstream 2024-06-18 14:07:22 -04:00
e4e49f10e2 block /debugdim 2024-06-18 00:22:21 -04:00
9e8c3333c0 port fixes 2024-06-18 00:10:54 -04:00
34fc390183 fix properties 2024-06-16 23:30:24 -04:00
6740cf9d4b make it compile 2024-06-16 23:26:33 -04:00
7449a5bb46 fix the first bunch of errors 2024-06-15 23:36:18 -04:00
ec2f02c347 change versions 2024-06-15 17:50:22 -04:00
27 changed files with 215 additions and 170 deletions

View file

@ -1,11 +1,15 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
@ -23,14 +27,6 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}
base {
archivesName = project.archives_base_name
}
processResources {
@ -42,8 +38,7 @@ processResources {
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 8
}
java {
@ -52,20 +47,21 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}

View file

@ -3,15 +3,12 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.17
# check these on https://fabricmc.net/develop
minecraft_version=20w14infinite
yarn_mappings=20w14infinite+build.4
loader_version=0.15.11
# Mod Properties
mod_version = rolling
maven_group = land.chipmunk.kaboomfabric
archives_base_name = extras
# Dependencies
fabric_version=0.75.3+1.19.4
mod_version=rolling
maven_group=land.chipmunk.kaboomfabric
archives_base_name=extras

Binary file not shown.

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

29
gradlew vendored
View file

@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

20
gradlew.bat vendored
View file

@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View file

@ -1,14 +1,13 @@
package land.chipmunk.kaboomfabric.extras;
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.minecraft.util.Formatting;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.mojang.brigadier.CommandDispatcher;
import land.chipmunk.kaboomfabric.extras.commands.*;
public class Extras implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("extras");
public static final Logger LOGGER = LogManager.getLogger("infinite-fixes");
private static final char[] escapeCodes = "0123456789abcdefklmnorx".toCharArray();
@Override
@ -41,7 +40,7 @@ public class Extras implements ModInitializer {
for (int i = 0; i < string.length(); i++) {
char character = string.charAt(i);
if (character == '&' && string.length() > (i + 1) && validateEscapeCode(string.charAt(i + 1))) sb.append(Formatting.FORMATTING_CODE_PREFIX);
if (character == '&' && string.length() > (i + 1) && validateEscapeCode(string.charAt(i + 1))) sb.append((char) 0xa7);
else sb.append(character);
}

View file

@ -7,7 +7,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
import static net.minecraft.server.command.CommandManager.literal;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.MutableText;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.server.network.ServerPlayerEntity;
@ -23,11 +23,11 @@ public interface CommandClearChat {
}
static int clearChatCommand (CommandContext<ServerCommandSource> context) {
final MutableText text = Text.literal("");
for (int i = 0; i < 100; i++) text.append(Text.literal("\n"));
text.append(Text.literal("The chat has been cleared").formatted(Formatting.DARK_GREEN));
final Text text = new LiteralText("");
for (int i = 0; i < 100; i++) text.append(new LiteralText("\n"));
text.append(new LiteralText("The chat has been cleared").formatted(Formatting.DARK_GREEN));
for (ServerPlayerEntity player : context.getSource().getServer().getPlayerManager().getPlayerList()) {
for (ServerPlayerEntity player : context.getSource().getMinecraftServer().getPlayerManager().getPlayerList()) {
player.sendMessage(text);
}

View file

@ -27,13 +27,13 @@ public interface CommandConsole {
static int consoleCommand (CommandContext<ServerCommandSource> context) {
// ? Should I optimize this to manually create a ParseResults object, or just not wrap the say command in the first place?
final ServerCommandSource source = context.getSource();
final MinecraftServer server = source.getServer();
final MinecraftServer server = source.getMinecraftServer();
final ServerCommandSource console = server.getCommandSource();
final String command = "say " + Extras.parseEscapeSequences(getString(context, "message"));
final CommandManager commandManager = server.getCommandManager();
commandManager.execute(commandManager.getDispatcher().parse(command, source), command);
commandManager.execute(console, command);
return Command.SINGLE_SUCCESS;
}

View file

@ -11,7 +11,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import land.chipmunk.kaboomfabric.extras.mixin.ServerWorldAccessor;
import land.chipmunk.kaboomfabric.extras.mixin.EntityAccessor;
// Currently broken
public interface CommandDestroyEntities {
@ -27,15 +29,15 @@ public interface CommandDestroyEntities {
static int destroyEntitiesCommand (CommandContext<ServerCommandSource> context) {
final ServerCommandSource source = context.getSource();
final MinecraftServer server = source.getServer();
final MinecraftServer server = source.getMinecraftServer();
int entityCount = 0;
int worldCount = 0;
for (ServerWorld world : server.getWorlds()) {
for (Entity entity : world.iterateEntities()) {
for (Entity entity : ((ServerWorldAccessor)(Object)world).entitiesById().values()) {
if (entity instanceof PlayerEntity) continue;
try {
entity.discard();
((EntityAccessor)(Object)entity).destroy();
entityCount++;
} catch (Exception ignored) {
}
@ -44,11 +46,11 @@ public interface CommandDestroyEntities {
}
source.sendFeedback(
Text.literal("Successfully destroyed ")
.append(Text.literal(String.valueOf(entityCount)))
.append(Text.literal(" entities in "))
.append(Text.literal(String.valueOf(worldCount)))
.append(Text.literal(" worlds")),
new LiteralText("Successfully destroyed ")
.append(new LiteralText(String.valueOf(entityCount)))
.append(new LiteralText(" entities in "))
.append(new LiteralText(String.valueOf(worldCount)))
.append(new LiteralText(" worlds")),
true);
return Command.SINGLE_SUCCESS;

View file

@ -7,19 +7,19 @@ import static net.minecraft.server.command.CommandManager.literal;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registries;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.util.registry.Registry;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
public abstract class CommandEnchantAll {
private static final SimpleCommandExceptionType EMPTY_ITEM_EXCEPTION = new SimpleCommandExceptionType(Text.literal("Please hold an item in your hand to enchant it"));
private static final SimpleCommandExceptionType EMPTY_ITEM_EXCEPTION = new SimpleCommandExceptionType(new LiteralText("Please hold an item in your hand to enchant it"));
public static void register (CommandDispatcher dispatcher) {
dispatcher.register(
@ -31,12 +31,12 @@ public abstract class CommandEnchantAll {
public static int enchantAllCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final ServerPlayerEntity player = source.getPlayerOrThrow();
final PlayerInventory inventory = player.getInventory();
final ServerPlayerEntity player = source.getPlayer();
final PlayerInventory inventory = player.inventory;
final NbtList enchantments = new NbtList();
for (Identifier identifier : Registries.ENCHANTMENT.getIds()) {
final NbtCompound enchantment = new NbtCompound();
final ListTag enchantments = new ListTag();
for (Identifier identifier : Registry.ENCHANTMENT.getIds()) {
final CompoundTag enchantment = new CompoundTag();
enchantment.putString("id", identifier.toString());
enchantment.putShort("lvl", (short) 0xFF);
enchantments.add(enchantment);
@ -45,15 +45,15 @@ public abstract class CommandEnchantAll {
final ItemStack stack = inventory.getStack(inventory.selectedSlot).copy();
if (stack.isEmpty()) throw EMPTY_ITEM_EXCEPTION.create();
NbtCompound nbt = stack.getNbt();
CompoundTag nbt = stack.getTag();
if (nbt == null) {
nbt = new NbtCompound();
stack.setNbt(nbt);
nbt = new CompoundTag();
stack.setTag(nbt);
}
stack.getNbt().put("Enchantments", enchantments);
stack.getTag().put("Enchantments", enchantments);
inventory.setStack(inventory.selectedSlot, stack);
source.sendFeedback(Text.literal("I killed Martin."), false);
source.sendFeedback(new LiteralText("I killed Martin."), false);
return Command.SINGLE_SUCCESS;
}

View file

@ -7,18 +7,18 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.LiteralCommandNode;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.command.argument.EntityArgumentType.players;
import static net.minecraft.command.argument.EntityArgumentType.getPlayers;
import static net.minecraft.command.arguments.EntityArgumentType.players;
import static net.minecraft.command.arguments.EntityArgumentType.getPlayers;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.registry.Registries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.Vec3d;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import java.util.Collection;
public interface CommandJumpscare {
@ -38,11 +38,11 @@ public interface CommandJumpscare {
static int jumpscareCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final Collection<ServerPlayerEntity> players = getPlayers(context, "targets");
final ParticleEffect particle = (ParticleEffect) Registries.PARTICLE_TYPE.get(new Identifier("minecraft", "elder_guardian"));
final SoundEvent soundEvent = Registries.SOUND_EVENT.get(new Identifier("minecraft", "entity.enderman.scream"));
final ParticleEffect particle = (ParticleEffect) Registry.PARTICLE_TYPE.get(new Identifier("minecraft", "elder_guardian"));
final SoundEvent soundEvent = Registry.SOUND_EVENT.get(new Identifier("minecraft", "entity.enderman.scream"));
for (ServerPlayerEntity player : players) {
final ServerWorld world = player.getWorld();
final ServerWorld world = player.getServerWorld();
final Vec3d position = player.getPos();
world.<ParticleEffect>spawnParticles(player, particle, false, position.getX(), position.getY(), position.getZ(), 4, 0, 0, 0, 1);
@ -53,15 +53,15 @@ public interface CommandJumpscare {
final ServerPlayerEntity player = (ServerPlayerEntity) players.toArray()[0];
source.sendFeedback(
Text.literal("Successfully created jumpscare for player \"")
.append(Text.literal(player.getGameProfile().getName()))
.append(Text.literal("\""))
new LiteralText("Successfully created jumpscare for player \"")
.append(new LiteralText(player.getGameProfile().getName()))
.append(new LiteralText("\""))
, true);
return Command.SINGLE_SUCCESS;
}
source.sendFeedback(Text.literal("Successfully created jumpscare for multiple players"), true);
source.sendFeedback(new LiteralText("Successfully created jumpscare for multiple players"), true);
return Command.SINGLE_SUCCESS;
}

View file

@ -6,17 +6,18 @@ import com.mojang.brigadier.context.CommandContext;
import static net.minecraft.server.command.CommandManager.literal;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.world.World;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.explosion.Explosion.DestructionType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.registry.Registries;
import net.minecraft.util.registry.Registry;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.BlockPos;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Clearable;
import java.util.concurrent.ThreadLocalRandom;
public interface CommandKaboom {
@ -29,41 +30,40 @@ public interface CommandKaboom {
}
static int kaboomCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
final ServerPlayerEntity player = context.getSource().getPlayerOrThrow();
final ServerPlayerEntity player = context.getSource().getPlayer();
boolean explode = ThreadLocalRandom.current().nextBoolean();
if (explode) {
final Vec3d position = player.getPos();
final ServerWorld world = player.getWorld();
final ServerWorld world = player.getServerWorld();
final int explosionCount = 20;
final int power = 8;
world.createExplosion(player, position.getX(), position.getY(), position.getZ(), power, true, World.ExplosionSourceType.MOB);
world.createExplosion(player, position.getX(), position.getY(), position.getZ(), power, true, DestructionType.DESTROY);
final int power2 = 4;
final BlockState lava = Registries.BLOCK.get(new Identifier("minecraft", "lava")).getDefaultState();
final BlockState lava = Registry.BLOCK.get(new Identifier("minecraft", "lava")).getDefaultState();
for (int i = 0; i < explosionCount; i++) {
final double posX = position.getX() + ThreadLocalRandom.current().nextInt(-15, 15);
final double posY = position.getY() + ThreadLocalRandom.current().nextInt(-6, 6);
final double posZ = position.getZ() + ThreadLocalRandom.current().nextInt(-15, 15);
world.createExplosion(player, posX, posY, posZ, power2, true, World.ExplosionSourceType.MOB);
world.createExplosion(player, posX, posY, posZ, power2, true, DestructionType.DESTROY);
final BlockPos blockPos = new BlockPos((int) posX, (int) posY, (int) posZ);
if (!world.canSetBlock(blockPos)) continue;
if (world.getBlockState(blockPos).hasBlockEntity()) world.removeBlockEntity(blockPos);
Clearable.clear(world.getBlockEntity(blockPos));
world.setBlockState(blockPos, lava);
}
player.sendMessage(Text.literal("Forgive me :c"));
player.sendMessage(new LiteralText("Forgive me :c"));
return Command.SINGLE_SUCCESS;
}
final PlayerInventory inventory = player.getInventory();
inventory.setStack(inventory.selectedSlot, new ItemStack(Registries.ITEM.get(new Identifier("minecraft", "cake"))));
player.sendMessage(Text.literal("Have a nice day :)"));
final PlayerInventory inventory = player.inventory;
inventory.setStack(inventory.selectedSlot, new ItemStack(Registry.ITEM.get(new Identifier("minecraft", "cake"))));
player.sendMessage(new LiteralText("Have a nice day :)"));
return Command.SINGLE_SUCCESS;
}
}

View file

@ -7,10 +7,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.LiteralCommandNode;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.command.argument.EntityArgumentType.player;
import static net.minecraft.command.argument.EntityArgumentType.getPlayer;
import static net.minecraft.command.arguments.EntityArgumentType.player;
import static net.minecraft.command.arguments.EntityArgumentType.getPlayer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.server.network.ServerPlayerEntity;
@ -32,15 +32,15 @@ public abstract class CommandPing {
public static int pingCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final ServerPlayerEntity player = source.getPlayerOrThrow();
final ServerPlayerEntity player = source.getPlayer();
final int ping = player.pingMilliseconds;
final Formatting highlighting = getHighlighting(ping);
source.sendFeedback(
Text.literal("Your")
.append(Text.literal(" ping is "))
.append(Text.literal(String.valueOf(ping)).formatted(highlighting))
.append(Text.literal("ms.").formatted(highlighting))
new LiteralText("Your")
.append(new LiteralText(" ping is "))
.append(new LiteralText(String.valueOf(ping)).formatted(highlighting))
.append(new LiteralText("ms.").formatted(highlighting))
, false);
return Command.SINGLE_SUCCESS;
@ -53,11 +53,11 @@ public abstract class CommandPing {
final Formatting highlighting = getHighlighting(ping);
source.sendFeedback(
Text.literal(target.getGameProfile().getName())
.append(Text.literal("'s"))
.append(Text.literal(" ping is "))
.append(Text.literal(String.valueOf(ping)).formatted(highlighting))
.append(Text.literal("ms.").formatted(highlighting))
new LiteralText(target.getGameProfile().getName())
.append(new LiteralText("'s"))
.append(new LiteralText(" ping is "))
.append(new LiteralText(String.valueOf(ping)).formatted(highlighting))
.append(new LiteralText("ms.").formatted(highlighting))
, false);
return Command.SINGLE_SUCCESS;

View file

@ -6,16 +6,16 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.command.argument.EntityArgumentType.players;
import static net.minecraft.command.argument.EntityArgumentType.getPlayers;
import static net.minecraft.command.arguments.EntityArgumentType.players;
import static net.minecraft.command.arguments.EntityArgumentType.getPlayers;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.registry.Registries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import java.util.Collection;
public interface CommandPumpkin {
@ -33,10 +33,10 @@ public interface CommandPumpkin {
static int pumpkinCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final Collection<ServerPlayerEntity> players = getPlayers(context, "targets");
final Item carvedPumpkin = Registries.ITEM.get(new Identifier("minecraft", "carved_pumpkin"));
final Item carvedPumpkin = Registry.ITEM.get(new Identifier("minecraft", "carved_pumpkin"));
for (ServerPlayerEntity player : players) {
final PlayerInventory inventory = player.getInventory();
final PlayerInventory inventory = player.inventory;
inventory.setStack(39, new ItemStack(carvedPumpkin));
}
@ -44,15 +44,15 @@ public interface CommandPumpkin {
final ServerPlayerEntity player = (ServerPlayerEntity) players.toArray()[0];
source.sendFeedback(
Text.literal("Player \"")
.append(Text.literal(player.getGameProfile().getName()))
.append(Text.literal("\" is now a pumpkin"))
new LiteralText("Player \"")
.append(new LiteralText(player.getGameProfile().getName()))
.append(new LiteralText("\" is now a pumpkin"))
, true);
return Command.SINGLE_SUCCESS;
}
source.sendFeedback(Text.literal("Multiple players are now pumpkins"), true);
source.sendFeedback(new LiteralText("Multiple players are now pumpkins"), true);
return Command.SINGLE_SUCCESS;
}

View file

@ -6,8 +6,7 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.tree.LiteralCommandNode;
import static net.minecraft.server.command.CommandManager.literal;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.MutableText;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@ -27,8 +26,8 @@ public abstract class CommandServerInfo {
private static void sendInfoMessage (ServerCommandSource source, String description, String value) {
source.sendFeedback(
Text.literal(description).formatted(Formatting.GRAY)
.append(Text.literal(": " + value).formatted(Formatting.WHITE))
new LiteralText(description).formatted(Formatting.GRAY)
.append(new LiteralText(": " + value).formatted(Formatting.WHITE))
, false);
}

View file

@ -8,10 +8,11 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import static net.minecraft.server.command.CommandManager.literal;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.level.LevelProperties;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import java.util.Set;
import java.util.HashSet;
@ -27,15 +28,13 @@ public interface CommandSpawn {
static int spawnCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final Entity entity = source.getEntityOrThrow();
final ServerWorld world = source.getServer().getOverworld();
final ServerWorld world = source.getMinecraftServer().getWorld(DimensionType.OVERWORLD);
final LevelProperties properties = world.getLevelProperties();
final Vec3d spawn = Vec3d.ofCenter(world.getSpawnPos());
final float spawnAngle = world.getSpawnAngle();
entity.setWorld(world);
entity.teleport(properties.getSpawnX() + 0.5, properties.getSpawnY(), properties.getSpawnZ() + 0.5);
final Set<PositionFlag> positionFlags = new HashSet<>();
entity.teleport(world, spawn.getX(), spawn.getY(), spawn.getZ(), positionFlags, spawnAngle, 0);
source.sendFeedback(Text.literal("Successfully moved to spawn"), false);
source.sendFeedback(new LiteralText("Successfully moved to spawn"), false);
return Command.SINGLE_SUCCESS;
}

View file

@ -9,11 +9,12 @@ import static net.minecraft.server.command.CommandManager.argument;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.registry.Registries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Clearable;
import land.chipmunk.kaboomfabric.extras.modules.block.BlockIterator;
public abstract class CommandSpidey {
@ -29,7 +30,7 @@ public abstract class CommandSpidey {
final ServerCommandSource source = context.getSource();
final Entity entity = source.getEntityOrThrow();
final ServerWorld world = source.getWorld();
/*
final Vec3d start = entity.getEyePos();
final Vec3d direction = Vec3d.fromPolar(entity.getYaw(), entity.getPitch());
final int yOffset = 0;
@ -37,15 +38,16 @@ public abstract class CommandSpidey {
final BlockIterator iterator = new BlockIterator(start, direction, yOffset, distance);
final BlockState cobweb = Registries.BLOCK.get(new Identifier("minecraft", "cobweb")).getDefaultState();
final BlockState cobweb = Registry.BLOCK.get(new Identifier("minecraft", "cobweb")).getDefaultState();
while (iterator.hasNext()) {
BlockPos pos = iterator.next();
if (!world.isInBuildLimit(pos) || !world.getBlockState(pos).isAir()) break;
if ((pos.getY() >= 0 && pos.getY() <= 255) || !world.getBlockState(pos).isAir()) break;
if (world.getBlockState(pos).hasBlockEntity()) world.removeBlockEntity(pos);
Clearable.clear(world.getBlockEntity(pos));
world.setBlockState(pos, cobweb);
}
*/
return Command.SINGLE_SUCCESS;
}

View file

@ -8,7 +8,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import com.mojang.brigadier.CommandDispatcher;
@Mixin(CommandManager.class)
@ -17,7 +16,7 @@ public abstract class CommandManagerMixin {
private CommandDispatcher<ServerCommandSource> dispatcher;
@Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/CommandDispatcher;setConsumer(Lcom/mojang/brigadier/ResultConsumer;)V", remap = false), method = "<init>")
private void init (CommandManager.RegistrationEnvironment environment, CommandRegistryAccess commandRegistryAccess, CallbackInfo info) {
private void init (boolean isDedicatedServer, CallbackInfo info) {
Extras.registerCommands(dispatcher);
}
}

View file

@ -0,0 +1,16 @@
package land.chipmunk.kaboomfabric.extras.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;
@Mixin(net.minecraft.server.command.DebugDimCommand.class)
public abstract class DebugDimCommandMixin {
@Inject(at = @At("HEAD"), method = "register", cancellable = true)
private static void register (CommandDispatcher<ServerCommandSource> dispatcher, CallbackInfo info) {
info.cancel();
}
}

View file

@ -0,0 +1,9 @@
package land.chipmunk.kaboomfabric.extras.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(net.minecraft.entity.Entity.class)
public interface EntityAccessor {
@Invoker("destroy") void destroy ();
}

View file

@ -3,14 +3,15 @@ package land.chipmunk.kaboomfabric.extras.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.server.command.ServerCommandSource;
import java.util.Collection;
@Mixin(net.minecraft.server.command.ReloadCommand.class)
public abstract class ReloadCommandMixin {
@Inject(at = @At("HEAD"), method = "tryReloadDataPacks", cancellable = true)
private static void tryReloadDataPacks (Collection<?> datapacks, ServerCommandSource source, CallbackInfo info) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;reload()V"), method = "method_13530", cancellable = true)
private static void reload (CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> info) {
info.cancel();
}
}

View file

@ -0,0 +1,11 @@
package land.chipmunk.kaboomfabric.extras.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.entity.Entity;
@Mixin(net.minecraft.server.world.ServerWorld.class)
public interface ServerWorldAccessor {
@Accessor("entitiesById") Int2ObjectMap<Entity> entitiesById ();
}

View file

@ -219,9 +219,12 @@ public class BlockIterator implements Iterator<BlockPos> {
return getPosition(direction.getZ(), position.getZ(), block.getZ());
}
// TODO: Backport
/*
public BlockIterator(Entity entity, int maxDistance) {
this(entity.getPos(), Vec3d.fromPolar(entity.getYaw(), entity.getPitch()), entity.getEyeHeight(entity.getPose()), maxDistance);
}
*/
/**
* Constructs the BlockIterator.
@ -231,9 +234,11 @@ public class BlockIterator implements Iterator<BlockPos> {
* @param entity Information from the entity is used to set up the trace
*/
/*
public BlockIterator(Entity entity) {
this(entity, 0);
}
*/
/**
* Returns true if the iteration has more elements

View file

@ -10,7 +10,10 @@
"StopCommandMixin",
"ReloadCommandMixin",
"OpCommandMixin",
"EntitySelectorMixin"
"EntitySelectorMixin",
"ServerWorldAccessor",
"EntityAccessor",
"DebugDimCommandMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -33,10 +33,11 @@
],
"depends": {
"fabricloader": ">=0.14.17",
"minecraft": "~1.19.4",
"java": ">=17"
"fabricloader": ">=0.15.11",
"minecraft": "1.16-alpha.20.13.inf",
"java": ">=8"
},
"suggests": {
"another-mod": "*"
}