Skip to content

Commit

Permalink
Fixes #23
Browse files Browse the repository at this point in the history
Also fix when no structures loaded on the server the client can't render anything
  • Loading branch information
irtimaled committed Dec 14, 2016
1 parent 4fa3ec2 commit 9fe7db8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 4 additions & 1 deletion java/com/irtimaled/bbor/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ public void render(float partialTicks) {

if (this.active) {
DimensionType dimensionType = entityPlayer.worldObj.provider.getDimensionType();
Map<BoundingBox, Set<BoundingBox>> boundingBoxes = null;
if (boundingBoxCacheMap.containsKey(dimensionType)) {
renderBoundingBoxes(boundingBoxCacheMap.get(dimensionType).getBoundingBoxes());
boundingBoxes = boundingBoxCacheMap.get(dimensionType).getBoundingBoxes();
}
renderBoundingBoxes(boundingBoxes);
}
}

Expand Down Expand Up @@ -276,6 +278,7 @@ private void renderBoundingBoxes(Map<BoundingBox, Set<BoundingBox>> map) {
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
}

if(map != null)
for (BoundingBox bb : map.keySet()) {
if (outerBoxOnly) {
renderBoundingBoxSet(map.get(bb));
Expand Down
20 changes: 10 additions & 10 deletions java/com/irtimaled/bbor/forge/ForgeCommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

public class ForgeCommonProxy implements IEventHandler {

public Map<EntityPlayerMP, Integer> playerDimensions = new ConcurrentHashMap<EntityPlayerMP, Integer>();
public Map<EntityPlayerMP, DimensionType> playerDimensions = new ConcurrentHashMap<EntityPlayerMP, DimensionType>();
private Map<EntityPlayerMP, Set<BoundingBox>> playerBoundingBoxesCache = new HashMap<EntityPlayerMP, Set<BoundingBox>>();

protected CommonProxy getProxy() {
Expand Down Expand Up @@ -60,10 +60,10 @@ public void chunkEvent(ChunkEvent.Load event) {
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent evt) {
if (playerDimensions.containsKey(evt.player)) {
EntityPlayerMP player = (EntityPlayerMP) evt.player;
int dimension = player.dimension;
playerDimensions.put(player, dimension);
DimensionType dimensionType = DimensionType.getById(player.dimension);
playerDimensions.put(player, dimensionType);

sendToPlayer(player, getProxy().boundingBoxCacheMap.get(dimension));
sendToPlayer(player, getProxy().boundingBoxCacheMap.get(dimensionType));
}
}

Expand All @@ -77,9 +77,9 @@ public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent evt) {
isRemotePlayer(evt.player)) {
EntityPlayerMP player = (EntityPlayerMP) evt.player;
initializeClient(player);
int dimension = player.dimension;
playerDimensions.put(player, dimension);
sendToPlayer(player, getProxy().boundingBoxCacheMap.get(dimension));
DimensionType dimensionType = DimensionType.getById(player.dimension);
playerDimensions.put(player, dimensionType);
sendToPlayer(player, getProxy().boundingBoxCacheMap.get(dimensionType));
}
}

Expand All @@ -98,9 +98,9 @@ public void tickEvent(TickEvent event) {
if(!mc.getPlayerList().getPlayerList().contains(player)) {
playerDimensions.remove(player);
} else {
int dimension = playerDimensions.get(player);
if (getProxy().boundingBoxCacheMap.containsKey(dimension)) {
sendToPlayer(player, getProxy().boundingBoxCacheMap.get(dimension));
DimensionType dimensionType = playerDimensions.get(player);
if (getProxy().boundingBoxCacheMap.containsKey(dimensionType)) {
sendToPlayer(player, getProxy().boundingBoxCacheMap.get(dimensionType));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions java/com/irtimaled/bbor/forge/ForgeMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ForgeMod {

public static final String MODID = "bbor";
public static final String NAME = "Bounding Box Outline Reloaded";
public static final String VERSION = "1.0.0-beta12";
public static final String VERSION = "1.0.0-beta13";
public static final String MCVERSION = "[1.10]";

private ConfigManager configManager;
Expand All @@ -35,7 +35,6 @@ public void preInit(FMLPreInitializationEvent evt) {
@Mod.EventHandler
public void load(FMLInitializationEvent evt) {
MinecraftForge.EVENT_BUS.register(proxy);
FMLCommonHandler.instance().bus().register(proxy);

proxy.init(configManager);
}
Expand Down

0 comments on commit 9fe7db8

Please sign in to comment.