diff options
Diffstat (limited to 'src')
14 files changed, 110 insertions, 110 deletions
diff --git a/src/main/java/makamys/neodymium/LODMod.java b/src/main/java/makamys/neodymium/Neodymium.java index 47c948b..236d85b 100644 --- a/src/main/java/makamys/neodymium/LODMod.java +++ b/src/main/java/makamys/neodymium/Neodymium.java @@ -35,18 +35,18 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import makamys.neodymium.renderer.LODRenderer; +import makamys.neodymium.renderer.NeoRenderer; import makamys.neodymium.util.SpriteUtil; -@Mod(modid = LODMod.MODID, version = LODMod.VERSION) -public class LODMod +@Mod(modid = Neodymium.MODID, version = Neodymium.VERSION) +public class Neodymium { - public static final String MODID = "lodmod"; + public static final String MODID = "neodymium"; public static final String VERSION = "0.0"; - public static final Logger LOGGER = LogManager.getLogger("lodmod"); + public static final Logger LOGGER = LogManager.getLogger("neodymium"); - public static LODRenderer renderer; + public static NeoRenderer renderer; public static boolean enabled; public static int chunkLoadsPerTick; @@ -141,7 +141,7 @@ public class LODMod renderer = null; } if(enabled && newWorld != null) { - renderer = new LODRenderer(newWorld); + renderer = new NeoRenderer(newWorld); } } diff --git a/src/main/java/makamys/neodymium/mixin/MixinChunkCache.java b/src/main/java/makamys/neodymium/mixin/MixinChunkCache.java index b4a7368..331e3cf 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinChunkCache.java +++ b/src/main/java/makamys/neodymium/mixin/MixinChunkCache.java @@ -4,9 +4,9 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.renderer.FarChunkCache; -import makamys.neodymium.renderer.LODRenderer; +import makamys.neodymium.renderer.NeoRenderer; import net.minecraft.world.ChunkCache; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @@ -17,8 +17,8 @@ abstract class MixinChunkCache { @Redirect(method = "<init>*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunkFromChunkCoords(II)Lnet/minecraft/world/chunk/Chunk;")) private Chunk redirectGetChunkFromChunkCoords(World world, int p1, int p2) { Chunk chunk = world.getChunkFromChunkCoords(p1, p2); - if(LODMod.isActive() && FarChunkCache.class.isInstance(this.getClass()) && chunk.isEmpty()) { - Chunk myChunk = LODMod.renderer.getChunkFromChunkCoords(p1, p2); + if(Neodymium.isActive() && FarChunkCache.class.isInstance(this.getClass()) && chunk.isEmpty()) { + Chunk myChunk = Neodymium.renderer.getChunkFromChunkCoords(p1, p2); if(myChunk != null) { chunk = myChunk; } diff --git a/src/main/java/makamys/neodymium/mixin/MixinEntityRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinEntityRenderer.java index 66d95ae..6e5cf7b 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinEntityRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinEntityRenderer.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.entity.EntityLivingBase; @@ -21,15 +21,15 @@ abstract class MixinEntityRenderer { @Inject(method = "setupCameraTransform", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;farPlaneDistance:F", shift = At.Shift.AFTER, ordinal = 1)) private void onConstructed(CallbackInfo ci) { - if(LODMod.isActive()) { - farPlaneDistance *= LODMod.renderer.getFarPlaneDistanceMultiplier(); + if(Neodymium.isActive()) { + farPlaneDistance *= Neodymium.renderer.getFarPlaneDistanceMultiplier(); } } @Inject(method = "setupFog", at = @At(value = "RETURN")) private void afterSetupFog(int mode, float alpha, CallbackInfo ci) { - if(LODMod.isActive()) { - LODMod.renderer.afterSetupFog(mode, alpha, farPlaneDistance); + if(Neodymium.isActive()) { + Neodymium.renderer.afterSetupFog(mode, alpha, farPlaneDistance); } } } diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderBlocks.java b/src/main/java/makamys/neodymium/mixin/MixinRenderBlocks.java index 0f8ff41..fdfbe65 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderBlocks.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderBlocks.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.renderer.FarChunkCache; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -19,8 +19,8 @@ abstract class MixinRenderBlocks { @Redirect(method = "renderBlockLiquid", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;shouldSideBeRendered(Lnet/minecraft/world/IBlockAccess;IIII)Z")) public boolean shouldSideBeRendered(Block block, IBlockAccess ba, int x, int y, int z, int w) { - if(LODMod.isActive()) { - return LODMod.renderer.shouldSideBeRendered(block, ba, x, y, z, w); + if(Neodymium.isActive()) { + return Neodymium.renderer.shouldSideBeRendered(block, ba, x, y, z, w); } else { return block.shouldSideBeRendered(ba, x, y, z, w); } diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java index dc561a2..03b8aac 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.renderer.WorldRenderer; @@ -26,15 +26,15 @@ abstract class MixinRenderGlobal { @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderAllRenderLists(ID)V")) private void redirectRenderAllRenderLists(RenderGlobal thiz, int p1, double p2) { - if(LODMod.shouldRenderVanillaWorld()) { + if(Neodymium.shouldRenderVanillaWorld()) { thiz.renderAllRenderLists(p1, p2); } } @Inject(method = "renderSortedRenderers", at = @At(value = "HEAD")) public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable cir) { - if(LODMod.isActive()) { - LODMod.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers); + if(Neodymium.isActive()) { + Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers); } } } diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java index dad164c..d63e3ad 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderGlobal; @@ -17,7 +17,7 @@ abstract class MixinRenderGlobal_OptiFine { // for OptiFine's Fast Render option @Redirect(method = "renderSortedRenderersFast", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallLists(Ljava/nio/IntBuffer;)V"), remap=false) private void redirectRenderAllRenderLists(IntBuffer buffer) { - if(LODMod.shouldRenderVanillaWorld()) { + if(Neodymium.shouldRenderVanillaWorld()) { GL11.glCallLists(buffer); } } diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java index 47450c3..7d1ffd8 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.ducks.IWorldRenderer; import makamys.neodymium.renderer.ChunkMesh; import makamys.neodymium.renderer.FarChunkCache; import makamys.neodymium.renderer.FarWorldRenderer; -import makamys.neodymium.renderer.LODRenderer; +import makamys.neodymium.renderer.NeoRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; @@ -71,7 +71,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { private void preUpdateRenderer(CallbackInfo ci) { saveDrawnStatus(); - if(LODMod.isActive()) { + if(Neodymium.isActive()) { if(needsUpdate) { if(chunkMeshes != null) { chunkMeshes.clear(); @@ -88,9 +88,9 @@ abstract class MixinWorldRenderer implements IWorldRenderer { private void postUpdateRenderer(CallbackInfo ci) { notifyIfDrawnStatusChanged(); - if(LODMod.isActive()) { + if(Neodymium.isActive()) { if(chunkMeshes != null) { - LODMod.renderer.onWorldRendererPost(WorldRenderer.class.cast(this)); + Neodymium.renderer.onWorldRendererPost(WorldRenderer.class.cast(this)); chunkMeshes.clear(); } } @@ -98,7 +98,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Inject(method = "postRenderBlocks", at = @At(value = "HEAD")) private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) { - if(LODMod.isActive() && !LODMod.disableChunkMeshes) { + if(Neodymium.isActive() && !Neodymium.disableChunkMeshes) { if(chunkMeshes != null) { chunkMeshes.add(ChunkMesh.fromTessellator(pass, WorldRenderer.class.cast(this), Tessellator.instance)); } @@ -143,8 +143,8 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Inject(method = "setDontDraw", at = @At(value = "HEAD")) private void preSetDontDraw(CallbackInfo ci) { - if(LODMod.isActive()) { - LODMod.renderer.onWorldRendererChanged(WorldRenderer.class.cast(this), LODRenderer.WorldRendererChange.DELETED); + if(Neodymium.isActive()) { + Neodymium.renderer.onWorldRendererChanged(WorldRenderer.class.cast(this), NeoRenderer.WorldRendererChange.DELETED); } } @@ -169,8 +169,8 @@ abstract class MixinWorldRenderer implements IWorldRenderer { private void notifyIfDrawnStatusChanged() { boolean drawn = isDrawn(); - if(LODMod.isActive() && drawn != savedDrawnStatus) { - LODMod.renderer.onWorldRendererChanged(WorldRenderer.class.cast(this), drawn ? LODRenderer.WorldRendererChange.VISIBLE : LODRenderer.WorldRendererChange.INVISIBLE); + if(Neodymium.isActive() && drawn != savedDrawnStatus) { + Neodymium.renderer.onWorldRendererChanged(WorldRenderer.class.cast(this), drawn ? NeoRenderer.WorldRendererChange.VISIBLE : NeoRenderer.WorldRendererChange.INVISIBLE); } } diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java index 6c4cd59..6d5dc2d 100644 --- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java +++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java @@ -14,7 +14,7 @@ import java.util.stream.Collectors; import org.lwjgl.BufferUtils; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.MixinConfigPlugin; import makamys.neodymium.ducks.IWorldRenderer; import makamys.neodymium.util.BufferWriter; @@ -78,12 +78,12 @@ public class ChunkMesh extends Mesh { int yOffset = wr.posY; int zOffset = wr.posZ; - boolean fr = MixinConfigPlugin.isOptiFinePresent() && LODMod.ofFastRender; + boolean fr = MixinConfigPlugin.isOptiFinePresent() && Neodymium.ofFastRender; int tessellatorXOffset = fr ? xOffset : 0; int tessellatorYOffset = fr ? yOffset : 0; int tessellatorZOffset = fr ? zOffset : 0; - boolean optimize = LODMod.optimizeChunkMeshes; + boolean optimize = Neodymium.optimizeChunkMeshes; ChunkMesh.Flags flags = new ChunkMesh.Flags(t.hasTexture, t.hasBrightness, t.hasColor, t.hasNormals); diff --git a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java index 75b1f64..1bb2623 100644 --- a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java +++ b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java @@ -6,7 +6,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.renderer.Mesh.GPUStatus; import makamys.neodymium.util.GuiHelper; @@ -23,7 +23,7 @@ public class GPUMemoryManager { public GPUMemoryManager() { VBO = glGenBuffers(); - bufferSize = LODMod.VRAMSize * 1024 * 1024; + bufferSize = Neodymium.VRAMSize * 1024 * 1024; glBindBuffer(GL_ARRAY_BUFFER, VBO); @@ -109,7 +109,7 @@ public class GPUMemoryManager { if(end() + mesh.bufferSize() >= bufferSize) { System.out.println("VRAM is full! Try increasing the allocated VRAM in the config, if possible. Reverting to vanilla renderer."); - LODMod.renderer.destroyPending = true; + Neodymium.renderer.destroyPending = true; // TODO restart renderer with more VRAM allocated when this happens. return; } diff --git a/src/main/java/makamys/neodymium/renderer/LODChunk.java b/src/main/java/makamys/neodymium/renderer/NeoChunk.java index 5dd3762..1184d84 100644 --- a/src/main/java/makamys/neodymium/renderer/LODChunk.java +++ b/src/main/java/makamys/neodymium/renderer/NeoChunk.java @@ -2,14 +2,14 @@ package makamys.neodymium.renderer; import java.util.List; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagEnd; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.chunk.Chunk; -public class LODChunk { +public class NeoChunk { int x, z; public boolean needsChunk = true; @@ -23,9 +23,9 @@ public class LODChunk { public boolean[] isSectionVisible = new boolean[16]; - LODRenderer renderer = LODMod.renderer; + NeoRenderer renderer = Neodymium.renderer; - public LODChunk(int x, int z) { + public NeoChunk(int x, int z) { this.x = x; this.z = z; } @@ -70,7 +70,7 @@ public class LODChunk { } chunkMeshes[cy * 2 + i] = newChunkMesh; } - LODMod.renderer.lodChunkChanged(this); + Neodymium.renderer.lodChunkChanged(this); dirty = true; discardedMesh = false; } @@ -89,7 +89,7 @@ public class LODChunk { } simpleMeshes[i] = newSimpleMesh; } - LODMod.renderer.lodChunkChanged(this); + Neodymium.renderer.lodChunkChanged(this); } public boolean hasChunkMeshes() { @@ -103,9 +103,9 @@ public class LODChunk { public void tick(Entity player) { double distSq = distSq(player); - if(LODMod.disableSimpleMeshes || distSq < Math.pow((LODMod.renderer.renderRange / 2) * 16, 2)) { + if(Neodymium.disableSimpleMeshes || distSq < Math.pow((Neodymium.renderer.renderRange / 2) * 16, 2)) { setLOD(2); - } else if(distSq < Math.pow((LODMod.renderer.renderRange) * 16, 2)) { + } else if(distSq < Math.pow((Neodymium.renderer.renderRange) * 16, 2)) { setLOD(1); } else { setLOD(0); @@ -116,7 +116,7 @@ public class LODChunk { if(lod == this.lod) return; this.lod = lod; - LODMod.renderer.lodChunkChanged(this); + Neodymium.renderer.lodChunkChanged(this); if(!dirty) { if(lod < 2) { for(int i = 0; i < chunkMeshes.length; i++) { @@ -144,7 +144,7 @@ public class LODChunk { } } else if(oldNbt != null && discardedMesh && lod == 2) { loadChunkMeshesNBT(chunkMeshesCompound, oldStringTable); - LODMod.renderer.lodChunkChanged(this); + Neodymium.renderer.lodChunkChanged(this); } nbt.setTag("chunkMeshes", chunkMeshesCompound); dirty = false; @@ -162,11 +162,11 @@ public class LODChunk { cm.destroy(); } } - LODMod.renderer.setVisible(this, false); + Neodymium.renderer.setVisible(this, false); } public void receiveChunk(Chunk chunk) { - if(!LODMod.disableSimpleMeshes) { + if(!Neodymium.disableSimpleMeshes) { putSimpleMeshes(SimpleChunkMesh.generateSimpleMeshes(chunk)); } } diff --git a/src/main/java/makamys/neodymium/renderer/LODRegion.java b/src/main/java/makamys/neodymium/renderer/NeoRegion.java index 22316f7..c670525 100644 --- a/src/main/java/makamys/neodymium/renderer/LODRegion.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRegion.java @@ -12,7 +12,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; @@ -22,19 +22,19 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.util.Constants.NBT; -public class LODRegion { +public class NeoRegion { - private LODChunk[][] data = new LODChunk[32][32]; + private NeoChunk[][] data = new NeoChunk[32][32]; int regionX, regionZ; - public LODRegion(int regionX, int regionZ) { + public NeoRegion(int regionX, int regionZ) { this.regionX = regionX; this.regionZ = regionZ; for(int i = 0; i < 32; i++) { for(int j = 0; j < 32; j++) { - data[i][j] = new LODChunk(regionX * 32 + i, regionZ * 32 + j); + data[i][j] = new NeoChunk(regionX * 32 + i, regionZ * 32 + j); } } } @@ -51,14 +51,14 @@ public class LODRegion { for(int j = 0; j < 32; j++) { data[i][j] = new LODChunk(list.getCompoundTagAt(idx++), stringTable); if(data[i][j].hasChunkMeshes()) { - LODMod.renderer.setVisible(data[i][j], true); + Neodymium.renderer.setVisible(data[i][j], true); } } } } */ - public static LODRegion load(Path saveDir, int regionX, int regionZ) { - /*if(!(LODMod.disableChunkMeshes || !LODMod.saveMeshes)) { + public static NeoRegion load(Path saveDir, int regionX, int regionZ) { + /*if(!(.disableChunkMeshes || !.saveMeshes)) { File saveFile = getSavePath(saveDir, regionX, regionZ).toFile(); if(saveFile.exists()) { try { @@ -69,7 +69,7 @@ public class LODRegion { } } }*/ - return new LODRegion(regionX, regionZ); + return new NeoRegion(regionX, regionZ); } /* private static Path getSavePath(Path saveDir, int regionX, int regionZ) { @@ -77,7 +77,7 @@ public class LODRegion { } public void save(Path saveDir) { - if(LODMod.disableChunkMeshes || !LODMod.saveMeshes) return; + if(.disableChunkMeshes || !.saveMeshes) return; try { File saveFile = getSavePath(saveDir, regionX, regionZ).toFile(); @@ -128,11 +128,11 @@ public class LODRegion { } } */ - public LODChunk getChunkAbsolute(int chunkXAbs, int chunkZAbs) { + public NeoChunk getChunkAbsolute(int chunkXAbs, int chunkZAbs) { return getChunk(chunkXAbs - regionX * 32, chunkZAbs - regionZ * 32); } - public LODChunk getChunk(int x, int z) { + public NeoChunk getChunk(int x, int z) { if(x >= 0 && x < 32 && z >= 0 && z < 32) { return data[x][z]; } else { @@ -140,7 +140,7 @@ public class LODRegion { } } - public LODChunk putChunk(Chunk chunk) { + public NeoChunk putChunk(Chunk chunk) { int relX = chunk.xPosition - regionX * 32; int relZ = chunk.zPosition - regionZ * 32; @@ -155,7 +155,7 @@ public class LODRegion { int visibleChunks = 0; for(int i = 0; i < 32; i++) { for(int j = 0; j < 32; j++) { - LODChunk chunk = data[i][j]; + NeoChunk chunk = data[i][j]; if(chunk != null) { chunk.tick(player); if(chunk.visible) { @@ -171,7 +171,7 @@ public class LODRegion { //save(saveDir); for(int i = 0; i < 32; i++) { for(int j = 0; j < 32; j++) { - LODChunk chunk = data[i][j]; + NeoChunk chunk = data[i][j]; if(chunk != null) { chunk.destroy(); } diff --git a/src/main/java/makamys/neodymium/renderer/LODRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 974c408..708a9db 100644 --- a/src/main/java/makamys/neodymium/renderer/LODRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -40,7 +40,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Matrix4f; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.ducks.IWorldRenderer; import makamys.neodymium.renderer.Mesh.GPUStatus; import makamys.neodymium.util.GuiHelper; @@ -52,7 +52,7 @@ import static org.lwjgl.opengl.GL15.*; import static org.lwjgl.opengl.GL20.*; import static org.lwjgl.opengl.GL30.*; -public class LODRenderer { +public class NeoRenderer { public boolean hasInited = false; public boolean destroyPending; @@ -73,10 +73,10 @@ public class LODRenderer { GPUMemoryManager mem; List<Chunk> myChunks = new ArrayList<Chunk>(); - List<LODChunk> pendingLODChunks = new ArrayList<>(); + List<NeoChunk> pendingLODChunks = new ArrayList<>(); private boolean hasServerInited = false; - private Map<ChunkCoordIntPair, LODRegion> loadedRegionsMap = new HashMap<>(); + private Map<ChunkCoordIntPair, NeoRegion> loadedRegionsMap = new HashMap<>(); public World world; @@ -101,7 +101,7 @@ public class LODRenderer { private boolean freezeMeshes; - public LODRenderer(World world){ + public NeoRenderer(World world){ this.world = world; if(shouldRenderInWorld(world)) { hasInited = init(); @@ -114,7 +114,7 @@ public class LODRenderer { public void preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { if(renderPass != 0) return; - LODMod.fogEventWasPosted = false; + Neodymium.fogEventWasPosted = false; renderedMeshes = 0; @@ -129,13 +129,13 @@ public class LODRenderer { mem.runGC(false); } lastGCTime = System.currentTimeMillis(); - if(lastSaveTime == -1 || (System.currentTimeMillis() - lastSaveTime) > saveInterval && LODMod.saveMeshes) { + if(lastSaveTime == -1 || (System.currentTimeMillis() - lastSaveTime) > saveInterval && Neodymium.saveMeshes) { onSave(); lastSaveTime = System.currentTimeMillis(); } if(rendererActive && renderWorld) { - if(frameCount % LODMod.sortFrequency == 0) { + if(frameCount % Neodymium.sortFrequency == 0) { sort(); } @@ -152,7 +152,7 @@ public class LODRenderer { public void onRenderTickEnd() { if(destroyPending) { - LODMod.renderer = null; + Neodymium.renderer = null; return; } if(showMemoryDebugger && mem != null) { @@ -182,7 +182,7 @@ public class LODRenderer { piFirst[i].limit(sentMeshes[i].size()); piCount[i].limit(sentMeshes[i].size()); for(Mesh mesh : sentMeshes[i]) { - if(mesh.visible && (LODMod.maxMeshesPerFrame == -1 || renderedMeshes < LODMod.maxMeshesPerFrame)) { + if(mesh.visible && (Neodymium.maxMeshesPerFrame == -1 || renderedMeshes < Neodymium.maxMeshesPerFrame)) { renderedMeshes++; piFirst[i].put(mesh.iFirst); piCount[i].put(mesh.iCount); @@ -195,7 +195,7 @@ public class LODRenderer { private void mainLoop() { while(!farChunks.isEmpty()) { - LODChunk lodChunk = receiveFarChunk(farChunks.remove()); + NeoChunk lodChunk = receiveFarChunk(farChunks.remove()); sendChunkToGPU(lodChunk); } @@ -229,7 +229,7 @@ public class LODRenderer { lastSortZ = player.posZ; for(Iterator<ChunkCoordIntPair> it = loadedRegionsMap.keySet().iterator(); it.hasNext();) { ChunkCoordIntPair k = it.next(); - LODRegion v = loadedRegionsMap.get(k); + NeoRegion v = loadedRegionsMap.get(k); if(v.distanceTaxicab(player) > renderRange * 16 + 16 * 16) { System.out.println("unloading " + v); @@ -244,19 +244,19 @@ public class LODRenderer { } public float getFarPlaneDistanceMultiplier() { - return (float)LODMod.farPlaneDistanceMultiplier; + return (float)Neodymium.farPlaneDistanceMultiplier; } public void afterSetupFog(int mode, float alpha, float farPlaneDistance) { EntityLivingBase entity = Minecraft.getMinecraft().renderViewEntity; - if(LODMod.fogEventWasPosted && !Minecraft.getMinecraft().theWorld.provider.doesXZShowFog((int)entity.posX, (int)entity.posZ)) { - GL11.glFogf(GL11.GL_FOG_START, mode < 0 ? 0 : farPlaneDistance * (float)LODMod.fogStart); - GL11.glFogf(GL11.GL_FOG_END, mode < 0 ? farPlaneDistance/4 : farPlaneDistance * (float)LODMod.fogEnd); + if(Neodymium.fogEventWasPosted && !Minecraft.getMinecraft().theWorld.provider.doesXZShowFog((int)entity.posX, (int)entity.posZ)) { + GL11.glFogf(GL11.GL_FOG_START, mode < 0 ? 0 : farPlaneDistance * (float)Neodymium.fogStart); + GL11.glFogf(GL11.GL_FOG_END, mode < 0 ? farPlaneDistance/4 : farPlaneDistance * (float)Neodymium.fogEnd); } } private void handleKeyboard() { - if(LODMod.debugPrefix == 0 || (LODMod.debugPrefix != -1 && Keyboard.isKeyDown(LODMod.debugPrefix))) { + if(Neodymium.debugPrefix == 0 || (Neodymium.debugPrefix != -1 && Keyboard.isKeyDown(Neodymium.debugPrefix))) { if(Keyboard.isKeyDown(Keyboard.KEY_F) && !wasDown[Keyboard.KEY_F]) { rendererActive = !rendererActive; } @@ -421,7 +421,7 @@ public class LODRenderer { int fragmentShader; fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fragmentShader, Util.readFile(LODMod.enableFog ? "shaders/chunk_fog.frag" : "shaders/chunk.frag")); + glShaderSource(fragmentShader, Util.readFile(Neodymium.enableFog ? "shaders/chunk_fog.frag" : "shaders/chunk.frag")); glCompileShader(fragmentShader); if(glGetShaderi(fragmentShader, GL_COMPILE_STATUS) == 0) { @@ -458,7 +458,7 @@ public class LODRenderer { int x = Math.floorDiv(wr.posX, 16); int y = Math.floorDiv(wr.posY, 16); int z = Math.floorDiv(wr.posZ, 16); - LODChunk lodChunk = getLODChunk(x, z); + NeoChunk lodChunk = getLODChunk(x, z); lodChunk.isSectionVisible[y] = change == WorldRendererChange.VISIBLE; if(change == WorldRendererChange.DELETED) { @@ -468,14 +468,14 @@ public class LODRenderer { } public void onWorldRendererPost(WorldRenderer wr) { - if(LODMod.disableChunkMeshes) return; + if(Neodymium.disableChunkMeshes) return; int x = Math.floorDiv(wr.posX, 16); int y = Math.floorDiv(wr.posY, 16); int z = Math.floorDiv(wr.posZ, 16); if(Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(x, z).isChunkLoaded) { - LODChunk lodChunk = getLODChunk(x, z); + NeoChunk lodChunk = getLODChunk(x, z); lodChunk.isSectionVisible[y] = ((IWorldRenderer)wr).isDrawn(); lodChunk.putChunkMeshes(y, ((IWorldRenderer)wr).getChunkMeshes()); } @@ -489,12 +489,12 @@ public class LODRenderer { serverChunkLoadQueue.addAll(coords); } - private LODChunk receiveFarChunk(Chunk chunk) { - LODRegion region = getRegionContaining(chunk.xPosition, chunk.zPosition); + private NeoChunk receiveFarChunk(Chunk chunk) { + NeoRegion region = getRegionContaining(chunk.xPosition, chunk.zPosition); return region.putChunk(chunk); } - private LODChunk getLODChunk(int chunkX, int chunkZ) { + private NeoChunk getLODChunk(int chunkX, int chunkZ) { return getRegionContaining(chunkX, chunkZ).getChunkAbsolute(chunkX, chunkZ); } @@ -503,7 +503,7 @@ public class LODRenderer { } public synchronized void serverTick() { - int chunkLoadsRemaining = LODMod.chunkLoadsPerTick; + int chunkLoadsRemaining = Neodymium.chunkLoadsPerTick; while(!serverChunkLoadQueue.isEmpty() && chunkLoadsRemaining-- > 0) { ChunkCoordIntPair coords = serverChunkLoadQueue.remove(0); ChunkProviderServer chunkProviderServer = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(world.provider.dimensionId).theChunkProviderServer; @@ -513,36 +513,36 @@ public class LODRenderer { } } - private LODRegion getRegionContaining(int chunkX, int chunkZ) { + private NeoRegion getRegionContaining(int chunkX, int chunkZ) { ChunkCoordIntPair key = new ChunkCoordIntPair(Math.floorDiv(chunkX , 32), Math.floorDiv(chunkZ, 32)); - LODRegion region = loadedRegionsMap.get(key); + NeoRegion region = loadedRegionsMap.get(key); if(region == null) { - region = LODRegion.load(getSaveDir(), Math.floorDiv(chunkX , 32), Math.floorDiv(chunkZ , 32)); + region = NeoRegion.load(getSaveDir(), Math.floorDiv(chunkX , 32), Math.floorDiv(chunkZ , 32)); loadedRegionsMap.put(key, region); } return region; } - private void sendChunkToGPU(LODChunk lodChunk) { + private void sendChunkToGPU(NeoChunk lodChunk) { Entity player = Minecraft.getMinecraft().renderViewEntity; lodChunk.tick(player); setVisible(lodChunk, true, true); } - public void setVisible(LODChunk chunk, boolean visible) { + public void setVisible(NeoChunk chunk, boolean visible) { setVisible(chunk, visible, false); } - public void setVisible(LODChunk lodChunk, boolean visible, boolean forceCheck) { + public void setVisible(NeoChunk lodChunk, boolean visible, boolean forceCheck) { if(!forceCheck && visible == lodChunk.visible) return; lodChunk.visible = visible; lodChunkChanged(lodChunk); } - public void lodChunkChanged(LODChunk lodChunk) { - int newLOD = (!lodChunk.hasChunkMeshes() && lodChunk.lod == 2) ? (LODMod.disableSimpleMeshes ? 0 : 1) : lodChunk.lod; + public void lodChunkChanged(NeoChunk lodChunk) { + int newLOD = (!lodChunk.hasChunkMeshes() && lodChunk.lod == 2) ? (Neodymium.disableSimpleMeshes ? 0 : 1) : lodChunk.lod; for(SimpleChunkMesh sm : lodChunk.simpleMeshes) { if(sm != null) { if(lodChunk.isFullyVisible() && newLOD == 1) { @@ -641,14 +641,14 @@ public class LODRenderer { } private Path getSaveDir(){ - return Minecraft.getMinecraft().mcDataDir.toPath().resolve("lodmod").resolve(Minecraft.getMinecraft().getIntegratedServer().getFolderName()); + return Minecraft.getMinecraft().mcDataDir.toPath().resolve("neodymium").resolve(Minecraft.getMinecraft().getIntegratedServer().getFolderName()); } private boolean shouldRenderInWorld(World world) { return world != null && !world.provider.isHellWorld; } - public static class LODChunkComparator implements Comparator<LODChunk> { + public static class LODChunkComparator implements Comparator<NeoChunk> { Entity player; public LODChunkComparator(Entity player) { @@ -656,13 +656,13 @@ public class LODRenderer { } @Override - public int compare(LODChunk p1, LODChunk p2) { + public int compare(NeoChunk p1, NeoChunk p2) { int distSq1 = distSq(p1); int distSq2 = distSq(p2); return distSq1 < distSq2 ? -1 : distSq1 > distSq2 ? 1 : 0; } - int distSq(LODChunk p) { + int distSq(NeoChunk p) { return (int)( Math.pow(((p.x * 16) - player.chunkCoordX), 2) + Math.pow(((p.z * 16) - player.chunkCoordZ), 2) diff --git a/src/main/java/makamys/neodymium/renderer/SimpleChunkMesh.java b/src/main/java/makamys/neodymium/renderer/SimpleChunkMesh.java index 964dec8..44031d4 100644 --- a/src/main/java/makamys/neodymium/renderer/SimpleChunkMesh.java +++ b/src/main/java/makamys/neodymium/renderer/SimpleChunkMesh.java @@ -16,7 +16,7 @@ import java.util.List; import org.lwjgl.BufferUtils; -import makamys.neodymium.LODMod; +import makamys.neodymium.Neodymium; import makamys.neodymium.util.MCUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockGrass; @@ -45,7 +45,7 @@ public class SimpleChunkMesh extends Mesh { } private static boolean isBad(Block block) { - for(Class clazz : LODMod.blockClassBlacklist) { + for(Class clazz : Neodymium.blockClassBlacklist) { if(clazz.isInstance(block)) { return true; } @@ -126,7 +126,7 @@ public class SimpleChunkMesh extends Mesh { } color = (0xFF << 24) | ((color >> 16 & 0xFF) << 0) | ((color >> 8 & 0xFF) << 8) | ((color >> 0 & 0xFF) << 16); - if((LODMod.forceVanillaBiomeTemperature ? MCUtil.getBiomeTemperatureVanilla(biome, worldX, y, worldZ) + if((Neodymium.forceVanillaBiomeTemperature ? MCUtil.getBiomeTemperatureVanilla(biome, worldX, y, worldZ) : biome.getFloatTemperature(worldX, y, worldZ)) < 0.15f) { builder.addCube(divX, divZ, worldY + 0.2f, 1f, Blocks.snow_layer.getIcon(1, 0), 0xFFFFFFFF, brightnessMult); diff --git a/src/main/java/makamys/neodymium/util/Util.java b/src/main/java/makamys/neodymium/util/Util.java index 2507a78..d39ccc7 100644 --- a/src/main/java/makamys/neodymium/util/Util.java +++ b/src/main/java/makamys/neodymium/util/Util.java @@ -15,11 +15,11 @@ import net.minecraft.launchwrapper.Launch; public class Util { - private static boolean allowResourceOverrides = Boolean.parseBoolean(System.getProperty("lodmod.allowResourceOverrides", "false")); + private static boolean allowResourceOverrides = Boolean.parseBoolean(System.getProperty("neodymium.allowResourceOverrides", "false")); public static Path getResourcePath(String relPath) { if(allowResourceOverrides) { - File overrideFile = new File(new File(Launch.minecraftHome, "lodmod/resources"), relPath); + File overrideFile = new File(new File(Launch.minecraftHome, "neodymium/resources"), relPath); if(overrideFile.exists()) { return overrideFile.toPath(); } |