name=bbor
buildVersion=2.4
# leave a space to reduce merge conflicts on version change
-mcVersion=1.18.2
+mcVersion=1.19
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.minecraft.server.command.ServerCommandSource;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.text.MutableText;
+import net.minecraft.text.TranslatableTextContent;
class CommandHelper {
static void feedback(CommandContext<ServerCommandSource> context, String format, Object... values) {
- context.getSource().sendFeedback(new TranslatableText(format, values), false);
+ context.getSource().sendFeedback(MutableText.of(new TranslatableTextContent(format, values)), false);
}
static boolean lastNodeIsLiteral(CommandContext<ServerCommandSource> context, String literal) {
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
+import net.minecraft.text.LiteralTextContent;
+import net.minecraft.text.MutableText;
import java.awt.*;
protected final MinecraftClient minecraft;
AbstractControl(int x, int y, int width, String name) {
- super(x, y, width, 20, new LiteralText(name));
+ super(x, y, width, 20, MutableText.of(new LiteralTextContent(name)));
this.minecraft = MinecraftClient.getInstance();
}
}
public void filter(String lowerValue) {
- String lowerString = this.getMessage().asString().toLowerCase();
+ String lowerString = this.getMessage().asTruncatedString(256).toLowerCase();
this.visible = lowerValue.equals("") ||
lowerString.startsWith(lowerValue) ||
lowerString.contains(" " + lowerValue);
import com.irtimaled.bbor.client.config.Setting;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.resource.language.I18n;
-import net.minecraft.text.LiteralText;
+import net.minecraft.text.LiteralTextContent;
+import net.minecraft.text.MutableText;
import java.util.HashMap;
import java.util.Map;
private void updateText() {
Integer value = setting.get();
- this.setMessage(new LiteralText(I18n.translate(format, displayValues.getOrDefault(value, value.toString()))));
+ this.setMessage(MutableText.of(new LiteralTextContent(I18n.translate(format, displayValues.getOrDefault(value, value.toString())))));
}
@Override
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.text.LiteralTextContent;
+import net.minecraft.text.MutableText;
+import net.minecraft.text.TranslatableTextContent;
import java.util.List;
private SearchField searchField;
ListScreen(Screen lastScreen) {
- super(new LiteralText("Bounding Box Outline Reloaded"));
+ super(MutableText.of(new LiteralTextContent("Bounding Box Outline Reloaded")));
this.lastScreen = lastScreen;
}
protected void init() {
this.controlList = this.buildList(48, this.height - 28);
this.searchField = new SearchField(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.controlList);
- this.doneButton = new ButtonWidget(this.width / 2 - 100, this.height - 24, 200, 20, new TranslatableText("gui.done"), buttonWidget -> onDoneClicked());
+ this.doneButton = new ButtonWidget(this.width / 2 - 100, this.height - 24, 200, 20, MutableText.of(new TranslatableTextContent("gui.done")), buttonWidget -> onDoneClicked());
this.addDrawableChild(this.searchField);
((List<Element>) this.children()).add(this.controlList);
this.renderBackground(matrixStack);
this.controlList.render(matrixStack, mouseX, mouseY);
- this.drawCenteredText(matrixStack, this.textRenderer, this.title.asString(), this.width / 2, 8, 16777215);
+ this.drawCenteredText(matrixStack, this.textRenderer, this.title.asTruncatedString(256), this.width / 2, 8, 16777215);
this.searchField.render(matrixStack, mouseX, mouseY);
this.doneButton.render(matrixStack, mouseX, mouseY, 0f);
import net.minecraft.world.level.storage.LevelSummary;
import java.util.List;
+import java.util.concurrent.ExecutionException;
public class LoadSavesScreen extends ListScreen {
private SelectableControlList controlList;
controlList = new SelectableControlList(this.width, this.height, top, bottom);
try {
final LevelStorage saveLoader = this.client.getLevelStorage();
- List<LevelSummary> saveList = saveLoader.getLevelList();
+ List<LevelSummary> saveList = saveLoader.loadSummaries(saveLoader.getLevelList()).get();
saveList.sort(null);
saveList.forEach(world -> controlList.add(new WorldSaveRow(world, saveLoader, controlList::setSelectedEntry)));
- } catch (LevelStorageException e) {
+ } catch (LevelStorageException | InterruptedException | ExecutionException e) {
e.printStackTrace();
}
return controlList;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
+import net.minecraft.text.LiteralTextContent;
+import net.minecraft.text.MutableText;
public class SearchField extends TextFieldWidget implements IControl {
private final ControlList controlList;
SearchField(TextRenderer fontRenderer, int left, int top, int width, int height, ControlList controlList) {
- super(fontRenderer, left, top, width, height, new LiteralText(""));
+ super(fontRenderer, left, top, width, height, MutableText.of(new LiteralTextContent("")));
this.controlList = controlList;
this.setChangedListener(text -> this.controlList.filter(removeLeadingSpaces(text.toLowerCase())));
- this.setRenderTextProvider((text, id) -> new LiteralText(removeLeadingSpaces(text)).asOrderedText());
+ this.setRenderTextProvider((text, id) -> MutableText.of(new LiteralTextContent(removeLeadingSpaces(text))).asOrderedText());
this.setFocused(true);
}
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
private final Identifier iconLocation;
private final NativeImageBackedTexture icon;
- private File iconFile;
+ private Path iconPath;
private long lastClickTime;
WorldSaveRow(LevelSummary worldSummary, LevelStorage saveLoader, Consumer<ControlListEntry> setSelectedEntry) {
this.saveLoader = saveLoader;
this.setSelectedEntry = setSelectedEntry;
this.client = MinecraftClient.getInstance();
- this.iconLocation = new Identifier("worlds/" + Hashing.sha1().hashUnencodedChars(worldSummary.getName()) + "/icon");
- this.iconFile = worldSummary.getFile();
- if (!this.iconFile.isFile()) {
- this.iconFile = null;
- }
+ this.iconPath = worldSummary.getIconPath();
+ this.iconLocation = new Identifier(this.iconPath.toString());
this.icon = this.loadIcon();
}
}
private NativeImageBackedTexture loadIcon() {
- if (this.iconFile == null || !this.iconFile.isFile()) {
- this.client.getTextureManager().destroyTexture(this.iconLocation);
- return null;
- }
-
- try (InputStream stream = new FileInputStream(this.iconFile)) {
+ try (InputStream stream = new FileInputStream(this.iconPath.toFile())) {
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.getName(), exception);
- this.iconFile = null;
return null;
}
}
import net.minecraft.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.ClickEvent;
-import net.minecraft.text.LiteralText;
+import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.Texts;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.text.TranslatableTextContent;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
} catch (CommandSyntaxException exception) {
commandSource.sendError(Texts.toText(exception.getRawMessage()));
if (exception.getInput() != null && exception.getCursor() >= 0) {
- MutableText suggestion = new LiteralText("")
+ MutableText suggestion = MutableText.of(new LiteralTextContent(""))
.formatted(Formatting.GRAY)
.styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)));
int textLength = Math.min(exception.getInput().length(), exception.getCursor());
suggestion.append(exception.getInput().substring(Math.max(0, textLength - 10), textLength));
if (textLength < exception.getInput().length()) {
- suggestion.append(new LiteralText(exception.getInput().substring(textLength))
+ suggestion.append(MutableText.of(new LiteralTextContent(exception.getInput().substring(textLength)))
.formatted(Formatting.RED, Formatting.UNDERLINE));
}
- suggestion.append(new TranslatableText("command.context.here")
+ suggestion.append(MutableText.of(new TranslatableTextContent("command.context.here"))
.formatted(Formatting.RED, Formatting.ITALIC));
commandSource.sendError(suggestion);
}
}
public static int getRenderDistanceChunks() {
- return MinecraftClient.getInstance().options.viewDistance;
+ return MinecraftClient.getInstance().options.getViewDistance().getValue();
}
public static void handleSeedMessage(Text chatComponent) {
- TypeHelper.doIfType(chatComponent, TranslatableText.class, message -> {
- if (!message.getKey().equals("commands.seed.success")) return;
+ TypeHelper.doIfType(chatComponent, MutableText.class, message -> {
+ TypeHelper.doIfType(message.getContent(), TranslatableTextContent.class, content -> {
+ if (!content.getKey().equals("commands.seed.success")) return;
- try {
- long seed = Long.parseLong(message.getArgs()[0].toString());
- SlimeChunkProvider.setSeed(seed);
- } catch (Exception ignored) {
- }
+ try {
+ long seed = Long.parseLong(content.getArgs()[0].toString());
+ SlimeChunkProvider.setSeed(seed);
+ } catch (Exception ignored) {
+ }
+ });
});
}
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.random.Random;
+import net.minecraft.util.math.random.CheckedRandom;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
import java.util.HashMap;
import java.util.Map;
-import java.util.Random;
public class FlowerForestHelper {
- private static final Random random = new Random();
+ private static final Random random = new CheckedRandom(new java.util.Random().nextLong());
private static final Map<BlockState, Setting<HexColor>> flowerColorMap = new HashMap<>();
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
+import net.minecraft.util.math.random.Random;
import net.minecraft.world.FeatureUpdater;
import net.minecraft.world.PersistentStateManager;
import net.minecraft.world.StructureWorldAccess;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Random;
import java.util.Set;
import java.util.function.BiFunction;
package com.irtimaled.bbor.client.interop;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.mixin.access.IBiome;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
+import net.minecraft.tag.BiomeTags;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
+import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
+import net.minecraft.world.biome.BiomeKeys;
public class SpawnableBlocksHelper {
private static final EntityType entityType = EntityType.Builder.create(SpawnGroup.MONSTER)
static boolean isSpawnable(World world, BlockPos pos, BlockState spawnBlockState, BlockState upperBlockState) {
VoxelShape collisionShape = upperBlockState.getCollisionShape(world, pos);
- Biome biome = world.getBiome(pos).value();
- boolean isNether = ((IBiome) biome).bbor$getCategory() == Biome.Category.NETHER;
- return ((IBiome) biome).bbor$getCategory() != Biome.Category.MUSHROOM &&
+ RegistryEntry<Biome> entry = world.getBiome(pos);
+ Biome biome = entry.value();
+ boolean isNether = entry.isIn(BiomeTags.IS_NETHER);
+ return entry == BiomeKeys.MUSHROOM_FIELDS &&
spawnBlockState.allowsSpawning(world, pos.down(), isNether ? EntityType.ZOMBIFIED_PIGLIN : entityType) &&
!Block.isFaceFullSquare(collisionShape, Direction.UP) &&
!upperBlockState.emitsRedstonePower() &&
import com.irtimaled.bbor.common.models.DimensionId;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
-import net.minecraft.world.gen.random.ChunkRandom;
+import net.minecraft.util.math.random.ChunkRandom;
import java.util.HashSet;
import java.util.Set;
final ClientWorld world = MinecraftClient.getInstance().world;
final int minimumY;
if (world != null) {
- minimumY = world.getDimension().getMinimumY();
+ minimumY = world.getDimension().minY();
} else {
minimumY = 0;
}
static void endBatch() {
RenderSystem.setShader(GameRenderer::getPositionColorShader);
long startTime = System.nanoTime();
- quadBufferBuilderMasked.end();
- quadBufferBuilderNonMasked.end();
- lineBufferBuilder.end();
+ BufferBuilder.BuiltBuffer quadBufferMasked = quadBufferBuilderMasked.end();
+ BufferBuilder.BuiltBuffer quadBufferNonMasked = quadBufferBuilderNonMasked.end();
+ BufferBuilder.BuiltBuffer lineBuffer = lineBufferBuilder.end();
synchronized (mutex) {
quadMaskedCountLast.set(quadMaskedCount.get());
}
RenderSystem.depthMask(true);
- BufferRenderer.draw(quadBufferBuilderMasked);
- BufferRenderer.draw(lineBufferBuilder);
+ BufferRenderer.drawWithShader(quadBufferMasked);
+ BufferRenderer.drawWithShader(lineBuffer);
RenderSystem.depthMask(false);
- BufferRenderer.draw(quadBufferBuilderNonMasked);
+ BufferRenderer.drawWithShader(quadBufferNonMasked);
lastDurationNanos.set(System.nanoTime() - startTime);
RenderSystem.depthMask(true);
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
-import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
+import net.minecraft.world.gen.structure.Structure;
import java.util.Arrays;
import java.util.Collection;
public static void chunkLoaded(WorldChunk chunk) {
DimensionId dimensionId = DimensionId.from(chunk.getWorld().getRegistryKey());
Map<String, StructureStart> structures = new HashMap<>();
- final Registry<ConfiguredStructureFeature<?, ?>> structureFeatureRegistry = chunk.getWorld().getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY);
- for (Map.Entry<ConfiguredStructureFeature<?, ?>, StructureStart> es : chunk.getStructureStarts().entrySet()) {
- final Optional<RegistryKey<ConfiguredStructureFeature<?, ?>>> optional = structureFeatureRegistry.getKey(es.getKey());
+ final Registry<Structure> structureRegistry = chunk.getWorld().getRegistryManager().get(Registry.STRUCTURE_KEY);
+ for (Map.Entry<Structure, StructureStart> es : chunk.getStructureStarts().entrySet()) {
+ final Optional<RegistryKey<Structure>> optional = structureRegistry.getKey(es.getKey());
optional.ifPresent(key -> structures.put(key.getValue().toString(), es.getValue()));
}
if (structures.size() > 0) EventBus.publish(new StructuresLoaded(structures, dimensionId));
}
public static void loadWorldStructures(World world) {
- final Registry<ConfiguredStructureFeature<?, ?>> structureFeatureRegistry = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY);
- System.out.println("Registring structures: " + Arrays.toString(structureFeatureRegistry.getEntrySet().stream().map(entry -> entry.getKey().getValue().toString()).distinct().toArray(String[]::new)));
- for (var entry : structureFeatureRegistry.getEntrySet()) {
+ final Registry<Structure> structureRegistry = world.getRegistryManager().get(Registry.STRUCTURE_KEY);
+ System.out.println("Registring structures: " + Arrays.toString(structureRegistry.getEntrySet().stream().map(entry -> entry.getKey().getValue().toString()).distinct().toArray(String[]::new)));
+ for (var entry : structureRegistry.getEntrySet()) {
final Identifier value = entry.getKey().getValue();
final BoundingBoxType boundingBoxType = BoundingBoxType.register("structure:" + value);
StructureProcessor.registerSupportedStructure(boundingBoxType);
+++ /dev/null
-package com.irtimaled.bbor.mixin.access;
-
-import net.minecraft.world.biome.Biome;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@Mixin(Biome.class)
-public interface IBiome {
-
- @Accessor("category")
- Biome.Category bbor$getCategory();
-
-}
@Mixin(GameMessageS2CPacket.class)
public class MixinSChatPacket {
@Shadow
- private Text message;
+ private Text content;
@Inject(method = "apply", at = @At("RETURN"))
private void processPacket(CallbackInfo ci) {
- ClientInterop.handleSeedMessage(this.message);
+ ClientInterop.handleSeedMessage(this.content);
}
}
"package": "com.irtimaled.bbor.mixin",
"mixins": [
"access.IBeaconBlockEntity",
- "access.IBiome",
"access.IStructureStart",
"client.renderer.MixinDebugHud",
"client.renderer.MixinWorldRenderer",