dependencies {
minecraft 'com.mojang:minecraft:' + project.mcVersion
- mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.9'
- modCompile 'net.fabricmc:fabric-loader:0.8.3+build.196'
+ mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.27'
+ modCompile 'net.fabricmc:fabric-loader:0.9.3+build.207'
}
minecraft {
name=bbor
buildVersion=2.4
# leave a space to reduce merge conflicts on version change
-mcVersion=1.15.2
+mcVersion=1.16.3
x = player.prevX + (player.getX() - player.prevX) * partialTicks;
y = player.prevY + (player.getY() - player.prevY) * partialTicks;
z = player.prevZ + (player.getZ() - player.prevZ) * partialTicks;
- dimensionId = DimensionId.from(player.dimension);
+ dimensionId = DimensionId.from(player.getEntityWorld().getRegistryKey());
}
static void setActiveY() {
import com.mojang.brigadier.arguments.*;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.command.arguments.BlockPosArgumentType;
-import net.minecraft.command.arguments.Vec3ArgumentType;
+import net.minecraft.command.argument.BlockPosArgumentType;
+import net.minecraft.command.argument.Vec3ArgumentType;
import net.minecraft.server.command.ServerCommandSource;
import java.util.function.Supplier;
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.server.command.CommandManager;
-import net.minecraft.server.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource;
import java.util.function.Function;
import com.irtimaled.bbor.client.providers.CustomSphereProvider;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import net.minecraft.command.CommandSource;
import net.minecraft.server.command.CommandManager;
-import net.minecraft.server.command.CommandSource;
public class CustomCommand {
private static final String COMMAND = "bbor:custom";
import com.irtimaled.bbor.client.providers.SlimeChunkProvider;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import net.minecraft.command.CommandSource;
import net.minecraft.server.command.CommandManager;
-import net.minecraft.server.command.CommandSource;
public class SeedCommand {
private static final String COMMAND = "bbor:seed";
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.command.CommandSource;
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;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import net.minecraft.command.CommandSource;
import net.minecraft.server.command.CommandManager;
-import net.minecraft.server.command.CommandSource;
public class StructuresCommand {
private static final String COMMAND = "bbor:structures";
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.text.LiteralText;
import java.awt.*;
protected final MinecraftClient minecraft;
AbstractControl(int x, int y, int width, String name) {
- super(x, y, width, 20, name);
+ super(x, y, width, 20, new LiteralText(name));
this.minecraft = MinecraftClient.getInstance();
}
@Override
- public void render(int mouseX, int mouseY) {
- super.render(mouseX, mouseY, 0f);
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
+ super.render(matrixStack, mouseX, mouseY, 0f);
}
public void setX(int x) {
}
@Override
- protected void renderBg(MinecraftClient minecraft, int mouseX, int mouseY) {
- if (active) renderBackground(mouseX, mouseY);
+ protected void renderBg(MatrixStack matrixStack, MinecraftClient minecraft, int mouseX, int mouseY) {
+ if (active) renderBackground(matrixStack, mouseX, mouseY);
}
- protected void renderBackground(int mouseX, int mouseY) {
+ protected void renderBackground(MatrixStack matrixStack, int mouseX, int mouseY) {
}
@Override
}
public void filter(String lowerValue) {
- String lowerString = this.getMessage().toLowerCase();
+ String lowerString = this.getMessage().asString().toLowerCase();
this.visible = lowerValue.equals("") ||
lowerString.startsWith(lowerValue) ||
lowerString.contains(" " + lowerValue);
}
- void drawRectangle(int left, int top, int right, int bottom, Color color) {
- fill(left, top, right, bottom, color.getRGB());
+ void drawRectangle(MatrixStack matrixStack, int left, int top, int right, int bottom, Color color) {
+ fill(matrixStack, left, top, right, bottom, color.getRGB());
}
@Override
import com.irtimaled.bbor.common.MathHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.SoundManager;
+import net.minecraft.client.util.math.MatrixStack;
abstract class AbstractSlider extends AbstractControl {
private final int optionCount;
}
@Override
- protected void renderBackground(int mouseX, int mouseY) {
+ protected void renderBackground(MatrixStack matrixStack, int mouseX, int mouseY) {
this.minecraft.getTextureManager().bindTexture(WIDGETS_LOCATION);
int hoverState = super.getYImage(this.isHovered());
- this.blit(this.x + (int) getProgressPercentage(), this.y, 0, 46 + hoverState * 20, 4, this.height);
- this.blit(this.x + (int) getProgressPercentage() + 4, this.y, 196, 46 + hoverState * 20, 4, 20);
+ this.drawTexture(matrixStack, this.x + (int) getProgressPercentage(), this.y, 0, 46 + hoverState * 20, 4, this.height);
+ this.drawTexture(matrixStack, this.x + (int) getProgressPercentage() + 4, this.y, 196, 46 + hoverState * 20, 4, 20);
}
private double getProgressPercentage() {
import com.irtimaled.bbor.client.config.ColorHelper;
import com.irtimaled.bbor.client.config.ConfigManager;
+import net.minecraft.client.util.math.MatrixStack;
public abstract class BoolButton extends AbstractButton {
BoolButton(int width, String label, boolean enabled) {
protected abstract boolean getValue();
@Override
- protected void renderBackground(int mouseX, int mouseY) {
+ protected void renderBackground(MatrixStack matrixStack, int mouseX, int mouseY) {
int left = this.x + 1;
int top = this.y + 1;
int right = left + this.width - 2;
int bottom = top + this.height - 2;
if (this.getValue()) {
- drawRectangle(left, top, right, bottom, ColorHelper.getColor(ConfigManager.buttonOnOverlay));
+ drawRectangle(matrixStack, left, top, right, bottom, ColorHelper.getColor(ConfigManager.buttonOnOverlay));
}
}
}
import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
import com.irtimaled.bbor.common.BoundingBoxType;
+import net.minecraft.client.util.math.MatrixStack;
import java.awt.*;
}
@Override
- protected void renderBackground(int mouseX, int mouseY) {
- super.renderBackground(mouseX, mouseY);
+ protected void renderBackground(MatrixStack matrixStack, int mouseX, int mouseY) {
+ super.renderBackground(matrixStack, mouseX, mouseY);
int left = x + 1;
int top = y + 1;
Color color = BoundingBoxTypeHelper.getColor(type);
// top & left
- drawRectangle(left, top, right, top + 1, color);
- drawRectangle(left, top, left + 1, bottom, color);
+ drawRectangle(matrixStack, left, top, right, top + 1, color);
+ drawRectangle(matrixStack, left, top, left + 1, bottom, color);
Color darker = color.darker();
// bottom left & top right
- drawRectangle(left, bottom - 2, left + 1, bottom, darker);
- drawRectangle(right - 1, top, right, top + 1, darker);
+ drawRectangle(matrixStack, left, bottom - 2, left + 1, bottom, darker);
+ drawRectangle(matrixStack, right - 1, top, right, top + 1, darker);
Color darkest = darker.darker();
// bottom & right
- drawRectangle(left + 1, bottom - 2, right, bottom, darkest);
- drawRectangle(right - 1, top + 1, right, bottom, darkest);
+ drawRectangle(matrixStack, left + 1, bottom - 2, right, bottom, darkest);
+ drawRectangle(matrixStack, right - 1, top + 1, right, bottom, darkest);
}
}
import com.irtimaled.bbor.common.MathHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.client.util.math.MatrixStack;
import java.util.ArrayList;
import java.util.List;
return true;
}
- public void render(int mouseX, int mouseY) {
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
this.amountScrolled = MathHelper.clamp(this.amountScrolled, 0.0D, this.getMaxScroll());
RenderHelper.disableLighting();
int listTop = this.top + PADDING - (int) this.amountScrolled;
- drawEntries(mouseX, mouseY, listTop);
+ drawEntries(matrixStack, mouseX, mouseY, listTop);
+
+ RenderHelper.enableDepthTest();
+ RenderHelper.depthFuncAlways();
- RenderHelper.disableDepthTest();
this.overlayBackground(0, this.top);
this.overlayBackground(this.bottom, this.height);
+ RenderHelper.depthFuncLessEqual();
+ RenderHelper.disableDepthTest();
RenderHelper.enableBlend();
RenderHelper.blendFuncGui();
RenderHelper.disableAlphaTest();
}
private void drawListBackground() {
- this.minecraft.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_LOCATION);
+ this.minecraft.getTextureManager().bindTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
Renderer.startTextured()
.setColor(32, 32, 32)
.setAlpha(255)
.render();
}
- private void drawEntries(int mouseX, int mouseY, int top) {
+ private void drawEntries(MatrixStack matrixStack, int mouseX, int mouseY, int top) {
for (ControlListEntry entry : this.entries) {
if (!entry.isVisible()) continue;
entry.setY(top);
int height = entry.getControlHeight();
- drawEntry(mouseX, mouseY, top, entry, height);
- top += height;
+ int bottom = top + height;
+ if(top <= this.bottom && bottom >= this.top) {
+ drawEntry(matrixStack, mouseX, mouseY, top, entry, height);
+ }
+ top = bottom;
}
}
- protected void drawEntry(int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
- entry.render(mouseX, mouseY);
+ protected void drawEntry(MatrixStack matrixStack, int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
+ entry.render(matrixStack, mouseX, mouseY);
}
private void overlayBackground(int top, int bottom) {
- this.minecraft.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_LOCATION);
+ this.minecraft.getTextureManager().bindTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
Renderer.startTextured()
.setColor(64, 64, 64)
.setAlpha(255)
- .addPoint(0, bottom, 0.0D, 0.0D, (float) bottom / 32.0F)
- .addPoint(this.width, bottom, 0.0D, (float) this.width / 32.0F, (float) bottom / 32.0F)
- .addPoint(this.width, top, 0.0D, (float) this.width / 32.0F, (float) top / 32.0F)
- .addPoint(0, top, 0.0D, 0.0D, (float) top / 32.0F)
+ .addPoint(0, bottom, -100.0D, 0.0D, (float) bottom / 32.0F)
+ .addPoint(this.width, bottom, -100.0D, (float) this.width / 32.0F, (float) bottom / 32.0F)
+ .addPoint(this.width, top, -100.0D, (float) this.width / 32.0F, (float) top / 32.0F)
+ .addPoint(0, top, -100.0D, 0.0D, (float) top / 32.0F)
.render();
}
package com.irtimaled.bbor.client.gui;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.util.math.MatrixStack;
import java.util.ArrayList;
import java.util.List;
}
@Override
- public void render(int mouseX, int mouseY) {
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
int x = this.getX();
int y = this.getY();
int top = y;
if (this.title != null) {
- this.minecraft.textRenderer.draw(this.title, x + 4, y + ((TITLE_HEIGHT - this.minecraft.textRenderer.fontHeight) / 1.5f), 16777215);
+ this.minecraft.textRenderer.draw(matrixStack, this.title, x + 4, y + ((TITLE_HEIGHT - this.minecraft.textRenderer.fontHeight) / 1.5f), 16777215);
top += titleHeight;
}
control.setX(left + x);
control.setY(top);
- control.render(mouseX, mouseY);
+ control.render(matrixStack, mouseX, mouseY);
if (left == 0) {
height = control.getControlHeight();
}
package com.irtimaled.bbor.client.gui;
import net.minecraft.client.gui.Element;
+import net.minecraft.client.util.math.MatrixStack;
interface IControl extends IFocusableControl, Element {
- void render(int mouseX, int mouseY);
+ void render(MatrixStack matrixStack, int mouseX, int mouseY);
boolean isVisible();
}
import com.irtimaled.bbor.client.config.Setting;
import net.minecraft.client.resource.language.I18n;
+import net.minecraft.text.LiteralText;
import java.util.HashMap;
import java.util.Map;
private void updateText() {
Integer value = setting.get();
- this.setMessage(I18n.translate(format, displayValues.getOrDefault(value, value.toString())));
+ this.setMessage(new LiteralText(I18n.translate(format, displayValues.getOrDefault(value, value.toString()))));
}
@Override
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
public abstract class ListScreen extends Screen {
@Override
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.searchField = new SearchField(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.controlList);
this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.translate("gui.done")) {
@Override
public void onPressed() {
protected abstract ControlList buildList(int top, int bottom);
@Override
- public void render(int mouseX, int mouseY, float unknown) {
- render(mouseX, mouseY);
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float unknown) {
+ render(matrixStack, mouseX, mouseY);
}
- protected void render(int mouseX, int mouseY) {
- this.controlList.render(mouseX, mouseY);
+ protected void render(MatrixStack matrixStack, int mouseX, int mouseY) {
+ this.controlList.render(matrixStack, mouseX, mouseY);
- this.drawCenteredString(this.font, this.title.asString(), this.width / 2, 8, 16777215);
- this.searchField.render(mouseX, mouseY);
- this.doneButton.render(mouseX, mouseY);
+ this.drawCenteredString(matrixStack, this.textRenderer, this.title.asString(), this.width / 2, 8, 16777215);
+ this.searchField.render(matrixStack, mouseX, mouseY);
+ this.doneButton.render(matrixStack, mouseX, mouseY);
- int left = this.width - this.font.getStringWidth(version) - 2;
+ int left = this.width - this.textRenderer.getWidth(version) - 2;
int top = this.height - 10;
- this.drawString(this.font, version, left, top, -10658467);
+ this.drawStringWithShadow(matrixStack, this.textRenderer, version, left, top, -10658467);
}
@Override
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.interop.ClientInterop;
+import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.world.level.storage.LevelStorage;
import net.minecraft.world.level.storage.LevelStorageException;
import net.minecraft.world.level.storage.LevelSummary;
protected ControlList buildList(int top, int bottom) {
controlList = new SelectableControlList(this.width, this.height, top, bottom);
try {
- final LevelStorage saveLoader = this.minecraft.getLevelStorage();
+ final LevelStorage saveLoader = this.client.getLevelStorage();
List<LevelSummary> saveList = saveLoader.getLevelList();
saveList.sort(null);
saveList.forEach(world -> controlList.add(new WorldSaveRow(world, saveLoader, controlList::setSelectedEntry)));
}
@Override
- public void render(int mouseX, int mouseY, float unknown) {
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float unknown) {
ControlListEntry selectedEntry = getSelectedEntry();
this.setCanExit(selectedEntry != null && selectedEntry.isVisible());
- super.render(mouseX, mouseY, unknown);
+ super.render(matrixStack, mouseX, mouseY, unknown);
}
private ControlListEntry getSelectedEntry() {
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;
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, "");
+ super(fontRenderer, left, top, width, height, new LiteralText(""));
this.controlList = controlList;
this.setChangedListener(text -> this.controlList.filter(removeLeadingSpaces(text.toLowerCase())));
- this.setRenderTextProvider((text, id) -> removeLeadingSpaces(text));
+ this.setRenderTextProvider((text, id) -> new LiteralText(removeLeadingSpaces(text)).asOrderedText());
this.setFocused(true);
}
}
@Override
- public void render(int mouseX, int mouseY) {
- this.render(mouseX, mouseY, 0f);
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
+ this.render(matrixStack, mouseX, mouseY, 0f);
}
@Override
import com.irtimaled.bbor.client.renderers.RenderHelper;
import com.irtimaled.bbor.client.renderers.Renderer;
+import net.minecraft.client.util.math.MatrixStack;
public class SelectableControlList extends ControlList {
private final int listRight;
}
@Override
- protected void drawEntry(int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
+ protected void drawEntry(MatrixStack matrixStack, int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
if (this.selectedElement == entry.index) {
RenderHelper.disableTexture();
int color = this.isFocused ? 255 : 128;
.render();
RenderHelper.enableTexture();
}
- super.drawEntry(mouseX, mouseY, top, entry, height);
+ super.drawEntry(matrixStack, mouseX, mouseY, top, entry, height);
}
@Override
protected ControlList buildList(int top, int bottom) {
String version = SharedConstants.getGameVersion().getName();
ControlList controlList = new ControlList(this.width, this.height, top, bottom);
- if (this.minecraft.world != null) controlList.setTransparentBackground();
+ if (this.client.world != null) controlList.setTransparentBackground();
controlList
.section(null,
- width -> new BoolButton(width, I18n.translate("bbor.options.active"), this.minecraft.world != null) {
+ width -> new BoolButton(width, I18n.translate("bbor.options.active"), this.client.world != null) {
@Override
public void onPressed() {
ClientRenderer.toggleActive();
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.nbt.NbtIo;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
-import net.minecraft.world.level.LevelProperties;
+import net.minecraft.util.WorldSavePath;
import net.minecraft.world.level.storage.LevelStorage;
import net.minecraft.world.level.storage.LevelSummary;
import org.apache.logging.log4j.LogManager;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
this.setSelectedEntry = setSelectedEntry;
this.client = MinecraftClient.getInstance();
this.iconLocation = new Identifier("worlds/" + Hashing.sha1().hashUnencodedChars(worldSummary.getName()) + "/icon");
- this.iconFile = saveLoader.resolveFile(worldSummary.getName(), "icon.png");
+ this.iconFile = worldSummary.getFile();
if (!this.iconFile.isFile()) {
this.iconFile = null;
}
@Override
public void done() {
String fileName = this.worldSummary.getName();
- LevelProperties worldInfo = saveLoader.getLevelProperties(fileName);
- long seed = worldInfo.getSeed();
- ClientInterop.saveLoaded(fileName, seed);
+ LevelStorage.Session worldInfo = null;
+ try {
+ worldInfo = saveLoader.createSession(fileName);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ long seed = NbtIo.readCompressed(new FileInputStream(worldInfo.getDirectory(WorldSavePath.LEVEL_DAT).toFile()))
+ .getCompound("Data")
+ .getCompound("WorldGenSettings").getLong("seed");
+ worldInfo.close();
+ ClientInterop.saveLoaded(fileName, seed);
+ } catch (IOException ignored) {
+ }
}
private NativeImageBackedTexture loadIcon() {
}
@Override
- public void render(int mouseX, int mouseY) {
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
String displayName = this.worldSummary.getDisplayName();
String details = this.worldSummary.getName() + " (" + DATE_FORMAT.format(new Date(this.worldSummary.getLastPlayed())) + ")";
int x = this.getX();
int y = this.getY();
- 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.textRenderer.draw(matrixStack, displayName, (float) (x + ICON_SIZE + 3), (float) (y + 1), 16777215);
+ this.client.textRenderer.draw(matrixStack, 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();
- DrawableHelper.blit(x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
+ DrawableHelper.drawTexture(matrixStack, x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
RenderHelper.disableBlend();
}
public static Random getRandomForChunk(int chunkX, int chunkZ) {
ChunkRandom random = new ChunkRandom();
- random.setSeed(chunkX, chunkZ);
+ random.setTerrainSeed(chunkX, chunkZ);
return random;
}
}
import com.irtimaled.bbor.common.models.Coords;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.world.ClientWorld;
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 = MinecraftClient.getInstance().world.getBiome(pos);
- return Registry.BIOME.getRawId(biome);
+ ClientWorld world = MinecraftClient.getInstance().world;
+ Biome biome = world.getBiome(pos);
+ return world.getRegistryManager().get(Registry.BIOME_KEY).getRawId(biome);
}
}
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
-import net.minecraft.server.command.CommandSource;
+import net.minecraft.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
public static void render(float partialTicks, ClientPlayerEntity player) {
Player.setPosition(partialTicks, player);
- ClientRenderer.render(DimensionId.from(player.dimension));
+ ClientRenderer.render(DimensionId.from(player.getEntityWorld().getRegistryKey()));
}
public static void renderDeferred() {
} catch (CommandSyntaxException exception) {
commandSource.sendError(Texts.toText(exception.getRawMessage()));
if (exception.getInput() != null && exception.getCursor() >= 0) {
- Text suggestion = new LiteralText("")
+ MutableText suggestion = new LiteralText("")
.formatted(Formatting.GRAY)
- .styled(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)));
+ .styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)));
int textLength = Math.min(exception.getInput().length(), exception.getCursor());
if (textLength > 10) {
suggestion.append("...");
import net.minecraft.block.Blocks;
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.util.registry.BuiltinRegistries;
+import net.minecraft.world.biome.Biome;
+import net.minecraft.world.biome.BiomeKeys;
+import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.FlowerFeature;
private static final FlowerFeature flowersFeature;
private static final FeatureConfig flowersConfig;
+ public static final Biome BIOME = BuiltinRegistries.BIOME.get(BiomeKeys.FLOWER_FOREST);
+
static {
flowerColorMap.put(Blocks.DANDELION.getDefaultState(), ConfigManager.colorFlowerForestDandelion);
flowerColorMap.put(Blocks.POPPY.getDefaultState(), ConfigManager.colorFlowerForestPoppy);
flowerColorMap.put(Blocks.OXEYE_DAISY.getDefaultState(), ConfigManager.colorFlowerForestOxeyeDaisy);
flowerColorMap.put(Blocks.CORNFLOWER.getDefaultState(), ConfigManager.colorFlowerForestCornflower);
flowerColorMap.put(Blocks.LILY_OF_THE_VALLEY.getDefaultState(), ConfigManager.colorFlowerForestLilyOfTheValley);
-
- DecoratedFeatureConfig config = (DecoratedFeatureConfig) Biomes.FLOWER_FOREST.getFlowerFeatures().get(0).config;
- flowersFeature = (FlowerFeature) config.feature.feature;
- flowersConfig = config.feature.config;
+ ConfiguredFeature<?, ?> config = BIOME.getGenerationSettings().getFlowerFeatures().get(0);
+ flowersFeature = (FlowerFeature) config.feature;
+ flowersConfig = config.config;
}
public static Setting<HexColor> getFlowerColorAtPos(Coords coords) {
int x = coords.getX();
int z = coords.getZ();
- BlockState blockState = flowersFeature.getFlowerToPlace(random, new BlockPos(x, coords.getY(), z), flowersConfig);
+ BlockState blockState = flowersFeature.getFlowerState(random, new BlockPos(x, coords.getY(), z), flowersConfig);
return flowerColorMap.get(blockState);
}
+++ /dev/null
-package com.irtimaled.bbor.client.interop;
-
-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 ResourcePackProvider {
- private static final String BBOR = "bbor";
- private final ResourcePack modPack;
-
- public ModPackFinder() {
- modPack = new DefaultResourcePack(BBOR);
- }
-
- @Override
- public <T extends ResourcePackProfile> void register(Map<String, T> map, ResourcePackProfile.Factory<T> factory) {
- T resourcePackInfo = ResourcePackProfile.of(BBOR,
- true,
- () -> this.modPack,
- factory,
- ResourcePackProfile.InsertionPosition.BOTTOM);
- if (resourcePackInfo != null) {
- map.put(BBOR, resourcePackInfo);
- }
- }
-}
import com.irtimaled.bbor.common.ReflectionHelper;
import com.irtimaled.bbor.common.events.StructuresLoaded;
import com.irtimaled.bbor.common.models.DimensionId;
+import net.minecraft.client.MinecraftClient;
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.BlockPos;
import net.minecraft.util.math.ChunkPos;
+import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.world.FeatureUpdater;
-import net.minecraft.world.IWorld;
import net.minecraft.world.PersistentStateManager;
-import net.minecraft.world.WorldSaveHandler;
+import net.minecraft.world.StructureWorldAccess;
+import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
+import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator;
+import net.minecraft.world.gen.feature.FeatureConfig;
+import net.minecraft.world.level.storage.LevelStorage;
import net.minecraft.world.storage.RegionBasedStorage;
import java.io.File;
import java.io.IOException;
import java.util.*;
-import java.util.function.Function;
+import java.util.function.BiFunction;
class NBTStructureLoader {
private final DimensionId dimensionId;
private final Set<String> loadedChunks = new HashSet<>();
private FeatureUpdater legacyStructureDataUtil = null;
- private WorldSaveHandler saveHandler = null;
+ private LevelStorage.Session saveHandler = null;
private File chunkSaveLocation = null;
private ChunkLoader chunkLoader;
- NBTStructureLoader(DimensionId dimensionId, WorldSaveHandler saveHandler, File worldDirectory) {
+ NBTStructureLoader(DimensionId dimensionId, LevelStorage.Session saveHandler, File worldDirectory) {
this.dimensionId = dimensionId;
this.configure(saveHandler, worldDirectory);
}
void clear() {
this.legacyStructureDataUtil = null;
- this.saveHandler = null;
this.chunkSaveLocation = null;
this.loadedChunks.clear();
+ close(this.saveHandler, this.chunkLoader);
+ this.saveHandler = null;
+ this.chunkLoader = null;
+ }
- if (this.chunkLoader == null) return;
- try {
- this.chunkLoader.close();
- } catch (IOException ignored) {
+ private void close(AutoCloseable... closeables) {
+ for (AutoCloseable closeable : closeables) {
+ if(closeable == null) continue;
+ try {
+ closeable.close();
+ } catch (Exception ignored) {
+ }
}
- this.chunkLoader = null;
}
- void configure(WorldSaveHandler saveHandler, File worldDirectory) {
+ void configure(LevelStorage.Session saveHandler, File worldDirectory) {
this.saveHandler = saveHandler;
if (worldDirectory != null) {
- this.chunkSaveLocation = new File(dimensionId.getDimensionType().getSaveDirectory(worldDirectory), "region");
+ this.chunkSaveLocation = new File(DimensionType.getSaveDirectory(this.dimensionId.getDimensionType(), worldDirectory), "region");
this.chunkLoader = new ChunkLoader(this.chunkSaveLocation);
}
}
private FeatureUpdater getLegacyStructureDataUtil() {
if (this.legacyStructureDataUtil == null) {
- File dataFolder = new File(DimensionType.OVERWORLD.getSaveDirectory(this.saveHandler.getWorldDir()), "data");
+ File dataFolder = new File(this.saveHandler.getWorldDirectory(World.OVERWORLD), "data");
this.legacyStructureDataUtil = FeatureUpdater.create(dimensionId.getDimensionType(),
- new PersistentStateManager(dataFolder, this.saveHandler.getDataFixer()));
+ new PersistentStateManager(dataFolder, MinecraftClient.getInstance().getDataFixer()));
}
return this.legacyStructureDataUtil;
}
CompoundTag structureStarts = loadStructureStarts(chunkX, chunkZ);
if (structureStarts == null || structureStarts.getSize() == 0) return;
- Map<String, StructureStart> structureStartMap = new HashMap<>();
+ Map<String, StructureStart<?>> structureStartMap = new HashMap<>();
for (String key : structureStarts.getKeys()) {
CompoundTag compound = structureStarts.getCompound(key);
if (compound.contains("BB")) {
EventBus.publish(new StructuresLoaded(structureStartMap, dimensionId));
}
- private static class SimpleStructureStart extends StructureStart {
+ private static class SimpleStructureStart extends StructureStart<FeatureConfig> {
SimpleStructureStart(CompoundTag compound) {
super(null,
0,
}
@Override
- public void initialize(ChunkGenerator<?> chunkGenerator, StructureManager structureManager, int i, int i1, Biome biome) {
-
+ public void init(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, int i, int j, Biome biome, FeatureConfig featureConfig) {
}
}
}
@Override
- public boolean generate(IWorld iWorld, ChunkGenerator<?> chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos) {
+ public boolean generate(StructureWorldAccess structureWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
return false;
}
}
- private static class ChunkLoader {
- private static final Function<File, RegionBasedStorage> creator =
- ReflectionHelper.getPrivateInstanceBuilder(RegionBasedStorage.class, File.class);
+ private static class ChunkLoader implements AutoCloseable {
+ private static final BiFunction<File, Boolean, RegionBasedStorage> creator =
+ ReflectionHelper.getPrivateInstanceBuilder(RegionBasedStorage.class, File.class, boolean.class);
private final RegionBasedStorage regionFileCache;
public ChunkLoader(File file) {
- this.regionFileCache = creator.apply(file);
+ this.regionFileCache = creator.apply(file, false);
}
public CompoundTag readChunk(int chunkX, int chunkZ) throws IOException {
import com.irtimaled.bbor.client.Player;
import com.irtimaled.bbor.common.models.DimensionId;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.world.WorldSaveHandler;
import net.minecraft.world.level.storage.LevelStorage;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class SaveGameStructureLoader {
private static final Map<DimensionId, NBTStructureLoader> nbtStructureLoaders = new HashMap<>();
- private static WorldSaveHandler saveHandler = null;
+ private static LevelStorage.Session saveHandler = null;
private static File worldDirectory = null;
static void loadSaveGame(String fileName) {
MinecraftClient minecraft = MinecraftClient.getInstance();
LevelStorage saveLoader = minecraft.getLevelStorage();
- saveHandler = saveLoader.createSaveHandler(fileName, null);
+ try {
+ saveHandler = saveLoader.createSession(fileName);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
worldDirectory = saveLoader.getSavesDirectory().resolve(fileName).toFile();
for (DimensionId dimensionId : nbtStructureLoaders.keySet()) {
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityType;
+import net.minecraft.entity.SpawnGroup;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.biome.Biome;
public class SpawnableBlocksHelper {
- private static final EntityType entityType = EntityType.Builder.create(EntityCategory.MONSTER)
+ private static final EntityType entityType = EntityType.Builder.create(SpawnGroup.MONSTER)
.setDimensions(0f, 0f).disableSaving().build(null);
public static void findSpawnableBlocks(Coords coords, int width, int height, BlockProcessor blockProcessor) {
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;
-
BlockState upperBlockState = world.getBlockState(new BlockPos(x, minY - 1, z));
for (int y = Math.max(1, minY); y < maxY; y++) {
BlockState spawnBlockState = upperBlockState;
}
}
- static boolean isBiomeHostileSpawnProof(World world, BlockPos pos) {
- Biome biome = world.getBiome(pos);
- 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.allowsSpawning(world, pos.down(), isNether ? EntityType.ZOMBIE_PIGMAN : entityType) &&
+ Biome biome = world.getBiome(pos);
+ boolean isNether = biome.getCategory() == Biome.Category.NETHER;
+ return biome.getCategory() != Biome.Category.MUSHROOM &&
+ spawnBlockState.allowsSpawning(world, pos.down(), isNether ? EntityType.ZOMBIFIED_PIGLIN : entityType) &&
!Block.isFaceFullSquare(collisionShape, Direction.UP) &&
!upperBlockState.emitsRedstonePower() &&
- !upperBlockState.matches(BlockTags.RAILS) &&
- collisionShape.getMaximum(Direction.Axis.Y) <= 0 &&
+ !upperBlockState.isIn(BlockTags.RAILS) &&
+ collisionShape.getMax(Direction.Axis.Y) <= 0 &&
upperBlockState.getFluidState().isEmpty() &&
(isNether || world.getLightLevel(LightType.BLOCK, pos) <= 7);
}
double distance = center.getDistance(new Point(closestX, center.getY(), closestZ));
if (distance > BoundingBoxSpawningSphere.SPAWN_RADIUS) continue;
- if (SpawnableBlocksHelper.isBiomeHostileSpawnProof(world, new BlockPos(x, 1, z))) continue;
-
BlockState upperBlockState = world.getBlockState(new BlockPos(x, minY - 1, z));
for (int y = minY; y < maxY; y++) {
BlockState spawnBlockState = upperBlockState;
}
@Override
- public void setKeyCode(InputUtil.KeyCode input) {
- super.setKeyCode(input);
- int keyCode = input.getKeyCode();
+ public void setBoundKey(InputUtil.Key input) {
+ super.setBoundKey(input);
+ int keyCode = input.getCode();
key.updateKeyCode(keyCode);
}
}
public Key register(String keyName) {
- InputUtil.KeyCode input = InputUtil.fromName(keyName);
- Key key = new Key(input.getKeyCode());
+ InputUtil.Key input = InputUtil.fromTranslationKey(keyName);
+ Key key = new Key(input.getCode());
subKeys.add(key);
return key;
}
}
public static Key register(String description, String keyName) {
- InputUtil.KeyCode input = InputUtil.fromName(keyName);
- CustomKeyBinding keyBinding = new CustomKeyBinding(description, input.getKeyCode());
+ InputUtil.Key input = InputUtil.fromTranslationKey(keyName);
+ CustomKeyBinding keyBinding = new CustomKeyBinding(description, input.getCode());
keyBindings.add(keyBinding);
Key key = keyBinding.getKey();
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.util.registry.Registry;
-import net.minecraft.world.biome.Biomes;
+import net.minecraft.util.registry.BuiltinRegistries;
import java.util.HashMap;
import java.util.Map;
public class FlowerForestProvider implements IBoundingBoxProvider<BoundingBoxFlowerForest>, ICachingProvider {
- public static final int FLOWER_FOREST_BIOME_ID = Registry.BIOME.getRawId(Biomes.FLOWER_FOREST);
+ public static final int FLOWER_FOREST_BIOME_ID = BuiltinRegistries.BIOME.getRawId(FlowerForestHelper.BIOME);
private static Coords lastPlayerCoords = null;
private static Integer lastRenderDistance = null;
private static Map<Coords, BoundingBoxFlowerForest> lastBoundingBoxes = new HashMap<>();
}
private static boolean isSlimeChunk(int chunkX, int chunkZ) {
- return ChunkRandom.create(chunkX, chunkZ, seed, 987234911L).nextInt(10) == 0;
+ return ChunkRandom.getSlimeRandom(chunkX, chunkZ, seed, 987234911L).nextInt(10) == 0;
}
public void clearCache() {
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.util.math.MatrixStack;
import java.awt.*;
import java.util.function.Supplier;
void renderText(OffsetPoint offsetPoint, String... texts) {
TextRenderer fontRenderer = MinecraftClient.getInstance().textRenderer;
-
RenderHelper.beforeRenderFont(offsetPoint);
float top = -(fontRenderer.fontHeight * texts.length) / 2f;
for (String text : texts) {
- float left = fontRenderer.getStringWidth(text) / 2f;
- fontRenderer.draw(text, -left, top, -1);
+ float left = fontRenderer.getWidth(text) / 2f;
+ fontRenderer.draw(new MatrixStack(), text, -left, top, -1);
top += fontRenderer.fontHeight;
}
RenderHelper.afterRenderFont();
public static void blendFuncGui() {
GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
}
+
+ public static void depthFuncAlways() {
+ GlStateManager.depthFunc(GL11.GL_ALWAYS);
+ }
+
+ public static void depthFuncLessEqual() {
+ GlStateManager.depthFunc(GL11.GL_LEQUAL);
+ }
}
public static final BoundingBoxType FlowerForest = register("Flower Forest");
public static final BoundingBoxType BedrockCeiling = register("Bedrock Ceiling");
- public static final BoundingBoxType JungleTemple = register("Jungle_Pyramid");
- public static final BoundingBoxType DesertTemple = register("Desert_Pyramid");
- public static final BoundingBoxType WitchHut = register("Swamp_Hut");
- public static final BoundingBoxType OceanMonument = register("Monument");
- public static final BoundingBoxType Shipwreck = register("Shipwreck");
- public static final BoundingBoxType OceanRuin = register("Ocean_Ruin");
- public static final BoundingBoxType BuriedTreasure = register("Buried_Treasure");
- public static final BoundingBoxType Stronghold = register("Stronghold");
- public static final BoundingBoxType MineShaft = register("Mineshaft");
- public static final BoundingBoxType NetherFortress = register("Fortress");
- public static final BoundingBoxType EndCity = register("EndCity");
- public static final BoundingBoxType Mansion = register("Mansion");
- public static final BoundingBoxType Igloo = register("Igloo");
- public static final BoundingBoxType PillagerOutpost = register("Pillager_Outpost");
- public static final BoundingBoxType Village = register("Village");
- public static final BoundingBoxType NetherFossil = register("Nether_Fossil");
- public static final BoundingBoxType BastionRemnant = register("Bastion_Remnant");
- public static final BoundingBoxType RuinedPortal = register("Ruined_Portal");
+ public static final BoundingBoxType JungleTemple = register("jungle_pyramid");
+ public static final BoundingBoxType DesertTemple = register("desert_pyramid");
+ public static final BoundingBoxType WitchHut = register("swamp_hut");
+ public static final BoundingBoxType OceanMonument = register("monument");
+ public static final BoundingBoxType Shipwreck = register("shipwreck");
+ public static final BoundingBoxType OceanRuin = register("ocean_ruin");
+ public static final BoundingBoxType BuriedTreasure = register("buried_treasure");
+ public static final BoundingBoxType Stronghold = register("stronghold");
+ public static final BoundingBoxType MineShaft = register("mineshaft");
+ public static final BoundingBoxType NetherFortress = register("fortress");
+ public static final BoundingBoxType EndCity = register("endcity");
+ public static final BoundingBoxType Mansion = register("mansion");
+ public static final BoundingBoxType Igloo = register("igloo");
+ public static final BoundingBoxType PillagerOutpost = register("pillager_outpost");
+ public static final BoundingBoxType Village = register("village");
+ public static final BoundingBoxType NetherFossil = register("nether_fossil");
+ public static final BoundingBoxType BastionRemnant = register("bastion_remnant");
+ public static final BoundingBoxType RuinedPortal = register("ruined_portal");
private static BoundingBoxType register(String name) {
return structureTypeMap.computeIfAbsent(name.hashCode(), k -> new BoundingBoxType(name));
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.util.function.BiFunction;
import java.util.function.Function;
public class ReflectionHelper {
public static <T, R> Function<T, R> getPrivateFieldGetter(Class<?> clazz, Type fieldType, Type... genericTypeArguments) {
- Field field = findField(clazz, fieldType, genericTypeArguments);
+ Field field = getGenericField(clazz, fieldType, genericTypeArguments);
if (field == null) return obj -> null;
field.setAccessible(true);
};
}
+ public static Field getGenericField(Class<?> clazz, Type fieldType, Type[] genericTypeArguments) {
+ Field field = findField(clazz, fieldType, genericTypeArguments);
+ return field != null ? field : findField(clazz, fieldType, null);
+ }
+
private static Field findField(Class<?> clazz, Type fieldType, Type[] genericTypeArguments) {
for (Field field : clazz.getDeclaredFields()) {
Type type = field.getGenericType();
Type rawType = genericType.getRawType();
if (rawType != fieldType) continue;
+ if (genericTypeArguments == null) return field;
+
Type[] actualTypeArguments = genericType.getActualTypeArguments();
if (!typesMatch(genericTypeArguments, actualTypeArguments)) continue;
return true;
}
- public static <T, R> Function<T, R> getPrivateInstanceBuilder(Class<R> clazz, Class<T> parameter) {
- Constructor<R> constructor = findConstructor(clazz, parameter);
- if (constructor == null) return obj -> null;
+ public static <T, R, S> BiFunction<T, R, S> getPrivateInstanceBuilder(Class<S> clazz, Class<T> parameter1, Class<R> parameter2) {
+ Constructor<S> constructor = findConstructor(clazz, parameter1, parameter2);
+ if (constructor == null) return (obj1, obj2) -> null;
constructor.setAccessible(true);
- return obj -> {
+ return (obj1, obj2) -> {
try {
- return (R) constructor.newInstance(obj);
+ return (S) constructor.newInstance(obj1, obj2);
} catch (Exception ignored) {
return null;
}
private final BoundingBoxCache boundingBoxCache;
- private void addStructures(BoundingBoxType type, Map<String, StructureStart> structureMap) {
- StructureStart structureStart = structureMap.get(type.getName());
+ private void addStructures(BoundingBoxType type, StructureStart<?> structureStart) {
if (structureStart == null) return;
BlockBox bb = structureStart.getBoundingBox();
return BoundingBoxCuboid.from(min, max, type);
}
- void process(Map<String, StructureStart> structures) {
+ void process(Map<String, StructureStart<?>> structures) {
if (structures.size() > 0) {
- supportedStructures.forEach(type -> addStructures(type, structures));
+ supportedStructures.forEach(type -> addStructures(type, structures.get(type.getName())));
}
}
}
import java.util.Map;
public class StructuresLoaded {
- private final Map<String, StructureStart> structures;
+ private final Map<String, StructureStart<?>> structures;
private final DimensionId dimensionId;
- public StructuresLoaded(Map<String, StructureStart> structures, DimensionId dimensionId) {
+ public StructuresLoaded(Map<String, StructureStart<?>> structures, DimensionId dimensionId) {
this.structures = structures;
this.dimensionId = dimensionId;
}
- public Map<String, StructureStart> getStructures() {
+ public Map<String, StructureStart<?>> getStructures() {
return structures;
}
import com.irtimaled.bbor.common.models.DimensionId;
import net.minecraft.server.world.ServerWorld;
-import net.minecraft.world.level.LevelProperties;
+import net.minecraft.world.WorldProperties;
public class WorldLoaded {
private final DimensionId dimensionId;
private final int spawnZ;
public WorldLoaded(ServerWorld world) {
- LevelProperties info = world.getLevelProperties();
- this.dimensionId = DimensionId.from(world.getDimension().getType());
- this.seed = info.getSeed();
+ WorldProperties info = world.getLevelProperties();
+ this.dimensionId = DimensionId.from(world.getRegistryKey());
+ this.seed = world.getSeed();
this.spawnX = info.getSpawnX();
this.spawnZ = info.getSpawnZ();
}
import net.minecraft.world.chunk.WorldChunk;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
public class CommonInterop {
public static void chunkLoaded(WorldChunk chunk) {
- DimensionId dimensionId = DimensionId.from(chunk.getWorld().getDimension().getType());
- Map<String, StructureStart> structures = chunk.getStructureStarts();
+ DimensionId dimensionId = DimensionId.from(chunk.getWorld().getRegistryKey());
+ Map<String, StructureStart<?>> structures = new HashMap<>();
+ chunk.getStructureStarts().entrySet().forEach(es -> structures.put(es.getKey().getName(), es.getValue()));
if (structures.size() > 0) EventBus.publish(new StructuresLoaded(structures, dimensionId));
}
ServerPlayNetworkHandler connection = player.networkHandler;
if (connection == null) return;
- ClientConnection networkManager = connection.client;
+ ClientConnection networkManager = connection.connection;
if (networkManager.isLocal()) return;
EventBus.publish(new PlayerLoggedIn(new ServerPlayer(player)));
import com.irtimaled.bbor.client.events.AddBoundingBoxReceived;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.world.dimension.DimensionType;
import java.util.HashSet;
import java.util.Set;
public class AddBoundingBox {
public static final String NAME = "bbor:add_bounding_box_v2";
- public static final String LEGACY = "bbor:add_bounding_box";
public static PayloadBuilder getPayload(DimensionId dimensionId, AbstractBoundingBox key, Set<AbstractBoundingBox> boundingBoxes) {
if (!BoundingBoxSerializer.canSerialize(key)) return null;
return builder;
}
- public static AddBoundingBoxReceived getEvent(PayloadReader reader, String name) {
- DimensionId dimensionId = getDimensionId(reader, name);
+ public static AddBoundingBoxReceived getEvent(PayloadReader reader) {
+ DimensionId dimensionId = reader.readDimensionId();
AbstractBoundingBox key = BoundingBoxDeserializer.deserialize(reader);
if (key == null) return null;
boundingBoxes.add(key);
return new AddBoundingBoxReceived(dimensionId, key, boundingBoxes);
}
-
- private static DimensionId getDimensionId(PayloadReader reader, String name) {
- if (name.equals(NAME)) return reader.readDimensionId();
-
- int dimensionRawId = reader.readVarInt();
- 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.client.network.packet.CustomPayloadS2CPacket;
import net.minecraft.network.Packet;
-import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
+import net.minecraft.network.PacketByteBuf;
+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 com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.DimensionId;
-import net.minecraft.util.PacketByteBuf;
+import net.minecraft.network.PacketByteBuf;
public class PayloadReader {
private final PacketByteBuf buffer;
package com.irtimaled.bbor.common.models;
+import com.irtimaled.bbor.common.ReflectionHelper;
import net.minecraft.util.Identifier;
+import net.minecraft.util.registry.RegistryKey;
+import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
public class DimensionId {
+ private static final Function<DimensionType, Optional<RegistryKey<DimensionType>>> getRegistryKey =
+ ReflectionHelper.getPrivateFieldGetter(DimensionType.class, Optional.class);
+ private static final Map<Identifier, RegistryKey<World>> typeMap = new HashMap<>();
private static final Map<Identifier, DimensionId> dimensionIdMap = new HashMap<>();
- public static DimensionId from(DimensionType dimensionType) {
- return from(DimensionType.getId(dimensionType));
+ public static DimensionId from(RegistryKey<World> registryKey) {
+ Identifier value = registryKey.getValue();
+ typeMap.put(value, registryKey);
+ return from(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);
+ public static DimensionId OVERWORLD = DimensionId.from(World.OVERWORLD);
+ public static DimensionId NETHER = DimensionId.from(World.NETHER);
private final Identifier value;
return value;
}
- public DimensionType getDimensionType() {
- return DimensionType.byId(value);
+ public RegistryKey<World> getDimensionType() {
+ return typeMap.get(value);
}
@Override
private final Consumer<Packet<?>> packetConsumer;
public ServerPlayer(ServerPlayerEntity player) {
- this.dimensionId = DimensionId.from(player.dimension);
+ this.dimensionId = DimensionId.from(player.getEntityWorld().getRegistryKey());
this.packetConsumer = player.networkHandler::sendPacket;
}
package com.irtimaled.bbor.mixin.client;
import com.irtimaled.bbor.client.ClientProxy;
-import com.irtimaled.bbor.client.interop.ModPackFinder;
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.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class)
-public class MixinMinecraft {
- @Shadow
- @Final
- private ResourcePackManager<ClientResourcePackProfile> resourcePackManager;
-
- @Inject(method = "<init>", at = @At("RETURN"))
+public abstract class MixinMinecraft {
+ @Inject(method = "<init>", at = @At(value = "RETURN"))
private void constructor(RunArgs configuration, CallbackInfo ci) {
new ClientProxy().init();
}
- @Inject(method = "startTimerHackThread", at = @At("RETURN"))
- private void init(CallbackInfo ci) {
- this.resourcePackManager.registerProvider(new ModPackFinder());
- }
}
import com.irtimaled.bbor.client.gui.SettingsScreenButton;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.SettingsScreen;
+import net.minecraft.client.gui.screen.options.OptionsScreen;
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(SettingsScreen.class)
+@Mixin(OptionsScreen.class)
public class MixinOptionsScreen extends Screen {
private MixinOptionsScreen() {
super(null);
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.WorldRenderer;
-import net.minecraft.client.util.math.Matrix4f;
import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.util.math.Matrix4f;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.irtimaled.bbor.common.interop.CommonInterop;
import com.irtimaled.bbor.common.messages.SubscribeToServer;
import net.minecraft.network.listener.ServerPlayPacketListener;
+import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
-import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Shadow
private Identifier channel;
- @Redirect(method = "apply", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/ServerPlayPacketListener;onCustomPayload(Lnet/minecraft/server/network/packet/CustomPayloadC2SPacket;)V"))
+ @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(((ServerPlayNetworkHandler) netHandlerPlayServer).player);
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.packet.ChatMessageS2CPacket;
+import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.text.Text;
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(ChatMessageS2CPacket.class)
+@Mixin(GameMessageS2CPacket.class)
public class MixinSChatPacket {
@Shadow
private Text message;
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.packet.ChunkDataS2CPacket;
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 com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.TypeHelper;
import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.client.network.packet.CommandTreeS2CPacket;
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 com.irtimaled.bbor.common.messages.PayloadReader;
import com.irtimaled.bbor.common.messages.SubscribeToServer;
import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
+import net.minecraft.network.PacketByteBuf;
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;
@Shadow
private Identifier channel;
- @Redirect(method = "apply", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/ClientPlayPacketListener;onCustomPayload(Lnet/minecraft/client/network/packet/CustomPayloadS2CPacket;)V"))
+ @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:")) {
((ClientPlayNetworkHandler) netHandlerPlayClient).sendPacket(SubscribeToServer.getPayload().build());
break;
}
- case AddBoundingBox.NAME:
- case AddBoundingBox.LEGACY: {
- EventBus.publish(AddBoundingBox.getEvent(reader, channelName));
+ case AddBoundingBox.NAME: {
+ EventBus.publish(AddBoundingBox.getEvent(reader));
break;
}
}
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.packet.PlayerSpawnPositionS2CPacket;
+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;
--- /dev/null
+package com.irtimaled.bbor.mixin.resource;
+
+import com.google.common.collect.ImmutableMap;
+import net.minecraft.resource.DefaultResourcePack;
+import net.minecraft.resource.ResourcePackManager;
+import net.minecraft.resource.ResourcePackProfile;
+import net.minecraft.resource.ResourcePackSource;
+import org.spongepowered.asm.mixin.Final;
+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.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.Map;
+
+@Mixin(ResourcePackManager.class)
+public class MixinResourcePackManager {
+ private static final String BBOR = "bbor";
+ @Shadow
+ @Final
+ private ResourcePackProfile.Factory profileFactory;
+ private ResourcePackProfile resourcePackProfile;
+
+ @Inject(method = "<init>(Lnet/minecraft/resource/ResourcePackProfile$Factory;[Lnet/minecraft/resource/ResourcePackProvider;)V",
+ at = @At("RETURN"))
+ private void afterConstructor(CallbackInfo ci) {
+ resourcePackProfile = ResourcePackProfile.of(BBOR,
+ true,
+ () -> new DefaultResourcePack(BBOR),
+ this.profileFactory,
+ ResourcePackProfile.InsertionPosition.BOTTOM,
+ ResourcePackSource.PACK_SOURCE_BUILTIN);
+ }
+
+ @Redirect(method = "providePackProfiles", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;"))
+ private ImmutableMap<String, ResourcePackProfile> beforeReturn(Map<String, ResourcePackProfile> map) {
+ map.put(BBOR, resourcePackProfile);
+ return ImmutableMap.copyOf(map);
+ }
+}
"client.network.login.MixinClientLoginNetHandler",
"client.network.play.MixinClientPlayNetHandler",
"client.renderer.MixinGameRenderer",
- "client.world.MixinClientWorld",
"client.settings.MixinKeyBinding",
+ "client.world.MixinClientWorld",
"network.play.server.MixinSChatPacket",
"network.play.server.MixinSChunkDataPacket",
"network.play.server.MixinSCommandListPacket",
"network.play.server.MixinSCustomPayloadPlayPacket",
- "network.play.server.MixinSSpawnPositionPacket"
+ "network.play.server.MixinSSpawnPositionPacket",
+ "resource.MixinResourcePackManager"
],
"server": [
"server.dedicated.MixinDedicatedServer"