buildscript {
repositories {
jcenter()
- maven { url 'https://repo.spongepowered.org/maven' }
- maven { url 'https://jitpack.io' }
- maven { url 'https://files.minecraftforge.net/maven' }
+ maven {
+ name = 'Fabric'
+ url = 'https://maven.fabricmc.net/'
+ }
}
dependencies {
- classpath 'com.github.Irtimaled:ForgeGradle:2.6-SNAPSHOT'
- classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
+ classpath "net.fabricmc:fabric-loom:0.2.7-SNAPSHOT"
}
}
-apply plugin: 'net.minecraftforge.gradle.tweaker-client'
+apply plugin: 'fabric-loom'
apply plugin: 'java'
-apply plugin: 'org.spongepowered.mixin'
+apply plugin: 'idea'
group 'com.irtimaled'
version project.buildVersion + '-' + project.mcVersion
sourceCompatibility = 1.8
targetCompatibility = 1.8
-repositories {
- mavenCentral()
- maven { url 'https://libraries.minecraft.net/' }
- maven { url 'https://repo.spongepowered.org/maven/' }
- maven { url 'https://jitpack.io' }
-}
-
dependencies {
- implementation('org.spongepowered:mixin:0.8') { transitive = false }
- implementation('net.minecraft:launchwrapper:1.12') { transitive = false }
- implementation 'org.ow2.asm:asm-tree:6.2'
- implementation 'org.ow2.asm:asm-commons:6.2'
- implementation "org.ow2.asm:asm-util:6.2"
+ minecraft 'com.mojang:minecraft:' + project.mcVersion
+ mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.16'
+ modCompile 'net.fabricmc:fabric-loader:0.8.3+build.196'
}
minecraft {
- version = project.mcVersion
- mappings = 'snapshot_20200119'
- runDir = 'run'
- tweakClass = 'com.irtimaled.bbor.launch.ClientTweaker'
- makeObfSourceJar = false
- clientJvmArgs = ['-XstartOnFirstThread']
-}
-
-mixin {
- defaultObfuscationEnv notch
- add sourceSets.main, 'mixins.bbor.refmap.json'
-}
-
-sourceSets {
- main
- debug {
- compileClasspath += main.compileClasspath
- }
+ refmapName = 'mixins.bbor.refmap.json'
}
processResources {
- filesMatching('profile.json') {
- expand([
- 'version' : project.version,
- 'mcVersion' : project.mcVersion,
- 'tweakClass' : project.minecraft.tweakClass,
- 'formattedTime': new Date().format("yyyy-MM-dd'T'HH:mm:ss'-08:00'")
- ])
+ filesMatching('fabric.mod.json') {
+ expand version: project.version
}
-
- inputs.property "version", project.version
- inputs.property "mcVersion", project.mcVersion
}
jar {
- finalizedBy reobfJar
manifest {
attributes([
"Main-Class": "com.irtimaled.bbor.Main",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
-
- classifier = 'vanilla'
}
-artifacts {
- archives jar
+afterEvaluate {
+ remapJar.classifier = 'fabric'
}
-#Sun May 24 16:37:33 PDT 2020
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
+#Tue May 26 09:16:06 PDT 2020
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
-#!/usr/bin/env sh
+#!/usr/bin/env bash
##############################################################################
##
esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi
-exec "$JAVACMD" "$@"
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+++ /dev/null
-package com.irtimaled.bbor;
-
-import com.irtimaled.bbor.install.Installer;
-import com.irtimaled.bbor.server.ServerRunner;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-public class Main {
- public static void main(String... args) throws IOException {
- if (args.length > 0 && args[0].equals("--server")) {
- ServerRunner.run(Arrays.asList(args).subList(1, args.length));
- } else {
- Installer.install();
- }
- }
-}
package com.irtimaled.bbor.client;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class Camera {
private static Vec3d getPos() {
- return Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
+ return MinecraftClient.getInstance().gameRenderer.getCamera().getPos();
}
public static double getX() {
import com.irtimaled.bbor.client.models.Point;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.client.entity.player.ClientPlayerEntity;
+import net.minecraft.client.network.ClientPlayerEntity;
public class Player {
private static double x;
private static DimensionId dimensionId;
public static void setPosition(double partialTicks, ClientPlayerEntity player) {
- x = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
- y = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
- z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
+ x = player.prevX + (player.x - player.prevX) * partialTicks;
+ y = player.prevY + (player.y - player.prevY) * partialTicks;
+ z = player.prevZ + (player.z - player.prevZ) * partialTicks;
dimensionId = DimensionId.from(player.dimension);
}
import com.mojang.brigadier.arguments.*;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.arguments.BlockPosArgument;
-import net.minecraft.command.arguments.Vec3Argument;
+import net.minecraft.command.arguments.BlockPosArgumentType;
+import net.minecraft.command.arguments.Vec3ArgumentType;
+import net.minecraft.server.command.ServerCommandSource;
import java.util.function.Supplier;
public class Arguments {
- public static BlockPosArgument coords() {
- return BlockPosArgument.blockPos();
+ public static BlockPosArgumentType coords() {
+ return BlockPosArgumentType.blockPos();
}
- public static Vec3Argument point() {
- return Vec3Argument.vec3();
+ public static Vec3ArgumentType point() {
+ return Vec3ArgumentType.vec3();
}
public static IntegerArgumentType integer() {
return new HexColorArgument();
}
- public static Coords getCoords(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
- return new Coords(getArgumentValueOrDefault(context, name, Vec3Argument::getVec3, () -> context.getSource().getPos()));
+ public static Coords getCoords(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
+ return new Coords(getArgumentValueOrDefault(context, name, Vec3ArgumentType::getVec3, () -> context.getSource().getPosition()));
}
- public static Point getPoint(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
- return new Point(getArgumentValueOrDefault(context, name, Vec3Argument::getVec3, () -> context.getSource().getPos()));
+ public static Point getPoint(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
+ return new Point(getArgumentValueOrDefault(context, name, Vec3ArgumentType::getVec3, () -> context.getSource().getPosition()));
}
- public static int getInteger(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
+ public static int getInteger(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
return getArgumentValueOrDefault(context, name, IntegerArgumentType::getInteger, () -> 0);
}
- public static double getDouble(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
+ public static double getDouble(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
return getArgumentValueOrDefault(context, name, DoubleArgumentType::getDouble, () -> 0.0D);
}
- public static String getString(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
+ public static String getString(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
return getArgumentValueOrDefault(context, name, StringArgumentType::getString, () -> "");
}
- public static boolean getBool(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
+ public static boolean getBool(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
return getArgumentValueOrDefault(context, name, BoolArgumentType::getBool, () -> false);
}
- private static <T> T getArgumentValueOrDefault(CommandContext<CommandSource> context,
+ private static <T> T getArgumentValueOrDefault(CommandContext<ServerCommandSource> context,
String name,
ArgumentFetcher<T> getValue,
Supplier<T> defaultValue) throws CommandSyntaxException {
@FunctionalInterface
private interface ArgumentFetcher<T> {
- T get(CommandContext<CommandSource> context, String name) throws CommandSyntaxException;
+ T get(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException;
}
}
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.ServerCommandSource;
class BeaconCommandBuilder {
private static final String LEVEL = "level";
- static LiteralArgumentBuilder<CommandSource> build(String command) {
- return Commands.literal(command)
- .then(Commands.literal(ArgumentNames.ADD)
- .then(Commands.argument(ArgumentNames.POS, Arguments.coords())
- .then(Commands.argument(LEVEL, Arguments.integer(1, 4))
+ static LiteralArgumentBuilder<ServerCommandSource> build(String command) {
+ return CommandManager.literal(command)
+ .then(CommandManager.literal(ArgumentNames.ADD)
+ .then(CommandManager.argument(ArgumentNames.POS, Arguments.coords())
+ .then(CommandManager.argument(LEVEL, Arguments.integer(1, 4))
.executes(BeaconCommandBuilder::addBeacon)))
- .then(Commands.argument(LEVEL, Arguments.integer(1, 4))
+ .then(CommandManager.argument(LEVEL, Arguments.integer(1, 4))
.executes(BeaconCommandBuilder::addBeacon)))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
CustomBeaconProvider.clear();
CommandHelper.feedback(context, "bbor.commands.beacon.cleared.all");
return 0;
})
- .then(Commands.argument(ArgumentNames.POS, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.POS, Arguments.coords())
.executes(context -> {
Coords coords = Arguments.getCoords(context, ArgumentNames.POS);
boolean removed = CustomBeaconProvider.remove(coords);
})));
}
- private static int addBeacon(CommandContext<CommandSource> context) throws CommandSyntaxException {
+ private static int addBeacon(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
Coords coords = Arguments.getCoords(context, ArgumentNames.POS);
int level = Arguments.getInteger(context, LEVEL);
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.ServerCommandSource;
class BoxCommandBuilder {
- static LiteralArgumentBuilder<CommandSource> build(String command) {
- return Commands.literal(command)
- .then(Commands.literal(ArgumentNames.ADD)
- .then(Commands.argument(ArgumentNames.FROM, Arguments.coords())
- .then(Commands.argument(ArgumentNames.TO, Arguments.coords())
+ static LiteralArgumentBuilder<ServerCommandSource> build(String command) {
+ return CommandManager.literal(command)
+ .then(CommandManager.literal(ArgumentNames.ADD)
+ .then(CommandManager.argument(ArgumentNames.FROM, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.TO, Arguments.coords())
.executes(BoxCommandBuilder::addBox))))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
CustomBoxProvider.clear();
CommandHelper.feedback(context, "bbor.commands.box.cleared.all");
return 0;
})
- .then(Commands.argument(ArgumentNames.FROM, Arguments.coords())
- .then(Commands.argument(ArgumentNames.TO, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.FROM, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.TO, Arguments.coords())
.executes(context -> {
Coords from = Arguments.getCoords(context, ArgumentNames.FROM);
Coords to = Arguments.getCoords(context, ArgumentNames.TO);
}))));
}
- private static int addBox(CommandContext<CommandSource> context) throws CommandSyntaxException {
+ private static int addBox(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
Coords from = Arguments.getCoords(context, ArgumentNames.FROM);
Coords to = Arguments.getCoords(context, ArgumentNames.TO);
Coords minCoords = getMinCoords(from, to);
import com.mojang.brigadier.context.ParsedCommandNode;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
-import net.minecraft.command.CommandSource;
-import net.minecraft.util.text.TranslationTextComponent;
+import net.minecraft.server.command.ServerCommandSource;
+import net.minecraft.text.TranslatableText;
class CommandHelper {
- static void feedback(CommandContext<CommandSource> context, String format, Object... values) {
- context.getSource().sendFeedback(new TranslationTextComponent(format, values), false);
+ static void feedback(CommandContext<ServerCommandSource> context, String format, Object... values) {
+ context.getSource().sendFeedback(new TranslatableText(format, values), false);
}
- static boolean lastNodeIsLiteral(CommandContext<CommandSource> context, String literal) {
+ static boolean lastNodeIsLiteral(CommandContext<ServerCommandSource> context, String literal) {
CommandNode lastNode = getLastNode(context);
if (lastNode instanceof LiteralCommandNode) {
LiteralCommandNode literalCommandNode = (LiteralCommandNode) lastNode;
return false;
}
- private static CommandNode getLastNode(CommandContext<CommandSource> context) {
+ private static CommandNode getLastNode(CommandContext<ServerCommandSource> context) {
ParsedCommandNode[] nodes = context.getNodes().toArray(new ParsedCommandNode[0]);
if (nodes.length == 0) return null;
return nodes[nodes.length - 1].getNode();
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.CommandSource;
+import net.minecraft.server.command.ServerCommandSource;
import java.util.function.Function;
private static final String VALUE = "value";
private static final String RESET = "reset";
- public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal(COMMAND)
+ public static void register(CommandDispatcher<CommandSource> commandDispatcher) {
+ LiteralArgumentBuilder command = CommandManager.literal(COMMAND)
.then(buildCommands(GET, ConfigCommand::getCommandForSetting))
.then(buildCommands(ArgumentNames.SET, ConfigCommand::setCommandForSetting))
.then(buildCommands(RESET, ConfigCommand::resetCommandForSetting)
ConfigManager.saveConfig();
return 0;
}))
- .then(Commands.literal(SAVE)
+ .then(CommandManager.literal(SAVE)
.executes(context -> {
ConfigManager.saveConfig();
return 0;
}))
- .then(Commands.literal(SHOW_GUI)
+ .then(CommandManager.literal(SHOW_GUI)
.executes(context -> {
SettingsScreen.show();
return 0;
commandDispatcher.register(command);
}
- private static LiteralArgumentBuilder<CommandSource> resetCommandForSetting(Setting<?> setting) {
- return Commands.literal(setting.getName())
+ private static LiteralArgumentBuilder<ServerCommandSource> resetCommandForSetting(Setting<?> setting) {
+ return CommandManager.literal(setting.getName())
.executes(context -> {
setting.reset();
ConfigManager.saveConfig();
});
}
- private interface CommandBuilder extends Function<Setting<?>, LiteralArgumentBuilder<CommandSource>> {
+ private interface CommandBuilder extends Function<Setting<?>, LiteralArgumentBuilder<ServerCommandSource>> {
}
- private static LiteralArgumentBuilder<CommandSource> buildCommands(String commandName, CommandBuilder commandBuilder) {
- LiteralArgumentBuilder<CommandSource> command = Commands.literal(commandName);
+ private static LiteralArgumentBuilder<ServerCommandSource> buildCommands(String commandName, CommandBuilder commandBuilder) {
+ LiteralArgumentBuilder<ServerCommandSource> command = CommandManager.literal(commandName);
for (Setting<?> setting : ConfigManager.getSettings()) {
command.then(commandBuilder.apply(setting));
}
return command;
}
- private static LiteralArgumentBuilder<CommandSource> getCommandForSetting(Setting<?> setting) {
- return Commands.literal(setting.getName())
+ private static LiteralArgumentBuilder<ServerCommandSource> getCommandForSetting(Setting<?> setting) {
+ return CommandManager.literal(setting.getName())
.executes(context -> {
CommandHelper.feedback(context, "%s: %s", setting.getName(), setting.get());
return 0;
});
}
- private static LiteralArgumentBuilder<CommandSource> setCommandForSetting(Setting<?> setting) {
- LiteralArgumentBuilder<CommandSource> command = Commands.literal(setting.getName());
+ private static LiteralArgumentBuilder<ServerCommandSource> setCommandForSetting(Setting<?> setting) {
+ LiteralArgumentBuilder<ServerCommandSource> command = CommandManager.literal(setting.getName());
switch (setting.getType()) {
case 'B':
buildSetSettingCommand(command, (Setting<Boolean>) setting, Arguments.bool(), Boolean.class);
return command;
}
- private static <T> void buildSetSettingCommand(LiteralArgumentBuilder<CommandSource> command,
+ private static <T> void buildSetSettingCommand(LiteralArgumentBuilder<ServerCommandSource> command,
Setting<T> setting, ArgumentType<T> argument, Class<T> clazz) {
- Command<CommandSource> setSettingCommand = context -> {
+ Command<ServerCommandSource> setSettingCommand = context -> {
setting.set(context.getArgument(VALUE, clazz));
if (CommandHelper.lastNodeIsLiteral(context, SAVE)) {
ConfigManager.saveConfig();
}
return 0;
};
- command.then(Commands.argument(VALUE, argument)
+ command.then(CommandManager.argument(VALUE, argument)
.executes(setSettingCommand)
- .then(Commands.literal(SAVE)
+ .then(CommandManager.literal(SAVE)
.executes(setSettingCommand)));
}
}
import com.irtimaled.bbor.client.providers.CustomSphereProvider;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import net.minecraft.command.Commands;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.CommandSource;
public class CustomCommand {
private static final String COMMAND = "bbor:custom";
private static final String LINE = "line";
private static final String SPHERE = "sphere";
- public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal(COMMAND)
+ public static void register(CommandDispatcher<CommandSource> commandDispatcher) {
+ LiteralArgumentBuilder command = CommandManager.literal(COMMAND)
.then(BoxCommandBuilder.build(BOX))
.then(BeaconCommandBuilder.build(BEACON))
.then(LineCommandBuilder.build(LINE))
.then(SphereCommandBuilder.build(SPHERE))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
CustomBoxProvider.clear();
CustomBeaconProvider.clear();
commandDispatcher.register(command);
}
}
-
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.ServerCommandSource;
class LineCommandBuilder {
private static final String WIDTH = "width";
- static LiteralArgumentBuilder<CommandSource> build(String command) {
- return Commands.literal(command)
- .then(Commands.literal(ArgumentNames.ADD)
- .then(Commands.argument(ArgumentNames.FROM, Arguments.point())
- .then(Commands.argument(ArgumentNames.TO, Arguments.point())
+ static LiteralArgumentBuilder<ServerCommandSource> build(String command) {
+ return CommandManager.literal(command)
+ .then(CommandManager.literal(ArgumentNames.ADD)
+ .then(CommandManager.argument(ArgumentNames.FROM, Arguments.point())
+ .then(CommandManager.argument(ArgumentNames.TO, Arguments.point())
.executes(LineCommandBuilder::addLine)
- .then(Commands.argument(WIDTH, Arguments.doubleArg())
+ .then(CommandManager.argument(WIDTH, Arguments.doubleArg())
.executes(LineCommandBuilder::addLine)))))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
CustomLineProvider.clear();
CommandHelper.feedback(context, "bbor.commands.line.cleared.all");
return 0;
})
- .then(Commands.argument(ArgumentNames.FROM, Arguments.coords())
- .then(Commands.argument(ArgumentNames.TO, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.FROM, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.TO, Arguments.coords())
.executes(context -> {
Point from = Arguments.getPoint(context, ArgumentNames.FROM).snapXZ(0.5d);
Point to = Arguments.getPoint(context, ArgumentNames.TO).snapXZ(0.5d);
}))));
}
- private static int addLine(CommandContext<CommandSource> context) throws CommandSyntaxException {
+ private static int addLine(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
Point from = Arguments.getPoint(context, ArgumentNames.FROM).snapXZ(0.5d);
Point to = Arguments.getPoint(context, ArgumentNames.TO).snapXZ(0.5d);
Double width = Arguments.getDouble(context, WIDTH);
import com.irtimaled.bbor.client.providers.SlimeChunkProvider;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import net.minecraft.command.Commands;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.CommandSource;
public class SeedCommand {
private static final String COMMAND = "bbor:seed";
private static final String SEED = "seed";
- public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal(COMMAND)
- .then(Commands.argument(SEED, Arguments.string())
+ public static void register(CommandDispatcher<CommandSource> commandDispatcher) {
+ LiteralArgumentBuilder command = CommandManager.literal(COMMAND)
+ .then(CommandManager.argument(SEED, Arguments.string())
.executes(context -> {
String argument = Arguments.getString(context, SEED);
handleSeedCommand(argument);
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.CommandSource;
+import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
private static final String COMMAND = "bbor:spawningSphere";
private static final String CALCULATE_SPAWNABLE = "calculateSpawnable";
- public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal(COMMAND)
- .then(Commands.literal(ArgumentNames.SET)
- .then(Commands.argument(ArgumentNames.POS, Arguments.point())
+ public static void register(CommandDispatcher<CommandSource> commandDispatcher) {
+ LiteralArgumentBuilder command = CommandManager.literal(COMMAND)
+ .then(CommandManager.literal(ArgumentNames.SET)
+ .then(CommandManager.argument(ArgumentNames.POS, Arguments.point())
.executes(SpawningSphereCommand::setSphere))
.executes(SpawningSphereCommand::setSphere))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
boolean cleared = SpawningSphereProvider.clearSphere();
CommandHelper.feedback(context, format);
return 0;
}))
- .then(Commands.literal(CALCULATE_SPAWNABLE)
+ .then(CommandManager.literal(CALCULATE_SPAWNABLE)
.executes(context -> {
if (!SpawningSphereProvider.hasSpawningSphereInDimension(Player.getDimensionId())) {
CommandHelper.feedback(context, "bbor.commands.spawningSphere.notSet");
}
Counts counts = new Counts();
- World world = Minecraft.getInstance().world;
+ World world = MinecraftClient.getInstance().world;
SpawningSphereProvider.calculateSpawnableSpacesCount(pos -> {
counts.spawnable++;
- if (world.getLightFor(LightType.SKY, pos) > 7)
+ if (world.getLightLevel(LightType.SKY, pos) > 7)
counts.nightSpawnable++;
});
SpawningSphereProvider.setSpawnableSpacesCount(counts.spawnable);
commandDispatcher.register(command);
}
- public static int setSphere(CommandContext<CommandSource> context) throws CommandSyntaxException {
+ public static int setSphere(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
SpawningSphereProvider.setSphere(Arguments.getPoint(context, ArgumentNames.POS).snapXZ(0.5d));
CommandHelper.feedback(context, "bbor.commands.spawningSphere.set");
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.ServerCommandSource;
class SphereCommandBuilder {
public static final String RADIUS = "radius";
- static LiteralArgumentBuilder<CommandSource> build(String command) {
- return Commands.literal(command)
- .then(Commands.literal(ArgumentNames.ADD)
- .then(Commands.argument(ArgumentNames.POS, Arguments.point())
- .then(Commands.argument(RADIUS, Arguments.integer())
+ static LiteralArgumentBuilder<ServerCommandSource> build(String command) {
+ return CommandManager.literal(command)
+ .then(CommandManager.literal(ArgumentNames.ADD)
+ .then(CommandManager.argument(ArgumentNames.POS, Arguments.point())
+ .then(CommandManager.argument(RADIUS, Arguments.integer())
.executes(SphereCommandBuilder::addSphere)))
- .then(Commands.argument(RADIUS, Arguments.integer())
+ .then(CommandManager.argument(RADIUS, Arguments.integer())
.executes(SphereCommandBuilder::addSphere)))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
CustomSphereProvider.clear();
CommandHelper.feedback(context, "bbor.commands.sphere.cleared.all");
return 0;
})
- .then(Commands.argument(ArgumentNames.FROM, Arguments.coords())
- .then(Commands.argument(ArgumentNames.TO, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.FROM, Arguments.coords())
+ .then(CommandManager.argument(ArgumentNames.TO, Arguments.coords())
.executes(context -> {
Point pos = Arguments.getPoint(context, ArgumentNames.POS).snapXZ(0.5d);
boolean removed = CustomSphereProvider.remove(pos);
}))));
}
- private static int addSphere(CommandContext<CommandSource> context) throws CommandSyntaxException {
+ private static int addSphere(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
Point pos = Arguments.getPoint(context, ArgumentNames.POS).snapXZ(0.5d);
int radius = Arguments.getInteger(context, RADIUS);
CustomSphereProvider.add(pos, radius);
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import net.minecraft.command.Commands;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.CommandSource;
public class StructuresCommand {
private static final String COMMAND = "bbor:structures";
private static final String LOAD = "load";
- public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal(COMMAND)
- .then(Commands.literal(LOAD)
+ public static void register(CommandDispatcher<CommandSource> commandDispatcher) {
+ LiteralArgumentBuilder command = CommandManager.literal(COMMAND)
+ .then(CommandManager.literal(LOAD)
.executes(context -> {
LoadSavesScreen.show();
return 0;
}))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
ClientInterop.clearStructures();
return 0;
package com.irtimaled.bbor.client.gui;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
abstract class AbstractButton extends AbstractControl {
AbstractButton(int x, int y, int width, String name) {
if (key != 257 && key != 32 && key != 335) {
return false;
} else {
- this.playDownSound(Minecraft.getInstance().getSoundHandler());
+ this.playDownSound(MinecraftClient.getInstance().getSoundManager());
this.onPressed();
return true;
}
package com.irtimaled.bbor.client.gui;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.widget.Widget;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.widget.AbstractButtonWidget;
import java.awt.*;
-abstract class AbstractControl extends Widget implements IControl {
+abstract class AbstractControl extends AbstractButtonWidget implements IControl {
private static final int PADDING = 4;
- protected final Minecraft minecraft;
+ protected final MinecraftClient minecraft;
AbstractControl(int x, int y, int width, String name) {
super(x, y, width, 20, name);
- this.minecraft = Minecraft.getInstance();
+ this.minecraft = MinecraftClient.getInstance();
}
@Override
}
@Override
- protected void renderBg(Minecraft minecraft, int mouseX, int mouseY) {
+ protected void renderBg(MinecraftClient minecraft, int mouseX, int mouseY) {
if (active) renderBackground(mouseX, mouseY);
}
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.common.MathHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.audio.SoundHandler;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.sound.SoundManager;
abstract class AbstractSlider extends AbstractControl {
private final int optionCount;
}
@Override
- public void playDownSound(SoundHandler soundHandler) {
+ public void playDownSound(SoundManager soundHandler) {
}
@Override
public void onRelease(double mouseX, double mouseY) {
- super.playDownSound(Minecraft.getInstance().getSoundHandler());
+ super.playDownSound(MinecraftClient.getInstance().getSoundManager());
}
}
import com.irtimaled.bbor.client.renderers.RenderHelper;
import com.irtimaled.bbor.client.renderers.Renderer;
import com.irtimaled.bbor.common.MathHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.AbstractGui;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.DrawableHelper;
import java.util.ArrayList;
import java.util.List;
-public class ControlList extends AbstractGui implements IControlSet {
+public class ControlList extends DrawableHelper implements IControlSet {
public static final int CONTROLS_WIDTH = 310;
protected static final int PADDING = 8;
protected final List<ControlListEntry> entries = new ArrayList<>();
private final int scrollBarLeft;
private final int listHeight;
- private final Minecraft minecraft;
+ private final MinecraftClient minecraft;
private final int width;
private final int height;
private final int top;
private boolean isDragging;
ControlList(int width, int height, int top, int bottom) {
- this.minecraft = Minecraft.getInstance();
+ this.minecraft = MinecraftClient.getInstance();
this.width = width;
this.scrollBarLeft = width - 6;
this.height = height;
}
private void drawListBackground() {
- this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
+ this.minecraft.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_LOCATION);
Renderer.startTextured()
.setColor(32, 32, 32)
.setAlpha(255)
}
private void overlayBackground(int top, int bottom) {
- this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
+ this.minecraft.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_LOCATION);
Renderer.startTextured()
.setColor(64, 64, 64)
.setAlpha(255)
package com.irtimaled.bbor.client.gui;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import java.util.ArrayList;
import java.util.List;
private static final int TITLE_HEIGHT = 16;
private final String title;
private final List<AbstractControl> controls = new ArrayList<>();
- private final Minecraft minecraft = Minecraft.getInstance();
+ private final MinecraftClient minecraft = MinecraftClient.getInstance();
private final int titleHeight;
private int height;
private IControl focused;
}
private int columnCount() {
- switch (minecraft.getLanguageManager().getCurrentLanguage().getCode()) {
+ switch (minecraft.getLanguageManager().getLanguage().getCode()) {
case "en_au":
case "en_us":
case "en_gb":
int y = this.getY();
int top = y;
if (this.title != null) {
- this.minecraft.fontRenderer.drawString(this.title, x + 4, y + ((TITLE_HEIGHT - this.minecraft.fontRenderer.FONT_HEIGHT) / 1.5f), 16777215);
+ this.minecraft.textRenderer.draw(this.title, x + 4, y + ((TITLE_HEIGHT - this.minecraft.textRenderer.fontHeight) / 1.5f), 16777215);
top += titleHeight;
}
package com.irtimaled.bbor.client.gui;
-import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.Element;
-interface IControl extends IFocusableControl, IGuiEventListener {
+interface IControl extends IFocusableControl, Element {
void render(int mouseX, int mouseY);
boolean isVisible();
package com.irtimaled.bbor.client.gui;
-import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.Element;
import java.util.List;
-public interface IControlSet extends IFocusableControl, IGuiEventListener {
+public interface IControlSet extends IFocusableControl, Element {
List<? extends IControl> controls();
IControl getFocused();
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.config.Setting;
-import net.minecraft.client.resources.I18n;
+import net.minecraft.client.resource.language.I18n;
import java.util.HashMap;
import java.util.Map;
private void updateText() {
Integer value = setting.get();
- this.setMessage(I18n.format(format, displayValues.getOrDefault(value, value.toString())));
+ this.setMessage(I18n.translate(format, displayValues.getOrDefault(value, value.toString())));
}
@Override
import com.irtimaled.bbor.Versions;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.text.StringTextComponent;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.text.LiteralText;
public abstract class ListScreen extends Screen {
private final Screen lastScreen;
private SearchField searchField;
ListScreen(Screen lastScreen) {
- super(new StringTextComponent("Bounding Box Outline Reloaded"));
+ super(new LiteralText("Bounding Box Outline Reloaded"));
this.lastScreen = lastScreen;
}
protected void init() {
this.controlList = this.buildList(48, this.height - 28);
this.searchField = new SearchField(this.font, this.width / 2 - 100, 22, 200, 20, this.controlList);
- this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.format("gui.done")) {
+ this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.translate("gui.done")) {
@Override
public void onPressed() {
onDoneClicked();
protected void render(int mouseX, int mouseY) {
this.controlList.render(mouseX, mouseY);
- this.drawCenteredString(this.font, this.title.getUnformattedComponentText(), this.width / 2, 8, 16777215);
+ this.drawCenteredString(this.font, this.title.asString(), this.width / 2, 8, 16777215);
this.searchField.render(mouseX, mouseY);
this.doneButton.render(mouseX, mouseY);
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
- for (IGuiEventListener control : this.children()) {
+ for (Element control : this.children()) {
if (control.mouseClicked(mouseX, mouseY, button)) {
- IGuiEventListener focused = getFocused();
+ Element focused = getFocused();
if (focused instanceof IFocusableControl && focused != control) {
((IFocusableControl) focused).clearFocus();
}
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.AnvilConverterException;
-import net.minecraft.world.storage.SaveFormat;
-import net.minecraft.world.storage.WorldSummary;
+import net.minecraft.world.level.storage.LevelStorage;
+import net.minecraft.world.level.storage.LevelStorageException;
+import net.minecraft.world.level.storage.LevelSummary;
import java.util.List;
protected ControlList buildList(int top, int bottom) {
controlList = new SelectableControlList(this.width, this.height, top, bottom);
try {
- final SaveFormat saveLoader = this.minecraft.getSaveLoader();
- List<WorldSummary> saveList = saveLoader.getSaveList();
+ final LevelStorage saveLoader = this.minecraft.getLevelStorage();
+ List<LevelSummary> saveList = saveLoader.getLevelList();
saveList.sort(null);
saveList.forEach(world -> controlList.add(new WorldSaveRow(world, saveLoader, controlList::setSelectedEntry)));
- } catch (AnvilConverterException e) {
+ } catch (LevelStorageException e) {
e.printStackTrace();
}
return controlList;
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.config.Setting;
-import net.minecraft.client.resources.I18n;
+import net.minecraft.client.resource.language.I18n;
class MaxYSettingSlider extends IntSettingSlider {
private final int actualMinValue;
MaxYSettingSlider(int width, int minValue, Setting<Integer> setting) {
- super(width, minValue - 2, 127, I18n.format("bbor.options.maxY", "%s"), setting);
+ super(width, minValue - 2, 127, I18n.translate("bbor.options.maxY", "%s"), setting);
this.actualMinValue = minValue;
this.setInitialPosition();
- this.addDisplayValue(-1, I18n.format("bbor.options.maxY.activated"));
- this.addDisplayValue(0, I18n.format("bbor.options.maxY.player"));
- this.addDisplayValue(63, I18n.format("bbor.options.maxY.seaLevel"));
+ this.addDisplayValue(-1, I18n.translate("bbor.options.maxY.activated"));
+ this.addDisplayValue(0, I18n.translate("bbor.options.maxY.player"));
+ this.addDisplayValue(63, I18n.translate("bbor.options.maxY.seaLevel"));
}
@Override
package com.irtimaled.bbor.client.gui;
-import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
public class SearchField extends TextFieldWidget implements IControl {
private final ControlList controlList;
- SearchField(FontRenderer fontRenderer, int left, int top, int width, int height, ControlList controlList) {
+ SearchField(TextRenderer fontRenderer, int left, int top, int width, int height, ControlList controlList) {
super(fontRenderer, left, top, width, height, "");
this.controlList = controlList;
- this.setResponder(text -> this.controlList.filter(removeLeadingSpaces(text.toLowerCase())));
- this.setTextFormatter((text, id) -> removeLeadingSpaces(text));
+ this.setChangedListener(text -> this.controlList.filter(removeLeadingSpaces(text.toLowerCase())));
+ this.setRenderTextProvider((text, id) -> removeLeadingSpaces(text));
this.setFocused(true);
}
@Override
public boolean isVisible() {
- return super.getVisible();
+ return super.isVisible();
}
}
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.BoundingBoxType;
+import net.minecraft.SharedConstants;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.SharedConstants;
+import net.minecraft.client.resource.language.I18n;
public class SettingsScreen extends ListScreen {
private static final String pillagerOutpostVersionPattern = "(?:1\\.1[4-9]|1\\.[2-9][0-9]|18w(?:4[7-9]|5[0-9])|19w|2[0-9]w).*";
@Override
protected ControlList buildList(int top, int bottom) {
- String version = SharedConstants.getVersion().getName();
+ String version = SharedConstants.getGameVersion().getName();
ControlList controlList = new ControlList(this.width, this.height, top, bottom);
if (this.minecraft.world != null) controlList.setTransparentBackground();
controlList
.section(null,
- width -> new BoolButton(width, I18n.format("bbor.options.active"), this.minecraft.world != null) {
+ width -> new BoolButton(width, I18n.translate("bbor.options.active"), this.minecraft.world != null) {
@Override
public void onPressed() {
ClientRenderer.toggleActive();
return ClientRenderer.getActive();
}
},
- width -> new BoolSettingButton(width, I18n.format("bbor.options.outerBoxOnly"), ConfigManager.outerBoxesOnly),
- width -> new BoolSettingButton(width, I18n.format("bbor.options.fill"), ConfigManager.fill))
- .section(I18n.format("bbor.features.spawnChunks"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.spawnChunks"), BoundingBoxType.WorldSpawn),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.lazyChunks"), BoundingBoxType.LazySpawnChunks),
+ width -> new BoolSettingButton(width, I18n.translate("bbor.options.outerBoxOnly"), ConfigManager.outerBoxesOnly),
+ width -> new BoolSettingButton(width, I18n.translate("bbor.options.fill"), ConfigManager.fill))
+ .section(I18n.translate("bbor.features.spawnChunks"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawnChunks"), BoundingBoxType.WorldSpawn),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.lazyChunks"), BoundingBoxType.LazySpawnChunks),
width -> new MaxYSettingSlider(width, 39, ConfigManager.worldSpawnMaxY))
- .section(I18n.format("bbor.features.slimeChunks"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.slimeChunks"), BoundingBoxType.SlimeChunks),
+ .section(I18n.translate("bbor.features.slimeChunks"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.slimeChunks"), BoundingBoxType.SlimeChunks),
width -> new MaxYSettingSlider(width, 39, ConfigManager.slimeChunkMaxY))
- .section(I18n.format("bbor.features.biomeBorders"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.biomeBorders"), BoundingBoxType.BiomeBorder),
+ .section(I18n.translate("bbor.features.biomeBorders"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.biomeBorders"), BoundingBoxType.BiomeBorder),
width -> new MaxYSettingSlider(width, 1, ConfigManager.biomeBordersMaxY),
width -> new IntSettingSlider(width, 1, 3, "bbor.options.distance", ConfigManager.biomeBordersRenderDistance)
- .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
- .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
- .addDisplayValue(3, I18n.format("bbor.options.distance.normal")))
- .section(I18n.format("bbor.features.flowerForests"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.flowerForests"), BoundingBoxType.FlowerForest),
+ .addDisplayValue(1, I18n.translate("bbor.options.distance.nearest"))
+ .addDisplayValue(2, I18n.translate("bbor.options.distance.nearer"))
+ .addDisplayValue(3, I18n.translate("bbor.options.distance.normal")))
+ .section(I18n.translate("bbor.features.flowerForests"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.flowerForests"), BoundingBoxType.FlowerForest),
width -> new IntSettingSlider(width, 1, 3, "bbor.options.distance", ConfigManager.flowerForestsRenderDistance)
- .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
- .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
- .addDisplayValue(3, I18n.format("bbor.options.distance.normal")))
- .section(I18n.format("bbor.features.bedrockCeilingBlocks"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.bedrockCeilingBlocks"), BoundingBoxType.BedrockCeiling))
- .section(I18n.format("bbor.features.mobSpawners"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.mobSpawners"), BoundingBoxType.MobSpawner),
- width -> new BoolSettingButton(width, I18n.format("bbor.features.mobSpawners.spawnArea"), ConfigManager.renderMobSpawnerSpawnArea),
- width -> new BoolSettingButton(width, I18n.format("bbor.features.mobSpawners.activationLines"), ConfigManager.renderMobSpawnerActivationLines))
- .section(I18n.format("bbor.sections.beaconsAndConduits"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.beacons"), BoundingBoxType.Beacon),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.conduits"), BoundingBoxType.Conduit),
- width -> new BoolSettingButton(width, I18n.format("bbor.features.conduits.mobHarmArea"), ConfigManager.renderConduitMobHarmArea))
- .section(I18n.format("bbor.features.spawnableBlocks"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.spawnableBlocks"), BoundingBoxType.SpawnableBlocks),
+ .addDisplayValue(1, I18n.translate("bbor.options.distance.nearest"))
+ .addDisplayValue(2, I18n.translate("bbor.options.distance.nearer"))
+ .addDisplayValue(3, I18n.translate("bbor.options.distance.normal")))
+ .section(I18n.translate("bbor.features.bedrockCeilingBlocks"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.bedrockCeilingBlocks"), BoundingBoxType.BedrockCeiling))
+ .section(I18n.translate("bbor.features.mobSpawners"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.mobSpawners"), BoundingBoxType.MobSpawner),
+ width -> new BoolSettingButton(width, I18n.translate("bbor.features.mobSpawners.spawnArea"), ConfigManager.renderMobSpawnerSpawnArea),
+ width -> new BoolSettingButton(width, I18n.translate("bbor.features.mobSpawners.activationLines"), ConfigManager.renderMobSpawnerActivationLines))
+ .section(I18n.translate("bbor.sections.beaconsAndConduits"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.beacons"), BoundingBoxType.Beacon),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.conduits"), BoundingBoxType.Conduit),
+ width -> new BoolSettingButton(width, I18n.translate("bbor.features.conduits.mobHarmArea"), ConfigManager.renderConduitMobHarmArea))
+ .section(I18n.translate("bbor.features.spawnableBlocks"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawnableBlocks"), BoundingBoxType.SpawnableBlocks),
width -> new IntSettingSlider(width, 1, 3, "bbor.options.distance.y", ConfigManager.spawnableBlocksRenderHeight)
.addDisplayValue(1, "2")
.addDisplayValue(2, "4")
.addDisplayValue(1, "8")
.addDisplayValue(2, "16")
.addDisplayValue(3, "32"))
- .section(I18n.format("bbor.features.spawningSpheres"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.spawningSpheres"), BoundingBoxType.AFKSphere),
- width -> new BoolSettingButton(width, I18n.format("bbor.features.spawnableBlocks"), ConfigManager.renderAFKSpawnableBlocks))
- .section(I18n.format("bbor.tabs.structures"),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.desertTemples"), BoundingBoxType.DesertTemple),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.jungleTemples"), BoundingBoxType.JungleTemple),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.witchHuts"), BoundingBoxType.WitchHut),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.mansions"), BoundingBoxType.Mansion),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.monuments"), BoundingBoxType.OceanMonument),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.igloos"), BoundingBoxType.Igloo),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.oceanRuins"), BoundingBoxType.OceanRuin),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.buriedTreasure"), BoundingBoxType.BuriedTreasure),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.shipwrecks"), BoundingBoxType.Shipwreck),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.strongholds"), BoundingBoxType.Stronghold),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.mineshafts"), BoundingBoxType.MineShaft),
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.villages"), BoundingBoxType.Village),
- width -> version.matches(pillagerOutpostVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.pillagerOutposts"), BoundingBoxType.PillagerOutpost) : null,
- width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.ruinedPortal"), BoundingBoxType.RuinedPortal) : null,
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.fortresses"), BoundingBoxType.NetherFortress),
- width -> version.matches(netherFossilVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.netherFossils"), BoundingBoxType.NetherFossil) : null,
- width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.bastionRemnants"), BoundingBoxType.BastionRemnant) : null,
- width -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.endCities"), BoundingBoxType.EndCity));
+ .section(I18n.translate("bbor.features.spawningSpheres"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawningSpheres"), BoundingBoxType.AFKSphere),
+ width -> new BoolSettingButton(width, I18n.translate("bbor.features.spawnableBlocks"), ConfigManager.renderAFKSpawnableBlocks))
+ .section(I18n.translate("bbor.tabs.structures"),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.desertTemples"), BoundingBoxType.DesertTemple),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.jungleTemples"), BoundingBoxType.JungleTemple),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.witchHuts"), BoundingBoxType.WitchHut),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.mansions"), BoundingBoxType.Mansion),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.monuments"), BoundingBoxType.OceanMonument),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.igloos"), BoundingBoxType.Igloo),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.oceanRuins"), BoundingBoxType.OceanRuin),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.buriedTreasure"), BoundingBoxType.BuriedTreasure),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.shipwrecks"), BoundingBoxType.Shipwreck),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.strongholds"), BoundingBoxType.Stronghold),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.mineshafts"), BoundingBoxType.MineShaft),
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.villages"), BoundingBoxType.Village),
+ width -> version.matches(pillagerOutpostVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.pillagerOutposts"), BoundingBoxType.PillagerOutpost) : null,
+ width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.ruinedPortal"), BoundingBoxType.RuinedPortal) : null,
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.fortresses"), BoundingBoxType.NetherFortress),
+ width -> version.matches(netherFossilVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.netherFossils"), BoundingBoxType.NetherFossil) : null,
+ width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.bastionRemnants"), BoundingBoxType.BastionRemnant) : null,
+ width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.endCities"), BoundingBoxType.EndCity));
return controlList;
}
}
import com.google.common.hash.Hashing;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.client.renderers.RenderHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.AbstractGui;
-import net.minecraft.client.renderer.texture.DynamicTexture;
-import net.minecraft.client.renderer.texture.NativeImage;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.client.texture.NativeImage;
+import net.minecraft.client.texture.NativeImageBackedTexture;
+import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
-import net.minecraft.world.storage.SaveFormat;
-import net.minecraft.world.storage.WorldInfo;
-import net.minecraft.world.storage.WorldSummary;
+import net.minecraft.world.level.LevelProperties;
+import net.minecraft.world.level.storage.LevelStorage;
+import net.minecraft.world.level.storage.LevelSummary;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class WorldSaveRow extends ControlListEntry implements Comparable<WorldSaveRow> {
private static final Logger LOGGER = LogManager.getLogger();
private static final DateFormat DATE_FORMAT = new SimpleDateFormat();
- private static final ResourceLocation ICON_MISSING = new ResourceLocation("textures/misc/unknown_server.png");
+ private static final Identifier ICON_MISSING = new Identifier("textures/misc/unknown_server.png");
private static final int ICON_SIZE = 20;
- private final Minecraft client;
- private final WorldSummary worldSummary;
- private final SaveFormat saveLoader;
+ private final MinecraftClient client;
+ private final LevelSummary worldSummary;
+ private final LevelStorage saveLoader;
private final Consumer<ControlListEntry> setSelectedEntry;
- private final ResourceLocation iconLocation;
- private final DynamicTexture icon;
+ private final Identifier iconLocation;
+ private final NativeImageBackedTexture icon;
private File iconFile;
private long lastClickTime;
- WorldSaveRow(WorldSummary worldSummary, SaveFormat saveLoader, Consumer<ControlListEntry> setSelectedEntry) {
+ WorldSaveRow(LevelSummary worldSummary, LevelStorage saveLoader, Consumer<ControlListEntry> setSelectedEntry) {
this.worldSummary = worldSummary;
this.saveLoader = saveLoader;
this.setSelectedEntry = setSelectedEntry;
- this.client = Minecraft.getInstance();
- this.iconLocation = new ResourceLocation("worlds/" + Hashing.sha1().hashUnencodedChars(worldSummary.getFileName()) + "/icon");
- this.iconFile = saveLoader.getFile(worldSummary.getFileName(), "icon.png");
+ this.client = MinecraftClient.getInstance();
+ this.iconLocation = new Identifier("worlds/" + Hashing.sha1().hashUnencodedChars(worldSummary.getName()) + "/icon");
+ this.iconFile = saveLoader.resolveFile(worldSummary.getName(), "icon.png");
if (!this.iconFile.isFile()) {
this.iconFile = null;
}
if (!isMouseOver(mouseX, mouseY)) return false;
this.setSelectedEntry.accept(this);
- if (Util.milliTime() - this.lastClickTime < 250L) {
+ if (Util.getMeasuringTimeMs() - this.lastClickTime < 250L) {
done();
} else {
- this.lastClickTime = Util.milliTime();
+ this.lastClickTime = Util.getMeasuringTimeMs();
}
return true;
}
@Override
public void done() {
- String fileName = this.worldSummary.getFileName();
- WorldInfo worldInfo = saveLoader.getWorldInfo(fileName);
+ String fileName = this.worldSummary.getName();
+ LevelProperties worldInfo = saveLoader.getLevelProperties(fileName);
long seed = worldInfo.getSeed();
ClientInterop.saveLoaded(fileName, seed);
}
- private DynamicTexture loadIcon() {
+ private NativeImageBackedTexture loadIcon() {
if (this.iconFile == null || !this.iconFile.isFile()) {
- this.client.getTextureManager().deleteTexture(this.iconLocation);
+ this.client.getTextureManager().destroyTexture(this.iconLocation);
return null;
}
try (InputStream stream = new FileInputStream(this.iconFile)) {
- DynamicTexture texture = new DynamicTexture(NativeImage.read(stream));
- this.client.getTextureManager().loadTexture(this.iconLocation, texture);
+ NativeImageBackedTexture texture = new NativeImageBackedTexture(NativeImage.read(stream));
+ this.client.getTextureManager().registerTexture(this.iconLocation, texture);
return texture;
} catch (Throwable exception) {
- LOGGER.error("Invalid icon for world {}", this.worldSummary.getFileName(), exception);
+ LOGGER.error("Invalid icon for world {}", this.worldSummary.getName(), exception);
this.iconFile = null;
return null;
}
@Override
public void render(int mouseX, int mouseY) {
String displayName = this.worldSummary.getDisplayName();
- String details = this.worldSummary.getFileName() + " (" + DATE_FORMAT.format(new Date(this.worldSummary.getLastTimePlayed())) + ")";
+ String details = this.worldSummary.getName() + " (" + DATE_FORMAT.format(new Date(this.worldSummary.getLastPlayed())) + ")";
int x = this.getX();
int y = this.getY();
- this.client.fontRenderer.drawString(displayName, (float) (x + ICON_SIZE + 3), (float) (y + 1), 16777215);
- this.client.fontRenderer.drawString(details, (float) (x + ICON_SIZE + 3), (float) (y + 1 + this.client.fontRenderer.FONT_HEIGHT + 1), 8421504);
+ this.client.textRenderer.draw(displayName, (float) (x + ICON_SIZE + 3), (float) (y + 1), 16777215);
+ this.client.textRenderer.draw(details, (float) (x + ICON_SIZE + 3), (float) (y + 1 + this.client.textRenderer.fontHeight + 1), 8421504);
this.client.getTextureManager().bindTexture(this.icon != null ? this.iconLocation : ICON_MISSING);
RenderHelper.enableBlend();
- AbstractGui.blit(x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
+ DrawableHelper.blit(x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
RenderHelper.disableBlend();
}
public void filter(String lowerValue) {
super.setVisible(lowerValue.isEmpty() ||
this.worldSummary.getDisplayName().toLowerCase().contains(lowerValue) ||
- this.worldSummary.getFileName().toLowerCase().contains(lowerValue));
+ this.worldSummary.getName().toLowerCase().contains(lowerValue));
}
@Override
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
-import net.minecraft.client.Minecraft;
-import net.minecraft.util.SharedSeedRandom;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.gen.ChunkRandom;
import java.util.Random;
public class BedrockCeilingHelper {
public static boolean isBedrock(int x, int y, int z){
BlockPos pos = new BlockPos(x, y, z);
- BlockState blockState = Minecraft.getInstance().world.getBlockState(pos);
+ BlockState blockState = MinecraftClient.getInstance().world.getBlockState(pos);
return blockState == Blocks.BEDROCK.getDefaultState();
}
public static boolean chunkLoaded(int chunkX, int chunkZ) {
- return Minecraft.getInstance().world.getChunkProvider().chunkExists(chunkX, chunkZ);
+ return MinecraftClient.getInstance().world.getChunkManager().isChunkLoaded(chunkX, chunkZ);
}
public static Random getRandomForChunk(int chunkX, int chunkZ) {
- SharedSeedRandom random = new SharedSeedRandom();
- random.setBaseChunkSeed(chunkX, chunkZ);
+ ChunkRandom random = new ChunkRandom();
+ random.setSeed(chunkX, chunkZ);
return random;
}
}
package com.irtimaled.bbor.client.interop;
import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
public static int getBiomeId(int x, int y, int z) {
BlockPos pos = new BlockPos(x, y, z);
- Biome biome = Minecraft.getInstance().world.getBiome(pos);
- return Registry.BIOME.getId(biome);
+ Biome biome = MinecraftClient.getInstance().world.getBiome(pos);
+ return Registry.BIOME.getRawId(biome);
}
}
import com.irtimaled.bbor.common.models.DimensionId;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.player.ClientPlayerEntity;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.network.play.ClientPlayNetHandler;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.server.command.CommandSource;
+import net.minecraft.server.command.ServerCommandSource;
+import net.minecraft.text.*;
+import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.text.*;
-import net.minecraft.util.text.event.ClickEvent;
public class ClientInterop {
public static void disconnectedFromRemoteServer() {
public static boolean interceptChatMessage(String message) {
if (message.startsWith("/bbor:")) {
- ClientPlayNetHandler connection = Minecraft.getInstance().getConnection();
+ ClientPlayNetworkHandler connection = MinecraftClient.getInstance().getNetworkHandler();
if (connection != null) {
- CommandDispatcher<ISuggestionProvider> commandDispatcher = connection.getCommandDispatcher();
- CommandSource commandSource = Minecraft.getInstance().player.getCommandSource();
+ CommandDispatcher<CommandSource> commandDispatcher = connection.getCommandDispatcher();
+ ServerCommandSource commandSource = MinecraftClient.getInstance().player.getCommandSource();
try {
commandDispatcher.execute(message.substring(1), commandSource);
} catch (CommandSyntaxException exception) {
- commandSource.sendErrorMessage(TextComponentUtils.toTextComponent(exception.getRawMessage()));
+ commandSource.sendError(Texts.toText(exception.getRawMessage()));
if (exception.getInput() != null && exception.getCursor() >= 0) {
- ITextComponent suggestion = new StringTextComponent("")
- .applyTextStyle(TextFormatting.GRAY)
- .applyTextStyle(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)));
+ Text suggestion = new LiteralText("")
+ .formatted(Formatting.GRAY)
+ .styled(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)));
int textLength = Math.min(exception.getInput().length(), exception.getCursor());
if (textLength > 10) {
- suggestion.appendText("...");
+ suggestion.append("...");
}
- suggestion.appendText(exception.getInput().substring(Math.max(0, textLength - 10), textLength));
+ suggestion.append(exception.getInput().substring(Math.max(0, textLength - 10), textLength));
if (textLength < exception.getInput().length()) {
- suggestion.appendSibling(new StringTextComponent(exception.getInput().substring(textLength))
- .applyTextStyles(TextFormatting.RED, TextFormatting.UNDERLINE));
+ suggestion.append(new LiteralText(exception.getInput().substring(textLength))
+ .formatted(Formatting.RED, Formatting.UNDERLINE));
}
- suggestion.appendSibling(new TranslationTextComponent("command.context.here")
- .applyTextStyles(TextFormatting.RED, TextFormatting.ITALIC));
- commandSource.sendErrorMessage(suggestion);
+ suggestion.append(new TranslatableText("command.context.here")
+ .formatted(Formatting.RED, Formatting.ITALIC));
+ commandSource.sendError(suggestion);
}
}
}
}
public static int getRenderDistanceChunks() {
- return Minecraft.getInstance().gameSettings.renderDistanceChunks;
+ return MinecraftClient.getInstance().options.viewDistance;
}
- public static void handleSeedMessage(ITextComponent chatComponent) {
- TypeHelper.doIfType(chatComponent, TranslationTextComponent.class, message -> {
+ public static void handleSeedMessage(Text chatComponent) {
+ TypeHelper.doIfType(chatComponent, TranslatableText.class, message -> {
if (!message.getKey().equals("commands.seed.success")) return;
try {
- long seed = Long.parseLong(message.getFormatArgs()[0].toString());
+ long seed = Long.parseLong(message.getArgs()[0].toString());
SlimeChunkProvider.setSeed(seed);
} catch (Exception ignored) {
}
});
}
- public static void registerClientCommands(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
+ public static void registerClientCommands(CommandDispatcher<CommandSource> commandDispatcher) {
SeedCommand.register(commandDispatcher);
SpawningSphereCommand.register(commandDispatcher);
CustomCommand.register(commandDispatcher);
public static void saveLoaded(String fileName, long seed) {
displayScreen(null);
- Minecraft.getInstance().mouseHelper.grabMouse();
+ MinecraftClient.getInstance().mouse.lockCursor();
clearStructures();
}
public static void displayScreen(Screen screen) {
- Minecraft.getInstance().displayGuiScreen(screen);
+ MinecraftClient.getInstance().openScreen(screen);
}
public static long getGameTime() {
- return Minecraft.getInstance().world.getGameTime();
+ return MinecraftClient.getInstance().world.getTime();
}
}
import com.irtimaled.bbor.common.models.Coords;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.feature.DecoratedFeatureConfig;
-import net.minecraft.world.gen.feature.FlowersFeature;
+import net.minecraft.world.gen.feature.FlowerFeature;
import java.util.HashMap;
import java.util.Map;
private static final Random random = new Random();
private static final Map<BlockState, Setting<HexColor>> flowerColorMap = new HashMap<>();
- private static final FlowersFeature flowersFeature;
+ private static final FlowerFeature flowersFeature;
static {
flowerColorMap.put(Blocks.DANDELION.getDefaultState(), ConfigManager.colorFlowerForestDandelion);
flowerColorMap.put(Blocks.CORNFLOWER.getDefaultState(), ConfigManager.colorFlowerForestCornflower);
flowerColorMap.put(Blocks.LILY_OF_THE_VALLEY.getDefaultState(), ConfigManager.colorFlowerForestLilyOfTheValley);
- DecoratedFeatureConfig config = (DecoratedFeatureConfig) Biomes.FLOWER_FOREST.getFlowers().get(0).config;
- flowersFeature = (FlowersFeature) config.feature.feature;
+ DecoratedFeatureConfig config = (DecoratedFeatureConfig) Biomes.FLOWER_FOREST.getFlowerFeatures().get(0).config;
+ flowersFeature = (FlowerFeature) config.feature.feature;
}
public static Setting<HexColor> getFlowerColorAtPos(Coords coords) {
int x = coords.getX();
int z = coords.getZ();
- BlockState blockState = flowersFeature.getRandomFlower(random, new BlockPos(x, coords.getY(), z));
+ BlockState blockState = flowersFeature.getFlowerToPlace(random, new BlockPos(x, coords.getY(), z));
return flowerColorMap.get(blockState);
}
}
public static boolean canGrowFlower(int x, int y, int z) {
- return Minecraft.getInstance().world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.GRASS_BLOCK;
+ return MinecraftClient.getInstance().world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.GRASS_BLOCK;
}
}
package com.irtimaled.bbor.client.interop;
-import net.minecraft.resources.IPackFinder;
-import net.minecraft.resources.IResourcePack;
-import net.minecraft.resources.ResourcePackInfo;
-import net.minecraft.resources.VanillaPack;
+import net.minecraft.resource.DefaultResourcePack;
+import net.minecraft.resource.ResourcePack;
+import net.minecraft.resource.ResourcePackProfile;
+import net.minecraft.resource.ResourcePackProvider;
import java.util.Map;
-public class ModPackFinder implements IPackFinder {
+public class ModPackFinder implements ResourcePackProvider {
private static final String BBOR = "bbor";
- private final IResourcePack modPack;
+ private final ResourcePack modPack;
public ModPackFinder() {
- modPack = new VanillaPack(BBOR);
+ modPack = new DefaultResourcePack(BBOR);
}
@Override
- public <T extends ResourcePackInfo> void addPackInfosToMap(Map<String, T> map, ResourcePackInfo.IFactory<T> factory) {
- T resourcePackInfo = ResourcePackInfo.createResourcePack(BBOR,
+ public <T extends ResourcePackProfile> void register(Map<String, T> map, ResourcePackProfile.Factory<T> factory) {
+ T resourcePackInfo = ResourcePackProfile.of(BBOR,
true,
() -> this.modPack,
factory,
- ResourcePackInfo.Priority.BOTTOM);
+ ResourcePackProfile.InsertionPosition.BOTTOM);
if (resourcePackInfo != null) {
map.put(BBOR, resourcePackInfo);
}
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.events.StructuresLoaded;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.nbt.CompoundNBT;
-import net.minecraft.nbt.ListNBT;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.structure.StructureManager;
+import net.minecraft.structure.StructurePiece;
+import net.minecraft.structure.StructureStart;
+import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.ChunkPos;
-import net.minecraft.util.math.MutableBoundingBox;
+import net.minecraft.world.FeatureUpdater;
import net.minecraft.world.IWorld;
+import net.minecraft.world.PersistentStateManager;
+import net.minecraft.world.WorldSaveHandler;
import net.minecraft.world.biome.Biome;
-import net.minecraft.world.chunk.storage.RegionFileCache;
import net.minecraft.world.dimension.DimensionType;
-import net.minecraft.world.gen.ChunkGenerator;
-import net.minecraft.world.gen.feature.structure.LegacyStructureDataUtil;
-import net.minecraft.world.gen.feature.structure.StructurePiece;
-import net.minecraft.world.gen.feature.structure.StructureStart;
-import net.minecraft.world.gen.feature.template.TemplateManager;
-import net.minecraft.world.storage.DimensionSavedDataManager;
-import net.minecraft.world.storage.SaveHandler;
+import net.minecraft.world.gen.chunk.ChunkGenerator;
+import net.minecraft.world.storage.RegionBasedStorage;
import java.io.File;
import java.io.IOException;
private final DimensionId dimensionId;
private final Set<String> loadedChunks = new HashSet<>();
- private LegacyStructureDataUtil legacyStructureDataUtil = null;
- private SaveHandler saveHandler = null;
+ private FeatureUpdater legacyStructureDataUtil = null;
+ private WorldSaveHandler saveHandler = null;
private File chunkSaveLocation = null;
private ChunkLoader chunkLoader;
- NBTStructureLoader(DimensionId dimensionId, SaveHandler saveHandler, File worldDirectory) {
+ NBTStructureLoader(DimensionId dimensionId, WorldSaveHandler saveHandler, File worldDirectory) {
this.dimensionId = dimensionId;
this.configure(saveHandler, worldDirectory);
}
this.chunkLoader = null;
}
- void configure(SaveHandler saveHandler, File worldDirectory) {
+ void configure(WorldSaveHandler saveHandler, File worldDirectory) {
this.saveHandler = saveHandler;
if (worldDirectory != null) {
- this.chunkSaveLocation = new File(dimensionId.getDimensionType().getDirectory(worldDirectory), "region");
+ this.chunkSaveLocation = new File(dimensionId.getDimensionType().getSaveDirectory(worldDirectory), "region");
this.chunkLoader = new ChunkLoader(this.chunkSaveLocation);
}
}
- private LegacyStructureDataUtil getLegacyStructureDataUtil() {
+ private FeatureUpdater getLegacyStructureDataUtil() {
if (this.legacyStructureDataUtil == null) {
- File dataFolder = new File(DimensionType.OVERWORLD.getDirectory(this.saveHandler.getWorldDirectory()), "data");
- this.legacyStructureDataUtil = LegacyStructureDataUtil.func_215130_a(dimensionId.getDimensionType(),
- new DimensionSavedDataManager(dataFolder, this.saveHandler.getFixer()));
+ File dataFolder = new File(DimensionType.OVERWORLD.getSaveDirectory(this.saveHandler.getWorldDir()), "data");
+ this.legacyStructureDataUtil = FeatureUpdater.create(dimensionId.getDimensionType(),
+ new PersistentStateManager(dataFolder, this.saveHandler.getDataFixer()));
}
return this.legacyStructureDataUtil;
}
- private CompoundNBT loadStructureStarts(int chunkX, int chunkZ) {
+ private CompoundTag loadStructureStarts(int chunkX, int chunkZ) {
try {
- CompoundNBT compound = this.chunkLoader.readChunk(chunkX, chunkZ);
+ CompoundTag compound = this.chunkLoader.readChunk(chunkX, chunkZ);
if (compound == null) return null;
int dataVersion = compound.contains("DataVersion", 99) ? compound.getInt("DataVersion") : -1;
if (dataVersion < 1493) {
if (compound.getCompound("Level").getBoolean("hasLegacyStructureData")) {
- compound = getLegacyStructureDataUtil().func_212181_a(compound);
+ compound = getLegacyStructureDataUtil().getUpdatedReferences(compound);
}
}
return compound.getCompound("Level").getCompound("Structures").getCompound("Starts");
if (!loadedChunks.add(String.format("%s,%s", chunkX, chunkZ))) return;
- CompoundNBT structureStarts = loadStructureStarts(chunkX, chunkZ);
- if (structureStarts == null || structureStarts.size() == 0) return;
+ CompoundTag structureStarts = loadStructureStarts(chunkX, chunkZ);
+ if (structureStarts == null || structureStarts.getSize() == 0) return;
Map<String, StructureStart> structureStartMap = new HashMap<>();
- for (String key : structureStarts.keySet()) {
- CompoundNBT compound = structureStarts.getCompound(key);
+ for (String key : structureStarts.getKeys()) {
+ CompoundTag compound = structureStarts.getCompound(key);
if (compound.contains("BB")) {
structureStartMap.put(key, new SimpleStructureStart(compound));
}
}
private static class SimpleStructureStart extends StructureStart {
- SimpleStructureStart(CompoundNBT compound) {
+ SimpleStructureStart(CompoundTag compound) {
super(null,
0,
0,
null,
- new MutableBoundingBox(compound.getIntArray("BB")),
+ new BlockBox(compound.getIntArray("BB")),
0,
0);
- ListNBT children = compound.getList("Children", 10);
+ ListTag children = compound.getList("Children", 10);
for (int index = 0; index < children.size(); ++index) {
- CompoundNBT child = children.getCompound(index);
- if (child.contains("BB")) this.components.add(new SimpleStructurePiece(child));
+ CompoundTag child = children.getCompound(index);
+ if (child.contains("BB")) this.children.add(new SimpleStructurePiece(child));
}
}
@Override
- public void init(ChunkGenerator<?> chunkGenerator, TemplateManager templateManager, int i, int i1, Biome biome) {
+ public void initialize(ChunkGenerator<?> chunkGenerator, StructureManager structureManager, int i, int i1, Biome biome) {
}
}
private static class SimpleStructurePiece extends StructurePiece {
- SimpleStructurePiece(CompoundNBT compound) {
+ SimpleStructurePiece(CompoundTag compound) {
super(null, compound);
}
@Override
- protected void readAdditional(CompoundNBT compoundNBT) {
+ protected void toNbt(CompoundTag compoundTag) {
}
@Override
- public boolean addComponentParts(IWorld iWorld, Random random, MutableBoundingBox mutableBoundingBox, ChunkPos chunkPos) {
+ public boolean generate(IWorld iWorld, Random random, BlockBox blockBox, ChunkPos chunkPos) {
return false;
}
}
private static class ChunkLoader {
- private final RegionFileCache regionFileCache;
+ private final RegionBasedStorage regionFileCache;
public ChunkLoader(File file) {
- this.regionFileCache = new RegionFileCache(file) {
+ this.regionFileCache = new RegionBasedStorage(file) {
};
}
- public CompoundNBT readChunk(int chunkX, int chunkZ) throws IOException {
- return regionFileCache.readChunk(new ChunkPos(chunkX, chunkZ));
+ public CompoundTag readChunk(int chunkX, int chunkZ) throws IOException {
+ return regionFileCache.getTagAt(new ChunkPos(chunkX, chunkZ));
}
public void close() throws IOException {
import com.irtimaled.bbor.client.Player;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.client.Minecraft;
-import net.minecraft.world.storage.SaveFormat;
-import net.minecraft.world.storage.SaveHandler;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.world.WorldSaveHandler;
+import net.minecraft.world.level.storage.LevelStorage;
import java.io.File;
import java.util.HashMap;
public class SaveGameStructureLoader {
private static final Map<DimensionId, NBTStructureLoader> nbtStructureLoaders = new HashMap<>();
- private static SaveHandler saveHandler = null;
+ private static WorldSaveHandler saveHandler = null;
private static File worldDirectory = null;
static void loadSaveGame(String fileName) {
- Minecraft minecraft = Minecraft.getInstance();
- SaveFormat saveLoader = minecraft.getSaveLoader();
- saveHandler = saveLoader.getSaveLoader(fileName, null);
- worldDirectory = saveLoader.func_215781_c().resolve(fileName).toFile();
+ MinecraftClient minecraft = MinecraftClient.getInstance();
+ LevelStorage saveLoader = minecraft.getLevelStorage();
+ saveHandler = saveLoader.createSaveHandler(fileName, null);
+ worldDirectory = saveLoader.getSavesDirectory().resolve(fileName).toFile();
for (DimensionId dimensionId : nbtStructureLoaders.keySet()) {
NBTStructureLoader dimensionProcessor = getNBTStructureLoader(dimensionId);
import com.irtimaled.bbor.common.models.Coords;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
-import net.minecraft.client.Minecraft;
-import net.minecraft.entity.EntityClassification;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityType;
-import net.minecraft.tags.BlockTags;
-import net.minecraft.util.Direction;
+import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.shapes.VoxelShape;
+import net.minecraft.util.math.Direction;
+import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public class SpawnableBlocksHelper {
- private static final EntityType entityType = EntityType.Builder.create(EntityClassification.MONSTER)
- .size(0f, 0f).disableSerialization().build(null);
+ private static final EntityType entityType = EntityType.Builder.create(EntityCategory.MONSTER)
+ .setDimensions(0f, 0f).disableSaving().build(null);
public static void findSpawnableBlocks(Coords coords, int width, int height, BlockProcessor blockProcessor) {
int blockX = coords.getX();
int minY = Math.max(1, blockY - height);
int maxY = Math.min(255, blockY + height);
- World world = Minecraft.getInstance().world;
+ World world = MinecraftClient.getInstance().world;
for (int x = minX; x < maxX; x++) {
for (int z = minZ; z < maxZ; z++) {
if (isBiomeHostileSpawnProof(world, new BlockPos(x, 1, z))) continue;
static boolean isBiomeHostileSpawnProof(World world, BlockPos pos) {
Biome biome = world.getBiome(pos);
- return biome.getSpawningChance() == 0 ||
- biome.getSpawns(EntityClassification.MONSTER).isEmpty();
+ return biome.getMaxSpawnLimit() == 0 ||
+ biome.getEntitySpawnList(EntityCategory.MONSTER).isEmpty();
}
static boolean isSpawnable(World world, BlockPos pos, BlockState spawnBlockState, BlockState upperBlockState) {
VoxelShape collisionShape = upperBlockState.getCollisionShape(world, pos);
boolean isNether = world.dimension.isNether();
- return spawnBlockState.canEntitySpawn(world, pos.down(), isNether ? EntityType.ZOMBIE_PIGMAN : entityType) &&
- !Block.doesSideFillSquare(collisionShape, Direction.UP) &&
- !upperBlockState.canProvidePower() &&
- !upperBlockState.isIn(BlockTags.RAILS) &&
- collisionShape.getEnd(Direction.Axis.Y) <= 0 &&
+ return spawnBlockState.allowsSpawning(world, pos.down(), isNether ? EntityType.ZOMBIE_PIGMAN : entityType) &&
+ !Block.isFaceFullSquare(collisionShape, Direction.UP) &&
+ !upperBlockState.emitsRedstonePower() &&
+ !upperBlockState.matches(BlockTags.RAILS) &&
+ collisionShape.getMaximum(Direction.Axis.Y) <= 0 &&
upperBlockState.getFluidState().isEmpty() &&
- (isNether || world.getLightFor(LightType.BLOCK, pos) <= 7);
+ (isNether || world.getLightLevel(LightType.BLOCK, pos) <= 7);
}
}
import com.irtimaled.bbor.client.models.Point;
import com.irtimaled.bbor.common.models.Coords;
import net.minecraft.block.BlockState;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
int minY = Math.max(1, blockY - height);
int maxY = Math.min(255, blockY + height);
- World world = Minecraft.getInstance().world;
+ World world = MinecraftClient.getInstance().world;
for (int x = minX; x < maxX; x++) {
for (int z = minZ; z < maxZ; z++) {
double closestX = x + 0.5D;
import com.irtimaled.bbor.common.TypeHelper;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-import net.minecraft.client.Minecraft;
-import net.minecraft.tileentity.TileEntity;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.client.MinecraftClient;
import java.util.Collection;
import java.util.HashSet;
import java.util.function.Function;
public class TileEntitiesHelper {
- public static <T extends TileEntity, S extends AbstractBoundingBox> Iterable<S> map(Class<T> clazz, Function<T, S> map) {
- Collection<TileEntity> tileEntities = Minecraft.getInstance().world.loadedTileEntityList;
+ public static <T extends BlockEntity, S extends AbstractBoundingBox> Iterable<S> map(Class<T> clazz, Function<T, S> map) {
+ Collection<BlockEntity> tileEntities = MinecraftClient.getInstance().world.blockEntities;
Set<S> results = new HashSet<>();
- for (TileEntity tileEntity : tileEntities) {
+ for (BlockEntity tileEntity : tileEntities) {
T typed = TypeHelper.as(tileEntity, clazz);
if (typed == null) {
continue;
package com.irtimaled.bbor.client.keyboard;
-import net.minecraft.client.settings.KeyBinding;
-import net.minecraft.client.util.InputMappings;
+import net.minecraft.client.options.KeyBinding;
+import net.minecraft.client.util.InputUtil;
class CustomKeyBinding extends KeyBinding {
private final Key key;
}
@Override
- public void bind(InputMappings.Input input) {
- super.bind(input);
+ public void setKeyCode(InputUtil.KeyCode input) {
+ super.setKeyCode(input);
int keyCode = input.getKeyCode();
key.updateKeyCode(keyCode);
}
package com.irtimaled.bbor.client.keyboard;
-import net.minecraft.client.util.InputMappings;
+import net.minecraft.client.util.InputUtil;
import java.util.HashSet;
import java.util.Set;
}
public Key register(String keyName) {
- InputMappings.Input input = InputMappings.getInputByName(keyName);
+ InputUtil.KeyCode input = InputUtil.fromName(keyName);
Key key = new Key(input.getKeyCode());
subKeys.add(key);
return key;
package com.irtimaled.bbor.client.keyboard;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.settings.KeyBinding;
-import net.minecraft.client.util.InputMappings;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.options.KeyBinding;
+import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;
import java.util.HashSet;
import java.util.Set;
public class KeyListener {
- private static final Minecraft minecraft = Minecraft.getInstance();
+ private static final MinecraftClient minecraft = MinecraftClient.getInstance();
private static long mainWindowHandle;
private static final Set<Key> keys = new HashSet<>();
private static final Set<CustomKeyBinding> keyBindings = new HashSet<>();
public static final String Category = "Bounding Box Outline Reloaded";
public static void init() {
- mainWindowHandle = minecraft.mainWindow.getHandle();
+ mainWindowHandle = minecraft.window.getHandle();
GLFW.glfwSetKeyCallback(mainWindowHandle, KeyListener::onKeyEvent);
}
public static Key register(String description, String keyName) {
- InputMappings.Input input = InputMappings.getInputByName(keyName);
+ InputUtil.KeyCode input = InputUtil.fromName(keyName);
CustomKeyBinding keyBinding = new CustomKeyBinding(description, input.getKeyCode());
keyBindings.add(keyBinding);
if (windowHandle == mainWindowHandle &&
minecraft.currentScreen == null &&
keyCode != -1 &&
- !InputMappings.isKeyDown(mainWindowHandle, 292) &&
+ !InputUtil.isKeyPressed(mainWindowHandle, 292) &&
handleKeyEvent(keyCode, isPressed))
return;
- minecraft.keyboardListener.onKeyEvent(windowHandle, keyCode, scanCode, action, modifiers);
+ minecraft.keyboard.onKey(windowHandle, keyCode, scanCode, action, modifiers);
}
private static boolean handleKeyEvent(int keyCode, boolean isPressed) {
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.tileentity.BeaconTileEntity;
+import net.minecraft.block.entity.BeaconBlockEntity;
+
public class BeaconProvider implements IBoundingBoxProvider<BoundingBoxBeacon> {
@Override
@Override
public Iterable<BoundingBoxBeacon> get(DimensionId dimensionId) {
- return TileEntitiesHelper.map(BeaconTileEntity.class, beacon -> {
- int levels = beacon.getLevels();
+ return TileEntitiesHelper.map(BeaconBlockEntity.class, beacon -> {
+ int levels = beacon.getLevel();
Coords coords = new Coords(beacon.getPos());
return BoundingBoxBeacon.from(coords, levels);
});
import com.irtimaled.bbor.common.ReflectionHelper;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.tileentity.ConduitTileEntity;
+import net.minecraft.block.entity.ConduitBlockEntity;
import net.minecraft.util.math.BlockPos;
import java.util.List;
import java.util.function.Function;
public class ConduitProvider implements IBoundingBoxProvider<BoundingBoxConduit> {
- private static final Function<ConduitTileEntity, List<BlockPos>> blocksFetcher =
- ReflectionHelper.getPrivateFieldGetter(ConduitTileEntity.class, List.class, BlockPos.class);
+ private static final Function<ConduitBlockEntity, List<BlockPos>> blocksFetcher =
+ ReflectionHelper.getPrivateFieldGetter(ConduitBlockEntity.class, List.class, BlockPos.class);
@Override
public boolean canProvide(DimensionId dimensionId) {
@Override
public Iterable<BoundingBoxConduit> get(DimensionId dimensionId) {
- return TileEntitiesHelper.map(ConduitTileEntity.class, conduit -> {
+ return TileEntitiesHelper.map(ConduitBlockEntity.class, conduit -> {
List<BlockPos> blocks = blocksFetcher.apply(conduit);
if (blocks == null) return null;
import java.util.Map;
public class FlowerForestProvider implements IBoundingBoxProvider<BoundingBoxFlowerForest>, ICachingProvider {
- public static final int FLOWER_FOREST_BIOME_ID = Registry.BIOME.getId(Biomes.FLOWER_FOREST);
+ public static final int FLOWER_FOREST_BIOME_ID = Registry.BIOME.getRawId(Biomes.FLOWER_FOREST);
private static Coords lastPlayerCoords = null;
private static Integer lastRenderDistance = null;
private static Map<Coords, BoundingBoxFlowerForest> lastBoundingBoxes = new HashMap<>();
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.tileentity.MobSpawnerTileEntity;
+import net.minecraft.block.entity.MobSpawnerBlockEntity;
public class MobSpawnerProvider implements IBoundingBoxProvider<BoundingBoxMobSpawner> {
@Override
@Override
public Iterable<BoundingBoxMobSpawner> get(DimensionId dimensionId) {
- return TileEntitiesHelper.map(MobSpawnerTileEntity.class, spawner -> {
+ return TileEntitiesHelper.map(MobSpawnerBlockEntity.class, spawner -> {
Coords coords = new Coords(spawner.getPos());
return BoundingBoxMobSpawner.from(coords);
});
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.util.SharedSeedRandom;
+import net.minecraft.world.gen.ChunkRandom;
import java.util.HashSet;
import java.util.Set;
}
private static boolean isSlimeChunk(int chunkX, int chunkZ) {
- return SharedSeedRandom.seedSlimeChunk(chunkX, chunkZ,seed, 987234911L).nextInt(10) == 0;
+ return ChunkRandom.create(chunkX, chunkZ, seed, 987234911L).nextInt(10) == 0;
}
public void clearCache() {
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import java.util.HashSet;
import java.util.Set;
public class SpawnableBlocksProvider implements IBoundingBoxProvider<BoundingBoxSpawnableBlocks>, ICachingProvider {
- public static final Minecraft minecraft = Minecraft.getInstance();
+ public static final MinecraftClient minecraft = MinecraftClient.getInstance();
private static Long lastGameTime = null;
private static Set<BoundingBoxSpawnableBlocks> lastBoundingBox = null;
@Override
public Iterable<BoundingBoxSpawnableBlocks> get(DimensionId dimensionId) {
- long gameTime = minecraft.world.getGameTime();
+ long gameTime = minecraft.world.getTime();
if (lastBoundingBox == null || (!((Long) gameTime).equals(lastGameTime) && gameTime % 2L == 0L)) {
lastGameTime = gameTime;
lastBoundingBox = getSpawnableBlocks();
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import java.util.HashSet;
import java.util.Set;
public class SpawningSphereProvider implements IBoundingBoxProvider<BoundingBoxSpawningSphere>, ICachingProvider {
- public static final Minecraft minecraft = Minecraft.getInstance();
+ public static final MinecraftClient minecraft = MinecraftClient.getInstance();
private static Long lastGameTime = null;
private static Set<BoundingBoxSpawningSphere> lastBoundingBox = null;
@Override
public Iterable<BoundingBoxSpawningSphere> get(DimensionId dimensionId) {
- long gameTime = minecraft.world.getGameTime();
+ long gameTime = minecraft.world.getTime();
if (lastBoundingBox == null || (!((Long) gameTime).equals(lastGameTime) && gameTime % 2L == 0L)) {
lastGameTime = gameTime;
lastBoundingBox = getSpawningSphere();
import com.irtimaled.bbor.client.models.Point;
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.font.TextRenderer;
import java.awt.*;
import java.util.function.Supplier;
}
void renderText(OffsetPoint offsetPoint, String... texts) {
- FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
+ TextRenderer fontRenderer = MinecraftClient.getInstance().textRenderer;
RenderHelper.beforeRenderFont(offsetPoint);
- float top = -(fontRenderer.FONT_HEIGHT * texts.length) / 2f;
+ float top = -(fontRenderer.fontHeight * texts.length) / 2f;
for (String text : texts) {
float left = fontRenderer.getStringWidth(text) / 2f;
- fontRenderer.drawString(text, -left, top, -1);
- top += fontRenderer.FONT_HEIGHT;
+ fontRenderer.draw(text, -left, top, -1);
+ top += fontRenderer.fontHeight;
}
RenderHelper.afterRenderFont();
}
import com.irtimaled.bbor.client.config.ConfigManager;
import com.mojang.blaze3d.platform.GlStateManager;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import org.lwjgl.opengl.GL11;
public class RenderHelper {
enableDepthTest();
if (ConfigManager.alwaysVisible.get()) {
- GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
+ GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC);
}
}
package com.irtimaled.bbor.client.renderers;
import com.irtimaled.bbor.client.Camera;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.client.renderer.vertex.VertexFormat;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormat;
+import net.minecraft.client.render.VertexFormats;
import java.awt.*;
private final int glMode;
static Renderer startLines() {
- return new Renderer(RenderHelper.LINES, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.LINES, VertexFormats.POSITION_COLOR);
}
static Renderer startLineLoop() {
- return new Renderer(RenderHelper.LINE_LOOP, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.LINE_LOOP, VertexFormats.POSITION_COLOR);
}
static Renderer startQuads() {
- return new Renderer(RenderHelper.QUADS, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.QUADS, VertexFormats.POSITION_COLOR);
}
static Renderer startPoints() {
- return new Renderer(RenderHelper.POINTS, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.POINTS, VertexFormats.POSITION_COLOR);
}
public static Renderer startTextured() {
- return new Renderer(RenderHelper.QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
+ return new Renderer(RenderHelper.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
}
private static final Tessellator tessellator = new Tessellator(2097152);
public void render() {
if (glMode == RenderHelper.QUADS) {
- bufferBuilder.sortVertexData((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ());
+ bufferBuilder.sortQuads((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ());
}
tessellator.draw();
}
private void pos(double x, double y, double z) {
- bufferBuilder.pos(x, y, z);
+ bufferBuilder.vertex(x, y, z);
}
private void tex(double u, double v) {
- bufferBuilder.tex(u, v);
+ bufferBuilder.texture(u, v);
}
private void color() {
}
private void end() {
- bufferBuilder.endVertex();
+ bufferBuilder.next();
}
}
import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
import com.irtimaled.bbor.client.models.Point;
import com.irtimaled.bbor.common.BoundingBoxType;
-import net.minecraft.client.resources.I18n;
+import net.minecraft.client.resource.language.I18n;
import java.awt.*;
Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
if (spawnableSpacesCount != null) {
- renderText(sphereCenter, I18n.format("bbor.renderer.spawningSphere.spawnable"),
+ renderText(sphereCenter, I18n.translate("bbor.renderer.spawningSphere.spawnable"),
spawnableSpacesCount == 0 ?
- I18n.format("bbor.renderer.spawningSphere.none") :
+ I18n.translate("bbor.renderer.spawningSphere.none") :
String.format("%,d", spawnableSpacesCount));
}
renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.util.math.MutableBoundingBox;
-import net.minecraft.world.gen.feature.structure.StructurePiece;
-import net.minecraft.world.gen.feature.structure.StructureStart;
+import net.minecraft.structure.StructurePiece;
+import net.minecraft.structure.StructureStart;
+import net.minecraft.util.math.BlockBox;
import java.util.HashSet;
import java.util.Map;
StructureStart structureStart = structureMap.get(type.getName());
if (structureStart == null) return;
- MutableBoundingBox bb = structureStart.getBoundingBox();
+ BlockBox bb = structureStart.getBoundingBox();
if (bb == null) return;
AbstractBoundingBox boundingBox = buildStructure(bb, type);
if (boundingBoxCache.isCached(boundingBox)) return;
Set<AbstractBoundingBox> structureBoundingBoxes = new HashSet<>();
- for (StructurePiece structureComponent : structureStart.getComponents()) {
+ for (StructurePiece structureComponent : structureStart.getChildren()) {
structureBoundingBoxes.add(buildStructure(structureComponent.getBoundingBox(), type));
}
boundingBoxCache.addBoundingBoxes(boundingBox, structureBoundingBoxes);
}
- private AbstractBoundingBox buildStructure(MutableBoundingBox bb, BoundingBoxType type) {
+ private AbstractBoundingBox buildStructure(BlockBox bb, BoundingBoxType type) {
Coords min = new Coords(bb.minX, bb.minY, bb.minZ);
Coords max = new Coords(bb.maxX, bb.maxY, bb.maxZ);
return BoundingBoxCuboid.from(min, max, type);
package com.irtimaled.bbor.common.events;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.world.gen.feature.structure.StructureStart;
+import net.minecraft.structure.StructureStart;
import java.util.Map;
package com.irtimaled.bbor.common.events;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.world.server.ServerWorld;
-import net.minecraft.world.storage.WorldInfo;
+import net.minecraft.server.world.ServerWorld;
+import net.minecraft.world.level.LevelProperties;
public class WorldLoaded {
private final DimensionId dimensionId;
private final int spawnZ;
public WorldLoaded(ServerWorld world) {
- WorldInfo info = world.getWorldInfo();
+ LevelProperties info = world.getLevelProperties();
this.dimensionId = DimensionId.from(world.getDimension().getType());
this.seed = info.getSeed();
this.spawnX = info.getSpawnX();
import com.irtimaled.bbor.common.events.*;
import com.irtimaled.bbor.common.models.DimensionId;
import com.irtimaled.bbor.common.models.ServerPlayer;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.network.NetworkManager;
-import net.minecraft.network.play.ServerPlayNetHandler;
-import net.minecraft.world.chunk.Chunk;
-import net.minecraft.world.gen.feature.structure.StructureStart;
-import net.minecraft.world.server.ServerWorld;
+import net.minecraft.network.ClientConnection;
+import net.minecraft.server.network.ServerPlayNetworkHandler;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.server.world.ServerWorld;
+import net.minecraft.structure.StructureStart;
+import net.minecraft.world.chunk.WorldChunk;
import java.util.Collection;
import java.util.Map;
public class CommonInterop {
- public static void chunkLoaded(Chunk chunk) {
+ public static void chunkLoaded(WorldChunk chunk) {
DimensionId dimensionId = DimensionId.from(chunk.getWorld().getDimension().getType());
Map<String, StructureStart> structures = chunk.getStructureStarts();
if (structures.size() > 0) EventBus.publish(new StructuresLoaded(structures, dimensionId));
}
public static void playerLoggedIn(ServerPlayerEntity player) {
- ServerPlayNetHandler connection = player.connection;
+ ServerPlayNetworkHandler connection = player.networkHandler;
if (connection == null) return;
- NetworkManager networkManager = connection.netManager;
- if (networkManager.isLocalChannel()) return;
+ ClientConnection networkManager = connection.connection;
+ if (networkManager.isLocal()) return;
EventBus.publish(new PlayerLoggedIn(new ServerPlayer(player)));
}
if (name.equals(NAME)) return reader.readDimensionId();
int dimensionRawId = reader.readVarInt();
- DimensionType dimensionType = DimensionType.getById(dimensionRawId);
+ DimensionType dimensionType = DimensionType.byRawId(dimensionRawId);
return DimensionId.from(dimensionType);
}
}
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
import io.netty.buffer.Unpooled;
-import net.minecraft.network.IPacket;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.client.CCustomPayloadPacket;
-import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.network.Packet;
+import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
+import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.PacketByteBuf;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
public class PayloadBuilder {
- private static final Map<String, ResourceLocation> packetNames = new HashMap<>();
+ private static final Map<String, Identifier> packetNames = new HashMap<>();
static PayloadBuilder clientBound(String name) {
- return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), SCustomPayloadPlayPacket::new);
+ return new PayloadBuilder(packetNames.computeIfAbsent(name, Identifier::new), CustomPayloadS2CPacket::new);
}
static PayloadBuilder serverBound(String name) {
- return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), CCustomPayloadPacket::new);
+ return new PayloadBuilder(packetNames.computeIfAbsent(name, Identifier::new), CustomPayloadC2SPacket::new);
}
- private final ResourceLocation name;
- private final BiFunction<ResourceLocation, PacketBuffer, IPacket<?>> packetBuilder;
- private final PacketBuffer buffer;
+ private final Identifier name;
+ private final BiFunction<Identifier, PacketByteBuf, Packet<?>> packetBuilder;
+ private final PacketByteBuf buffer;
- private PayloadBuilder(ResourceLocation name, BiFunction<ResourceLocation, PacketBuffer, IPacket<?>> packetBuilder) {
+ private PayloadBuilder(Identifier name, BiFunction<Identifier, PacketByteBuf, Packet<?>> packetBuilder) {
this.name = name;
- this.buffer = new PacketBuffer(Unpooled.buffer());
+ this.buffer = new PacketByteBuf(Unpooled.buffer());
this.packetBuilder = packetBuilder;
}
- private IPacket<?> packet;
+ private Packet<?> packet;
- public IPacket<?> build() {
+ public Packet<?> build() {
if (packet == null)
packet = packetBuilder.apply(name, buffer);
return packet;
}
public PayloadBuilder writeDimensionId(DimensionId dimensionId) {
- buffer.writeResourceLocation(dimensionId.getValue());
+ buffer.writeIdentifier(dimensionId.getValue());
packet = null;
return this;
}
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.network.PacketBuffer;
+import net.minecraft.util.PacketByteBuf;
public class PayloadReader {
- private final PacketBuffer buffer;
+ private final PacketByteBuf buffer;
- public PayloadReader(PacketBuffer buffer) {
+ public PayloadReader(PacketByteBuf buffer) {
this.buffer = buffer;
}
}
DimensionId readDimensionId() {
- return DimensionId.from(buffer.readResourceLocation());
+ return DimensionId.from(buffer.readIdentifier());
}
}
package com.irtimaled.bbor.common.models;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Identifier;
import net.minecraft.world.dimension.DimensionType;
import java.util.HashMap;
import java.util.Map;
public class DimensionId {
- private static final Map<ResourceLocation, DimensionId> dimensionIdMap = new HashMap<>();
+ private static final Map<Identifier, DimensionId> dimensionIdMap = new HashMap<>();
public static DimensionId from(DimensionType dimensionType) {
- return from(DimensionType.getKey(dimensionType));
+ return from(DimensionType.getId(dimensionType));
}
- public static DimensionId from(ResourceLocation value) {
+ public static DimensionId from(Identifier value) {
return dimensionIdMap.computeIfAbsent(value, DimensionId::new);
}
public static DimensionId OVERWORLD = DimensionId.from(DimensionType.OVERWORLD);
public static DimensionId NETHER = DimensionId.from(DimensionType.THE_NETHER);
- private final ResourceLocation value;
+ private final Identifier value;
- public DimensionId(ResourceLocation value) {
+ public DimensionId(Identifier value) {
this.value = value;
}
- public ResourceLocation getValue() {
+ public Identifier getValue() {
return value;
}
public DimensionType getDimensionType() {
- return DimensionType.byName(value);
+ return DimensionType.byId(value);
}
@Override
package com.irtimaled.bbor.common.models;
import com.irtimaled.bbor.common.messages.PayloadBuilder;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.network.IPacket;
+import net.minecraft.network.Packet;
+import net.minecraft.server.network.ServerPlayerEntity;
import java.util.function.Consumer;
public class ServerPlayer {
private final DimensionId dimensionId;
- private final Consumer<IPacket<?>> packetConsumer;
+ private final Consumer<Packet<?>> packetConsumer;
public ServerPlayer(ServerPlayerEntity player) {
this.dimensionId = DimensionId.from(player.dimension);
- this.packetConsumer = player.connection::sendPacket;
+ this.packetConsumer = player.networkHandler::sendPacket;
}
public DimensionId getDimensionId() {
+++ /dev/null
-package com.irtimaled.bbor.install;
-
-import com.irtimaled.bbor.Versions;
-
-import javax.swing.*;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-public class Installer {
- public static void install() {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Throwable t) {
- t.printStackTrace();
- }
-
- try {
- String osName = getOsName();
- File minecraftFolder = getMinecraftFolder(osName);
- String version = "BBOR-" + Versions.minecraft;
- File versionFolder = new File(minecraftFolder, "versions/" + version + "/");
- versionFolder.mkdirs();
-
- File versionJson = new File(versionFolder, version + ".json");
- Files.copy(Installer.class.getResourceAsStream("/profile.json"), versionJson.toPath(), StandardCopyOption.REPLACE_EXISTING);
-
- try {
- File profilesJson = new File(minecraftFolder, "launcher_profiles.json");
- if (profilesJson.exists()) {
- String identifier = "\"" + version.toLowerCase() + "\"";
- String contents = new String(Files.readAllBytes(profilesJson.toPath()));
- if (contents.contains(identifier)) {
- contents = contents.replaceAll(",\n?\\s*" + identifier + "\\s*:\\s*\\{[^}]*},", ",");
- contents = contents.replaceAll(",?\n?\\s*" + identifier + "\\s*:\\s*\\{[^}]*},?", "");
- }
-
- String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
-
- contents = contents.replaceAll("([}],\n?\\s*\"profiles\"\\s*:\\s*[{]\n?)", "$1" +
- " " + identifier + ": {\n" +
- " \"name\": \"Bounding Box Outline Reloaded\",\n" +
- " \"type\": \"custom\",\n" +
- " \"created\": \"" + date + "T00:00:00.000Z\",\n" +
- " \"lastUsed\": \"2100-01-01T00:00:00.000Z\",\n" +
- " \"lastVersionId\": \"" + version + "\"\n" +
- " },\n");
-
- Files.write(profilesJson.toPath(), contents.getBytes());
- }
- } catch (Throwable t) {
- t.printStackTrace();
- }
-
- try {
- String source = Installer.class.getProtectionDomain().getCodeSource().getLocation().getPath();
- if (source.startsWith("/") && osName.contains("win")) {
- source = source.substring(1);
- }
- File mainJar = new File(minecraftFolder, "libraries/com/irtimaled/bbor/" + Versions.minecraft + "/" + version.toLowerCase() + ".jar");
- mainJar.getParentFile().mkdirs();
- Files.copy(Paths.get(source), mainJar.toPath(), StandardCopyOption.REPLACE_EXISTING);
- } catch (Throwable t) {
- t.printStackTrace();
- }
-
- JOptionPane.showMessageDialog(null,
- "Bounding Box Outline Reloaded " + Versions.build + " for " + Versions.minecraft + " has been successfully installed!\n" +
- "\n" +
- "Re-open the Minecraft Launcher to see it in the dropdown.",
- "Bounding Box Outline Reloaded Installer", JOptionPane.INFORMATION_MESSAGE);
- } catch (Throwable t) {
- StringWriter w = new StringWriter();
- t.printStackTrace(new PrintWriter(w));
- JOptionPane.showMessageDialog(null,
- "An error occured while installing Bounding Box Outline Reloaded, please report this to the issue\n" +
- "tracker (https://github.com/irtimaled/BoundingBoxOutlineReloaded/issues):\n" +
- "\n" +
- w.toString().replace("\t", " "), "Bounding Box Outline Reloaded Installer", JOptionPane.ERROR_MESSAGE);
- }
- }
-
- private static File getMinecraftFolder(String osName) {
- File minecraftFolder;
- if (osName.contains("win")) {
- minecraftFolder = new File(System.getenv("APPDATA") + "/.minecraft");
- } else if (osName.contains("mac")) {
- minecraftFolder = new File(System.getProperty("user.home") + "/Library/Application Support/minecraft");
- } else {
- minecraftFolder = new File(System.getProperty("user.home") + "/.minecraft");
- }
- return minecraftFolder;
- }
-
- private static String getOsName() {
- return System.getProperty("os.name").toLowerCase(Locale.ROOT);
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.launch;
-
-import java.io.File;
-import java.util.List;
-
-public class ClientTweaker extends Tweaker {
- @Override
- protected void addOptions(List<String> args, File gameDir, File assetsDir, String profile) {
- if (!isOptifineLoaded()) {
- super.addOptions(args, gameDir, assetsDir, profile);
- addArg("--gameDir", gameDir != null ? gameDir.getAbsolutePath() : null);
- addArg("--assetsDir", assetsDir != null ? assetsDir.getPath() : null);
- addArg("--version", profile);
- }
- }
-
- private boolean isOptifineLoaded() {
- try {
- Class cls = Class.forName("optifine.OptiFineTweaker");
- return cls != null;
- } catch (Throwable e) {
- return false;
- }
- }
-
- @Override
- public String getLaunchTarget() {
- return "net.minecraft.client.main.Main";
- }
-
- @Override
- protected boolean isClient() {
- return true;
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.launch;
-
-public class ServerTweaker extends Tweaker {
- @Override
- protected boolean isClient() {
- return false;
- }
-
- @Override
- public String getLaunchTarget() {
- return "net.minecraft.server.MinecraftServer";
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.launch;
-
-import net.minecraft.launchwrapper.ITweaker;
-import net.minecraft.launchwrapper.LaunchClassLoader;
-import org.spongepowered.asm.launch.MixinBootstrap;
-import org.spongepowered.asm.mixin.MixinEnvironment;
-import org.spongepowered.asm.mixin.Mixins;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class Tweaker implements ITweaker {
- private List<String> args;
-
- @Override
- public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
- this.args = new ArrayList<>();
- addOptions(args, gameDir, assetsDir, profile);
- }
-
- void addArg(String name, String value) {
- if (value != null) {
- args.add(name);
- args.add(value);
- }
- }
-
- protected void addOptions(List<String> args, File gameDir, File assetsDir, String profile) {
- this.args.addAll(args);
- }
-
- @Override
- public void injectIntoClassLoader(LaunchClassLoader classLoader) {
- MixinBootstrap.init();
- MixinEnvironment.getDefaultEnvironment().setSide(isClient() ? MixinEnvironment.Side.CLIENT : MixinEnvironment.Side.SERVER);
- Mixins.addConfiguration("mixins.bbor.json");
- }
-
- protected abstract boolean isClient();
-
- @Override
- public String[] getLaunchArguments() {
- return args.toArray(new String[0]);
- }
-}
import com.irtimaled.bbor.client.ClientProxy;
import com.irtimaled.bbor.client.keyboard.KeyListener;
-import net.minecraft.client.GameSettings;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.client.options.GameOptions;
+import net.minecraft.client.options.KeyBinding;
import org.apache.commons.lang3.ArrayUtils;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import java.io.File;
-
-@Mixin(GameSettings.class)
+@Mixin(GameOptions.class)
public abstract class MixinGameSettings {
@Mutable
@Final
@Shadow
- public KeyBinding[] keyBindings;
+ public KeyBinding[] keysAll;
@Shadow
- public abstract void loadOptions();
+ public abstract void load();
@Inject(method = "<init>", at = @At("RETURN"))
- private void init(Minecraft minecraft, File file, CallbackInfo ci) {
+ private void init(CallbackInfo ci) {
ClientProxy.registerKeyBindings();
- keyBindings = ArrayUtils.addAll(keyBindings, KeyListener.keyBindings());
- this.loadOptions();
+ keysAll = ArrayUtils.addAll(keysAll, KeyListener.keyBindings());
+ this.load();
}
-
}
import com.irtimaled.bbor.client.ClientProxy;
import com.irtimaled.bbor.client.interop.ModPackFinder;
-import net.minecraft.client.GameConfiguration;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.ClientResourcePackInfo;
-import net.minecraft.resources.ResourcePackList;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.RunArgs;
+import net.minecraft.client.resource.ClientResourcePackProfile;
+import net.minecraft.resource.ResourcePackManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(Minecraft.class)
+@Mixin(MinecraftClient.class)
public class MixinMinecraft {
@Shadow
@Final
- private ResourcePackList<ClientResourcePackInfo> resourcePackRepository;
+ private ResourcePackManager<ClientResourcePackProfile> resourcePackManager;
private ClientProxy clientProxy;
@Inject(method = "<init>", at = @At("RETURN"))
- private void constructor(GameConfiguration configuration, CallbackInfo ci) {
+ private void constructor(RunArgs configuration, CallbackInfo ci) {
clientProxy = new ClientProxy();
- this.resourcePackRepository.addPackFinder(new ModPackFinder());
+ this.resourcePackManager.registerProvider(new ModPackFinder());
}
@Inject(method = "init", at = @At("RETURN"))
package com.irtimaled.bbor.mixin.client.entity.player;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.entity.player.ClientPlayerEntity;
+import net.minecraft.client.network.ClientPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
package com.irtimaled.bbor.mixin.client.gui.screen;
import com.irtimaled.bbor.client.gui.ListScreen;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ChatScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(ChatScreen.class)
public class MixinChatScreen {
- @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/screen/Screen;)V", shift = At.Shift.BEFORE), cancellable = true)
+ @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;openScreen(Lnet/minecraft/client/gui/screen/Screen;)V", shift = At.Shift.BEFORE), cancellable = true)
private void keyPressed(CallbackInfoReturnable<Boolean> cir) {
- if (Minecraft.getInstance().currentScreen instanceof ListScreen) {
+ if (MinecraftClient.getInstance().currentScreen instanceof ListScreen) {
cir.setReturnValue(true);
cir.cancel();
}
package com.irtimaled.bbor.mixin.client.gui.screen;
import com.irtimaled.bbor.client.gui.SettingsScreenButton;
-import net.minecraft.client.gui.screen.OptionsScreen;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.widget.Widget;
+import net.minecraft.client.gui.screen.SettingsScreen;
+import net.minecraft.client.gui.widget.AbstractButtonWidget;
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;
-@Mixin(OptionsScreen.class)
+@Mixin(SettingsScreen.class)
public class MixinOptionsScreen extends Screen {
private MixinOptionsScreen() {
super(null);
//shuffle middle buttons up by 12 px to make space
int top = this.height / 6 + 42;
int bottom = this.height / 6 + 168;
-
- for (Widget button : buttons) {
+ for (AbstractButtonWidget button : buttons) {
if (button.y >= top && button.y < bottom)
button.y -= 12;
}
package com.irtimaled.bbor.mixin.client.network.login;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.login.ClientLoginNetHandler;
+import net.minecraft.client.network.ClientLoginNetworkHandler;
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;
-@Mixin(ClientLoginNetHandler.class)
+@Mixin(ClientLoginNetworkHandler.class)
public class MixinClientLoginNetHandler {
@Inject(method = "onDisconnect", at = @At("HEAD"))
private void onDisconnect(CallbackInfo ci) {
package com.irtimaled.bbor.mixin.client.network.play;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.play.ClientPlayNetHandler;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
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;
-@Mixin(ClientPlayNetHandler.class)
+@Mixin(ClientPlayNetworkHandler.class)
public class MixinClientPlayNetHandler {
@Inject(method = "onDisconnect", at = @At("HEAD"))
private void onDisconnect(CallbackInfo ci) {
package com.irtimaled.bbor.mixin.client.renderer;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GameRenderer;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
public class MixinGameRenderer {
@Shadow
@Final
- private Minecraft mc;
+ private MinecraftClient client;
- @Inject(method = "updateCameraAndRender(FJ)V", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/profiler/IProfiler;endStartSection(Ljava/lang/String;)V", args = "ldc=hand", shift = At.Shift.BEFORE))
+ @Inject(method = "renderCenter(FJ)V", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", args = "ldc=hand", shift = At.Shift.BEFORE))
private void render(float partialTicks, long ignored, CallbackInfo ci) {
- ClientInterop.render(partialTicks, this.mc.player);
+ ClientInterop.render(partialTicks, this.client.player);
}
}
package com.irtimaled.bbor.mixin.client.settings;
import com.irtimaled.bbor.client.keyboard.KeyListener;
-import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.client.options.KeyBinding;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
public class MixinKeyBinding {
@Final
@Shadow
- private static Map<String, Integer> CATEGORY_ORDER;
+ private static Map<String, Integer> categoryOrderMap;
static {
- CATEGORY_ORDER.put(KeyListener.Category, 0);
+ categoryOrderMap.put(KeyListener.Category, 0);
}
}
@Mixin(ClientWorld.class)
public class MixinClientWorld {
- @Inject(method = "sendQuittingDisconnectingPacket", at = @At("RETURN"))
+ @Inject(method = "disconnect", at = @At("RETURN"))
private void sendQuittingDisconnectingPacket(CallbackInfo ci) {
ClientInterop.disconnectedFromRemoteServer();
}
import com.irtimaled.bbor.common.interop.CommonInterop;
import com.irtimaled.bbor.common.messages.SubscribeToServer;
-import net.minecraft.network.play.IServerPlayNetHandler;
-import net.minecraft.network.play.ServerPlayNetHandler;
-import net.minecraft.network.play.client.CCustomPayloadPacket;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.network.listener.ServerPlayPacketListener;
+import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
+import net.minecraft.server.network.ServerPlayNetworkHandler;
+import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
-@Mixin(CCustomPayloadPacket.class)
+@Mixin(CustomPayloadC2SPacket.class)
public class MixinCCustomPayloadPacket {
@Shadow
- private ResourceLocation channel;
+ private Identifier channel;
- @Redirect(method = "processPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/IServerPlayNetHandler;processCustomPayload(Lnet/minecraft/network/play/client/CCustomPayloadPacket;)V"))
- private void processPacket(IServerPlayNetHandler netHandlerPlayServer, CCustomPayloadPacket packet) {
+ @Redirect(method = "apply", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/ServerPlayPacketListener;onCustomPayload(Lnet/minecraft/network/packet/c2s/play/CustomPayloadC2SPacket;)V"))
+ private void processPacket(ServerPlayPacketListener netHandlerPlayServer, CustomPayloadC2SPacket packet) {
if (this.channel.toString().equals(SubscribeToServer.NAME)) {
- CommonInterop.playerSubscribed(((ServerPlayNetHandler) netHandlerPlayServer).player);
+ CommonInterop.playerSubscribed(((ServerPlayNetworkHandler) netHandlerPlayServer).player);
} else {
- netHandlerPlayServer.processCustomPayload(packet);
+ netHandlerPlayServer.onCustomPayload(packet);
}
}
}
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.network.play.server.SChatPacket;
-import net.minecraft.util.text.ITextComponent;
+import net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket;
+import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(SChatPacket.class)
+@Mixin(ChatMessageS2CPacket.class)
public class MixinSChatPacket {
@Shadow
- private ITextComponent chatComponent;
+ private Text message;
- @Inject(method = "processPacket", at = @At("RETURN"))
+ @Inject(method = "apply", at = @At("RETURN"))
private void processPacket(CallbackInfo ci) {
- ClientInterop.handleSeedMessage(this.chatComponent);
+ ClientInterop.handleSeedMessage(this.message);
}
}
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.play.IClientPlayNetHandler;
-import net.minecraft.network.play.server.SChunkDataPacket;
+import net.minecraft.network.listener.ClientPlayPacketListener;
+import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(SChunkDataPacket.class)
+@Mixin(ChunkDataS2CPacket.class)
public class MixinSChunkDataPacket {
@Shadow
private int chunkX;
@Shadow
private int chunkZ;
- @Inject(method = "processPacket", at = @At("RETURN"))
- private void processPacket(IClientPlayNetHandler netHandlerPlayClient, CallbackInfo ci) {
+ @Inject(method = "apply", at = @At("RETURN"))
+ private void processPacket(ClientPlayPacketListener netHandlerPlayClient, CallbackInfo ci) {
ClientInterop.receivedChunk(this.chunkX, this.chunkZ);
}
}
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.TypeHelper;
-import net.minecraft.client.network.play.ClientPlayNetHandler;
-import net.minecraft.client.network.play.IClientPlayNetHandler;
-import net.minecraft.network.play.server.SCommandListPacket;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.network.listener.ClientPlayPacketListener;
+import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket;
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;
-@Mixin(SCommandListPacket.class)
+@Mixin(CommandTreeS2CPacket.class)
public class MixinSCommandListPacket {
- @Inject(method = "processPacket", at = @At("RETURN"))
- private void processPacket(IClientPlayNetHandler netHandlerPlayClient, CallbackInfo ci) {
- TypeHelper.doIfType(netHandlerPlayClient, ClientPlayNetHandler.class, handler ->
+ @Inject(method = "apply", at = @At("RETURN"))
+ private void processPacket(ClientPlayPacketListener netHandlerPlayClient, CallbackInfo ci) {
+ TypeHelper.doIfType(netHandlerPlayClient, ClientPlayNetworkHandler.class, handler ->
ClientInterop.registerClientCommands(handler.getCommandDispatcher())
);
}
import com.irtimaled.bbor.common.messages.InitializeClient;
import com.irtimaled.bbor.common.messages.PayloadReader;
import com.irtimaled.bbor.common.messages.SubscribeToServer;
-import net.minecraft.client.network.play.ClientPlayNetHandler;
-import net.minecraft.client.network.play.IClientPlayNetHandler;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.network.listener.ClientPlayPacketListener;
+import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.PacketByteBuf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
-@Mixin(SCustomPayloadPlayPacket.class)
+@Mixin(CustomPayloadS2CPacket.class)
public abstract class MixinSCustomPayloadPlayPacket {
@Shadow
- private ResourceLocation channel;
+ private Identifier channel;
- @Redirect(method = "processPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/play/IClientPlayNetHandler;handleCustomPayload(Lnet/minecraft/network/play/server/SCustomPayloadPlayPacket;)V"))
- private void processPacket(IClientPlayNetHandler netHandlerPlayClient, SCustomPayloadPlayPacket packet) {
+ @Redirect(method = "apply", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/ClientPlayPacketListener;onCustomPayload(Lnet/minecraft/network/packet/s2c/play/CustomPayloadS2CPacket;)V"))
+ private void processPacket(ClientPlayPacketListener netHandlerPlayClient, CustomPayloadS2CPacket packet) {
String channelName = channel.toString();
if (channelName.startsWith("bbor:")) {
- PacketBuffer data = null;
+ PacketByteBuf data = null;
try {
- data = packet.getBufferData();
+ data = packet.getData();
PayloadReader reader = new PayloadReader(data);
switch (channelName) {
case InitializeClient.NAME: {
EventBus.publish(InitializeClient.getEvent(reader));
- ((ClientPlayNetHandler) netHandlerPlayClient).sendPacket(SubscribeToServer.getPayload().build());
+ ((ClientPlayNetworkHandler) netHandlerPlayClient).sendPacket(SubscribeToServer.getPayload().build());
break;
}
case AddBoundingBox.NAME:
data.release();
}
} else {
- netHandlerPlayClient.handleCustomPayload(packet);
+ netHandlerPlayClient.onCustomPayload(packet);
}
}
}
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.network.play.server.SSpawnPositionPacket;
+import net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(SSpawnPositionPacket.class)
+@Mixin(PlayerSpawnPositionS2CPacket.class)
public abstract class MixinSSpawnPositionPacket {
@Shadow
- private BlockPos spawnBlockPos;
+ private BlockPos pos;
- @Inject(method = "processPacket", at = @At("RETURN"))
+ @Inject(method = "apply", at = @At("RETURN"))
private void afterProcessPacket(CallbackInfo ci) {
- ClientInterop.updateWorldSpawnReceived(spawnBlockPos);
+ ClientInterop.updateWorldSpawnReceived(pos);
}
}
import com.irtimaled.bbor.common.interop.CommonInterop;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.dimension.DimensionType;
-import net.minecraft.world.server.ServerWorld;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Final
private Map<DimensionType, ServerWorld> worlds;
- @Inject(method = "loadInitialChunks", at = @At("HEAD"))
+ @Inject(method = "prepareStartRegion", at = @At("HEAD"))
private void initialWorldChunkLoad(CallbackInfo ci) {
CommonInterop.loadWorlds(worlds.values());
}
package com.irtimaled.bbor.mixin.server.dedicated;
import com.irtimaled.bbor.common.CommonProxy;
-import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.dedicated.MinecraftDedicatedServer;
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.CallbackInfoReturnable;
-@Mixin(DedicatedServer.class)
+@Mixin(MinecraftDedicatedServer.class)
public class MixinDedicatedServer {
- @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServer;loadAllWorlds(Ljava/lang/String;Ljava/lang/String;JLnet/minecraft/world/WorldType;Lcom/google/gson/JsonElement;)V"))
+ @Inject(method = "setupServer", at = @At(value = "NEW", target = "net/minecraft/server/dedicated/DedicatedPlayerManager"))
private void init(CallbackInfoReturnable<Boolean> cir) {
new CommonProxy().init();
}
package com.irtimaled.bbor.mixin.server.management;
import com.irtimaled.bbor.common.interop.CommonInterop;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.network.NetworkManager;
-import net.minecraft.server.management.PlayerList;
+import net.minecraft.network.ClientConnection;
+import net.minecraft.server.PlayerManager;
+import net.minecraft.server.network.ServerPlayerEntity;
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;
-@Mixin(PlayerList.class)
+@Mixin(PlayerManager.class)
public class MixinPlayerList {
- @Inject(method = "initializeConnectionToPlayer", at = @At("RETURN"))
- private void playerLoggedIn(NetworkManager networkManager, ServerPlayerEntity player, CallbackInfo ci) {
+ @Inject(method = "onPlayerConnect", at = @At("RETURN"))
+ private void playerLoggedIn(ClientConnection netManager, ServerPlayerEntity player, CallbackInfo ci) {
CommonInterop.playerLoggedIn(player);
}
- @Inject(method = "playerLoggedOut", at = @At("HEAD"))
+ @Inject(method = "remove", at = @At("HEAD"))
private void playerLoggedOut(ServerPlayerEntity player, CallbackInfo ci) {
CommonInterop.playerLoggedOut(player);
}
package com.irtimaled.bbor.mixin.world.chunk;
import com.irtimaled.bbor.common.interop.CommonInterop;
-import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.WorldChunk;
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;
-@Mixin(Chunk.class)
+@Mixin(WorldChunk.class)
public class MixinChunk {
- @Inject(method = "func_217318_w", at = @At("RETURN"))
+ @Inject(method = "loadToWorld", at = @At("RETURN"))
private void onLoad(CallbackInfo ci) {
- CommonInterop.chunkLoaded((Chunk) (Object) this);
+ CommonInterop.chunkLoaded((WorldChunk) (Object) this);
}
}
+++ /dev/null
-package com.irtimaled.bbor.server;
-
-import com.irtimaled.bbor.Versions;
-import net.minecraft.launchwrapper.Launch;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.channels.Channels;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ServerRunner {
- private static final Map<String, String> VANILLA_SERVER_JARS = new HashMap<>();
-
- private static final String[] LIBRARIES = {
- "https://github.com/irtimaled/Mixin/releases/download/org/spongepowered/mixin/0.7.11-SNAPSHOT/mixin-0.7.11-SNAPSHOT.jar",
- "https://repo1.maven.org/maven2/org/ow2/asm/asm/6.2/asm-6.2.jar",
- "https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/6.2/asm-commons-6.2.jar",
- "https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/6.2/asm-tree-6.2.jar",
- "https://libraries.minecraft.net/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar"
- };
-
- private static final ThrowableConsumer<URL> addURL;
-
- static {
- VANILLA_SERVER_JARS.put("1.14.4", "https://launcher.mojang.com/v1/objects/3dc3d84a581f14691199cf6831b71ed1296a9fdf/server.jar");
- VANILLA_SERVER_JARS.put("1.14.2", "https://launcher.mojang.com/v1/objects/808be3869e2ca6b62378f9f4b33c946621620019/server.jar");
- VANILLA_SERVER_JARS.put("1.13.2", "https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar");
-
- try {
- Method method = URLClassLoader.class
- .getDeclaredMethod("addURL", URL.class);
- method.setAccessible(true);
- addURL = url -> method.invoke(ClassLoader.getSystemClassLoader(), url);
- } catch (ReflectiveOperationException e) {
- throw new AssertionError(e);
- }
- }
-
- private static void addURLToClasspath(File file) throws MalformedURLException {
- addURL.accept(file.toURI().toURL());
- }
-
- public static void run(List<String> args) throws IOException {
- String serverJarUrl = VANILLA_SERVER_JARS.get(Versions.minecraft);
-
- addURLToClasspath(getOrDownload(new File("."), serverJarUrl));
- for (String url : LIBRARIES) {
- addURLToClasspath(getOrDownload(new File("libs"), url));
- }
-
- args = new ArrayList<>(args);
- args.add("--tweakClass");
- args.add("com.irtimaled.bbor.launch.ServerTweaker");
-
- System.out.println("Launching server...");
- Launch.main(args.toArray(new String[0]));
- }
-
- private static File getOrDownload(File directory, String url) throws IOException {
- String fileName = url.substring(url.lastIndexOf('/') + 1);
- File target = new File(directory, fileName);
- if (target.isFile()) {
- return target;
- }
- target.getParentFile().mkdirs();
-
- System.out.println("Downloading library: " + url);
- new FileOutputStream(target).getChannel()
- .transferFrom(Channels.newChannel(new URL(url).openStream()), 0, Long.MAX_VALUE);
-
- return target;
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.server;
-
-import com.irtimaled.bbor.common.TypeHelper;
-
-import java.util.function.Consumer;
-
-public interface ThrowableConsumer<T> extends Consumer<T> {
- @Override
- default void accept(final T elem) {
- try {
- acceptThrows(elem);
- } catch (final Throwable t) {
- throw TypeHelper.as(t, RuntimeException.class, () -> new RuntimeException(t));
- }
- }
-
- void acceptThrows(T elem) throws Throwable;
-}
--- /dev/null
+{
+ "schemaVersion": 1,
+ "id": "bbor",
+ "name": "BoundingBoxOutlineReloaded",
+ "description": "Shows the bounding boxes of structures and features.",
+ "authors": [
+ "Irtimaled"
+ ],
+ "version": "$version",
+ "mixins": [
+ "mixins.bbor.json"
+ ]
+}
+++ /dev/null
-{
- "inheritsFrom": "${mcVersion}",
- "id": "BBOR-${mcVersion}",
- "jar": "${mcVersion}",
- "time": "${formattedTime}",
- "type": "release",
- "arguments": {
- "game": [
- "--tweakClass",
- "${tweakClass}"
- ]
- },
- "mainClass": "net.minecraft.launchwrapper.Launch",
- "libraries": [
- {
- "name": "com.irtimaled:bbor:${mcVersion}",
- "url": "https://github.com/irtimaled/maven/releases/download/"
- },
- {
- "name": "org.spongepowered:mixin:0.8",
- "url": "https://github.com/irtimaled/maven/releases/download/"
- },
- {
- "name": "org.ow2.asm:asm:6.2",
- "url": "https://repo1.maven.org/maven2/"
- },
- {
- "name": "org.ow2.asm:asm-tree:6.2",
- "url": "https://repo1.maven.org/maven2/"
- },
- {
- "name": "org.ow2.asm:asm-commons:6.2",
- "url": "https://repo1.maven.org/maven2/"
- },
- {
- "name": "org.ow2.asm:asm-util:6.2",
- "url": "https://repo1.maven.org/maven2/"
- },
- {
- "name": "org.ow2.asm:asm-analysis:6.2",
- "url": "https://repo1.maven.org/maven2/"
- },
- {
- "name": "net.minecraft:launchwrapper:1.12"
- }
- ]
-}
\ No newline at end of file