name=bbor
buildVersion=1.0.13
# leave a space to reduce merge conflicts on version change
-mcVersion=1.13.2
+mcVersion=1.14
ServerRunner.run("@MC_VERSION@", Arrays.asList(args).subList(1, args.length));
} else {
Installer.install("@VERSION@", "@MC_VERSION@");
-
}
}
}
--- /dev/null
+package com.irtimaled.bbor.client;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.math.Vec3d;
+
+public class CameraCoords {
+ private static Vec3d getCameraPos() {
+ return Minecraft.getInstance().gameRenderer.func_215316_n().func_216785_c();
+ }
+
+ public static double getX() {
+ return getCameraPos().x;
+ }
+
+ public static double getY() {
+ return getCameraPos().y;
+ }
+
+ public static double getZ() {
+ return getCameraPos().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;
import com.irtimaled.bbor.config.ConfigManager;
import com.irtimaled.bbor.config.Setting;
active = false;
if (ConfigManager.keepCacheBetweenSessions.get()) return;
ready = false;
- VillageColorCache.clear();
clearCaches();
renderer.clear();
}
ClientRenderer(GetCache getCache) {
this.getCache = getCache;
- boundingBoxRendererMap.put(BoundingBoxVillage.class, new VillageRenderer());
boundingBoxRendererMap.put(BoundingBoxSlimeChunk.class, new SlimeChunkRenderer());
boundingBoxRendererMap.put(BoundingBoxWorldSpawn.class, new WorldSpawnRenderer());
boundingBoxRendererMap.put(BoundingBoxStructure.class, new StructureRenderer());
package com.irtimaled.bbor.client;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
public class PlayerCoords {
private static double x;
private static double z;
private static double activeY;
- public static void setPlayerPosition(double partialTicks, EntityPlayer entityPlayer) {
+ public static void setPlayerPosition(double partialTicks, PlayerEntity entityPlayer) {
x = entityPlayer.lastTickPosX + (entityPlayer.posX - entityPlayer.lastTickPosX) * partialTicks;
y = entityPlayer.lastTickPosY + (entityPlayer.posY - entityPlayer.lastTickPosY) * partialTicks;
z = entityPlayer.lastTickPosZ + (entityPlayer.posZ - entityPlayer.lastTickPosZ) * partialTicks;
package com.irtimaled.bbor.client.gui;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.widget.Widget;
-abstract class AbstractButton extends GuiButton implements IRenderableControl {
- AbstractButton(int id, int x, int y, int width, String name) {
- super(id, x, y, width, 20, name);
+abstract class AbstractButton extends Widget implements IRenderableControl {
+ AbstractButton(int x, int y, int width, String name) {
+ super(x, y, width, 20, name);
}
- AbstractButton(int id, int x, int y, int width, String name, boolean enabled) {
- this(id, x, y, width, name);
- this.enabled = enabled;
+ AbstractButton(int x, int y, int width, String name, boolean enabled) {
+ this(x, y, width, name);
+ this.active = enabled;
}
@Override
}
@Override
- protected void renderBg(Minecraft p_renderBg_1_, int p_renderBg_2_, int p_renderBg_3_) {
+ protected void renderBg(Minecraft minecraft, int mouseX, int mouseY) {
renderBackground();
}
}
@Override
- protected int getHoverState(boolean p_getHoverState_1_) {
+ protected int getYImage(boolean hovered) {
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 net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL11;
-abstract class AbstractSlider extends GuiButton implements IRenderableControl {
+abstract class AbstractSlider extends Widget implements IRenderableControl {
double progress;
- AbstractSlider(int id, int x, int y, int width) {
- super(id, x, y, width, 20, "");
+ AbstractSlider(int x, int y, int width) {
+ super(x, y, width, 20, "");
}
@Override
@Override
protected void renderBg(Minecraft minecraft, int mouseX, int mouseY) {
- minecraft.getTextureManager().bindTexture(BUTTON_TEXTURES);
+ minecraft.getTextureManager().bindTexture(WIDGETS_LOCATION);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.drawTexturedModalRect(this.x + (int) (this.progress * (double) (this.width - 8)), this.y, 0, 66, 4, 20);
- this.drawTexturedModalRect(this.x + (int) (this.progress * (double) (this.width - 8)) + 4, this.y, 196, 66, 4, 20);
+ this.blit(this.x + (int) (this.progress * (double) (this.width - 8)), this.y, 0, 66, 4, 20);
+ this.blit(this.x + (int) (this.progress * (double) (this.width - 8)) + 4, this.y, 196, 66, 4, 20);
}
boolean setProgress(double progress) {
}
@Override
- protected int getHoverState(boolean hovered) {
+ protected int getYImage(boolean hovered) {
return 0;
}
public class BoolSettingButton extends AbstractButton {
private final Setting<Boolean> setting;
- BoolSettingButton(int id, int x, int y, int width, String label, Setting<Boolean> setting) {
- super(id, x, y, width, label);
+ BoolSettingButton(int x, int y, int width, String label, Setting<Boolean> setting) {
+ super(x, y, width, label);
this.setting = setting;
}
@Override
protected int getState() {
- return enabled ? setting.get() ? 2 : 1 : 0;
+ return active ? setting.get() ? 2 : 1 : 0;
}
@Override
public class BoundingBoxTypeButton extends BoolSettingButton {
private final Color color;
- BoundingBoxTypeButton(int id, int x, int y, int width, String label, BoundingBoxType type) {
- super(id, x, y, width, label, type.shouldRenderSetting);
+ BoundingBoxTypeButton(int x, int y, int width, String label, BoundingBoxType type) {
+ super(x, y, width, label, type.shouldRenderSetting);
color = type.getColor();
}
public BoundingBoxTypeButton(int id, int x, int y, int width, String label, BoundingBoxType type, boolean enabled) {
- this(id, x, y, width, label, type);
- this.enabled = enabled;
+ this(x, y, width, label, type);
+ this.active = enabled;
}
@Override
protected void renderBackground() {
- if (!enabled) return;
+ if (!active) return;
int left = x + 1;
int top = y + 1;
}
private 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());
}
}
@FunctionalInterface
interface CreateControl {
- IControl create(Integer id, Integer x, Integer y, Integer width);
+ IControl create(Integer x, Integer y, Integer width);
}
final int minValue;
final int range;
- IntSettingSlider(int id, int x, int y, int width, int minValue, int maxValue, String prefix, Setting<Integer> setting) {
- super(id, x, y, width);
+ IntSettingSlider(int x, int y, int width, int minValue, int maxValue, String prefix, Setting<Integer> setting) {
+ super(x, y, width);
this.setting = setting;
this.minValue = minValue;
this.prefix = prefix;
@Override
protected void updateText() {
- this.displayString = this.getDisplayValue();
+ this.setMessage(this.getDisplayValue());
}
@Override
class MaxYSettingSlider extends IntSettingSlider {
private final int actualMinValue;
- MaxYSettingSlider(int id, int x, int y, int width, int minValue, Setting<Integer> setting) {
- super(id, x, y, width, minValue - 2, 127, "Max Y", setting);
+ MaxYSettingSlider(int x, int y, int width, int minValue, Setting<Integer> setting) {
+ super(x, y, width, minValue - 2, 127, "Max Y", setting);
this.actualMinValue = minValue;
this.setProgress(getSliderValue());
this.addDisplayValue(-1, "Activated");
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.TypeHelper;
import com.irtimaled.bbor.config.ConfigManager;
+import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.IGuiEventListener;
-import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.util.text.StringTextComponent;
import org.lwjgl.opengl.GL11;
import java.util.HashSet;
import java.util.Set;
-public class SettingsScreen extends GuiScreen {
+public class SettingsScreen extends Screen {
private static final int CONTROLS_WIDTH = 310;
- private final GuiScreen lastScreen;
+ private final Screen lastScreen;
private final int tabIndex;
- private String title;
private Set<IRenderableControl> controls = new HashSet<>();
- SettingsScreen(GuiScreen lastScreen, int tabIndex) {
+ SettingsScreen(Screen lastScreen, int tabIndex) {
+ super(new StringTextComponent(ClientProxy.Name));
this.lastScreen = lastScreen;
this.tabIndex = tabIndex;
}
for (String label : labels) {
final int index = column;
addControl(0, column, y, CONTROLS_WIDTH / columns,
- (id, x, y1, width) -> new AbstractButton(id, x, y, width, label, index != tabIndex) {
+ (x, y1, width) -> new AbstractButton(x, y, width, label, index != tabIndex) {
@Override
public void onPressed() {
Minecraft.getInstance().displayGuiScreen(new SettingsScreen(lastScreen, index));
}
//done button
- addControl(new AbstractButton(200, this.width / 2 - 100, getY(5.5), 200, "Done") {
+ addControl(new AbstractButton(this.width / 2 - 100, getY(5.5), 200, "Done") {
@Override
public void onPressed() {
ConfigManager.saveConfig();
- mc.displayGuiScreen(lastScreen);
+ minecraft.displayGuiScreen(lastScreen);
}
});
}
private IControl addControl(int offset, int column, int y, int width, CreateControl createControl) {
int x = getX(width, column, offset);
- int id = controls.size();
- IControl control = createControl.create(id, x, y, width);
+ IControl control = createControl.create(x, y, width);
TypeHelper.doIfType(control, IRenderableControl.class, this::addControl);
return control;
}
}
@Override
- protected void initGui() {
- this.title = ClientProxy.Name;
-
+ protected void init() {
this.controls = new HashSet<>();
- this.addTabs("General", "Structures", "Villages");
+ this.addTabs("General", "Structures");
buildTab(0,
- (id, x, y, width) -> new AbstractButton(id, x, y, width, "Active", this.mc.world != null) {
+ (x, y, width) -> new AbstractButton(x, y, width, "Active", this.minecraft.world != null) {
@Override
public void onPressed() {
ClientProxy.toggleActive();
@Override
protected int getState() {
- return enabled ? ClientProxy.active ? 2 : 1 : 0;
+ return active ? ClientProxy.active ? 2 : 1 : 0;
}
},
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Outer Box Only", ConfigManager.outerBoxesOnly),
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Fill", ConfigManager.fill),
+ (x, y, width) -> new BoolSettingButton(x, y, width, "Outer Box Only", ConfigManager.outerBoxesOnly),
+ (x, y, width) -> new BoolSettingButton(x, y, width, "Fill", ConfigManager.fill),
- (id, x, y, width) -> (IRowHeight) () -> 0.5,
+ (x, y, width) -> (IRowHeight) () -> 0.5,
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Spawn Chunks", BoundingBoxType.WorldSpawn),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Lazy Chunks", BoundingBoxType.LazySpawnChunks),
- (id, x, y, width) -> new MaxYSettingSlider(id, x, y, width, 39, ConfigManager.worldSpawnMaxY),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Spawn Chunks", BoundingBoxType.WorldSpawn),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Lazy Chunks", BoundingBoxType.LazySpawnChunks),
+ (x, y, width) -> new MaxYSettingSlider(x, y, width, 39, ConfigManager.worldSpawnMaxY),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Slime Chunks", BoundingBoxType.SlimeChunks),
- (id, x, y, width) -> new MaxYSettingSlider(id, x, y, width, 39, ConfigManager.slimeChunkMaxY),
- (id, x, y, width) -> (IRowHeight) () -> 0,
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Slime Chunks", BoundingBoxType.SlimeChunks),
+ (x, y, width) -> new MaxYSettingSlider(x, y, width, 39, ConfigManager.slimeChunkMaxY),
+ (x, y, width) -> (IRowHeight) () -> 0,
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Mob Spawners", BoundingBoxType.MobSpawner),
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Spawn Area", ConfigManager.renderMobSpawnerSpawnArea),
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Activation Lines", ConfigManager.renderMobSpawnerActivationLines));
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Mob Spawners", BoundingBoxType.MobSpawner),
+ (x, y, width) -> new BoolSettingButton(x, y, width, "Spawn Area", ConfigManager.renderMobSpawnerSpawnArea),
+ (x, y, width) -> new BoolSettingButton(x, y, width, "Activation Lines", ConfigManager.renderMobSpawnerActivationLines));
buildTab(1,
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Desert Temples", BoundingBoxType.DesertTemple),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Jungle Temples", BoundingBoxType.JungleTemple),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Witch Huts", BoundingBoxType.WitchHut),
-
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Mansions", BoundingBoxType.Mansion),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Monuments", BoundingBoxType.OceanMonument),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Igloos", BoundingBoxType.Igloo),
-
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Ocean Ruins", BoundingBoxType.OceanRuin),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Buried Treasure", BoundingBoxType.BuriedTreasure),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Shipwrecks", BoundingBoxType.Shipwreck),
-
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Pillager Outposts", BoundingBoxType.PillagerOutpost, false),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Strongholds", BoundingBoxType.Stronghold),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Mineshafts", BoundingBoxType.MineShaft),
-
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Fortresses", BoundingBoxType.NetherFortress),
- (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "End Cities", BoundingBoxType.EndCity));
- buildTab(2,
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Villages", ConfigManager.drawVillages),
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Door Lines", ConfigManager.drawVillageDoors),
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Golem Spawn", ConfigManager.drawIronGolemSpawnArea),
-
- (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Render Sphere", ConfigManager.renderVillageAsSphere),
- (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 5, "Dot Size", ConfigManager.villageSphereDotSize),
- (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 5, "Density", ConfigManager.villageSphereDensity)
- .addDisplayValue(1, "Fewest")
- .addDisplayValue(2, "Fewer")
- .addDisplayValue(3, "Normal")
- .addDisplayValue(4, "More")
- .addDisplayValue(5, "Most"));
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Desert Temples", BoundingBoxType.DesertTemple),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Jungle Temples", BoundingBoxType.JungleTemple),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Witch Huts", BoundingBoxType.WitchHut),
+
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Mansions", BoundingBoxType.Mansion),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Monuments", BoundingBoxType.OceanMonument),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Igloos", BoundingBoxType.Igloo),
+
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Ocean Ruins", BoundingBoxType.OceanRuin),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Buried Treasure", BoundingBoxType.BuriedTreasure),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Shipwrecks", BoundingBoxType.Shipwreck),
+
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Pillager Outposts", BoundingBoxType.PillagerOutpost),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Strongholds", BoundingBoxType.Stronghold),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Mineshafts", BoundingBoxType.MineShaft),
+
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "Fortresses", BoundingBoxType.NetherFortress),
+ (x, y, width) -> new BoundingBoxTypeButton(x, y, width, "End Cities", BoundingBoxType.EndCity));
}
private void drawScreen(int top, int bottom) {
- this.mc.getTextureManager().bindTexture(Gui.OPTIONS_BACKGROUND);
+ this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_DEPTH_TEST);
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(7425);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(7424);
GL11.glEnable(GL11.GL_ALPHA_TEST);
- 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_BLEND);
}
@Override
public void render(int mouseX, int mouseY, float unknown) {
- if (this.mc.world == null) {
- this.drawDefaultBackground();
+ if (this.minecraft.world == null) {
+ this.renderBackground();
this.drawScreen(getY(-1), getY(5.5) - 4);
}
- this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 15, 16777215);
+ this.drawCenteredString(this.font, title.getUnformattedComponentText(), this.width / 2, 15, 16777215);
for (IRenderableControl control : controls) {
control.render(mouseX, mouseY);
}
package com.irtimaled.bbor.client.gui;
import net.minecraft.client.Minecraft;
-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 id, int x, int y, int width, String label, GuiScreen lastScreen) {
- super(id, x, y, width, label);
+ public SettingsScreenButton(int x, int y, int width, String label, Screen lastScreen) {
+ super(x, y, width, label);
screen = new SettingsScreen(lastScreen, 0);
}
import com.irtimaled.bbor.client.events.SeedCommandTyped;
import com.irtimaled.bbor.client.events.UpdateWorldSpawnReceived;
import com.irtimaled.bbor.common.EventBus;
-import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.util.math.BlockPos;
public class ClientInterop {
EventBus.publish(new DisconnectedFromRemoteServer());
}
- public static void render(float partialTicks, EntityPlayerSP player) {
+ public static void render(float partialTicks, ClientPlayerEntity player) {
PlayerCoords.setPlayerPosition(partialTicks, player);
EventBus.publish(new Render(player.dimension.getId()));
}
}
private static void onKeyEvent(long windowHandle, int keyCode, int scanCode, int action, int modifiers) {
- if (windowHandle == mainWindowHandle && minecraft.currentScreen == null && keyCode != -1 && !InputMappings.isKeyDown(292)) {
+ if (windowHandle == mainWindowHandle && minecraft.currentScreen == null && keyCode != -1 && !InputMappings.func_216506_a(mainWindowHandle, 292)) {
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
for (Key key : keys) {
if (key.getInput() == input) {
package com.irtimaled.bbor.client.renderers;
-import com.irtimaled.bbor.client.PlayerCoords;
import com.irtimaled.bbor.common.models.BoundingBoxMobSpawner;
import com.irtimaled.bbor.common.models.Colors;
import com.irtimaled.bbor.common.models.Coords;
}
private void renderActivationLine(OffsetPoint centerPoint) {
- OffsetPoint playerPos = new OffsetPoint(PlayerCoords.getX(), PlayerCoords.getY(), PlayerCoords.getZ());
- double distance = centerPoint.getDistance(playerPos);
+ OffsetPoint camera = OffsetPoint.Camera();
+ double distance = centerPoint.getDistance(camera);
if (distance <= 20) {
Color color = distance > 18 ? Color.RED : distance > 16 ? Colors.DARK_ORANGE : Color.GREEN;
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
- Renderer.startLines().setColor(color).addPoint(centerPoint).addPoint(playerPos.offset(0, 0.1, 0)).render();
+ Renderer.startLines().setColor(color).addPoint(centerPoint).addPoint(camera.offset(0, -1, 0)).render();
}
}
}
package com.irtimaled.bbor.client.renderers;
-import com.irtimaled.bbor.client.PlayerCoords;
+import com.irtimaled.bbor.client.CameraCoords;
import com.irtimaled.bbor.common.models.Coords;
class OffsetPoint {
this.z = Coords.getZ();
}
+ static OffsetPoint Camera() {
+ return new OffsetPoint(CameraCoords.getX(), CameraCoords.getY(), CameraCoords.getZ());
+ }
+
double getX() {
- return x - PlayerCoords.getX();
+ return x - CameraCoords.getX();
}
double getY() {
- return y - PlayerCoords.getY();
+ return y - CameraCoords.getY();
}
double getZ() {
- return z - PlayerCoords.getZ();
+ return z - CameraCoords.getZ();
}
OffsetPoint offset(double x, double y, double z) {
+++ /dev/null
-package com.irtimaled.bbor.client.renderers;
-
-import com.irtimaled.bbor.common.models.BoundingBoxVillage;
-import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-import java.util.HashSet;
-import java.util.Set;
-
-public class VillageRenderer extends AbstractRenderer<BoundingBoxVillage> {
- @Override
- public void render(BoundingBoxVillage boundingBox) {
- if (ConfigManager.renderVillageAsSphere.get()) {
- renderBoundingBoxVillageAsSphere(boundingBox);
- } else {
- renderBoundingBox(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.getCenter())
- .offset(boundingBox.getCenterOffsetX(), 0.0, boundingBox.getCenterOffsetZ());
- OffsetBox bb = new OffsetBox(offsetCenter, offsetCenter)
- .grow(8, 3, 8);
-
- renderUnfilledCuboid(bb, boundingBox.getColor());
- }
-
- private void renderVillageDoors(BoundingBoxVillage boundingBox) {
- OffsetPoint center = new OffsetPoint(boundingBox.getCenter())
- .offset(boundingBox.getCenterOffsetX(), 0.0, boundingBox.getCenterOffsetZ());
- 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) {
- OffsetPoint center = new OffsetPoint(boundingBox.getCenter())
- .offset(boundingBox.getCenterOffsetX(), 0.0, boundingBox.getCenterOffsetZ());
- int radius = boundingBox.getRadius();
- Color color = boundingBox.getColor();
- int density = ConfigManager.villageSphereDensity.get();
- int dotSize = ConfigManager.villageSphereDotSize.get();
-
- GL11.glEnable(GL11.GL_POINT_SMOOTH);
- GL11.glPointSize(dotSize);
- Renderer renderer = Renderer.startPoints()
- .setColor(color);
- buildPoints(center, (double) radius, density)
- .forEach(renderer::addPoint);
- renderer.render();
- }
-
- private Set<OffsetPoint> buildPoints(OffsetPoint center, double radius, int density) {
- int segments = 24 + (density * 8);
-
- Set<OffsetPoint> points = new HashSet<>(segments * segments);
- double tau = 6.283185307179586D;
- double pi = tau / 2D;
-
- double thetaSegment = pi / (double) segments;
- double phiSegment = tau / (double) segments;
-
- for (double phi = 0.0D; phi < tau; phi += phiSegment) {
- for (double theta = 0.0D; theta < pi; theta += thetaSegment) {
- double dx = radius * Math.sin(phi) * Math.cos(theta);
- double dz = radius * Math.sin(phi) * Math.sin(theta);
- double dy = radius * Math.cos(phi);
-
- points.add(center.offset(dx, dy, dz));
- }
- }
- return points;
- }
-}
public final static BoundingBoxType LazySpawnChunks = register(Color.RED, "Lazy_Chunks", ConfigManager.drawLazySpawnChunks);
public final static BoundingBoxType MobSpawner = register(Color.GREEN, "Mob_Spawner", ConfigManager.drawMobSpawners);
public final static BoundingBoxType SlimeChunks = register(Colors.DARK_GREEN, "Slime_Chunks", ConfigManager.drawSlimeChunks);
- public final static BoundingBoxType Village = register(null, "Village", ConfigManager.drawVillages);
private static BoundingBoxType register(Color color, String name, Setting<Boolean> shouldRenderSetting) {
return structureTypeMap.computeIfAbsent(name.hashCode(), k -> new BoundingBoxType(color, name, shouldRenderSetting));
public class CommonProxy {
private Map<Integer, ServerPlayer> players = new ConcurrentHashMap<>();
private Map<Integer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
- private Map<Integer, VillageProcessor> villageProcessors = new HashMap<>();
private Map<Integer, AbstractChunkProcessor> chunkProcessors = 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) {
}
Logger.info("create world dimension: %s (seed: %d)", dimensionId, seed);
chunkProcessors.put(dimensionId, chunkProcessor);
- villageProcessors.put(dimensionId, new VillageProcessor(dimensionId, boundingBoxCache));
}
private void chunkLoaded(ChunkLoaded event) {
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;
}
}
- private void serverWorldTick(ServerWorldTick event) {
- VillageProcessor villageProcessor = villageProcessors.get(event.getDimensionId());
- if (villageProcessor == null) return;
-
- 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();
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 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 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();
- }
-}
import com.irtimaled.bbor.common.models.BoundingBoxMobSpawner;
import com.irtimaled.bbor.common.models.BoundingBoxStructure;
import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.tileentity.MobSpawnerTileEntity;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.feature.structure.StructurePiece;
private void addMobSpawners(Chunk chunk) {
Collection<TileEntity> tileEntities = chunk.getTileEntityMap().values();
for (TileEntity tileEntity : tileEntities) {
- TileEntityMobSpawner spawner = TypeHelper.as(tileEntity, TileEntityMobSpawner.class);
+ MobSpawnerTileEntity spawner = TypeHelper.as(tileEntity, MobSpawnerTileEntity.class);
if (spawner != null) {
Coords coords = new Coords(spawner.getPos());
boundingBoxCache.addBoundingBox(BoundingBoxMobSpawner.from(coords));
+++ /dev/null
-package com.irtimaled.bbor.common.events;
-
-import net.minecraft.world.WorldServer;
-
-public class ServerWorldTick {
- private final int dimensionId;
- private 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.models.ServerPlayer;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.block.Block;
-import net.minecraft.block.BlockMobSpawner;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.network.NetHandlerPlayServer;
+import net.minecraft.block.SpawnerBlock;
+import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.NetworkManager;
+import net.minecraft.network.play.ServerPlayNetHandler;
import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.ServerWorld;
import net.minecraft.world.World;
-import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import java.io.File;
EventBus.publish(new ChunkLoaded(chunk));
}
- 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)));
}
public static void tryHarvestBlock(Block block, BlockPos pos, World world) {
- if (block instanceof BlockMobSpawner) {
+ if (block instanceof SpawnerBlock) {
EventBus.publish(new MobSpawnerBroken(world.dimension.getType().getId(), new Coords(pos)));
}
}
package com.irtimaled.bbor.common.messages;
import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.common.models.*;
-
-import java.awt.*;
-import java.util.HashSet;
-import java.util.Set;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.common.models.BoundingBoxMobSpawner;
+import com.irtimaled.bbor.common.models.BoundingBoxStructure;
+import com.irtimaled.bbor.common.models.Coords;
class BoundingBoxDeserializer {
static AbstractBoundingBox deserialize(PayloadReader reader) {
char type = reader.readChar();
switch (type) {
- case 'V':
- return deserializeVillage(reader);
case 'S':
return deserializeStructure(reader);
case 'M':
return BoundingBoxStructure.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);
- }
-
private static AbstractBoundingBox deserializeMobSpawner(PayloadReader reader) {
return BoundingBoxMobSpawner.from(reader.readCoords());
}
package com.irtimaled.bbor.common.messages;
-import com.irtimaled.bbor.common.models.*;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.common.models.BoundingBoxMobSpawner;
+import com.irtimaled.bbor.common.models.BoundingBoxStructure;
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(BoundingBoxStructure.class, (bb, pb) -> serializeStructure((BoundingBoxStructure) bb, pb));
serializers.put(BoundingBoxMobSpawner.class, (bb, pb) -> serializeMobSpawner((BoundingBoxMobSpawner) bb, pb));
}
serializer.accept(boundingBox, builder);
}
- private static void serializeVillage(BoundingBoxVillage boundingBox, PayloadBuilder builder) {
- builder.writeChar('V')
- .writeCoords(boundingBox.getCenter())
- .writeVarInt(boundingBox.getRadius())
- .writeBoolean(boundingBox.getSpawnsIronGolems())
- .writeVarInt(boundingBox.getColor().getRGB());
- for (Coords door : boundingBox.getDoors()) {
- builder.writeCoords(door);
- }
- }
-
private static void serializeStructure(BoundingBoxStructure boundingBox, PayloadBuilder builder) {
builder.writeChar('S')
.writeInt(boundingBox.getTypeName().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 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;
+++ /dev/null
-package com.irtimaled.bbor.common.models;
-
-import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.common.VillageColorCache;
-import com.irtimaled.bbor.common.VillageHelper;
-
-import java.awt.*;
-import java.util.Set;
-
-public class BoundingBoxVillage extends AbstractBoundingBox {
- private final Coords center;
- private final Integer radius;
- private final boolean spawnsIronGolems;
- private final Color color;
- private Set<Coords> doors;
- private Double centerOffsetX;
- private Double centerOffsetZ;
- private int villageHash;
-
- private BoundingBoxVillage(Coords center, Integer radius, Color color, boolean spawnsIronGolems, Set<Coords> doors, Coords minCoords, Coords maxCoords) {
- super(minCoords, maxCoords, BoundingBoxType.Village);
- this.center = center;
- this.radius = radius;
- this.color = color;
- this.spawnsIronGolems = spawnsIronGolems;
- this.doors = doors;
- this.villageHash = VillageHelper.computeHash(center, radius, spawnsIronGolems, doors);
- calculateCenterOffsets(doors);
- }
-
- public static BoundingBoxVillage from(Coords center, Integer radius, Color color, boolean spawnsIronGolems, Set<Coords> doors) {
- Coords minCoords = new Coords(center.getX() - radius,
- center.getY() - 4,
- center.getZ() - radius);
- Coords maxCoords = new Coords(center.getX() + radius,
- center.getY() + 4,
- center.getZ() + radius);
- return new BoundingBoxVillage(center, radius, color, spawnsIronGolems, doors, minCoords, maxCoords);
- }
-
- 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 void calculateCenterOffsets(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;
- }
- centerOffsetX = Math.abs(maxX - minX) % 2 == 0 ? 0.5 : (minX < 0 ? 0 : 1);
- centerOffsetZ = Math.abs(maxZ - minZ) % 2 == 0 ? 0.5 : (minZ < 0 ? 0 : 1);
- }
-
- @Override
- public String toString() {
- return "(" + center.toString() + "; " + radius.toString() + ")";
- }
-
- public Integer getRadius() {
- return radius;
- }
-
- public Coords getCenter() {
- return center;
- }
-
- public Color getColor() {
- return color;
- }
-
- public Double getCenterOffsetX() {
- return centerOffsetX;
- }
-
- public Double getCenterOffsetZ() {
- return centerOffsetZ;
- }
-
- @Override
- public int hashCode() {
- return (super.hashCode() * 31) + villageHash;
- }
-
- public boolean getSpawnsIronGolems() {
- return spawnsIronGolems;
- }
-
- public Set<Coords> getDoors() {
- return doors;
- }
-
- public int getVillageHash() {
- return villageHash;
- }
-}
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;
}
public static File configDir;
public static Setting<Boolean> fill;
- public static Setting<Boolean> drawVillages;
public static Setting<Boolean> drawDesertTemples;
public static Setting<Boolean> drawJungleTemples;
public static Setting<Boolean> drawWitchHuts;
public static Setting<Boolean> drawNetherFortresses;
public static Setting<Boolean> drawOceanMonuments;
public static Setting<Boolean> alwaysVisible;
- public static Setting<Boolean> renderVillageAsSphere;
- 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 void loadConfig(File mcConfigDir) {
configDir = new File(mcConfigDir, "config");
alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
- drawVillages = setup(config, "villages", "drawVillages", true, "If set to true village bounding boxes are drawn.");
- renderVillageAsSphere = setup(config, "villages", "renderVillageAsSphere", true, "If set to true villages will be drawn as a sphere. (default:true)");
- 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.");
-
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.");
drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
@Override
protected void addOptions(List<String> args, File gameDir, File assetsDir, String profile) {
addArg("--assetsDir", assetsDir.getPath());
+ addArg("--version", profile);
}
@Override
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
this.args = new ArrayList<>(args);
- addArg("--version", profile);
addOptions(args, gameDir, assetsDir, profile);
}
import com.irtimaled.bbor.client.ClientProxy;
import com.irtimaled.bbor.common.interop.CommonInterop;
+import net.minecraft.client.GameConfiguration;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.main.GameConfiguration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
package com.irtimaled.bbor.mixin.client.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) {
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;
}
- this.addButton(new SettingsScreenButton(199, this.width / 2 - 155, top + 84, 150, "BBOR", this));
+ this.addButton(new SettingsScreenButton(this.width / 2 - 155, top + 84, 150, "BBOR", this));
}
}
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.client.network.play.ClientPlayNetHandler;
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) {
@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;func_219895_b(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) {
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);
}
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: {
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());
}
import net.minecraft.block.Block;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.World;
+import net.minecraft.world.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(PlayerInteractionManager.class)
public class MixinPlayerInteractionManager {
@Shadow
- public World world;
+ public ServerWorld world;
@Inject(method = "tryHarvestBlock", at = @At("HEAD"))
private void tryHarvestBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
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", "https://launcher.mojang.com/v1/objects/f1a0073671057f01aa843443fef34330281333ce/server.jar");
VANILLA_SERVER_JARS.put("1.13.2", "https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar");
VANILLA_SERVER_JARS.put("1.13.1", "https://launcher.mojang.com/v1/objects/fe123682e9cb30031eae351764f653500b7396c9/server.jar");
VANILLA_SERVER_JARS.put("1.13", "https://launcher.mojang.com/v1/objects/d0caafb8438ebd206f99930cfaecfa6c9a13dca0/server.jar");
"server.MixinMinecraftServer",
"server.management.MixinPlayerInteractionManager",
"server.management.MixinPlayerList",
- "world.MixinWorldServer",
"world.chunk.MixinChunk"
],
"client": [