Skip to content

Commit

Permalink
Setup tweaker for 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
irtimaled committed Jan 31, 2019
1 parent 94f5b34 commit 099161f
Show file tree
Hide file tree
Showing 58 changed files with 451 additions and 1,141 deletions.
46 changes: 0 additions & 46 deletions java/com/irtimaled/bbor/ReflectionHelper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BoundingBoxOutlineReloaded {
private static ClientProxy proxy;

public static void init() {
ConfigManager.loadConfig(new File(Minecraft.getMinecraft().mcDataDir, "config"));
ConfigManager.loadConfig(new File(Minecraft.getInstance().gameDir, "config"));
proxy = new ClientProxy();
proxy.init();
}
Expand Down
4 changes: 2 additions & 2 deletions java/com/irtimaled/bbor/client/ClientBoundingBoxProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.DimensionType;
import net.minecraft.world.dimension.DimensionType;

import java.awt.*;
import java.util.HashSet;
Expand Down Expand Up @@ -64,7 +64,7 @@ private Set<BoundingBox> getClientBoundingBoxes(DimensionType dimensionType) {
}

private Set<BoundingBoxSlimeChunk> getSlimeChunks() {
Minecraft minecraft = Minecraft.getMinecraft();
Minecraft minecraft = Minecraft.getInstance();
int renderDistanceChunks = minecraft.gameSettings.renderDistanceChunks;
int playerChunkX = MathHelper.floor(minecraft.player.posX / 16.0D);
int playerChunkZ = MathHelper.floor(minecraft.player.posZ / 16.0D);
Expand Down
11 changes: 5 additions & 6 deletions java/com/irtimaled/bbor/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.NetworkManager;
import net.minecraft.world.DimensionType;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.ArrayUtils;
import org.lwjgl.input.Keyboard;

import java.net.InetSocketAddress;
import java.net.SocketAddress;
Expand All @@ -36,16 +35,16 @@ public void keyPressed() {
@Override
public void init() {
String category = "Bounding Box Outline Reloaded";
activeHotKey = new KeyBinding("Toggle On/Off", Keyboard.KEY_B, category);
outerBoxOnlyHotKey = new KeyBinding("Toggle Display Outer Box Only", Keyboard.KEY_O, category);
Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.addAll(Minecraft.getMinecraft().gameSettings.keyBindings, activeHotKey, outerBoxOnlyHotKey);
activeHotKey = new KeyBinding("Toggle On/Off", 0x42, category);
outerBoxOnlyHotKey = new KeyBinding("Toggle Display Outer Box Only", 0x4f, category);
Minecraft.getInstance().gameSettings.keyBindings = ArrayUtils.addAll(Minecraft.getInstance().gameSettings.keyBindings, activeHotKey, outerBoxOnlyHotKey);
ClientDimensionCache clientDimensionCache = new ClientDimensionCache();
renderer = new ClientRenderer(clientDimensionCache);
dimensionCache = clientDimensionCache;
}

public void render(float partialTicks) {
EntityPlayer entityPlayer = Minecraft.getMinecraft().player;
EntityPlayer entityPlayer = Minecraft.getInstance().player;
PlayerData.setPlayerPosition(partialTicks, entityPlayer);

if (this.active) {
Expand Down
4 changes: 2 additions & 2 deletions java/com/irtimaled/bbor/client/ClientRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.irtimaled.bbor.common.models.*;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.client.Minecraft;
import net.minecraft.world.DimensionType;
import net.minecraft.world.dimension.DimensionType;
import org.lwjgl.opengl.GL11;

import java.util.HashMap;
Expand All @@ -24,7 +24,7 @@ public class ClientRenderer {
}

public void render(DimensionType dimensionType, Boolean outerBoxesOnly) {
Set<BoundingBox> boundingBoxes = clientBoundingBoxProvider.getBoundingBoxes(dimensionType, outerBoxesOnly, Minecraft.getMinecraft().world);
Set<BoundingBox> boundingBoxes = clientBoundingBoxProvider.getBoundingBoxes(dimensionType, outerBoxesOnly, Minecraft.getInstance().world);
if (boundingBoxes == null || boundingBoxes.size() == 0)
return;

Expand Down
6 changes: 3 additions & 3 deletions java/com/irtimaled/bbor/client/NBTFileParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.dimension.DimensionType;

import java.awt.*;
import java.io.File;
Expand Down Expand Up @@ -180,8 +180,8 @@ private static NBTTagCompound loadNbtFile(File file) {

private static NBTTagCompound[] getChildCompoundTags(NBTTagCompound parent, String key) {
NBTTagList tagList = parent.getTagList(key, 10);
NBTTagCompound[] result = new NBTTagCompound[tagList.tagCount()];
for (int index = 0; index < tagList.tagCount(); index++) {
NBTTagCompound[] result = new NBTTagCompound[tagList.size()];
for (int index = 0; index < tagList.size(); index++) {
result[index] = tagList.getCompoundTagAt(index);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.irtimaled.bbor.client.renderers;

import com.irtimaled.bbor.common.models.BoundingBoxSlimeChunk;
import com.irtimaled.bbor.client.PlayerData;
import com.irtimaled.bbor.common.models.BoundingBoxSlimeChunk;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.util.math.AxisAlignedBB;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.irtimaled.bbor.client.renderers;

import com.irtimaled.bbor.common.models.BoundingBoxVillage;
import com.irtimaled.bbor.client.PlayerData;
import com.irtimaled.bbor.common.models.BoundingBoxVillage;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.irtimaled.bbor.client.renderers;

import com.irtimaled.bbor.common.models.BoundingBoxWorldSpawn;
import com.irtimaled.bbor.client.PlayerData;
import com.irtimaled.bbor.common.models.BoundingBoxWorldSpawn;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.util.math.AxisAlignedBB;

Expand Down
14 changes: 6 additions & 8 deletions java/com/irtimaled/bbor/common/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.irtimaled.bbor.common;


import com.irtimaled.bbor.Logger;
import com.irtimaled.bbor.ReflectionHelper;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraft.world.gen.IChunkGenerator;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -22,11 +21,10 @@ public class CommonProxy {
public void worldLoaded(World world) {
IChunkProvider chunkProvider = world.getChunkProvider();
if (chunkProvider instanceof ChunkProviderServer) {
IChunkGenerator chunkGenerator = ReflectionHelper.getPrivateValue(ChunkProviderServer.class, (ChunkProviderServer) chunkProvider, IChunkGenerator.class);
dimensionCache.setWorldData(world.getSeed(), world.getWorldInfo().getSpawnX(), world.getWorldInfo().getSpawnZ());
DimensionType dimensionType = world.provider.getDimensionType();
Logger.info("create world dimension: %s, %s (chunkprovider: %s) (seed: %d)", dimensionType, world.getClass().toString(), chunkGenerator.getClass().toString(), world.getSeed());
DimensionProcessor boundingBoxCache = new DimensionProcessor(dimensionType, chunkGenerator);
DimensionType dimensionType = world.dimension.getType();
Logger.info("create world dimension: %s, %s (seed: %d)", dimensionType, world.getClass().toString(), world.getSeed());
DimensionProcessor boundingBoxCache = new DimensionProcessor(dimensionType, (ChunkProviderServer)chunkProvider);
dimensionCache.put(dimensionType, boundingBoxCache);
if (ConfigManager.drawVillages.getBoolean()) {
villageProcessors.add(new VillageProcessor(world, dimensionType, eventHandler, boundingBoxCache));
Expand All @@ -35,7 +33,7 @@ public void worldLoaded(World world) {
}

public void chunkLoaded(Chunk chunk) {
DimensionType dimensionType = chunk.getWorld().provider.getDimensionType();
DimensionType dimensionType = chunk.getWorld().dimension.getType();
dimensionCache.refresh(dimensionType);
}

Expand Down
2 changes: 1 addition & 1 deletion java/com/irtimaled/bbor/common/DimensionCache.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.irtimaled.bbor.common;

import com.irtimaled.bbor.common.models.WorldData;
import net.minecraft.world.DimensionType;
import net.minecraft.world.dimension.DimensionType;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down
128 changes: 49 additions & 79 deletions java/com/irtimaled/bbor/common/DimensionProcessor.java
Original file line number Diff line number Diff line change
@@ -1,122 +1,92 @@
package com.irtimaled.bbor.common;

import com.irtimaled.bbor.Logger;
import com.irtimaled.bbor.ReflectionHelper;
import com.irtimaled.bbor.common.models.BoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxStructure;
import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.gen.ChunkGeneratorEnd;
import net.minecraft.world.gen.ChunkGeneratorHell;
import net.minecraft.world.gen.ChunkGeneratorOverworld;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.structure.*;
import com.irtimaled.bbor.config.Setting;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraft.world.gen.feature.structure.StructurePiece;
import net.minecraft.world.gen.feature.structure.StructureStart;

import java.awt.*;
import java.util.*;

public class DimensionProcessor extends BoundingBoxCache {
DimensionProcessor(DimensionType dimensionType, IChunkGenerator chunkGenerator) {
DimensionProcessor(DimensionType dimensionType, ChunkProviderServer chunkProvider) {
this.dimensionType = dimensionType;
this.chunkGenerator = chunkGenerator;
this.chunkProvider = chunkProvider;
}

private DimensionType dimensionType;
private IChunkGenerator chunkGenerator;
private ChunkProviderServer chunkProvider;

private boolean closed = false;

@Override
public void close() {
closed = true;
chunkGenerator = null;
super.close();
}

private static <T extends IChunkGenerator, R extends MapGenStructure> Collection<StructureStart> getStructures(T chunkGenerator, Class<R> generatorClass) {
Class<T> chunkGeneratorClass = (Class<T>) chunkGenerator.getClass();
R structureGenerator = ReflectionHelper.getPrivateValue(chunkGeneratorClass, chunkGenerator, generatorClass);
if (structureGenerator != null) {
Map<ChunkPos, StructureStart> structureMap = ReflectionHelper.getPrivateValue(MapGenStructure.class, structureGenerator, Map.class);
return structureMap.values();
}
return Collections.emptyList();
}

private Map<StructureType, Collection<StructureStart>> getStructures() {
Map<StructureType, Collection<StructureStart>> structureMap = new HashMap<>();
if (chunkGenerator instanceof ChunkGeneratorOverworld) {
if (ConfigManager.drawDesertTemples.getBoolean()) {
structureMap.put(StructureType.DesertTemple, getStructuresWithComponent(getStructures(chunkGenerator, MapGenScatteredFeature.class), ComponentScatteredFeaturePieces.DesertPyramid.class));
}
private void addStructures(Setting drawStructure, StructureType structureType, Map<String, Collection<StructureStart>> structureMap) {
if (!drawStructure.getBoolean()) return;

if (ConfigManager.drawJungleTemples.getBoolean()) {
structureMap.put(StructureType.JungleTemple, getStructuresWithComponent(getStructures(chunkGenerator, MapGenScatteredFeature.class), ComponentScatteredFeaturePieces.JunglePyramid.class));
}
Collection<StructureStart> structureStarts = structureMap.get(structureType.getName());
if (structureStarts == null || structureStarts.size() == 0) return;
Color color = structureType.getColor();
for (StructureStart structureStart : structureStarts) {

if (ConfigManager.drawWitchHuts.getBoolean()) {
structureMap.put(StructureType.WitchHut, getStructuresWithComponent(getStructures(chunkGenerator, MapGenScatteredFeature.class), ComponentScatteredFeaturePieces.SwampHut.class));
}
MutableBoundingBox bb = structureStart.getBoundingBox();
if(bb == null)
continue;

if (ConfigManager.drawOceanMonuments.getBoolean()) {
structureMap.put(StructureType.OceanMonument, getStructures(chunkGenerator, StructureOceanMonument.class));
}
BoundingBox boundingBox = BoundingBoxStructure.from(bb, color);
if (isCached(boundingBox)) continue;

if (ConfigManager.drawStrongholds.getBoolean()) {
structureMap.put(StructureType.Stronghold, getStructures(chunkGenerator, MapGenStronghold.class));
}

if (ConfigManager.drawMansions.getBoolean()) {
structureMap.put(StructureType.Mansion, getStructures(chunkGenerator, WoodlandMansion.class));
}

if (ConfigManager.drawMineShafts.getBoolean()) {
structureMap.put(StructureType.MineShaft, getStructures(chunkGenerator, MapGenMineshaft.class));
}
} else if (chunkGenerator instanceof ChunkGeneratorHell) {
if (ConfigManager.drawNetherFortresses.getBoolean()) {
structureMap.put(StructureType.NetherFortress, getStructures(chunkGenerator, MapGenNetherBridge.class));
}
} else if (chunkGenerator instanceof ChunkGeneratorEnd) {
if (ConfigManager.drawEndCities.getBoolean()) {
structureMap.put(StructureType.EndCity, getStructures(chunkGenerator, MapGenEndCity.class));
Set<BoundingBox> structureBoundingBoxes = new HashSet<>();
for (StructurePiece structureComponent : structureStart.getComponents()) {
structureBoundingBoxes.add(BoundingBoxStructure.from(structureComponent.getBoundingBox(), color));
}
addBoundingBoxes(boundingBox, structureBoundingBoxes);
Logger.info("[%s] new dimensionCache entries: %d", dimensionType, structureBoundingBoxes.size());
}

return structureMap;
}

private Collection<StructureStart> getStructuresWithComponent(Collection<StructureStart> structures, Class structureComponent) {
Collection<StructureStart> validStructures = new HashSet<>();
for (StructureStart structure : structures) {
if (structure.getComponents().get(0).getClass().equals(structureComponent)) {
validStructures.add(structure);
private Map<String, Collection<StructureStart>> getStructureMap(ChunkProviderServer chunkProvider) {
Map<String, Collection<StructureStart>> map = new HashMap<>();
for (Chunk chunk : chunkProvider.getLoadedChunks()) {
Map<String, StructureStart> structureStarts = chunk.getStructureStarts();
for (String key : structureStarts.keySet()) {
map.computeIfAbsent(key, s -> new HashSet<>())
.add(structureStarts.get(key));
}
}
return validStructures;
return map;
}

@Override
public synchronized void refresh() {
if (closed) return;

Map<StructureType, Collection<StructureStart>> structureMap = getStructures();
for (StructureType structureType : structureMap.keySet()) {
Color color = structureType.getColor();
for (StructureStart structureStart : structureMap.get(structureType)) {
if (structureStart.getBoundingBox() != null) {
BoundingBox boundingBox = BoundingBoxStructure.from(structureStart.getBoundingBox(), color);
if (!isCached(boundingBox)) {
Set<BoundingBox> structureBoundingBoxes = new HashSet<>();
for (StructureComponent structureComponent : structureStart.getComponents()) {
structureBoundingBoxes.add(BoundingBoxStructure.from(structureComponent.getBoundingBox(), color));
}
addBoundingBoxes(boundingBox, structureBoundingBoxes);
Logger.info("[%s] new dimensionCache entries: %d", dimensionType, structureBoundingBoxes.size());
}
}
}
Map<String, Collection<StructureStart>> structureMap = getStructureMap(chunkProvider);
if (structureMap.size() > 0) {
addStructures(ConfigManager.drawDesertTemples, StructureType.DesertTemple, structureMap);
addStructures(ConfigManager.drawJungleTemples, StructureType.JungleTemple, structureMap);
addStructures(ConfigManager.drawWitchHuts, StructureType.WitchHut, structureMap);
addStructures(ConfigManager.drawOceanMonuments, StructureType.OceanMonument, structureMap);
addStructures(ConfigManager.drawStrongholds, StructureType.Stronghold, structureMap);
addStructures(ConfigManager.drawMansions, StructureType.Mansion, structureMap);
addStructures(ConfigManager.drawMineShafts, StructureType.MineShaft, structureMap);
addStructures(ConfigManager.drawShipwrecks, StructureType.Shipwreck, structureMap);
addStructures(ConfigManager.drawOceanRuins, StructureType.OceanRuin, structureMap);
addStructures(ConfigManager.drawBuriedTreasure, StructureType.BuriedTreasure, structureMap);
addStructures(ConfigManager.drawIgloos, StructureType.Igloo, structureMap);
addStructures(ConfigManager.drawNetherFortresses, StructureType.NetherFortress, structureMap);
addStructures(ConfigManager.drawEndCities, StructureType.EndCity, structureMap);
}
}
}
Loading

0 comments on commit 099161f

Please sign in to comment.