minecraft {
version = project.mcVersion
- mappings = 'snapshot_20190227'
+ mappings = 'snapshot_20190624'
runDir = 'run'
tweakClass = 'com.irtimaled.bbor.launch.ClientTweaker'
makeObfSourceJar = false
name=bbor
buildVersion=2.0b
# leave a space to reduce merge conflicts on version change
-mcVersion=1.13.2
+mcVersion=1.14.2
--- /dev/null
+package com.irtimaled.bbor.client;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.math.Vec3d;
+
+public class Camera {
+ private static Vec3d getPos() {
+ return Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
+ }
+
+ public static double getX() {
+ return getPos().x;
+ }
+
+ public static double getY() {
+ return getPos().y;
+ }
+
+ public static double getZ() {
+ return getPos().z;
+ }
+}
+
import com.irtimaled.bbor.common.BoundingBoxCache;
import com.irtimaled.bbor.common.CommonProxy;
import com.irtimaled.bbor.common.EventBus;
-import com.irtimaled.bbor.common.VillageColorCache;
public class ClientProxy extends CommonProxy {
public static void registerKeyBindings() {
EventBus.subscribe(DisconnectedFromRemoteServer.class, e -> disconnectedFromServer());
EventBus.subscribe(InitializeClientReceived.class, this::onInitializeClientReceived);
EventBus.subscribe(AddBoundingBoxReceived.class, this::addBoundingBox);
- EventBus.subscribe(RemoveBoundingBoxReceived.class, this::onRemoveBoundingBoxReceived);
EventBus.subscribe(UpdateWorldSpawnReceived.class, this::onUpdateWorldSpawnReceived);
EventBus.subscribe(SaveLoaded.class, e -> clear());
CustomBeaconProvider.clear();
CustomBoxProvider.clear();
BiomeBorderProvider.clear();
- VillageColorCache.clear();
clearCaches();
}
cache.addBoundingBoxes(event.getKey(), event.getBoundingBoxes());
}
- private void onRemoveBoundingBoxReceived(RemoveBoundingBoxReceived event) {
- super.removeBoundingBox(event.getDimensionId(), event.getKey());
- }
-
private void onInitializeClientReceived(InitializeClientReceived event) {
setWorldSpawn(event.getSpawnX(), event.getSpawnZ());
setSeed(event.getSeed());
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
import com.irtimaled.bbor.common.models.BoundingBoxSphere;
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
}
static {
- registerRenderer(BoundingBoxVillage.class, new VillageRenderer());
registerRenderer(BoundingBoxSlimeChunk.class, new SlimeChunkRenderer());
registerRenderer(BoundingBoxWorldSpawn.class, new WorldSpawnRenderer());
registerRenderer(BoundingBoxCuboid.class, new CuboidRenderer());
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.Point;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.client.entity.player.ClientPlayerEntity;
public class Player {
private static double x;
private static double activeY;
private static int dimensionId;
- public static void setPosition(double partialTicks, EntityPlayer player) {
+ 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;
package com.irtimaled.bbor.client.commands;
import com.mojang.brigadier.context.CommandContext;
+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.TextComponentTranslation;
+import net.minecraft.util.text.TranslationTextComponent;
class CommandHelper {
static void feedback(CommandContext<CommandSource> context, String format, Object... values) {
- context.getSource().sendFeedback(new TextComponentTranslation(format, values), false);
+ context.getSource().sendFeedback(new TranslationTextComponent(format, values), false);
}
static boolean lastNodeIsLiteral(CommandContext<CommandSource> context, String literal) {
}
private static CommandNode getLastNode(CommandContext<CommandSource> context) {
- CommandNode[] nodes = context.getNodes().keySet().toArray(new CommandNode[0]);
- return nodes[nodes.length-1];
+ ParsedCommandNode[] nodes = context.getNodes().toArray(new ParsedCommandNode[0]);
+ if (nodes.length == 0) return null;
+ return nodes[nodes.length - 1].getNode();
}
}
public static final SimpleCommandExceptionType EXPECTED_HEX_COLOR = new SimpleCommandExceptionType(new LiteralMessage("Expected hex color"));
@Override
- public <S> HexColor parse(StringReader reader) throws CommandSyntaxException {
+ public HexColor parse(StringReader reader) throws CommandSyntaxException {
String value = reader.getRemaining().split(" ")[0].toLowerCase();
if (value.isEmpty()) {
throw EXPECTED_HEX_COLOR.createWithContext(reader);
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.ISuggestionProvider;
-import net.minecraft.world.EnumLightType;
+import net.minecraft.world.LightType;
import net.minecraft.world.World;
public class SpawningSphereCommand {
World world = Minecraft.getInstance().world;
SpawningSphereProvider.calculateSpawnableSpacesCount(pos -> {
counts.spawnable++;
- if(world.getLightFor(EnumLightType.SKY, pos) > 7)
+ if(world.getLightFor(LightType.SKY, pos) > 7)
counts.nightSpawnable++;
});
SpawningSphereProvider.setSpawnableSpacesCount(counts.spawnable);
registerType(BoundingBoxType.Igloo, ConfigManager.drawIgloos, ConfigManager.colorIgloos);
registerType(BoundingBoxType.PillagerOutpost, ConfigManager.drawPillagerOutposts, ConfigManager.colorPillagerOutposts);
registerType(BoundingBoxType.Village, ConfigManager.drawVillages, ConfigManager.colorVillages);
- registerType(BoundingBoxType.VillageSpheres, ConfigManager.drawVillageSpheres, ConfigManager.colorVillages);
registerType(BoundingBoxType.NetherFossil, ConfigManager.drawNetherFossils, ConfigManager.colorNetherFossils);
registerType(BoundingBoxType.BastionRemnant, ConfigManager.drawBastionRemnants, ConfigManager.colorBastionRemnants);
registerType(BoundingBoxType.RuinedPortal, ConfigManager.drawRuinedPortals, ConfigManager.colorRuinedPortals);
public static Setting<Boolean> drawNetherFortresses;
public static Setting<Boolean> drawOceanMonuments;
public static Setting<Boolean> alwaysVisible;
- public static Setting<Boolean> drawIronGolemSpawnArea;
- public static Setting<Boolean> drawVillageDoors;
public static Setting<Boolean> drawSlimeChunks;
public static Setting<Integer> slimeChunkMaxY;
public static Setting<Boolean> keepCacheBetweenSessions;
public static Setting<Boolean> renderMobSpawnerActivationLines;
public static Setting<Boolean> drawPillagerOutposts;
public static Setting<Boolean> outerBoxesOnly;
- public static Setting<Integer> villageSphereDotSize;
- public static Setting<Integer> villageSphereDensity;
- public static Setting<Boolean> drawVillageSpheres;
public static Setting<Boolean> drawAFKSpheres;
public static Setting<Boolean> renderAFKSpawnableBlocks;
public static Setting<Integer> afkSpawnableBlocksRenderDistance;
biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
biomeBordersMaxY = setup(config, "biomeBorders", "biomeBordersMaxY", -1, "The maximum top of the biome borders. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
- drawVillageSpheres = setup(config, "villages", "drawVillageSpheres", true, "If set to true village bounding spheres are drawn.");
- drawIronGolemSpawnArea = setup(config, "villages", "drawIronGolemSpawnArea", true, "If set to true the iron golem spawn area of the village will be drawn. (default:true)");
- drawVillageDoors = setup(config, "villages", "drawVillageDoors", false, "If set to true lines between the village centre and doors will be drawn. (default:false)");
- villageSphereDotSize = setup(config, "villages", "villageSphereDotSize", 2, "The size of the dots used when rendering village as sphere.");
- villageSphereDensity = setup(config, "villages", "villageSphereDensity", 3, "The density of the dots used when rendering village as sphere.");
-
drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
+++ /dev/null
-package com.irtimaled.bbor.client.events;
-
-import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-
-public class RemoveBoundingBoxReceived {
- private final int dimensionId;
- private final AbstractBoundingBox key;
-
- public RemoveBoundingBoxReceived(int dimensionId, AbstractBoundingBox key) {
- this.dimensionId = dimensionId;
- this.key = key;
- }
-
- public int getDimensionId() {
- return dimensionId;
- }
-
- public AbstractBoundingBox getKey() {
- return key;
- }
-}
AbstractButton(int x, int y, int width, String name, boolean enabled) {
this(x, y, width, name);
- this.enabled = enabled;
+ this.active = enabled;
}
@Override
- protected int getHoverState(boolean p_getHoverState_1_) {
+ protected int getYImage(boolean p_getHoverState_1_) {
return getState();
}
protected int getState() {
- return this.enabled ? this.hovered ? 2 : 1 : 0;
+ return this.active ? this.isHovered ? 2 : 1 : 0;
}
@Override
package com.irtimaled.bbor.client.gui;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.widget.Widget;
import java.awt.*;
-abstract class AbstractControl extends GuiButton implements IControl {
+abstract class AbstractControl extends Widget implements IControl {
private static final int PADDING = 4;
protected final Minecraft minecraft;
AbstractControl(int x, int y, int width, String name) {
- super(0, x, y, width, 20, name);
+ super(x, y, width, 20, name);
this.minecraft = Minecraft.getInstance();
}
@Override
protected void renderBg(Minecraft minecraft, int mouseX, int mouseY) {
- if (enabled) renderBackground(mouseX, mouseY);
+ if (active) renderBackground(mouseX, mouseY);
}
protected void renderBackground(int mouseX, int mouseY) {
@Override
public void filter(String lowerValue) {
- String lowerString = this.displayString.toLowerCase();
+ String lowerString = this.getMessage().toLowerCase();
this.setVisible(lowerValue.equals("") ||
lowerString.startsWith(lowerValue) ||
lowerString.contains(" " + lowerValue));
}
void drawRectangle(int left, int top, int right, int bottom, Color color) {
- drawRect(left, top, right, bottom, color.getRGB());
+ fill(left, top, right, bottom, color.getRGB());
}
}
@Override
protected void renderBackground(int mouseX, int mouseY) {
- this.minecraft.getTextureManager().bindTexture(BUTTON_TEXTURES);
+ this.minecraft.getTextureManager().bindTexture(WIDGETS_LOCATION);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if(isDragging) {
changeProgress(mouseX);
}
- int hoverState = super.getHoverState(this.hovered);
- this.drawTexturedModalRect(this.x + (int) (this.progress * (double) (this.width - 8)), this.y, 0, 46 + hoverState * 20, 4, this.height);
- this.drawTexturedModalRect(this.x + (int) (this.progress * (double) (this.width - 8)) + 4, this.y, 196, 46 + hoverState * 20, 4, 20);
+ int hoverState = super.getYImage(this.isHovered);
+ this.blit(this.x + (int) (this.progress * (double) (this.width - 8)), this.y, 0, 46 + hoverState * 20, 4, this.height);
+ this.blit(this.x + (int) (this.progress * (double) (this.width - 8)) + 4, this.y, 196, 46 + hoverState * 20, 4, 20);
}
boolean setProgress(double progress) {
}
@Override
- protected int getHoverState(boolean hovered) {
+ protected int getYImage(boolean hovered) {
return 0;
}
@Override
protected int getState() {
- return enabled ? super.getState() : 0;
+ return active ? super.getState() : 0;
}
protected boolean getValue() {
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.renderers.Renderer;
+import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.GuiEventHandler;
+import net.minecraft.client.gui.AbstractGui;
+import net.minecraft.client.gui.FocusableGui;
import net.minecraft.client.gui.IGuiEventListener;
-import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL11;
import java.util.Collections;
import java.util.List;
-public class ControlList extends GuiEventHandler {
+public class ControlList extends FocusableGui {
private static final int CONTROLS_WIDTH = 310;
private final int scrollBarLeft;
private final int listHeight;
}
@Override
- public boolean mouseScrolled(double scrollAmount) {
+ public boolean mouseScrolled(double mouseX, double mouseY, double scrollAmount) {
this.amountScrolled -= scrollAmount * 10;
return true;
}
this.overlayBackground(0, this.top);
this.overlayBackground(this.bottom, this.height);
GL11.glEnable(GL11.GL_BLEND);
- OpenGlHelper.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
+ GLX.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
private void drawListBackground() {
- this.minecraft.getTextureManager().bindTexture(Gui.OPTIONS_BACKGROUND);
+ this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
Renderer.startTextured()
.setColor(32, 32, 32)
.setAlpha(255)
}
private void overlayBackground(int top, int bottom) {
- this.minecraft.getTextureManager().bindTexture(Gui.OPTIONS_BACKGROUND);
+ this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Renderer.startTextured()
.setColor(64, 64, 64)
}
@Override
- protected List<? extends IGuiEventListener> getChildren() {
+ public List<? extends IGuiEventListener> children() {
return Collections.emptyList();
}
}
private int columnCount() {
- switch (minecraft.getLanguageManager().getCurrentLanguage().getLanguageCode()){
+ switch (minecraft.getLanguageManager().getCurrentLanguage().getCode()){
case "en_au":
case "en_us":
case "en_gb": return 3;
@Override
protected void updateText() {
- this.displayString = this.getDisplayValue();
+ this.setMessage(this.getDisplayValue());
}
@Override
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
+import net.minecraft.util.text.StringTextComponent;
-public abstract class ListScreen extends GuiScreen {
- private final GuiScreen lastScreen;
+public abstract class ListScreen extends Screen {
+ private final Screen lastScreen;
private AbstractButton doneButton;
- private String title;
private ControlList controlList;
private SearchField searchField;
- ListScreen(GuiScreen lastScreen) {
+ ListScreen(Screen lastScreen) {
+ super(new StringTextComponent("Bounding Box Outline Reloaded"));
this.lastScreen = lastScreen;
}
}
@Override
- protected void initGui() {
- this.title = "Bounding Box Outline Reloaded";
+ protected void init() {
this.controlList = new ControlList(this.width, this.height, 48, this.height - 28);
- this.searchField = new SearchField(this.fontRenderer, this.width / 2 - 100, 22, 200, 20, this.controlList);
+ 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")) {
@Override
public void onPressed() {
protected void render(int mouseX, int mouseY) {
this.controlList.render(mouseX, mouseY);
- this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 8, 16777215);
+ this.drawCenteredString(this.font, this.title.getUnformattedComponentText(), this.width / 2, 8, 16777215);
this.searchField.render(mouseX, mouseY);
this.doneButton.render(mouseX, mouseY);
}
}
@Override
- public boolean mouseScrolled(double scrollAmount) {
- return this.controlList.mouseScrolled(scrollAmount);
+ public boolean mouseScrolled(double mouseX, double mouseY, double scrollAmount) {
+ return this.controlList.mouseScrolled(mouseX, mouseY, scrollAmount);
}
@Override
- public void onGuiClosed() {
+ public void removed() {
this.controlList.close();
}
import com.irtimaled.bbor.client.interop.ClientInterop;
import net.minecraft.client.AnvilConverterException;
-import net.minecraft.world.storage.ISaveFormat;
+import net.minecraft.world.storage.SaveFormat;
import net.minecraft.world.storage.WorldSummary;
import java.util.List;
ControlList controlList = this.getControlList();
controlList.showSelectionBox();
try {
- final ISaveFormat saveLoader = this.mc.getSaveLoader();
+ final SaveFormat saveLoader = this.minecraft.getSaveLoader();
List<WorldSummary> saveList = saveLoader.getSaveList();
saveList.sort(null);
saveList.forEach(world -> controlList.add(new WorldSaveRow(world, saveLoader)));
@Override
public void render(int mouseX, int mouseY, float unknown) {
ControlListEntry selectedEntry = this.getControlList().getSelectedEntry();
- this.getDoneButton().enabled = selectedEntry != null && selectedEntry.getVisible();
+ this.getDoneButton().active = selectedEntry != null && selectedEntry.getVisible();
super.render(mouseX, mouseY, unknown);
}
}
package com.irtimaled.bbor.client.gui;
import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.widget.TextFieldWidget;
-public class SearchField extends GuiTextField {
+public class SearchField extends TextFieldWidget {
private final ControlList controlList;
SearchField(FontRenderer fontRenderer, int left, int top, int width, int height, ControlList controlList) {
- super(0, fontRenderer, left, top, width, height);
+ super(fontRenderer, left, top, width, height, "");
this.controlList = controlList;
- this.setTextAcceptHandler((id, text) -> this.controlList.filter(removeLeadingSpaces(text.toLowerCase())));
+ this.func_212954_a(text -> this.controlList.filter(removeLeadingSpaces(text.toLowerCase())));
this.setTextFormatter((text, id) -> removeLeadingSpaces(text));
this.setFocused(true);
this.setCanLoseFocus(false);
}
public void render(int mouseX, int mouseY) {
- this.drawTextField(mouseX, mouseY, 0f);
+ this.render(mouseX, mouseY, 0f);
}
@Override
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.BoundingBoxType;
-import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
+import net.minecraft.util.SharedConstants;
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).*";
ClientInterop.displayScreen(new SettingsScreen(null));
}
- SettingsScreen(GuiScreen lastScreen) {
+ SettingsScreen(Screen lastScreen) {
super(lastScreen);
}
@Override
protected void setup() {
- String version = this.mc.getVersion();
+ String version = SharedConstants.getVersion().getName();
ControlList controlList = this.getControlList();
- if (this.mc.world != null) controlList.setTransparentBackground();
+ if (this.minecraft.world != null) controlList.setTransparentBackground();
controlList
.section(null,
- (x, width) -> new BoolButton(width, I18n.format("bbor.options.active"), this.mc.world != null) {
+ (x, width) -> new BoolButton(width, I18n.format("bbor.options.active"), this.minecraft.world != null) {
@Override
public void onPressed() {
ClientRenderer.toggleActive();
(x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.fortresses"), BoundingBoxType.NetherFortress),
(x, width) -> version.matches(netherFossilVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.netherFossils"), BoundingBoxType.NetherFossil) : null,
(x, width) -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.bastionRemnants"), BoundingBoxType.BastionRemnant) : null,
- (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.endCities"), BoundingBoxType.EndCity))
- .section(I18n.format("bbor.tabs.villages"),
- (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.villageSpheres"), ConfigManager.drawVillageSpheres),
- (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.villageSpheres.doorLines"), ConfigManager.drawVillageDoors),
- (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.villageSpheres.golemSpawn"), ConfigManager.drawIronGolemSpawnArea),
- (x, width) -> new IntSettingSlider(width, 1, 5, "bbor.features.villageSpheres.dotSize", ConfigManager.villageSphereDotSize),
- (x, width) -> new IntSettingSlider(width, 1, 5, "bbor.features.villageSpheres.density", ConfigManager.villageSphereDensity)
- .addDisplayValue(1, I18n.format("bbor.features.villageSpheres.density.fewest"))
- .addDisplayValue(2, I18n.format("bbor.features.villageSpheres.density.fewer"))
- .addDisplayValue(3, I18n.format("bbor.features.villageSpheres.density.normal"))
- .addDisplayValue(4, I18n.format("bbor.features.villageSpheres.density.more"))
- .addDisplayValue(5, I18n.format("bbor.features.villageSpheres.density.most")));
+ (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.endCities"), BoundingBoxType.EndCity));
}
}
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.screen.Screen;
public class SettingsScreenButton extends AbstractButton {
private final SettingsScreen screen;
- public SettingsScreenButton(int x, int y, int width, String label, GuiScreen lastScreen) {
+ public SettingsScreenButton(int x, int y, int width, String label, Screen lastScreen) {
super(x, y, width, label);
screen = new SettingsScreen(lastScreen);
}
import com.google.common.hash.Hashing;
import com.irtimaled.bbor.client.interop.ClientInterop;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
+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.util.Util;
-import net.minecraft.world.storage.ISaveFormat;
+import net.minecraft.world.storage.SaveFormat;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.world.storage.WorldSummary;
import org.apache.logging.log4j.LogManager;
private static final int ICON_SIZE = 20;
private final Minecraft client;
private final WorldSummary worldSummary;
- private final ISaveFormat saveLoader;
+ private final SaveFormat saveLoader;
private final ResourceLocation iconLocation;
private final DynamicTexture icon;
private File iconFile;
private long lastClickTime;
- WorldSaveRow(WorldSummary worldSummary, ISaveFormat saveLoader) {
+ WorldSaveRow(WorldSummary worldSummary, SaveFormat saveLoader) {
this.worldSummary = worldSummary;
this.saveLoader = saveLoader;
this.client = Minecraft.getInstance();
this.client.fontRenderer.drawString(details, (float) (x + ICON_SIZE + 3), (float) (y + 1 + this.client.fontRenderer.FONT_HEIGHT + 1), 8421504);
this.client.getTextureManager().bindTexture(this.icon != null ? this.iconLocation : ICON_MISSING);
GL11.glEnable(GL11.GL_BLEND);
- Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32.0F, 32.0F);
+ AbstractGui.blit(x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
GL11.glDisable(GL11.GL_BLEND);
}
import com.irtimaled.bbor.common.models.Coords;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.registry.IRegistry;
+import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
public class BiomeBorderHelper {
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 IRegistry.BIOME.getId(biome);
+ return Registry.BIOME.getId(biome);
}
}
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.client.entity.player.ClientPlayerEntity;
+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.util.math.BlockPos;
EventBus.publish(new DisconnectedFromRemoteServer());
}
- public static void render(float partialTicks, EntityPlayerSP player) {
+ public static void render(float partialTicks, ClientPlayerEntity player) {
Player.setPosition(partialTicks, player);
ClientRenderer.render(player.dimension.getId());
}
public static boolean interceptChatMessage(String message) {
if (message.startsWith("/bbor:")) {
- NetHandlerPlayClient connection = Minecraft.getInstance().getConnection();
+ ClientPlayNetHandler connection = Minecraft.getInstance().getConnection();
if (connection != null) {
CommandDispatcher<ISuggestionProvider> commandDispatcher = connection.func_195515_i();
CommandSource commandSource = Minecraft.getInstance().player.getCommandSource();
} catch (CommandSyntaxException exception) {
commandSource.sendErrorMessage(TextComponentUtils.toTextComponent(exception.getRawMessage()));
if (exception.getInput() != null && exception.getCursor() >= 0) {
- ITextComponent suggestion = new TextComponentString("")
+ ITextComponent suggestion = new StringTextComponent("")
.applyTextStyle(TextFormatting.GRAY)
.applyTextStyle(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)));
int textLength = Math.min(exception.getInput().length(), exception.getCursor());
suggestion.appendText(exception.getInput().substring(Math.max(0, textLength - 10), textLength));
if (textLength < exception.getInput().length()) {
- suggestion.appendSibling(new TextComponentString(exception.getInput().substring(textLength))
+ suggestion.appendSibling(new StringTextComponent(exception.getInput().substring(textLength))
.applyTextStyles(TextFormatting.RED, TextFormatting.UNDERLINE));
}
- suggestion.appendSibling(new TextComponentTranslation("command.context.here")
+ suggestion.appendSibling(new TranslationTextComponent("command.context.here")
.applyTextStyles(TextFormatting.RED, TextFormatting.ITALIC));
commandSource.sendErrorMessage(suggestion);
}
}
public static void handleSeedMessage(ITextComponent chatComponent) {
- TypeHelper.doIfType(chatComponent, TextComponentTranslation.class, message -> {
+ TypeHelper.doIfType(chatComponent, TranslationTextComponent.class, message -> {
if (!message.getKey().equals("commands.seed.success")) return;
try {
SaveGameStructureLoader.clear();
}
- public static void displayScreen(GuiScreen screen) {
+ public static void displayScreen(Screen screen) {
Minecraft.getInstance().displayGuiScreen(screen);
}
}
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.events.StructuresLoaded;
-import net.minecraft.nbt.CompressedStreamTools;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.CompoundNBT;
+import net.minecraft.nbt.ListNBT;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
+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.ISaveHandler;
-import net.minecraft.world.storage.WorldSavedDataStorage;
+import net.minecraft.world.storage.DimensionSavedDataManager;
+import net.minecraft.world.storage.SaveHandler;
-import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.util.*;
private final Set<String> loadedChunks = new HashSet<>();
private LegacyStructureDataUtil legacyStructureDataUtil = null;
- private ISaveHandler saveHandler = null;
+ private SaveHandler saveHandler = null;
private File chunkSaveLocation = null;
+ private ChunkLoader chunkLoader;
- NBTStructureLoader(int dimensionId, ISaveHandler saveHandler, File worldDirectory) {
+ NBTStructureLoader(int dimensionId, SaveHandler saveHandler, File worldDirectory) {
this.dimensionId = dimensionId;
this.configure(saveHandler, worldDirectory);
}
this.saveHandler = null;
this.chunkSaveLocation = null;
this.loadedChunks.clear();
+
+ if(this.chunkLoader == null) return;
+ try {
+ this.chunkLoader.close();
+ } catch (IOException ignored) {
+ }
}
- void configure(ISaveHandler saveHandler, File worldDirectory) {
+ void configure(SaveHandler saveHandler, File worldDirectory) {
this.saveHandler = saveHandler;
- if(worldDirectory != null) {
- this.chunkSaveLocation = DimensionType.getById(dimensionId).getDirectory(worldDirectory);
+ if (worldDirectory != null) {
+ this.chunkSaveLocation = new File(DimensionType.getById(dimensionId).getDirectory(worldDirectory), "region");
+ this.chunkLoader = new ChunkLoader(this.chunkSaveLocation);
}
}
private LegacyStructureDataUtil getLegacyStructureDataUtil() {
if (this.legacyStructureDataUtil == null) {
- this.legacyStructureDataUtil = LegacyStructureDataUtil.func_212183_a(DimensionType.getById(dimensionId), new WorldSavedDataStorage(saveHandler));
+ File dataFolder = new File(DimensionType.OVERWORLD.getDirectory(this.saveHandler.getWorldDirectory()), "data");
+ this.legacyStructureDataUtil = LegacyStructureDataUtil.func_215130_a(DimensionType.getById(dimensionId),
+ new DimensionSavedDataManager(dataFolder, this.saveHandler.getFixer()));
}
return this.legacyStructureDataUtil;
}
- private NBTTagCompound loadStructureStarts(int chunkX, int chunkZ) {
+ private CompoundNBT loadStructureStarts(int chunkX, int chunkZ) {
try {
- DataInputStream stream = RegionFileCache.getChunkInputStream(chunkSaveLocation, chunkX, chunkZ);
- if (stream != null) {
- NBTTagCompound compound = CompressedStreamTools.read(stream);
- stream.close();
- 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);
- }
+ CompoundNBT 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);
}
- return compound.getCompound("Level").getCompound("Structures").getCompound("Starts");
}
+ return compound.getCompound("Level").getCompound("Structures").getCompound("Starts");
} catch (IOException ignored) {
}
return null;
if (!loadedChunks.add(String.format("%s,%s", chunkX, chunkZ))) return;
- NBTTagCompound structureStarts = loadStructureStarts(chunkX, chunkZ);
+ CompoundNBT structureStarts = loadStructureStarts(chunkX, chunkZ);
if (structureStarts == null || structureStarts.size() == 0) return;
Map<String, StructureStart> structureStartMap = new HashMap<>();
for (String key : structureStarts.keySet()) {
- NBTTagCompound compound = structureStarts.getCompound(key);
+ CompoundNBT compound = structureStarts.getCompound(key);
if (compound.contains("BB")) {
structureStartMap.put(key, new SimpleStructureStart(compound));
}
}
private static class SimpleStructureStart extends StructureStart {
- SimpleStructureStart(NBTTagCompound compound) {
- this.boundingBox = new MutableBoundingBox(compound.getIntArray("BB"));
-
- NBTTagList children = compound.getList("Children", 10);
+ SimpleStructureStart(CompoundNBT compound) {
+ super(null,
+ 0,
+ 0,
+ null,
+ new MutableBoundingBox(compound.getIntArray("BB")),
+ 0,
+ 0);
+
+ ListNBT children = compound.getList("Children", 10);
for (int index = 0; index < children.size(); ++index) {
- NBTTagCompound child = children.getCompound(index);
+ CompoundNBT child = children.getCompound(index);
if (child.contains("BB")) this.components.add(new SimpleStructurePiece(child));
}
}
+
+ @Override
+ public void init(ChunkGenerator<?> chunkGenerator, TemplateManager templateManager, int i, int i1, Biome biome) {
+
+ }
}
private static class SimpleStructurePiece extends StructurePiece {
- SimpleStructurePiece(NBTTagCompound compound) {
- this.boundingBox = new MutableBoundingBox(compound.getIntArray("BB"));
+ SimpleStructurePiece(CompoundNBT compound) {
+ super(null, compound);
}
@Override
- protected void writeAdditional(NBTTagCompound nbtTagCompound) {
- }
+ protected void readAdditional(CompoundNBT compoundNBT) {
- @Override
- protected void readAdditional(NBTTagCompound nbtTagCompound, TemplateManager templateManager) {
}
@Override
return false;
}
}
+
+ private static class ChunkLoader {
+ private final RegionFileCache regionFileCache;
+
+ public ChunkLoader(File file) {
+ this.regionFileCache = new RegionFileCache(file) {
+ };
+ }
+
+ public CompoundNBT readChunk(int chunkX, int chunkZ) throws IOException {
+ return regionFileCache.readChunk(new ChunkPos(chunkX, chunkZ));
+ }
+
+ public void close() throws IOException {
+ regionFileCache.close();
+ }
+ }
}
import com.irtimaled.bbor.client.Player;
import net.minecraft.client.Minecraft;
-import net.minecraft.world.chunk.storage.RegionFileCache;
-import net.minecraft.world.storage.ISaveFormat;
-import net.minecraft.world.storage.ISaveHandler;
+import net.minecraft.world.storage.SaveFormat;
+import net.minecraft.world.storage.SaveHandler;
import java.io.File;
import java.util.HashMap;
public class SaveGameStructureLoader {
private static final Map<Integer, NBTStructureLoader> nbtStructureLoaders = new HashMap<>();
- private static ISaveHandler saveHandler = null;
+ private static SaveHandler saveHandler = null;
private static File worldDirectory = null;
static void loadSaveGame(String fileName) {
Minecraft minecraft = Minecraft.getInstance();
- ISaveFormat saveLoader = minecraft.getSaveLoader();
+ SaveFormat saveLoader = minecraft.getSaveLoader();
saveHandler = saveLoader.getSaveLoader(fileName, null);
- worldDirectory = saveLoader.getWorldFolder(fileName).toFile();
+ worldDirectory = saveLoader.func_215781_c().resolve(fileName).toFile();
for (int dimensionId : nbtStructureLoaders.keySet()) {
NBTStructureLoader dimensionProcessor = getNBTStructureLoader(dimensionId);
nbtStructureLoaders.clear();
saveHandler = null;
worldDirectory = null;
- RegionFileCache.clearRegionFileReferences();
}
}
import com.irtimaled.bbor.common.models.Coords;
import net.minecraft.block.Block;
-import net.minecraft.block.state.IBlockState;
+import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
-import net.minecraft.entity.EnumCreatureType;
-import net.minecraft.init.Blocks;
+import net.minecraft.entity.EntityClassification;
+import net.minecraft.entity.EntityType;
import net.minecraft.tags.BlockTags;
-import net.minecraft.util.EnumFacing;
+import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.EnumLightType;
+import net.minecraft.util.math.shapes.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);
+
public static void findSpawnableBlocks(Coords coords, int width, int height, BlockProcessor blockProcessor) {
int blockX = coords.getX();
int minX = blockX - width;
for (int z = minZ; z < maxZ; z++) {
if (isBiomeHostileSpawnProof(world, new BlockPos(x, 1, z))) continue;
- IBlockState upperBlockState = world.getBlockState(new BlockPos(x, minY - 1, z));
+ BlockState upperBlockState = world.getBlockState(new BlockPos(x, minY - 1, z));
for (int y = Math.max(1, minY); y < maxY; y++) {
- IBlockState spawnBlockState = upperBlockState;
+ BlockState spawnBlockState = upperBlockState;
BlockPos pos = new BlockPos(x, y, z);
upperBlockState = world.getBlockState(pos);
if (isSpawnable(world, pos, spawnBlockState, upperBlockState)) {
static boolean isBiomeHostileSpawnProof(World world, BlockPos pos) {
Biome biome = world.getBiome(pos);
return biome.getSpawningChance() == 0 ||
- biome.getSpawns(EnumCreatureType.MONSTER).isEmpty();
+ biome.getSpawns(EntityClassification.MONSTER).isEmpty();
}
- static boolean isSpawnable(World world, BlockPos pos, IBlockState spawnBlockState, IBlockState upperBlockState) {
- Block spawnBlock = spawnBlockState.getBlock();
- return spawnBlock != Blocks.AIR &&
- spawnBlock != Blocks.BEDROCK &&
- spawnBlock != Blocks.BARRIER &&
- spawnBlockState.isTopSolid() &&
- !upperBlockState.isBlockNormalCube() &&
+ 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) &&
- upperBlockState.getCollisionShape(world, pos).getEnd(EnumFacing.Axis.Y) <= 0 &&
+ collisionShape.getEnd(Direction.Axis.Y) <= 0 &&
upperBlockState.getFluidState().isEmpty() &&
- (world.dimension.isNether() || world.getLightFor(EnumLightType.BLOCK, pos) <= 7);
+ (isNether || world.getLightFor(LightType.BLOCK, pos) <= 7);
}
}
import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.Point;
-import net.minecraft.block.state.IBlockState;
+import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
if (SpawnableBlocksHelper.isBiomeHostileSpawnProof(world, new BlockPos(x, 1, z))) continue;
- IBlockState upperBlockState = world.getBlockState(new BlockPos(x, minY - 1, z));
+ BlockState upperBlockState = world.getBlockState(new BlockPos(x, minY - 1, z));
for (int y = minY; y < maxY; y++) {
- IBlockState spawnBlockState = upperBlockState;
+ BlockState spawnBlockState = upperBlockState;
BlockPos pos = new BlockPos(x, y, z);
upperBlockState = world.getBlockState(pos);
distance = center.getDistance(new Point(closestX, y, closestZ));
if (windowHandle == mainWindowHandle &&
minecraft.currentScreen == null &&
keyCode != -1 &&
- !InputMappings.isKeyDown(292) &&
+ !InputMappings.isKeyDown(mainWindowHandle, 292) &&
handleKeyEvent(keyCode, isPressed))
return;
minecraft.keyboardListener.onKeyEvent(windowHandle, keyCode, scanCode, action, modifiers);
import com.irtimaled.bbor.client.models.BoundingBoxBeacon;
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.tileentity.TileEntityBeacon;
+import net.minecraft.tileentity.BeaconTileEntity;
public class BeaconProvider implements IBoundingBoxProvider<BoundingBoxBeacon> {
@Override
@Override
public Iterable<BoundingBoxBeacon> get(int dimensionId) {
- return TileEntitiesHelper.map(TileEntityBeacon.class, beacon -> {
+ return TileEntitiesHelper.map(BeaconTileEntity.class, beacon -> {
int levels = beacon.getLevels();
Coords coords = new Coords(beacon.getPos());
return BoundingBoxBeacon.from(coords, levels);
import com.irtimaled.bbor.client.models.BoundingBoxConduit;
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.tileentity.TileEntityConduit;
+import net.minecraft.tileentity.ConduitTileEntity;
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<TileEntityConduit, List<BlockPos>> blocksFetcher =
- ReflectionHelper.getPrivateFieldGetter(TileEntityConduit.class, List.class, BlockPos.class);
+ private static final Function<ConduitTileEntity, List<BlockPos>> blocksFetcher =
+ ReflectionHelper.getPrivateFieldGetter(ConduitTileEntity.class, List.class, BlockPos.class);
@Override
public boolean canProvide(int dimensionId) {
@Override
public Iterable<BoundingBoxConduit> get(int dimensionId) {
- return TileEntitiesHelper.map(TileEntityConduit.class, conduit -> {
+ return TileEntitiesHelper.map(ConduitTileEntity.class, conduit -> {
List<BlockPos> blocks = blocksFetcher.apply(conduit);
if (blocks == null) return null;
import com.irtimaled.bbor.client.models.BoundingBoxMobSpawner;
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.tileentity.TileEntityMobSpawner;
+import net.minecraft.tileentity.MobSpawnerTileEntity;
public class MobSpawnerProvider implements IBoundingBoxProvider<BoundingBoxMobSpawner> {
@Override
@Override
public Iterable<BoundingBoxMobSpawner> get(int dimensionId) {
- return TileEntitiesHelper.map(TileEntityMobSpawner.class, spawner -> {
+ return TileEntitiesHelper.map(MobSpawnerTileEntity.class, spawner -> {
Coords coords = new Coords(spawner.getPos());
return BoundingBoxMobSpawner.from(coords);
});
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.Point;
+import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
import java.awt.*;
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
- OpenGlHelper.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
+ GLX.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_DEPTH_TEST);
package com.irtimaled.bbor.client.renderers;
-import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.Camera;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.common.models.Point;
}
double getX() {
- return point.getX() - Player.getX();
+ return point.getX() - Camera.getX();
}
double getY() {
- return point.getY() - Player.getY();
+ return point.getY() - Camera.getY();
}
double getZ() {
- return point.getZ() - Player.getZ();
+ return point.getZ() - Camera.getZ();
}
OffsetPoint offset(double x, double y, double z) {
+++ /dev/null
-package com.irtimaled.bbor.client.renderers;
-
-import com.irtimaled.bbor.client.config.ConfigManager;
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
-import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.common.models.Point;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-
-public class VillageRenderer extends AbstractRenderer<BoundingBoxVillage> {
- @Override
- public void render(BoundingBoxVillage boundingBox) {
- renderBoundingBoxVillageAsSphere(boundingBox);
- if (ConfigManager.drawIronGolemSpawnArea.get() &&
- boundingBox.getSpawnsIronGolems()) {
- renderIronGolemSpawnArea(boundingBox);
- }
- if (ConfigManager.drawVillageDoors.get()) {
- renderVillageDoors(boundingBox);
- }
- }
-
- private void renderIronGolemSpawnArea(BoundingBoxVillage boundingBox) {
- OffsetPoint offsetCenter = new OffsetPoint(boundingBox.getPoint());
- OffsetBox bb = new OffsetBox(offsetCenter, offsetCenter)
- .grow(8, 3, 8);
-
- renderOutlinedCuboid(bb.nudge(), boundingBox.getColor());
- }
-
- private void renderVillageDoors(BoundingBoxVillage boundingBox) {
- OffsetPoint center = new OffsetPoint(boundingBox.getPoint());
- Color color = boundingBox.getColor();
-
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
- Renderer renderer = Renderer.startLines()
- .setColor(color);
- for (Coords door : boundingBox.getDoors()) {
- OffsetPoint point = new OffsetPoint(door).offset(0.5, 0, 0.5);
-
- renderer.addPoint(point)
- .addPoint(center);
- }
- renderer.render();
- }
-
- private void renderBoundingBoxVillageAsSphere(BoundingBoxVillage boundingBox) {
- Point point = boundingBox.getPoint();
- double radius = boundingBox.getRadius();
- Color color = boundingBox.getColor();
- int density = ConfigManager.villageSphereDensity.get();
- int dotSize = ConfigManager.villageSphereDotSize.get();
-
- renderSphere(point, radius, color, density, dotSize);
- }
-}
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 VillageSpheres = register("Village Sphere");
public static final BoundingBoxType NetherFossil = register("Nether_Fossil");
public static final BoundingBoxType BastionRemnant = register("Bastion_Remnant");
public static final BoundingBoxType RuinedPortal = register("Ruined_Portal");
import com.irtimaled.bbor.common.messages.AddBoundingBox;
import com.irtimaled.bbor.common.messages.InitializeClient;
import com.irtimaled.bbor.common.messages.PayloadBuilder;
-import com.irtimaled.bbor.common.messages.RemoveBoundingBox;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.ServerPlayer;
public class CommonProxy {
private final Map<Integer, ServerPlayer> players = new ConcurrentHashMap<>();
private final Map<Integer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
- private final Map<Integer, VillageProcessor> villageProcessors = new HashMap<>();
private final Map<Integer, StructureProcessor> structureProcessors = new HashMap<>();
private final Map<Integer, BoundingBoxCache> dimensionCache = new ConcurrentHashMap<>();
private Long seed = null;
EventBus.subscribe(PlayerLoggedIn.class, this::playerLoggedIn);
EventBus.subscribe(PlayerLoggedOut.class, this::playerLoggedOut);
EventBus.subscribe(PlayerSubscribed.class, this::onPlayerSubscribed);
- EventBus.subscribe(ServerWorldTick.class, this::serverWorldTick);
EventBus.subscribe(ServerTick.class, e -> serverTick());
- EventBus.subscribe(VillageRemoved.class, this::onVillageRemoved);
}
protected void setSeed(long seed) {
playerBoundingBoxesCache.remove(playerId);
}
- private void onVillageRemoved(VillageRemoved event) {
- sendRemoveBoundingBox(event.getDimensionId(), event.getVillage());
- }
-
- private void sendRemoveBoundingBox(int dimensionId, AbstractBoundingBox boundingBox) {
- PayloadBuilder payload = RemoveBoundingBox.getPayload(dimensionId, boundingBox);
- if (payload == null) return;
-
- for (Map.Entry<Integer, ServerPlayer> playerEntry : players.entrySet()) {
- int playerId = playerEntry.getKey();
- ServerPlayer player = playerEntry.getValue();
- if (player.getDimensionId() == dimensionId) {
- player.sendPacket(payload);
-
- if (playerBoundingBoxesCache.containsKey(playerId)) {
- playerBoundingBoxesCache.get(playerId).remove(boundingBox);
- }
- }
- }
- }
-
private void onPlayerSubscribed(PlayerSubscribed event) {
int playerId = event.getPlayerId();
ServerPlayer player = event.getPlayer();
}
}
- protected void removeBoundingBox(int dimensionId, AbstractBoundingBox key) {
- BoundingBoxCache cache = getCache(dimensionId);
- if (cache == null) return;
-
- cache.removeBoundingBox(key);
- }
-
private void serverTick() {
for (Map.Entry<Integer, ServerPlayer> playerEntry : players.entrySet()) {
int playerId = playerEntry.getKey();
}
}
- private void serverWorldTick(ServerWorldTick event) {
- int dimensionId = event.getDimensionId();
- VillageProcessor villageProcessor = villageProcessors.get(dimensionId);
- if (villageProcessor == null) {
- villageProcessor = new VillageProcessor(dimensionId, getOrCreateCache(dimensionId));
- villageProcessors.put(dimensionId, villageProcessor);
- }
-
- villageProcessor.process(event.getWorld());
- }
-
protected BoundingBoxCache getCache(int dimensionId) {
return dimensionCache.get(dimensionId);
}
}
protected void clearCaches() {
- for (VillageProcessor villageProcessor : villageProcessors.values()) {
- villageProcessor.clear();
- }
- villageProcessors.clear();
structureProcessors.clear();
for (BoundingBoxCache cache : dimensionCache.values()) {
cache.clear();
+++ /dev/null
-package com.irtimaled.bbor.common;
-
-import java.awt.*;
-import java.util.HashMap;
-import java.util.Map;
-
-public class VillageColorCache {
- private static int colorIndex = -1;
-
- public static void clear() {
- colorIndex = -1;
- villageColorCache.clear();
- }
-
- private static Color getNextColor() {
- switch (++colorIndex % 6) {
- case 0:
- return Color.RED;
- case 1:
- return Color.GREEN;
- case 2:
- return Color.BLUE;
- case 3:
- return Color.MAGENTA;
- case 4:
- return Color.YELLOW;
- case 5:
- return Color.CYAN;
- }
- return Color.WHITE;
- }
-
- private static final Map<Integer, Color> villageColorCache = new HashMap<>();
-
- public static Color getColor(int villageId) {
- return villageColorCache.computeIfAbsent(villageId, k -> getNextColor());
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.common;
-
-import com.irtimaled.bbor.common.models.Coords;
-
-import java.util.Set;
-
-public class VillageHelper {
- public static boolean shouldSpawnIronGolems(int population, int doorCount) {
- return population >= 10 && doorCount >= 21;
- }
-
- public static int computeHash(Coords center, Integer radius, boolean spawnsIronGolems, Set<Coords> doors) {
- int result = (center.hashCode() * 31) + radius;
- for (Coords door : doors) {
- result = (31 * result) + door.hashCode();
- }
- if (spawnsIronGolems) {
- result = 31 * result;
- }
- return result;
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.common;
-
-import com.irtimaled.bbor.common.events.VillageRemoved;
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
-import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.village.Village;
-import net.minecraft.village.VillageCollection;
-import net.minecraft.village.VillageDoorInfo;
-import net.minecraft.world.WorldServer;
-
-import java.util.*;
-
-class VillageProcessor {
- private final BoundingBoxCache boundingBoxCache;
-
- private Map<Integer, BoundingBoxVillage> villageCache = new HashMap<>();
- private final int dimensionId;
-
- VillageProcessor(int dimensionId, BoundingBoxCache boundingBoxCache) {
- this.dimensionId = dimensionId;
- this.boundingBoxCache = boundingBoxCache;
- }
-
- void process(WorldServer world) {
- Map<Integer, BoundingBoxVillage> oldVillages = new HashMap<>(villageCache);
- Map<Integer, BoundingBoxVillage> newVillages = new HashMap<>();
- VillageCollection villageCollection = world.getVillageCollection();
- for (Village village : villageCollection.getVillageList()) {
- int villageId = village.hashCode();
- BoundingBoxVillage newVillage = oldVillages.get(villageId);
- if (areEquivalent(village, newVillage)) {
- oldVillages.remove(villageId);
- } else {
- newVillage = buildBoundingBox(village);
- boundingBoxCache.addBoundingBox(newVillage);
- }
- newVillages.put(villageId, newVillage);
- }
- for (BoundingBoxVillage village : oldVillages.values()) {
- boundingBoxCache.removeBoundingBox(village);
- EventBus.publish(new VillageRemoved(dimensionId, village));
- }
- villageCache = newVillages;
- }
-
- private static Set<Coords> getDoorsFromVillage(Village village) {
- Set<Coords> doors = new HashSet<>();
- List<VillageDoorInfo> doorInfoList = village.getVillageDoorInfoList();
- for (VillageDoorInfo doorInfo : doorInfoList) {
- doors.add(new Coords(doorInfo.getDoorBlockPos()));
- }
- return doors;
- }
-
- private boolean areEquivalent(Village village, BoundingBoxVillage newVillage) {
- if (newVillage == null) return false;
- Coords center = new Coords(village.getCenter());
- int radius = village.getVillageRadius();
- boolean spawnsIronGolems = VillageHelper.shouldSpawnIronGolems(village.getNumVillagers(), village.getNumVillageDoors());
- Set<Coords> doors = getDoorsFromVillage(village);
- int villageHash = VillageHelper.computeHash(center, radius, spawnsIronGolems, doors);
- return newVillage.getVillageHash() == villageHash;
- }
-
- private BoundingBoxVillage buildBoundingBox(Village village) {
- Coords center = new Coords(village.getCenter());
- int radius = village.getVillageRadius();
- Set<Coords> doors = getDoorsFromVillage(village);
- return BoundingBoxVillage.from(center, radius, village.hashCode(), village.getNumVillagers(), doors);
- }
-
- void clear() {
- villageCache.clear();
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.common.events;
-
-import net.minecraft.world.WorldServer;
-
-public class ServerWorldTick {
- private final int dimensionId;
- private final WorldServer world;
-
- public ServerWorldTick(WorldServer world) {
- this.world = world;
- this.dimensionId = world.getDimension().getType().getId();
- }
-
- public WorldServer getWorld() {
- return world;
- }
-
- public int getDimensionId() {
- return dimensionId;
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.common.events;
-
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
-
-public class VillageRemoved {
- private final int dimensionId;
- private final BoundingBoxVillage village;
-
- public VillageRemoved(int dimensionId, BoundingBoxVillage village) {
- this.dimensionId = dimensionId;
- this.village = village;
- }
-
- public int getDimensionId() {
- return dimensionId;
- }
-
- public BoundingBoxVillage getVillage() {
- return village;
- }
-}
package com.irtimaled.bbor.common.events;
-import net.minecraft.world.WorldServer;
+import net.minecraft.world.ServerWorld;
import net.minecraft.world.storage.WorldInfo;
public class WorldLoaded {
private final int spawnX;
private final int spawnZ;
- public WorldLoaded(WorldServer world) {
+ public WorldLoaded(ServerWorld world) {
WorldInfo info = world.getWorldInfo();
this.dimensionId = world.getDimension().getType().getId();
this.seed = info.getSeed();
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.events.*;
import com.irtimaled.bbor.common.models.ServerPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.network.NetHandlerPlayServer;
+import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.NetworkManager;
-import net.minecraft.world.WorldServer;
+import net.minecraft.network.play.ServerPlayNetHandler;
+import net.minecraft.world.ServerWorld;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.feature.structure.StructureStart;
if(structures.size() > 0) EventBus.publish(new StructuresLoaded(structures, dimensionId));
}
- public static void loadWorlds(Collection<WorldServer> worlds) {
- for (WorldServer world : worlds) {
+ public static void loadWorlds(Collection<ServerWorld> worlds) {
+ for (ServerWorld world : worlds) {
loadWorld(world);
}
}
- public static void loadWorld(WorldServer world) {
+ public static void loadWorld(ServerWorld world) {
EventBus.publish(new WorldLoaded(world));
}
EventBus.publish(new ServerTick());
}
- public static void worldTick(WorldServer worldServer) {
- EventBus.publish(new ServerWorldTick(worldServer));
- }
-
- public static void playerLoggedIn(EntityPlayerMP player) {
- NetHandlerPlayServer connection = player.connection;
+ public static void playerLoggedIn(ServerPlayerEntity player) {
+ ServerPlayNetHandler connection = player.connection;
if (connection == null) return;
NetworkManager networkManager = connection.netManager;
EventBus.publish(new PlayerLoggedIn(new ServerPlayer(player)));
}
- public static void playerLoggedOut(EntityPlayerMP player) {
+ public static void playerLoggedOut(ServerPlayerEntity player) {
EventBus.publish(new PlayerLoggedOut(player.getEntityId()));
}
- public static void playerSubscribed(EntityPlayerMP player) {
+ public static void playerSubscribed(ServerPlayerEntity player) {
EventBus.publish(new PlayerSubscribed(player.getEntityId(), new ServerPlayer(player)));
}
}
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
import com.irtimaled.bbor.common.models.Coords;
-import java.awt.*;
-import java.util.HashSet;
-import java.util.Set;
-
class BoundingBoxDeserializer {
static AbstractBoundingBox deserialize(PayloadReader reader) {
if (!reader.isReadable(2)) return null;
char type = reader.readChar();
- switch (type) {
- case 'V':
- return deserializeVillage(reader);
- case 'S':
- return deserializeStructure(reader);
- }
- return null;
+ return type == 'S' ? deserializeStructure(reader) : null;
}
private static AbstractBoundingBox deserializeStructure(PayloadReader reader) {
Coords maxCoords = reader.readCoords();
return BoundingBoxCuboid.from(minCoords, maxCoords, type);
}
-
- private static AbstractBoundingBox deserializeVillage(PayloadReader reader) {
- Coords center = reader.readCoords();
- int radius = reader.readVarInt();
- boolean spawnsIronGolems = reader.readBoolean();
- Color color = new Color(reader.readVarInt());
- Set<Coords> doors = new HashSet<>();
- while (reader.isReadable()) {
- doors.add(reader.readCoords());
- }
- return BoundingBoxVillage.from(center, radius, color, spawnsIronGolems, doors);
- }
}
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
-import com.irtimaled.bbor.common.models.Coords;
import java.util.HashMap;
import java.util.Map;
private static final Map<Class, BiConsumer<AbstractBoundingBox, PayloadBuilder>> serializers = new HashMap<>();
static {
- serializers.put(BoundingBoxVillage.class, (bb, pb) -> serializeVillage((BoundingBoxVillage) bb, pb));
serializers.put(BoundingBoxCuboid.class, (bb, pb) -> serializeStructure((BoundingBoxCuboid)bb, pb));
}
serializer.accept(boundingBox, builder);
}
- private static void serializeVillage(BoundingBoxVillage boundingBox, PayloadBuilder builder) {
- builder.writeChar('V')
- .writeCoords(boundingBox.getCenter())
- .writeVarInt((int)boundingBox.getRadius())
- .writeBoolean(boundingBox.getSpawnsIronGolems())
- .writeVarInt(boundingBox.getColor().getRGB());
- for (Coords door : boundingBox.getDoors()) {
- builder.writeCoords(door);
- }
- }
-
private static void serializeStructure(BoundingBoxCuboid boundingBox, PayloadBuilder builder) {
builder.writeChar('S')
.writeInt(boundingBox.getType().hashCode())
import com.irtimaled.bbor.common.models.Coords;
import io.netty.buffer.Unpooled;
-import net.minecraft.network.Packet;
+import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.client.CPacketCustomPayload;
-import net.minecraft.network.play.server.SPacketCustomPayload;
+import net.minecraft.network.play.client.CCustomPayloadPacket;
+import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.util.ResourceLocation;
import java.util.HashMap;
private static final Map<String, ResourceLocation> packetNames = new HashMap<>();
static PayloadBuilder clientBound(String name) {
- return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), SPacketCustomPayload::new);
+ return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), SCustomPayloadPlayPacket::new);
}
static PayloadBuilder serverBound(String name) {
- return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), CPacketCustomPayload::new);
+ return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), CCustomPayloadPacket::new);
}
private final ResourceLocation name;
- private final BiFunction<ResourceLocation, PacketBuffer, Packet<?>> packetBuilder;
+ private final BiFunction<ResourceLocation, PacketBuffer, IPacket<?>> packetBuilder;
private final PacketBuffer buffer;
- private PayloadBuilder(ResourceLocation name, BiFunction<ResourceLocation, PacketBuffer, Packet<?>> packetBuilder) {
+ private PayloadBuilder(ResourceLocation name, BiFunction<ResourceLocation, PacketBuffer, IPacket<?>> packetBuilder) {
this.name = name;
this.buffer = new PacketBuffer(Unpooled.buffer());
this.packetBuilder = packetBuilder;
}
- private Packet<?> packet;
+ private IPacket<?> packet;
- public Packet<?> build() {
+ public IPacket<?> build() {
if (packet == null)
packet = packetBuilder.apply(name, buffer);
return packet;
return this;
}
- PayloadBuilder writeBoolean(boolean value) {
- buffer.writeBoolean(value);
- packet = null;
- return this;
- }
-
PayloadBuilder writeCoords(Coords coords) {
return writeVarInt(coords.getX())
.writeVarInt(coords.getY())
return buffer.readChar();
}
- boolean readBoolean() {
- return buffer.readBoolean();
- }
-
Coords readCoords() {
int x = readVarInt();
int y = readVarInt();
+++ /dev/null
-package com.irtimaled.bbor.common.messages;
-
-import com.irtimaled.bbor.client.events.RemoveBoundingBoxReceived;
-import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-
-public class RemoveBoundingBox {
- public static final String NAME = "bbor:remove_bounding_box";
-
- public static PayloadBuilder getPayload(int dimensionId, AbstractBoundingBox key) {
- if (!BoundingBoxSerializer.canSerialize(key)) return null;
-
- PayloadBuilder builder = PayloadBuilder.clientBound(NAME)
- .writeVarInt(dimensionId);
- BoundingBoxSerializer.serialize(key, builder);
- return builder;
- }
-
- public static RemoveBoundingBoxReceived getEvent(PayloadReader reader) {
- int dimensionId = reader.readVarInt();
- AbstractBoundingBox key = BoundingBoxDeserializer.deserialize(reader);
- if (key == null) return null;
-
- return new RemoveBoundingBoxReceived(dimensionId, key);
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.common.models;
-
-import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.common.TypeHelper;
-import com.irtimaled.bbor.common.VillageColorCache;
-import com.irtimaled.bbor.common.VillageHelper;
-
-import java.awt.*;
-import java.util.Set;
-
-public class BoundingBoxVillage extends BoundingBoxSphere {
- private final boolean spawnsIronGolems;
- private final Color color;
- private final Coords center;
- private final Set<Coords> doors;
- private final int villageHash;
-
- private BoundingBoxVillage(Point point, Integer radius, Color color, boolean spawnsIronGolems, Set<Coords> doors) {
- super(point, radius, BoundingBoxType.VillageSpheres);
- this.center = point.getCoords();
- this.color = color;
- this.spawnsIronGolems = spawnsIronGolems;
- this.doors = doors;
- this.villageHash = VillageHelper.computeHash(this.center, radius, spawnsIronGolems, doors);
- }
-
- public static BoundingBoxVillage from(Coords center, Integer radius, Color color, boolean spawnsIronGolems, Set<Coords> doors) {
- Point point = calculateCenterPoint(center, doors);
- return new BoundingBoxVillage(point, radius, color, spawnsIronGolems, doors);
- }
-
- public static BoundingBoxVillage from(Coords center, Integer radius, int villageId, int population, Set<Coords> doors) {
- boolean spawnsIronGolems = VillageHelper.shouldSpawnIronGolems(population, doors.size());
- Color color = VillageColorCache.getColor(villageId);
- return from(center, radius, color, spawnsIronGolems, doors);
- }
-
- private static Point calculateCenterPoint(Coords center, Set<Coords> doors) {
- boolean processedFirstDoor = false;
- int minX = 0;
- int maxX = 0;
- int minZ = 0;
- int maxZ = 0;
- for (Coords door : doors) {
- if (!processedFirstDoor ||
- (minX > door.getX()))
- minX = door.getX();
- if (!processedFirstDoor ||
- maxX < door.getX())
- maxX = door.getX();
- if (!processedFirstDoor ||
- minZ > door.getZ())
- minZ = door.getZ();
- if (!processedFirstDoor ||
- maxZ < door.getZ())
- maxZ = door.getZ();
-
- processedFirstDoor = true;
- }
-
- double x = Math.abs(maxX - minX) % 2 == 0 ? 0.5 : (minX < 0 ? 0 : 1);
- double z = Math.abs(maxZ - minZ) % 2 == 0 ? 0.5 : (minZ < 0 ? 0 : 1);
- return new Point(center).offset(x, 0.0D, z);
- }
-
- public Color getColor() {
- return color;
- }
-
- @Override
- public int hashCode() {
- return TypeHelper.combineHashCodes(super.hashCode(), villageHash);
- }
-
- public boolean getSpawnsIronGolems() {
- return spawnsIronGolems;
- }
-
- public Set<Coords> getDoors() {
- return doors;
- }
-
- public int getVillageHash() {
- return villageHash;
- }
-
- public Coords getCenter() {
- return center;
- }
-}
package com.irtimaled.bbor.common.models;
import com.irtimaled.bbor.common.messages.PayloadBuilder;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.network.Packet;
+import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.network.IPacket;
import java.util.function.Consumer;
public class ServerPlayer {
private final int dimensionId;
- private final Consumer<Packet<?>> packetConsumer;
+ private final Consumer<IPacket<?>> packetConsumer;
- public ServerPlayer(EntityPlayerMP player) {
+ public ServerPlayer(ServerPlayerEntity player) {
this.dimensionId = player.dimension.getId();
this.packetConsumer = player.connection::sendPacket;
}
MixinBootstrap.init();
Mixins.addConfiguration("mixins.bbor.json");
MixinEnvironment.getDefaultEnvironment().setSide(isClient() ? MixinEnvironment.Side.CLIENT : MixinEnvironment.Side.SERVER);
-
}
protected abstract boolean isClient();
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.main.GameConfiguration;
-import net.minecraft.client.resources.ResourcePackInfoClient;
+import net.minecraft.client.resources.ClientResourcePackInfo;
import net.minecraft.resources.ResourcePackList;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(Minecraft.class)
public class MixinMinecraft {
- @Shadow @Final private ResourcePackList<ResourcePackInfoClient> resourcePackRepository;
+ @Shadow @Final private ResourcePackList<ClientResourcePackInfo> resourcePackRepository;
private ClientProxy clientProxy;
@Inject(method = "<init>", at = @At("RETURN"))
package com.irtimaled.bbor.mixin.client.entity;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.entity.player.ClientPlayerEntity;
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(EntityPlayerSP.class)
+@Mixin(ClientPlayerEntity.class)
public abstract class MixinEntityPlayerSP {
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void sendChatMessage(String message, CallbackInfo ci) {
import com.irtimaled.bbor.client.gui.ListScreen;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiChat;
+import net.minecraft.client.gui.screen.ChatScreen;
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(GuiChat.class)
+@Mixin(ChatScreen.class)
public class MixinGuiChat {
- @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V", shift = At.Shift.BEFORE), cancellable = true)
+ @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)
private void keyPressed(CallbackInfoReturnable<Boolean> cir) {
if (Minecraft.getInstance().currentScreen instanceof ListScreen) {
cir.setReturnValue(true);
package com.irtimaled.bbor.mixin.client.gui;
import com.irtimaled.bbor.client.gui.SettingsScreenButton;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.gui.GuiOptions;
-import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.screen.OptionsScreen;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.widget.Widget;
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(GuiOptions.class)
-public class MixinGuiOptions extends GuiScreen {
- @Inject(method = "initGui", at = @At("RETURN"))
+@Mixin(OptionsScreen.class)
+public class MixinGuiOptions extends Screen {
+ private MixinGuiOptions() {
+ super(null);
+ }
+
+ @Inject(method = "init", at = @At("RETURN"))
private void initGui(CallbackInfo ci) {
//shuffle middle buttons up by 12 px to make space
int top = this.height / 6 + 42;
int bottom = this.height / 6 + 168;
- for (GuiButton button : buttons) {
+
+ for (Widget button : buttons) {
if (button.y >= top && button.y < bottom)
button.y -= 12;
}
package com.irtimaled.bbor.mixin.client.multiplayer;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.client.world.ClientWorld;
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(WorldClient.class)
+@Mixin(ClientWorld.class)
public class MixinWorldClient {
@Inject(method = "sendQuittingDisconnectingPacket", at = @At("RETURN"))
private void sendQuittingDisconnectingPacket(CallbackInfo ci) {
package com.irtimaled.bbor.mixin.client.network;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.NetHandlerLoginClient;
+import net.minecraft.client.network.login.ClientLoginNetHandler;
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(NetHandlerLoginClient.class)
+@Mixin(ClientLoginNetHandler.class)
public abstract class MixinNetHandlerLoginClient {
@Inject(method = "onDisconnect", at = @At("HEAD"))
private void onDisconnect(CallbackInfo ci) {
package com.irtimaled.bbor.mixin.client.network;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.network.NetHandlerPlayClient;
-import net.minecraft.network.play.server.SPacketChunkData;
+import net.minecraft.client.network.play.ClientPlayNetHandler;
+import net.minecraft.network.play.server.SChunkDataPacket;
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(NetHandlerPlayClient.class)
+@Mixin(ClientPlayNetHandler.class)
public class MixinNetHandlerPlayClient {
@Inject(method = "onDisconnect", at = @At("HEAD"))
private void onDisconnect(CallbackInfo ci) {
}
@Inject(method="handleChunkData", at = @At("RETURN"))
- private void onChunkData(SPacketChunkData packet, CallbackInfo ci) {
+ private void onChunkData(SChunkDataPacket packet, CallbackInfo ci) {
ClientInterop.receivedChunk(packet.getChunkX(), packet.getChunkZ());
}
}
@Final
private Minecraft mc;
- @Inject(method = "updateCameraAndRender(FJ)V", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", args = "ldc=hand", shift = At.Shift.BEFORE))
+ @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))
private void render(float partialTicks, long ignored, CallbackInfo ci) {
ClientInterop.render(partialTicks, this.mc.player);
}
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import org.apache.commons.lang3.ArrayUtils;
+import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@Mixin(GameSettings.class)
public abstract class MixinGameSettings {
+ @Mutable
+ @Final
@Shadow
public KeyBinding[] keyBindings;
@Shadow
public abstract void loadOptions();
- @Inject(method = "<init>(Lnet/minecraft/client/Minecraft;Ljava/io/File;)V", at = @At("RETURN"))
+ @Inject(method = "<init>", at = @At("RETURN"))
private void init(Minecraft minecraft, File file, CallbackInfo ci) {
ClientProxy.registerKeyBindings();
keyBindings = ArrayUtils.addAll(keyBindings, KeyListener.keyBindings());
this.loadOptions();
}
+
}
import com.irtimaled.bbor.common.interop.CommonInterop;
import com.irtimaled.bbor.common.messages.SubscribeToServer;
-import net.minecraft.network.NetHandlerPlayServer;
-import net.minecraft.network.play.INetHandlerPlayServer;
-import net.minecraft.network.play.client.CPacketCustomPayload;
+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 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(CPacketCustomPayload.class)
+@Mixin(CCustomPayloadPacket.class)
public class MixinCPacketCustomPayload {
@Shadow
private ResourceLocation channel;
- @Redirect(method = "processPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/INetHandlerPlayServer;processCustomPayload(Lnet/minecraft/network/play/client/CPacketCustomPayload;)V"))
- private void processPacket(INetHandlerPlayServer netHandlerPlayServer, CPacketCustomPayload packet) {
+ @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) {
if (this.channel.toString().equals(SubscribeToServer.NAME)) {
- CommonInterop.playerSubscribed(((NetHandlerPlayServer) netHandlerPlayServer).player);
+ CommonInterop.playerSubscribed(((ServerPlayNetHandler) netHandlerPlayServer).player);
} else {
netHandlerPlayServer.processCustomPayload(packet);
}
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.network.play.server.SPacketChat;
+import net.minecraft.network.play.server.SChatPacket;
import net.minecraft.util.text.ITextComponent;
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(SPacketChat.class)
+@Mixin(SChatPacket.class)
public class MixinSPacketChat {
@Shadow private ITextComponent chatComponent;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.TypeHelper;
-import net.minecraft.client.network.NetHandlerPlayClient;
-import net.minecraft.network.play.INetHandlerPlayClient;
-import net.minecraft.network.play.server.SPacketCommandList;
+import net.minecraft.client.network.play.ClientPlayNetHandler;
+import net.minecraft.client.network.play.IClientPlayNetHandler;
+import net.minecraft.network.play.server.SCommandListPacket;
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(SPacketCommandList.class)
+@Mixin(SCommandListPacket.class)
public class MixinSPacketCommandList {
@Inject(method = "processPacket", at= @At("RETURN"))
- private void processPacket(INetHandlerPlayClient netHandlerPlayClient, CallbackInfo ci) {
- TypeHelper.doIfType(netHandlerPlayClient, NetHandlerPlayClient.class, handler ->
+ private void processPacket(IClientPlayNetHandler netHandlerPlayClient, CallbackInfo ci) {
+ TypeHelper.doIfType(netHandlerPlayClient, ClientPlayNetHandler.class, handler ->
ClientInterop.registerClientCommands(handler.func_195515_i()));
}
}
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.messages.*;
-import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.client.network.play.ClientPlayNetHandler;
+import net.minecraft.client.network.play.IClientPlayNetHandler;
import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.INetHandlerPlayClient;
-import net.minecraft.network.play.server.SPacketCustomPayload;
+import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.util.ResourceLocation;
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(SPacketCustomPayload.class)
+@Mixin(SCustomPayloadPlayPacket.class)
public abstract class MixinSPacketCustomPayload {
@Shadow
private ResourceLocation channel;
- @Redirect(method = "processPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/INetHandlerPlayClient;handleCustomPayload(Lnet/minecraft/network/play/server/SPacketCustomPayload;)V"))
- private void processPacket(INetHandlerPlayClient netHandlerPlayClient, SPacketCustomPayload packet) {
+ @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) {
String channelName = channel.toString();
if (channelName.startsWith("bbor:")) {
PacketBuffer data = null;
switch (channelName) {
case InitializeClient.NAME: {
EventBus.publish(InitializeClient.getEvent(reader));
- ((NetHandlerPlayClient) netHandlerPlayClient).sendPacket(SubscribeToServer.getPayload().build());
+ ((ClientPlayNetHandler) netHandlerPlayClient).sendPacket(SubscribeToServer.getPayload().build());
break;
}
case AddBoundingBox.NAME: {
EventBus.publish(AddBoundingBox.getEvent(reader));
break;
}
- case RemoveBoundingBox.NAME: {
- EventBus.publish(RemoveBoundingBox.getEvent(reader));
- break;
- }
}
} finally {
if (data != null)
package com.irtimaled.bbor.mixin.network.play.server;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.network.play.server.SPacketSpawnPosition;
+import net.minecraft.network.play.server.SSpawnPositionPacket;
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(SPacketSpawnPosition.class)
+@Mixin(SSpawnPositionPacket.class)
public abstract class MixinSPacketSpawnPosition {
@Shadow
private BlockPos spawnBlockPos;
import com.irtimaled.bbor.common.interop.CommonInterop;
import net.minecraft.server.MinecraftServer;
-import net.minecraft.world.WorldServer;
+import net.minecraft.world.ServerWorld;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
public class MixinMinecraftServer {
@Shadow
@Final
- private Map<DimensionType, WorldServer> worlds;
+ private Map<DimensionType, ServerWorld> worlds;
- @Inject(method = "initialWorldChunkLoad", at = @At("HEAD"))
+ @Inject(method = "func_213186_a", at = @At("HEAD"))
private void initialWorldChunkLoad(CallbackInfo ci) {
CommonInterop.loadWorlds(worlds.values());
}
package com.irtimaled.bbor.mixin.server.management;
import com.irtimaled.bbor.common.interop.CommonInterop;
-import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.network.NetworkManager;
import net.minecraft.server.management.PlayerList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(PlayerList.class)
public class MixinPlayerList {
- @Inject(method = "playerLoggedIn", at = @At("RETURN"))
- private void playerLoggedIn(EntityPlayerMP player, CallbackInfo ci) {
+ @Inject(method = "initializeConnectionToPlayer", at = @At("RETURN"))
+ private void playerLoggedIn(NetworkManager networkManager, ServerPlayerEntity player, CallbackInfo ci) {
CommonInterop.playerLoggedIn(player);
}
@Inject(method = "playerLoggedOut", at = @At("HEAD"))
- private void playerLoggedOut(EntityPlayerMP player, CallbackInfo ci) {
+ private void playerLoggedOut(ServerPlayerEntity player, CallbackInfo ci) {
CommonInterop.playerLoggedOut(player);
}
}
+++ /dev/null
-package com.irtimaled.bbor.mixin.world;
-
-import com.irtimaled.bbor.common.interop.CommonInterop;
-import net.minecraft.world.WorldServer;
-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(WorldServer.class)
-public class MixinWorldServer {
- @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/village/VillageCollection;tick()V", shift = At.Shift.AFTER))
- private void afterVillageTick(CallbackInfo ci) {
- CommonInterop.worldTick((WorldServer) (Object) this);
- }
-}
@Mixin(Chunk.class)
public class MixinChunk {
- @Inject(method = "onLoad", at = @At("RETURN"))
+ @Inject(method = "func_217318_w", at = @At("RETURN"))
private void onLoad(CallbackInfo ci) {
CommonInterop.chunkLoaded((Chunk) (Object) this);
}
private static final ThrowableConsumer<URL> addURL;
static {
+ 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 {
"network.play.client.MixinCPacketCustomPayload",
"server.MixinMinecraftServer",
"server.management.MixinPlayerList",
- "world.MixinWorldServer",
"world.chunk.MixinChunk"
],
"client": [