diff --git a/README.txt b/README.txt index b45931f4..01e77f9f 100644 --- a/README.txt +++ b/README.txt @@ -24,7 +24,7 @@ Linux/Mac OS: "./gradlew setupDecompWorkspace" Step 3: After all that finished, you're left with a choice. For eclipse, run "gradlew eclipse" (./gradlew eclipse if you are on Mac/Linux) -If you preffer to use IntelliJ, steps are a little different. +If you prefer to use IntelliJ, steps are a little different. 1. Open IDEA, and import project. 2. Select your build.gradle file and have it import. 3. Once it's finished you must close IntelliJ and run the following command: diff --git a/build.gradle b/build.gradle index 6ffe1773..e9203d4d 100644 --- a/build.gradle +++ b/build.gradle @@ -10,13 +10,13 @@ buildscript { apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup. -ext.modversion = "3.0.0-a3" +ext.modversion = "3.0.0-a4" ext.mcversion = "1.12.2" ext.forgeversion = "14.23.1.2555" //spongeSchematicVersion = "1" version = mcversion + "-" + modversion -group= "com.zixiken.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +group = "com.zixiken.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "dimdoors" sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly. @@ -46,8 +46,7 @@ jar { from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } } -processResources -{ +processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version diff --git a/src/main/java/com/zixiken/dimdoors/DimDoors.java b/src/main/java/com/zixiken/dimdoors/DimDoors.java index 71d44192..05cd0d01 100644 --- a/src/main/java/com/zixiken/dimdoors/DimDoors.java +++ b/src/main/java/com/zixiken/dimdoors/DimDoors.java @@ -10,7 +10,6 @@ import com.zixiken.dimdoors.shared.RiftRegistry; import com.zixiken.dimdoors.shared.SchematicHandler; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.translation.I18n; @@ -27,11 +26,11 @@ import java.util.List; @Mod(modid = DimDoors.MODID, name = "Dimensional Doors", version = DimDoors.VERSION, dependencies = "required-after:forge@[14.23.0.2517,)") public class DimDoors { - public static final String VERSION = "${version}"; public static final String MODID = "dimdoors"; + public static final String VERSION = "${version}"; @SidedProxy(clientSide = "com.zixiken.dimdoors.client.DDProxyClient", - serverSide = "com.zixiken.dimdoors.server.DDProxyServer") + serverSide = "com.zixiken.dimdoors.server.DDProxyServer") public static DDProxyCommon proxy; @Mod.Instance(DimDoors.MODID) @@ -67,7 +66,6 @@ public class DimDoors { private void registerCommands(FMLServerStartingEvent event) { event.registerServerCommand(new TeleportCommand()); event.registerServerCommand(new PocketCommand()); - //@todo event.registerServerCommand( new DDCommand() ); //to register commands that this mod offers? } public static boolean isClient() { @@ -86,14 +84,31 @@ public class DimDoors { player.sendMessage(new TextComponentString("[DimDoors] " + text)); } - public static void warn(Class classFiredFrom, String text) { - FMLLog.warning("[DimDoors] " + text + " (" + classFiredFrom.toString() + " )", 0); + public static void warn(String text) { + warn(null, text); } - public static void log(Class classFiredFrom, String text) { - FMLLog.info("[DimDoors] " + text + " (" + classFiredFrom.toString() + " )", 0); + public static void warn(Class classFiredFrom, String text) { + if(classFiredFrom != null) { + FMLLog.log.warn("[DimDoors] " + text + " (" + classFiredFrom + " )", 0); + } else { + FMLLog.log.warn("[DimDoors] " + text, 0); + } } + public static void log(String text) { + log(null, text); + } + + public static void log(Class classFiredFrom, String text) { + if(classFiredFrom != null) { + FMLLog.log.info("[DimDoors] " + text + " (" + classFiredFrom + " )", 0); + } else { + FMLLog.log.info("[DimDoors] " + text, 0); + } + } + + // TODO: I18n is deprecated, convert to TextComponentTranslation public static void translateAndAdd(String key, List list) { for (int i = 0; i < 10; i++) { if (I18n.canTranslate(key + Integer.toString(i))) { diff --git a/src/main/java/com/zixiken/dimdoors/client/ClosingRiftFX.java b/src/main/java/com/zixiken/dimdoors/client/ClosingRiftFX.java index e1367a97..fcf9a3ed 100644 --- a/src/main/java/com/zixiken/dimdoors/client/ClosingRiftFX.java +++ b/src/main/java/com/zixiken/dimdoors/client/ClosingRiftFX.java @@ -19,23 +19,19 @@ public class ClosingRiftFX extends Particle { private boolean hasFadeColour; public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) { - super(world, x, y, z); this.motionX = motionX; this.motionY = motionY; this.motionZ = motionZ; - this.particleScale *= .55F; - this.particleMaxAge = 30 + this.rand.nextInt(16); + particleScale *= .55F; + particleMaxAge = 30 + rand.nextInt(16); } @Override - public void renderParticle(BufferBuilder worldRenderer, Entity entityIn, float partialTicks, float p_180434_4_, - float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { - if (!this.twinkle - || this.particleAge < this.particleMaxAge / 3 - || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) { - this.doRenderParticle(worldRenderer, partialTicks, p_180434_4_, - p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_); + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, + float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { + if (!twinkle || particleAge < particleMaxAge / 3 || (particleAge + particleMaxAge) / 3 % 2 == 0) { + doRenderParticle(buffer, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); } } @@ -43,29 +39,29 @@ public class ClosingRiftFX extends Particle { float par5, float par6, float par7) { float var8 = super.particleTextureIndexX % 16 / 16.0F; float var9 = var8 + 0.0624375F; - float var10 = this.particleTextureIndexX / 16 / 16.0F; + float var10 = particleTextureIndexX / 16 / 16.0F; float var11 = var10 + 0.0624375F; - float var12 = 0.1F * this.particleScale; - float var13 = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX); - float var14 = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY); - float var15 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); + float var12 = 0.1F * particleScale; + float var13 = (float) (prevPosX + (posX - prevPosX) * par2 - interpPosX); + float var14 = (float) (prevPosY + (posY - prevPosY) * par2 - interpPosY); + float var15 = (float) (prevPosZ + (posZ - prevPosZ) * par2 - interpPosZ); float var16 = 0.8F; worldRenderer.pos(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12) .tex(var9, var11) - .color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7) + .color(particleRed * var16, particleGreen * var16, particleBlue * var16, (float) .7) .endVertex(); worldRenderer.pos(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12) .tex(var9, var10) - .color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7) + .color(particleRed * var16, particleGreen * var16, particleBlue * var16, (float) .7) .endVertex(); worldRenderer.pos(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12) .tex(var8, var10) - .color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7) + .color(particleRed * var16, particleGreen * var16, particleBlue * var16, (float) .7) .endVertex(); worldRenderer.pos(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12) .tex(var8, var11) - .color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7) + .color(particleRed * var16, particleGreen * var16, particleBlue * var16, (float) .7) .endVertex(); } @@ -74,48 +70,49 @@ public class ClosingRiftFX extends Particle { */ @Override public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + particleAge++; - if (this.particleAge++ >= this.particleMaxAge) { - this.setExpired(); + if (particleAge >= particleMaxAge) { + setExpired(); } - if (this.particleAge > this.particleMaxAge / 2) { - this.setAlphaF(1.0F - ((float) this.particleAge - (float) (this.particleMaxAge / 2)) / this.particleMaxAge); + if (particleAge > particleMaxAge / 2) { + setAlphaF(1.0F - ((float) particleAge - (float) (particleMaxAge / 2)) / particleMaxAge); - if (this.hasFadeColour) { - this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F; - this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F; - this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F; + if (hasFadeColour) { + particleRed += (fadeColourRed - particleRed) * 0.2F; + particleGreen += (fadeColourGreen - particleGreen) * 0.2F; + particleBlue += (fadeColourBlue - particleBlue) * 0.2F; } } - this.setParticleTextureIndex(this.baseTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge)); + setParticleTextureIndex(baseTextureIndex + 7 - particleAge * 8 / particleMaxAge); // this.motionY -= 0.004D; - this.move(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9100000262260437D; - this.motionY *= 0.9100000262260437D; - this.motionZ *= 0.9100000262260437D; + move(motionX, motionY, motionZ); + motionX *= 0.9100000262260437D; + motionY *= 0.9100000262260437D; + motionZ *= 0.9100000262260437D; - if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) { - ClosingRiftFX var1 = new ClosingRiftFX(this.world, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); - var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue); + if (trail && particleAge < particleMaxAge / 2 && (particleAge + particleMaxAge) % 2 == 0) { + ClosingRiftFX var1 = new ClosingRiftFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D); + var1.setRBGColorF(particleRed, particleGreen, particleBlue); var1.particleAge = var1.particleMaxAge / 2; - if (this.hasFadeColour) { + if (hasFadeColour) { var1.hasFadeColour = true; - var1.fadeColourRed = this.fadeColourRed; - var1.fadeColourGreen = this.fadeColourGreen; - var1.fadeColourBlue = this.fadeColourBlue; + var1.fadeColourRed = fadeColourRed; + var1.fadeColourGreen = fadeColourGreen; + var1.fadeColourBlue = fadeColourBlue; } - var1.twinkle = this.twinkle; + var1.twinkle = twinkle; } } @Override - public int getBrightnessForRender(float par1) { + public int getBrightnessForRender(float p_189214_1_) { return 15728880; } } diff --git a/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java b/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java index dbf09417..742c2bd6 100644 --- a/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java +++ b/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java @@ -10,8 +10,7 @@ public class CloudRenderBlank extends IRenderHandler { @Override @SideOnly(Side.CLIENT) - public void render(float partialTicks, WorldClient world, Minecraft mc) - { + public void render(float partialTicks, WorldClient world, Minecraft mc) { } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/client/DDProxyClient.java b/src/main/java/com/zixiken/dimdoors/client/DDProxyClient.java index 6ca64a40..3401e33b 100644 --- a/src/main/java/com/zixiken/dimdoors/client/DDProxyClient.java +++ b/src/main/java/com/zixiken/dimdoors/client/DDProxyClient.java @@ -9,19 +9,14 @@ import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor; import com.zixiken.dimdoors.shared.tileentities.TileEntityRift; import com.zixiken.dimdoors.shared.tileentities.TileEntityTransTrapdoor; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -@SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"}) public class DDProxyClient extends DDProxyCommon { @Override @@ -45,13 +40,7 @@ public class DDProxyClient extends DDProxyCommon { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDimDoor.class, new RenderDimDoor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransTrapdoor.class, new RenderTransTrapdoor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRift.class, new RenderRift()); - RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, new IRenderFactory() - { - @Override - public Render createRenderFor(RenderManager manager) { - return new RenderMobObelisk(manager, 0.5f); - } - }); + RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, manager -> new RenderMobObelisk(manager, 0.5f)); } @Override @@ -64,11 +53,6 @@ public class DDProxyClient extends DDProxyCommon { return Minecraft.getMinecraft().player; } - @Override - public World getDefWorld() { - return getWorldServer(0); //gets the client world dim 0 handler - } - @Override public WorldServer getWorldServer(int dimId) { return Minecraft.getMinecraft().getIntegratedServer().getWorld(dimId); diff --git a/src/main/java/com/zixiken/dimdoors/client/GoggleRiftFX.java b/src/main/java/com/zixiken/dimdoors/client/GoggleRiftFX.java index 59dcc812..2fdd4b3c 100644 --- a/src/main/java/com/zixiken/dimdoors/client/GoggleRiftFX.java +++ b/src/main/java/com/zixiken/dimdoors/client/GoggleRiftFX.java @@ -8,9 +8,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GoggleRiftFX extends ParticleCloud { - public GoggleRiftFX(World par1World, double par2, double par4, double par6, - double par8, double par10, double par12) { + public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) { super(par1World, par2, par4, par6, par12, par12, par12); - this.particleMaxAge = 40 + this.rand.nextInt(26); + particleMaxAge = 40 + rand.nextInt(26); } } diff --git a/src/main/java/com/zixiken/dimdoors/client/RenderDimDoor.java b/src/main/java/com/zixiken/dimdoors/client/RenderDimDoor.java index d768d5ad..37e19645 100644 --- a/src/main/java/com/zixiken/dimdoors/client/RenderDimDoor.java +++ b/src/main/java/com/zixiken/dimdoors/client/RenderDimDoor.java @@ -1,7 +1,5 @@ package com.zixiken.dimdoors.client; -import static org.lwjgl.opengl.GL11.GL_LIGHTING; -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_DST_COLOR; import java.nio.FloatBuffer; import java.util.Random; @@ -42,7 +40,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer float var16 = 0.2625F; float var17 = 1.0F / (var15 + .80F); - this.bindTexture(warpPath); + bindTexture(warpPath); GlStateManager.enableBlend(); if (count == 0) { @@ -72,28 +70,28 @@ public class RenderDimDoor extends TileEntitySpecialRenderer switch (orientation) { case SOUTH: - GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); - GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F)); + GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F)); break; case WEST: - GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); - GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F)); + GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F)); break; case NORTH: - GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); - GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F)); + GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F)); break; case EAST: - GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); - GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); - GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F)); + GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F)); break; } @@ -146,29 +144,29 @@ public class RenderDimDoor extends TileEntitySpecialRenderer worldRenderer.pos(x, y + 1, z + .99).endVertex(); break; /*case 4: - GL11.glVertex3d(x + .15F, y - 1 , z); - GL11.glVertex3d(x + .15, y - 1, z + 1.0D); - GL11.glVertex3d(x + .15, y + 1, z + 1.0D); - GL11.glVertex3d(x + .15, y + 1, z); - break; - case 5: - GL11.glVertex3d(x, y + 1, z + .15); - GL11.glVertex3d(x + 1, y + 1, z + .15); - GL11.glVertex3d(x + 1, y - 1, z + .15); - GL11.glVertex3d(x, y - 1, z + .15); - break; - case 6: - GL11.glVertex3d(x + .85, y + 1, z); - GL11.glVertex3d(x + .85, y + 1, z + 1.0D); - GL11.glVertex3d(x + .85, y - 1, z + 1.0D); - GL11.glVertex3d(x + .85, y - 1, z); - break; - case 7: - GL11.glVertex3d(x, y - 1, z + .85); - GL11.glVertex3d(x + 1, y - 1, z + .85); - GL11.glVertex3d(x + 1, y + 1, z + .85); - GL11.glVertex3d(x, y + 1, z + .85); - break;*/ + GL11.glVertex3d(x + .15F, y - 1 , z); + GL11.glVertex3d(x + .15, y - 1, z + 1.0D); + GL11.glVertex3d(x + .15, y + 1, z + 1.0D); + GL11.glVertex3d(x + .15, y + 1, z); + break; + case 5: + GL11.glVertex3d(x, y + 1, z + .15); + GL11.glVertex3d(x + 1, y + 1, z + .15); + GL11.glVertex3d(x + 1, y - 1, z + .15); + GL11.glVertex3d(x, y - 1, z + .15); + break; + case 6: + GL11.glVertex3d(x + .85, y + 1, z); + GL11.glVertex3d(x + .85, y + 1, z + 1.0D); + GL11.glVertex3d(x + .85, y - 1, z + 1.0D); + GL11.glVertex3d(x + .85, y - 1, z); + break; + case 7: + GL11.glVertex3d(x, y - 1, z + .85); + GL11.glVertex3d(x + 1, y - 1, z + .85); + GL11.glVertex3d(x + 1, y + 1, z + .85); + GL11.glVertex3d(x, y + 1, z + .85); + break;*/ } tessellator.draw(); @@ -265,7 +263,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer renderDimDoorTileEntity(te, x, y, z); if (te.lockStatus >= 1) { for (int i = 0; i < 1 + te.lockStatus; i++) { - this.renderKeyHole(te, x, y, z, i); + renderKeyHole(te, x, y, z, i); } } diff --git a/src/main/java/com/zixiken/dimdoors/client/RenderRift.java b/src/main/java/com/zixiken/dimdoors/client/RenderRift.java index cfd638e4..24ab050d 100644 --- a/src/main/java/com/zixiken/dimdoors/client/RenderRift.java +++ b/src/main/java/com/zixiken/dimdoors/client/RenderRift.java @@ -4,25 +4,20 @@ import com.flowpowered.math.TrigMath; import com.flowpowered.math.vector.Vector3f; import com.flowpowered.math.vector.Vector4f; import com.zixiken.dimdoors.DimDoors; -import com.zixiken.dimdoors.shared.items.ModItems; import com.zixiken.dimdoors.shared.tileentities.TileEntityRift; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class RenderRift extends TileEntitySpecialRenderer { - private static final EntityItem ITEM = new EntityItem(Minecraft.getMinecraft().world, 0,0,0, new ItemStack(ModItems.STABLE_FABRIC)); private static ResourceLocation tesseract_path = new ResourceLocation(DimDoors.MODID + ":textures/other/tesseract.png"); - private static Vector4f tesseract[] = { + private static Vector4f[] tesseract = { new Vector4f(-0.5f,-0.5f,-0.5f,-0.5f), new Vector4f(0.5f,-0.5f,-0.5f,-0.5f), new Vector4f(0.5f,-0.5f,0.5f,-0.5f), @@ -157,7 +152,7 @@ public class RenderRift extends TileEntitySpecialRenderer { GlStateManager.pushMatrix(); GlStateManager.disableCull(); - this.bindTexture(tesseract_path); + bindTexture(tesseract_path); GlStateManager.translate(x+0.5,y+0.5,z+0.5); GlStateManager.scale(0.25,0.25,0.25); @@ -180,7 +175,8 @@ public class RenderRift extends TileEntitySpecialRenderer { } private double update(float partialTicks) { - return (angle = (angle + 3*partialTicks) % 360); + angle = (angle + 3 * partialTicks) % 360; + return angle; } private Vector4f rotation(Vector4f v, double angle) { diff --git a/src/main/java/com/zixiken/dimdoors/client/RenderTransTrapdoor.java b/src/main/java/com/zixiken/dimdoors/client/RenderTransTrapdoor.java index 9262d121..1de97000 100644 --- a/src/main/java/com/zixiken/dimdoors/client/RenderTransTrapdoor.java +++ b/src/main/java/com/zixiken/dimdoors/client/RenderTransTrapdoor.java @@ -15,7 +15,6 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexBuffer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; @@ -45,7 +44,7 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer event) { + public static void registerRecipes(RegistryEvent.Register event) { // TODO event.getRegistry().register(makeShapedRecipe(new ItemStack(ModItems.STABLE_FABRIC, 1), "yxy", 'x', Items.ENDER_PEARL, 'y', ModItems.WORLD_THREAD)); diff --git a/src/main/java/com/zixiken/dimdoors/shared/DDConfig.java b/src/main/java/com/zixiken/dimdoors/shared/DDConfig.java index fce66936..21031b06 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/DDConfig.java +++ b/src/main/java/com/zixiken/dimdoors/shared/DDConfig.java @@ -8,6 +8,7 @@ package com.zixiken.dimdoors.shared; import com.zixiken.dimdoors.DimDoors; import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -35,8 +36,8 @@ public class DDConfig { private static int maxDungeonDepth = 8; private static int owCoordinateOffsetBase = 64; private static double owCoordinateOffsetPower = 1.3; - private static int[] doorRelativeDepths = new int[]{-1, 0, 1}; - private static int[] doorRelativeDepthWeights = new int[]{20, 30, 50}; + private static int[] doorRelativeDepths = {-1, 0, 1}; + private static int[] doorRelativeDepthWeights = {20, 30, 50}; private static boolean dangerousLimboMonolithsEnabled = false; private static boolean monolithTeleportationEnabled = true; @@ -113,7 +114,7 @@ public class DDConfig { DimDoors.log(DDConfig.class, "pocketGridSize was set to " + pocketGridSize); maxPocketSize = setConfigIntWithMaxAndMin(config, "pocket_dimension", "maxPocketSize", maxPocketSize, - "Sets how deep and wide any pocket can be. [min: 0, max: pocketGridSize/2, default: 4]", 0, (int) (((double) pocketGridSize / 2) - 0.5)); + "Sets how deep and wide any pocket can be. [min: 0, max: pocketGridSize/2, default: 4]", 0, (int) ((double) pocketGridSize / 2 - 0.5)); privatePocketSize = setConfigIntWithMaxAndMin(config, "pocket_dimension", "privatePocketSize", privatePocketSize, "Sets how deep and wide any personal pocket can be. [min: 0, max: maxPocketsSize, default: 3]", 0, maxPocketSize); @@ -160,9 +161,7 @@ public class DDConfig { public static List getDungeonSchematicNames() { List dungeonSchematicNamesArrayList = new ArrayList<>(); - for (String dungeonSchematicName : dungeonSchematicNames) { - dungeonSchematicNamesArrayList.add(dungeonSchematicName); - } + Collections.addAll(dungeonSchematicNamesArrayList, dungeonSchematicNames); return dungeonSchematicNamesArrayList; } diff --git a/src/main/java/com/zixiken/dimdoors/shared/DDEventHandler.java b/src/main/java/com/zixiken/dimdoors/shared/DDEventHandler.java index 94819d59..3e280c26 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/DDEventHandler.java +++ b/src/main/java/com/zixiken/dimdoors/shared/DDEventHandler.java @@ -16,27 +16,16 @@ import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; -/** - * - * @author Robijnvogel - */ public class DDEventHandler { @SubscribeEvent public void onPlayerJoinWorld(EntityJoinWorldEvent event) { - //check if config default values have been checked - if (!DDConfig.HAVE_CONFIG_DEFAULTS_BEEN_CHECKED_FOR_CORRECTNESS) { - if (!DimDoors.VERSION.contains("a")) { //if it is not an alpha version - Entity entity = event.getEntity(); - World world = entity.world; - if (!world.isRemote) { - if (entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entity; - DimDoors.chat(player, "The default values for the config files fo this non-alpha version of DimDoors have not been sufficiently checked on correctness. Please notify the developer about this IF no newer version of this mod is available."); - } - } + Entity entity = event.getEntity(); + if(entity instanceof EntityPlayer && !entity.world.isRemote) { // check that it's a player first to avoid calling String.contains for every entity + if (!DDConfig.HAVE_CONFIG_DEFAULTS_BEEN_CHECKED_FOR_CORRECTNESS && !DimDoors.VERSION.contains("a")) { // default values were not checked in non-alpha version + EntityPlayer player = (EntityPlayer) entity; + DimDoors.chat(player, "The default values for the config files for this non-alpha version of DimDoors have not been sufficiently checked on correctness. Please notify the developer about this ONLY IF no newer version of this mod is available."); } } } @@ -49,43 +38,17 @@ public class DDEventHandler { } } - @SubscribeEvent - public void onPlayerChangedDim(PlayerChangedDimensionEvent event) { - EntityPlayer player = event.player; - int dimID = event.toDim; - World world = player.world; - if (!world.isRemote && DimDoorDimensions.isPocketDimensionID(dimID)) { - if (player instanceof EntityPlayerMP) { - EntityPlayerMP playerMP = (EntityPlayerMP) player; - checkPlayerLocationPermission(playerMP); - } - } - } - @SubscribeEvent public void onEntityEnterChunk(EntityEvent.EnteringChunk event) { Entity entity = event.getEntity(); if (entity instanceof EntityPlayerMP) { + EntityPlayerMP player = (EntityPlayerMP) entity; World world = entity.world; - if (!world.isRemote && DimDoorDimensions.isPocketDimensionID(world.provider.getDimension())) { - EntityPlayerMP player = (EntityPlayerMP) entity; - checkPlayerLocationPermission(player); - } - } - } - - /** - * - * @param player the player entity to check for permissions - * @pre {@code (entity instanceof EntityPlayerMP)} - */ - private void checkPlayerLocationPermission(EntityPlayerMP player) { - if (!player.isDead && !(player.getPosition().getY() < 1)) { - Location location = Location.getLocation(player); - DimDoors.log(this.getClass(), "A player just entered a new chunk in a DimDoors dimension."); - if (!PocketRegistry.INSTANCE.isPlayerAllowedToBeHere(player, location)) { - //@todo this doesn't really work yet. - //DimDoors.chat(player, "You are not supposed to be here. In future version of this mod, you will be teleported to Limbo if you go here."); + if (!world.isRemote && !player.isDead && !PocketRegistry.INSTANCE.isPlayerAllowedToBeHere(player, Location.getLocation(player))) { + // TODO: Avoid players even getting here by making a maximum build distance that's smaller than the pocket size + // TODO: This doesn't really work yet. + // DimDoors.chat(player, "You travelled too far into the void and have been sent to Limbo."); + // PocketRegistry.sendToLimbo(player); // TODO } } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/DDProxyCommon.java b/src/main/java/com/zixiken/dimdoors/shared/DDProxyCommon.java index 89409377..5285c491 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/DDProxyCommon.java +++ b/src/main/java/com/zixiken/dimdoors/shared/DDProxyCommon.java @@ -5,13 +5,7 @@ import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase; import com.zixiken.dimdoors.shared.blocks.ModBlocks; import com.zixiken.dimdoors.shared.entities.MobMonolith; import com.zixiken.dimdoors.shared.items.ModItems; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorChaos; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorGold; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorPersonal; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorWarp; -import com.zixiken.dimdoors.shared.tileentities.TileEntityRift; -import com.zixiken.dimdoors.shared.tileentities.TileEntityTransTrapdoor; +import com.zixiken.dimdoors.shared.tileentities.*; import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import net.minecraft.block.BlockDoor; import net.minecraft.block.state.IBlockState; @@ -36,19 +30,20 @@ public abstract class DDProxyCommon implements IDDProxy { DimDoorDimensions.init(); - GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor"); + GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor"); // TODO: use new registry GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift"); GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityTransTrapdoor"); GameRegistry.registerTileEntity(TileEntityDimDoorGold.class, "TileEntityDimDoorGold"); GameRegistry.registerTileEntity(TileEntityDimDoorPersonal.class, "TileEntityDimDoorPersonal"); - GameRegistry.registerTileEntity(TileEntityDimDoorChaos.class, "TileEntityDimDoorChaos"); + GameRegistry.registerTileEntity(TileEntityDimDoorUnstable.class, "TileEntityDimDoorUnstable"); GameRegistry.registerTileEntity(TileEntityDimDoorWarp.class, "TileEntityDimDoorWarp"); + + EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), MobMonolith.class, "monolith", 0, DimDoors.instance, 70, 1, true); + EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff); } @Override public void onInitialization(FMLInitializationEvent event) { - EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), MobMonolith.class, "monolith", 0, DimDoors.instance, 70, 1, true); - EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff); } public void updateDoorTE(BlockDimDoorBase door, World world, BlockPos pos) { @@ -66,5 +61,7 @@ public abstract class DDProxyCommon implements IDDProxy { } @Override - public abstract boolean isClient(); + public World getDefWorld() { + return getWorldServer(0); //gets the client world dim 0 handler + } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/DDSavedData.java b/src/main/java/com/zixiken/dimdoors/shared/DDSavedData.java index 3a9699b4..ef6d0b72 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/DDSavedData.java +++ b/src/main/java/com/zixiken/dimdoors/shared/DDSavedData.java @@ -23,5 +23,4 @@ abstract class DDSavedData extends WorldSavedData { File saveDir = world.getSaveHandler().getWorldDirectory(); return new File(saveDir, "dimdoors/"); } - } diff --git a/src/main/java/com/zixiken/dimdoors/shared/EnumPocketType.java b/src/main/java/com/zixiken/dimdoors/shared/EnumPocketType.java index c92314cb..28a29401 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/EnumPocketType.java +++ b/src/main/java/com/zixiken/dimdoors/shared/EnumPocketType.java @@ -10,6 +10,7 @@ package com.zixiken.dimdoors.shared; * @author s101426 */ public enum EnumPocketType { + PRIVATE, PUBLIC, DUNGEON; static EnumPocketType getFromInt(int integer) { diff --git a/src/main/java/com/zixiken/dimdoors/shared/ModelManager.java b/src/main/java/com/zixiken/dimdoors/shared/ModelManager.java index 49f0ec0b..4cd6eda5 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/ModelManager.java +++ b/src/main/java/com/zixiken/dimdoors/shared/ModelManager.java @@ -13,7 +13,6 @@ import net.minecraftforge.client.model.ModelLoader; import static net.minecraft.item.Item.getItemFromBlock; -@SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"}) public class ModelManager { public static void registerModels() { @@ -60,7 +59,6 @@ public class ModelManager { new ModelResourceLocation(item.getRegistryName() + "_" + name, "inventory")); } - @SuppressWarnings("LocalVariableDeclarationSideOnly") public static void addCustomStateMappers() { StateMap map = new StateMap.Builder().ignore(BlockDoor.POWERED).build(); diff --git a/src/main/java/com/zixiken/dimdoors/shared/Pocket.java b/src/main/java/com/zixiken/dimdoors/shared/Pocket.java index 8ec2d9f6..30556eea 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/Pocket.java +++ b/src/main/java/com/zixiken/dimdoors/shared/Pocket.java @@ -27,7 +27,7 @@ import net.minecraft.world.WorldServer; */ public class Pocket { - private int ID; //this gets reset every server-load + private int id; //this gets reset every server-load private final int size; //in chunks 0 -> 1*1 chunk, 1 -> 2*2 chunks private final int depth; private final EnumPocketType typeID; // dungeon, pocket, or personal pocket @@ -46,11 +46,11 @@ public class Pocket { this.z = z; this.riftIDs = riftIDs; this.depthZeroLocation = depthZeroLocation; - playerUUIDs = new ArrayList(); + playerUUIDs = new ArrayList<>(); } public int getID() { - return ID; + return id; } public int getX() { @@ -77,15 +77,15 @@ public class Pocket { } public void setID(int newID) { - ID = newID; + id = newID; - //propagate this ID to the rifts in this pocket + //propagate this id to the rifts in this pocket for (int riftID : riftIDs) { Location riftLocation = RiftRegistry.INSTANCE.getRiftLocation(riftID); WorldServer worldServer = DimDoors.proxy.getWorldServer(riftLocation.getDimensionID()); if (!worldServer.isRemote) { DDTileEntityBase rift = (DDTileEntityBase) riftLocation.getTileEntity(); - rift.setPocket(this.ID, this.typeID); //set the rift's pocket ID to this pocket's pocket ID; + rift.setPocket(id, typeID); //set the rift's pocket id to this pocket's pocket id; } } } @@ -96,7 +96,7 @@ public class Pocket { EnumPocketType typeID = EnumPocketType.getFromInt(pocketNBT.getInteger("typeID")); int x = pocketNBT.getInteger("x"); int z = pocketNBT.getInteger("z"); - List riftIDs = new ArrayList(); + List riftIDs = new ArrayList<>(); NBTTagList doorsTagList = (NBTTagList) pocketNBT.getTag("doorIDs"); for (int i = 0; i < doorsTagList.tagCount(); i++) { int doorID = doorsTagList.getIntAt(i); @@ -106,7 +106,7 @@ public class Pocket { Pocket pocket = new Pocket(size, depth, typeID, x, z, riftIDs, depthZeroLocation); - pocket.setID(pocketNBT.getInteger("ID")); //basically re-register the pocket + pocket.setID(pocketNBT.getInteger("id")); //basically re-register the pocket NBTTagList playersTagList = (NBTTagList) pocketNBT.getTag("playerUUIDs"); for (int i = 0; i < playersTagList.tagCount(); i++) { String playerUUID = playersTagList.getStringTagAt(i); @@ -117,7 +117,7 @@ public class Pocket { static NBTBase writeToNBT(Pocket pocket) { NBTTagCompound pocketNBT = new NBTTagCompound(); - pocketNBT.setInteger("ID", pocket.ID); + pocketNBT.setInteger("id", pocket.id); pocketNBT.setInteger("size", pocket.size); pocketNBT.setInteger("depth", pocket.depth); pocketNBT.setInteger("typeID", pocket.typeID.getIntValue()); @@ -150,7 +150,7 @@ public class Pocket { int riftID = riftIDs.get(i); //DimDoors.log(Pocket.class, "findWarpDoorIndex: i = " + i + " riftID = " + riftID); //for troubleshooting purposes TileEntity tileEntity = RiftRegistry.INSTANCE.getRiftLocation(riftID).getTileEntity(); - if (tileEntity != null && tileEntity instanceof TileEntityDimDoorWarp) { + if (tileEntity instanceof TileEntityDimDoorWarp) { index = i; break; } @@ -195,17 +195,11 @@ public class Pocket { boolean isLocationWithinPocketBounds(final Location location, final int gridSize) { int locX = location.getPos().getX(); int locZ = location.getPos().getY(); - //minimum bounds of the pocket - int pocX = x * gridSize; - int pocZ = z * gridSize; - if (pocX <= locX && pocZ <= locZ) { - //convert to maximum bounds of the pocket - pocX = pocX + (size + 1) * 16; - pocZ = pocZ + (size + 1) * 16; - if (locX < pocX && locZ < pocZ) { - return true; - } - } - return false; + // pocket bounds + int pocMinX = x * gridSize; + int pocMinZ = z * gridSize; + int pocMaxX = pocMinX + (size + 1) * 16; + int pocMaxZ = pocMinX + (size + 1) * 16; + return pocMinX <= locX && pocMinZ <= locZ && locX < pocMaxX && locZ < pocMaxZ; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/PocketRegistry.java b/src/main/java/com/zixiken/dimdoors/shared/PocketRegistry.java index 7f89dc96..58150b3c 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/PocketRegistry.java +++ b/src/main/java/com/zixiken/dimdoors/shared/PocketRegistry.java @@ -7,7 +7,7 @@ package com.zixiken.dimdoors.shared; import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.DimDoors; -import com.zixiken.dimdoors.shared.util.DDRandomUtils; +import com.zixiken.dimdoors.shared.util.RandomUtils; import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import java.util.ArrayList; import java.util.HashMap; @@ -38,16 +38,16 @@ public class PocketRegistry { // Methods private PocketRegistry() { - nextUnusedIDs = new HashMap(); + nextUnusedIDs = new HashMap<>(); for (EnumPocketType pocketType : EnumPocketType.values()) { nextUnusedIDs.put(pocketType, 0); } - privatePockets = new HashMap(); - pocketLists = new HashMap(); + privatePockets = new HashMap<>(); + pocketLists = new HashMap<>(); for (EnumPocketType pocketType : EnumPocketType.values()) { - pocketLists.put(pocketType, new HashMap()); + pocketLists.put(pocketType, new HashMap<>()); } - pocketListsPerDepth = new ArrayList(); + pocketListsPerDepth = new ArrayList<>(); } public int getGridSize() { @@ -99,8 +99,8 @@ public class PocketRegistry { if (nbt.hasKey("privatePockets")) { NBTTagCompound privatePocketsTagCompound = nbt.getCompoundTag("privatePockets"); privatePockets.clear(); - for (String UUID : privatePocketsTagCompound.getKeySet()) { - privatePockets.put(UUID, privatePocketsTagCompound.getInteger(UUID)); + for (String uuid : privatePocketsTagCompound.getKeySet()) { + privatePockets.put(uuid, privatePocketsTagCompound.getInteger(uuid)); } } if (nbt.hasKey("pocketData")) { @@ -109,7 +109,7 @@ public class PocketRegistry { for (EnumPocketType pocketType : EnumPocketType.values()) { String tagListName = pocketType.toString(); if (pocketsTagCompound.hasKey(tagListName)) { - Map pocketList = new HashMap(); + Map pocketList = new HashMap<>(); NBTTagList pocketTagList = (NBTTagList) pocketsTagCompound.getTag(tagListName); for (int j = 0; j < pocketTagList.tagCount(); j++) { //@todo this defeats the purpose of a Map over a List (pocketList) NBTTagCompound pocketTag = pocketTagList.getCompoundTagAt(j); @@ -137,8 +137,8 @@ public class PocketRegistry { nbt.setTag("nextUnusedIDs", nextUnusedIDTagCompound); NBTTagCompound privatePocketsTagCompound = new NBTTagCompound(); - for (String UUID : privatePockets.keySet()) { - privatePocketsTagCompound.setInteger(UUID, privatePockets.get(UUID)); + for (String uuid : privatePockets.keySet()) { + privatePocketsTagCompound.setInteger(uuid, privatePockets.get(uuid)); } nbt.setTag("privatePockets", privatePocketsTagCompound); @@ -171,17 +171,11 @@ public class PocketRegistry { } } - public Pocket getPocket(int ID, EnumPocketType pocketType) { - return pocketLists.get(pocketType).get(ID); + public Pocket getPocket(int id, EnumPocketType pocketType) { + return pocketLists.get(pocketType).get(id); // TODO: null pointer } - public int getEntranceDoorIDOfNewPocket(EnumPocketType typeID, int depth, Location origRiftLocation) {//should return the riftID of the entrance door of the newly generated pocket - Pocket pocket = generateRandomPocketAt(typeID, depth, origRiftLocation); - int entranceDoorID = pocket.getEntranceDoorID(); - return entranceDoorID; - } - - private Pocket generateRandomPocketAt(EnumPocketType typeID, int depth, Location origRiftLocation) { + public Pocket generateRandomPocketAt(EnumPocketType typeID, int depth, Location origRiftLocation) { //Correcting the depth. Just in case... if (typeID == EnumPocketType.DUNGEON) { if (depth <= 0) { @@ -193,7 +187,7 @@ public class PocketRegistry { depth = 0; } - //Fetching the pocket template + // Fetch the pocket template PocketTemplate pocketTemplate = getRandomPocketTemplate(typeID, depth, maxPocketSize); return generatePocketAt(typeID, depth, origRiftLocation, pocketTemplate); @@ -206,12 +200,17 @@ public class PocketRegistry { int shortenedZ = shortenedLocation.getPos().getZ(); int dimID = shortenedLocation.getDimensionID(); Location depthZeroLocation; - if (typeID == EnumPocketType.DUNGEON) { - depthZeroLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), depth, origRiftLocation); - } else if (typeID == EnumPocketType.PUBLIC) { - depthZeroLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), 1, origRiftLocation); - } else { //PRIVATE - depthZeroLocation = origRiftLocation; + switch (typeID) { + case DUNGEON: + depthZeroLocation = RandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), depth, origRiftLocation); + break; + case PUBLIC: + depthZeroLocation = RandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), 1, origRiftLocation); + break; + case PRIVATE: + default: + depthZeroLocation = origRiftLocation; + break; } Pocket pocket = pocketTemplate.place(shortenedX, 0, shortenedZ, gridSize, dimID, nextUnusedIDs.get(typeID), depth, typeID, depthZeroLocation); @@ -222,7 +221,7 @@ public class PocketRegistry { public int getPrivateDimDoorID(String playerUUID) { if (!privatePockets.containsKey(playerUUID)) { //generate a new private pocket - int doorID = getEntranceDoorIDOfNewPocket(EnumPocketType.PRIVATE, 0, new Location(0, 0, 0, 0)); //Location doesn't really matter in this case + int doorID = generateRandomPocketAt(EnumPocketType.PRIVATE, 0, new Location(0, 0, 0, 0)).getEntranceDoorID(); //Location doesn't really matter in this case privatePockets.put(playerUUID, doorID); return doorID; } @@ -239,17 +238,16 @@ public class PocketRegistry { z = 0; } else { int radius = (int) Math.sqrt(nextUnusedID); //casting to int rounds down the double resulting from taking the square root - int radiusNumber = nextUnusedID - (radius * radius); - double splitter = ((double) radiusNumber) / ((double) radius); //always between 0 and 2 - DimDoors.log(this.getClass(), "id is " + nextUnusedID); - DimDoors.log(this.getClass(), "Radius is " + radius); - DimDoors.log(this.getClass(), "Radius number is " + radiusNumber); - DimDoors.log(this.getClass(), "Splitter is " + splitter); + int radiusNumber = nextUnusedID - radius * radius; + double splitter = (double) radiusNumber / (double) radius; //always between 0 and 2 + DimDoors.log(getClass(), "id is " + nextUnusedID); + DimDoors.log(getClass(), "Radius is " + radius); + DimDoors.log(getClass(), "Radius number is " + radiusNumber); + DimDoors.log(getClass(), "Splitter is " + splitter); x = splitter <= 1.0 ? radius : radius - (radiusNumber - radius); z = splitter >= 1.0 ? radius : radiusNumber; } - Location location = new Location(dimID, x, y, z); - return location; + return new Location(dimID, x, y, z); } private PocketTemplate getRandomPocketTemplate(EnumPocketType typeID, int depth, int maxPocketSize) { @@ -333,20 +331,13 @@ public class PocketRegistry { } public boolean isPlayerAllowedToBeHere(final EntityPlayerMP player, final Location location) { - if (player.isCreative()) { + int pocketID = getPocketIDFromCoords(location); + if (pocketID < 0) { // not in a pocket dimension return true; } else { - int pocketID = getPocketIDFromCoords(location); - if (pocketID < 0) { //not in a pocket dimension - return true; - } else { - EnumPocketType type = DimDoorDimensions.getPocketType(location.getDimensionID()); - Pocket pocket = pocketLists.get(type).get(pocketID); - if (pocket.isPlayerAllowedInPocket(player) && pocket.isLocationWithinPocketBounds(location, gridSize)) { - return true; - } - return false; - } + EnumPocketType type = DimDoorDimensions.getPocketType(location.getDimensionID()); + Pocket pocket = pocketLists.get(type).get(pocketID); + return pocket.isPlayerAllowedInPocket(player) && pocket.isLocationWithinPocketBounds(location, gridSize); } } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/PocketSavedData.java b/src/main/java/com/zixiken/dimdoors/shared/PocketSavedData.java index ecff4cec..9931cd62 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/PocketSavedData.java +++ b/src/main/java/com/zixiken/dimdoors/shared/PocketSavedData.java @@ -43,21 +43,21 @@ public class PocketSavedData extends DDSavedData { } @Override - public NBTTagCompound writeToNBT(NBTTagCompound pocketnbt) { + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagCompound pockets = new NBTTagCompound(); PocketRegistry.INSTANCE.writeToNBT(pockets); - pocketnbt.setTag("pockets", pockets); + nbt.setTag("pockets", pockets); - return pocketnbt; + return nbt; } @Override - public void readFromNBT(NBTTagCompound pocketnbt) { + public void readFromNBT(NBTTagCompound nbt) { // Load NBT - if (pocketnbt != null) { - if (pocketnbt.hasKey("pockets")) { - NBTTagCompound pockets = pocketnbt.getCompoundTag("pockets"); + if (nbt != null) { + if (nbt.hasKey("pockets")) { + NBTTagCompound pockets = nbt.getCompoundTag("pockets"); PocketRegistry.INSTANCE.readFromNBT(pockets); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/PocketTemplate.java b/src/main/java/com/zixiken/dimdoors/shared/PocketTemplate.java index c24ce0bc..fd9e508e 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/PocketTemplate.java +++ b/src/main/java/com/zixiken/dimdoors/shared/PocketTemplate.java @@ -94,11 +94,11 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff public Pocket place(int shortenedX, int yBase, int shortenedZ, int gridSize, int dimID, int pocketID, int depth, EnumPocketType pocketTypeID, Location depthZeroLocation) { //returns the riftID of the entrance DimDoor int xBase = shortenedX * gridSize * 16; int zBase = shortenedZ * gridSize * 16; - DimDoors.log(this.getClass(), "Placing new pocket at x = " + xBase + ", z = " + zBase); - DimDoors.log(this.getClass(), "Name of new pocket schematic is " + schematic.getSchematicName()); + DimDoors.log(getClass(), "Placing new pocket at x = " + xBase + ", z = " + zBase); + DimDoors.log(getClass(), "Name of new pocket schematic is " + schematic.getSchematicName()); if (schematic == null) { - DimDoors.log(this.getClass(), "The schematic for variant " + variantName + " somehow didn't load correctly despite all precautions."); + DimDoors.log(getClass(), "The schematic for variant " + variantName + " somehow didn't load correctly despite all precautions."); return null; } //@todo make sure that the door tile entities get registered! @@ -116,14 +116,14 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff } //Load TileEntity Data - List rifts = new ArrayList(); + List rifts = new ArrayList<>(); for (NBTTagCompound tileEntityNBT : schematic.getTileEntities()) { BlockPos pos = new BlockPos(xBase + tileEntityNBT.getInteger("x"), yBase + tileEntityNBT.getInteger("y"), zBase + tileEntityNBT.getInteger("z")); - DimDoors.log(this.getClass(), "Re-loading tile-entity at blockPos: " + pos.toString()); + DimDoors.log(getClass(), "Re-loading tile-entity at blockPos: " + pos); TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity != null) { if (tileEntity instanceof DDTileEntityBase) { - DimDoors.log(this.getClass(), "Rift found in schematic: " + pos.toString()); + DimDoors.log(getClass(), "Rift found in schematic: " + pos); DDTileEntityBase rift = (DDTileEntityBase) tileEntity; rifts.add(rift); if (rift instanceof TileEntityDimDoor) { @@ -133,7 +133,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff try { tileEntity.readFromNBT(tileEntityNBT); //this reads in the wrong blockPos } catch(Exception e) { - DimDoors.warn(this.getClass(), "Loading in the data for TileEntity of type " + tileEntity.toString() + " went wrong. Details: " + e.getLocalizedMessage()); + DimDoors.warn(getClass(), "Loading in the data for TileEntity of type " + tileEntity + " went wrong. Details: " + e.getLocalizedMessage()); } } tileEntity.setPos(pos); //correct the position @@ -141,7 +141,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff } } - List riftIDs = new ArrayList(); + List riftIDs = new ArrayList<>(); for (DDTileEntityBase rift : rifts) { rift.register(depth); rift.setIsInPocket(); diff --git a/src/main/java/com/zixiken/dimdoors/shared/RiftRegistry.java b/src/main/java/com/zixiken/dimdoors/shared/RiftRegistry.java index 6aba351f..803b24b3 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/RiftRegistry.java +++ b/src/main/java/com/zixiken/dimdoors/shared/RiftRegistry.java @@ -5,10 +5,10 @@ */ package com.zixiken.dimdoors.shared; +import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorUnstable; import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.shared.tileentities.DDTileEntityBase; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorChaos; import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorPersonal; import java.util.ArrayList; import java.util.HashMap; @@ -44,12 +44,12 @@ public class RiftRegistry { // Methods private RiftRegistry() { nextRiftID = 0; - rifts = new HashMap(); - personalDoors = new ArrayList(); //@todo read from and write to NBT - unpairedRifts = new ArrayList(); - unpairedRiftsPerDepth = new ArrayList(); + rifts = new HashMap<>(); + personalDoors = new ArrayList<>(); //@todo read from and write to NBT + unpairedRifts = new ArrayList<>(); + unpairedRiftsPerDepth = new ArrayList<>(); for (int i = 0; i <= maximumDungeonDepth; i++) { - unpairedRiftsPerDepth.add(new ArrayList()); + unpairedRiftsPerDepth.add(new ArrayList<>()); } } @@ -103,7 +103,7 @@ public class RiftRegistry { NBTTagList riftListsNBT = (NBTTagList) nbt.getTag("unpairedDepthRiftList"); maximumDungeonDepth = riftListsNBT.tagCount(); //makes sure both are synched for (int i = 0; i < riftListsNBT.tagCount(); i++) { - unpairedRiftsPerDepth.add(new ArrayList()); + unpairedRiftsPerDepth.add(new ArrayList<>()); NBTTagList riftsNBT = (NBTTagList) riftListsNBT.get(i); for (int j = 0; j < riftsNBT.tagCount(); j++) { NBTTagCompound riftTag = riftsNBT.getCompoundTagAt(j); @@ -160,15 +160,15 @@ public class RiftRegistry { public int registerNewRift(DDTileEntityBase rift, final int depth) { Location riftLocation = Location.getLocation(rift); final int assignedID = nextRiftID; - DimDoors.log(this.getClass(), "Starting registering rift as ID: " + assignedID); + DimDoors.log(getClass(), "Starting registering rift as ID: " + assignedID); rifts.put(assignedID, riftLocation); - if (rift instanceof TileEntityDimDoorPersonal || rift instanceof TileEntityDimDoorChaos) { + if (rift instanceof TileEntityDimDoorPersonal || rift instanceof TileEntityDimDoorUnstable) { if (rift instanceof TileEntityDimDoorPersonal) { personalDoors.add(assignedID); } } else { - DimDoors.log(this.getClass(), "Registering rift in unpairedRiftRegistry. ID = " + assignedID + " at depth: " + depth); + DimDoors.log(getClass(), "Registering rift in unpairedRiftRegistry. ID = " + assignedID + " at depth: " + depth); unpairedRifts.add(assignedID); registerUnpairedRiftAtDepth(assignedID, depth); } @@ -179,13 +179,13 @@ public class RiftRegistry { } public void unregisterRift(int riftID) { - DimDoors.log(this.getClass(), "unregistering rift " + riftID); + DimDoors.log(getClass(), "unregistering rift " + riftID); unpair(riftID); unRegisterUnpairedRiftAtDepth(riftID); //@todo, will this crash if it doesn't find that value? unpairedRifts.remove((Integer) riftID); personalDoors.remove((Integer) riftID); - rifts.remove((Integer) riftID); + rifts.remove(riftID); RiftSavedData.get(DimDoors.getDefWorld()).markDirty(); //Notify that this needs to be saved on world save } @@ -206,15 +206,15 @@ public class RiftRegistry { void unRegisterUnpairedRiftAtDepth(DDTileEntityBase rift) { int depth = rift.getDepth(); - DimDoors.log(this.getClass(), "unregistering rift "+ rift.getRiftID() + " as unpaired at depth " + depth); + DimDoors.log(getClass(), "unregistering rift "+ rift.getRiftID() + " as unpaired at depth " + depth); if (depth < maximumDungeonDepth) { List unpairedRiftListAtDepth = unpairedRiftsPerDepth.get(depth); unpairedRiftListAtDepth.remove((Integer) rift.getRiftID()); } } - public Location getRiftLocation(int ID) { - return rifts.get(ID); + public Location getRiftLocation(int id) { + return rifts.get(id); } public void pair(int riftID, int riftID2) { @@ -223,12 +223,12 @@ public class RiftRegistry { } Location location = rifts.get(riftID); TileEntity tileEntity = location.getTileEntity(); //@todo this method might need to be in another class? - if (tileEntity != null && tileEntity instanceof DDTileEntityBase) { + if (tileEntity instanceof DDTileEntityBase) { DDTileEntityBase rift = (DDTileEntityBase) tileEntity; - DimDoors.log(this.getClass(), "RiftRegistry trying to connect rift " + riftID + " to rift " + riftID2 + "."); + DimDoors.log(getClass(), "RiftRegistry trying to connect rift " + riftID + " to rift " + riftID2 + "."); boolean alreadyPaired = rift.pair(riftID2); if (!alreadyPaired) { - DimDoors.log(this.getClass(), "RiftRegistry unregistering rift " + riftID + " from unPairedRiftRegistry."); + DimDoors.log(getClass(), "RiftRegistry unregistering rift " + riftID + " from unPairedRiftRegistry."); unpairedRifts.remove((Integer) riftID); unRegisterUnpairedRiftAtDepth(riftID); } @@ -241,10 +241,10 @@ public class RiftRegistry { } Location location = rifts.get(riftID); if (location == null) { - DimDoors.warn(this.getClass(), "RiftID with null location: rift " + riftID); + DimDoors.warn(getClass(), "RiftID with null location: rift " + riftID); } else { TileEntity tileEntity = location.getTileEntity(); - if (tileEntity != null && tileEntity instanceof DDTileEntityBase) { + if (tileEntity instanceof DDTileEntityBase) { DDTileEntityBase rift = (DDTileEntityBase) tileEntity; boolean alreadyUnPaired = rift.unpair(); if (!alreadyUnPaired) { @@ -264,15 +264,15 @@ public class RiftRegistry { } public boolean teleportEntityToRift(Entity entity, int pairedRiftID) { //@todo implement this code in the sending rift tiles instead - DimDoors.log(this.getClass(), "RiftID of rift that the entity trying to teleport to is " + pairedRiftID + "."); + DimDoors.log(getClass(), "RiftID of rift that the entity trying to teleport to is " + pairedRiftID + "."); if (pairedRiftID < 0) { - DimDoors.warn(this.getClass(), "RiftID of rift that entity " + entity + " is trying to teleport to seems to be lower than 0 and it shouldn't."); + DimDoors.warn(getClass(), "RiftID of rift that entity " + entity + " is trying to teleport to seems to be lower than 0 and it shouldn't."); return false; } Location destinationRiftLocation = getRiftLocation(pairedRiftID); DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity(); if (destinationRift == null) { - DimDoors.warn(this.getClass(), "The rift that an entity is trying to teleport to seems to be null."); + DimDoors.warn(getClass(), "The rift that an entity is trying to teleport to seems to be null."); } return TeleporterDimDoors.instance().teleport(entity, destinationRift.getTeleportTargetLocation()); } @@ -298,7 +298,7 @@ public class RiftRegistry { int returnID = -1; //After using a command to generate a particular schematic as a pocket to be the next non-random Golden (and randomly Iron) Dimdoor destination - if (this.lastGeneratedEntranceDoorID != -1) { + if (lastGeneratedEntranceDoorID != -1) { returnID = lastGeneratedEntranceDoorID; lastGeneratedEntranceDoorID = -1; return returnID; @@ -308,15 +308,14 @@ public class RiftRegistry { List rifts = unpairedRiftsPerDepth.get(depth); int numberOfUnpairedRifts = rifts.size(); if (numberOfUnpairedRifts > 1) { - DimDoors.log(this.getClass(), "There's more than 1 unpaired rift at this depth."); + DimDoors.log(getClass(), "There's more than 1 unpaired rift at this depth."); Random random = new Random(); - int indexOforigRiftID = -1; int randomRiftIDIndex; boolean origRiftIsOnSameDepth = rifts.contains(origRiftID); if (origRiftIsOnSameDepth) { - indexOforigRiftID = rifts.indexOf(origRiftID); + int indexOfOrigRiftID = rifts.indexOf(origRiftID); randomRiftIDIndex = random.nextInt(numberOfUnpairedRifts - 1); //-1 because we do not want to include the key of the original rift, so it will not randomly pair to itself - if (randomRiftIDIndex >= indexOforigRiftID) { + if (randomRiftIDIndex >= indexOfOrigRiftID) { randomRiftIDIndex++; } } else { @@ -325,7 +324,7 @@ public class RiftRegistry { returnID = rifts.get(randomRiftIDIndex); } } - DimDoors.log(this.getClass(), "Rift to pair to was chosen: returnID = " + returnID); + DimDoors.log(getClass(), "Rift to pair to was chosen: returnID = " + returnID); return returnID; } @@ -377,7 +376,7 @@ public class RiftRegistry { } public int getRandomNonPersonalRiftID() { - List nonPersonalRiftIDs = new ArrayList(rifts.keySet()); + List nonPersonalRiftIDs = new ArrayList<>(rifts.keySet()); for (int persRiftID : personalDoors) { //DimDoors.log(this.getClass(), "Removing personal rift: " + persRiftID + " from nonPersonalRiftIDs. nPRI size = " + nonPersonalRiftIDs.size()); nonPersonalRiftIDs.remove((Integer) persRiftID); @@ -393,13 +392,13 @@ public class RiftRegistry { public Location getTeleportLocation(int riftId) { if (riftId < 0) { - DimDoors.warn(this.getClass(), "RiftID of rift that entity is trying to teleport to seems to be lower than 0 and it shouldn't."); + DimDoors.warn(getClass(), "RiftID of rift that entity is trying to teleport to seems to be lower than 0 and it shouldn't."); return null; } Location destinationRiftLocation = getRiftLocation(riftId); DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity(); if (destinationRift == null) { - DimDoors.warn(this.getClass(), "The rift that an entity is trying to teleport to seems to be null. RiftID: " + riftId + ". Expecting to crash in 3... 2... 1.."); + DimDoors.warn(getClass(), "The rift that an entity is trying to teleport to seems to be null. RiftID: " + riftId + ". Expecting to crash in 3... 2... 1.."); } return destinationRift.getTeleportTargetLocation(); } @@ -409,7 +408,7 @@ public class RiftRegistry { Location riftLocation = getRiftLocation(riftID); if (riftLocation != null) { TileEntity tileEntity = riftLocation.getTileEntity(); - if (tileEntity != null && tileEntity instanceof DDTileEntityBase) { + if (tileEntity instanceof DDTileEntityBase) { DDTileEntityBase rift = (DDTileEntityBase) tileEntity; EntityPlayer player = (EntityPlayer) entity; rift.validatePlayerPocketEntry(player); @@ -434,9 +433,9 @@ public class RiftRegistry { } /** - * @param ID the lastGeneratedEntranceDoorID to set + * @param id the lastGeneratedEntranceDoorID to set */ - public void setLastGeneratedEntranceDoorID(int ID) { - this.lastGeneratedEntranceDoorID = ID; + public void setLastGeneratedEntranceDoorID(int id) { + lastGeneratedEntranceDoorID = id; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/RiftSavedData.java b/src/main/java/com/zixiken/dimdoors/shared/RiftSavedData.java index e7af0f9f..1a770309 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/RiftSavedData.java +++ b/src/main/java/com/zixiken/dimdoors/shared/RiftSavedData.java @@ -43,21 +43,21 @@ public class RiftSavedData extends DDSavedData { } @Override - public NBTTagCompound writeToNBT(NBTTagCompound riftnbt) { + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagCompound rifts = new NBTTagCompound(); RiftRegistry.INSTANCE.writeToNBT(rifts); - riftnbt.setTag("rifts", rifts); + nbt.setTag("rifts", rifts); - return riftnbt; + return nbt; } @Override - public void readFromNBT(NBTTagCompound riftnbt) { + public void readFromNBT(NBTTagCompound nbt) { // Load NBT - if (riftnbt != null) { - if (riftnbt.hasKey("rifts")) { - NBTTagCompound rifts = riftnbt.getCompoundTag("rifts"); + if (nbt != null) { + if (nbt.hasKey("rifts")) { + NBTTagCompound rifts = nbt.getCompoundTag("rifts"); RiftRegistry.INSTANCE.readFromNBT(rifts); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java b/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java index e9de7b2c..3df4479b 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java +++ b/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import net.minecraft.nbt.NBTTagCompound; @@ -46,21 +45,19 @@ public class SchematicHandler { private PocketTemplate personalPocketTemplate; private PocketTemplate publicPocketTemplate; private List dungeonTemplates; //@todo should this be a Map? Does it need to? It gets reloaded from scratch on ServerStart every time, so... - final private Map> dungeonNameMap = new HashMap(); + final private Map> dungeonNameMap = new HashMap<>(); //@todo, sort templates by depth over here? that'd mean that that doesn't have to be done on pocket placement each and every time PocketTemplate getRandomDungeonPocketTemplate(int depth, int maxPocketSize) { //@todo maxPocketSize is passed for no reason at all here; pockets exceeding maxPocketSize have not been loaded in the first place... - List validTemplates = new ArrayList(); + List validTemplates = new ArrayList<>(); int totalWeight = 0; for (PocketTemplate template : dungeonTemplates) { - if (template.getMinDepth() > depth || template.getMaxDepth() < depth) { - //do nothing - } else { + if (depth >= template.getMinDepth() && depth <= template.getMaxDepth()) { validTemplates.add(template); totalWeight += template.getWeight(depth); } } - DimDoors.log(this.getClass(), "depth = " + depth + ". totalWeight = " + totalWeight); + DimDoors.log(getClass(), "depth = " + depth + ". totalWeight = " + totalWeight); Random random = new Random(); int chosenTemplatePointer = random.nextInt(totalWeight); @@ -70,14 +67,14 @@ public class SchematicHandler { return template; } } - DimDoors.warn(this.getClass(), "No valid dungeon could be chosen for this depth. What have you done to make this happen? Now crashing:"); + DimDoors.warn(getClass(), "No valid dungeon could be chosen for this depth. What have you done to make this happen? Now crashing:"); return null; } public void loadSchematics() { personalPocketTemplate = loadTemplatesFromJson("default_private", PocketRegistry.INSTANCE.getPrivatePocketSize()).get(0); publicPocketTemplate = loadTemplatesFromJson("default_public", PocketRegistry.INSTANCE.getPublicPocketSize()).get(0); - dungeonTemplates = new ArrayList(); + dungeonTemplates = new ArrayList<>(); List dungeonSchematicNameStrings = DDConfig.getDungeonSchematicNames(); int maxPocketSize = PocketRegistry.INSTANCE.getMaxPocketSize(); for (String nameString : dungeonSchematicNameStrings) { @@ -112,7 +109,7 @@ public class SchematicHandler { bufferedMap = dungeonNameMap.get(dirName); bufferedMap.put(template.getName(), dungeonTemplates.indexOf(template)); } else { - bufferedMap = new HashMap(); + bufferedMap = new HashMap<>(); bufferedMap.put(template.getName(), dungeonTemplates.indexOf(template)); dungeonNameMap.put(dirName, bufferedMap); } @@ -143,7 +140,7 @@ public class SchematicHandler { IOUtils.copy(jsonJarStream, writer, StandardCharsets.UTF_8); } catch (IOException ex) { Logger.getLogger(SchematicHandler.class.getName()).log(Level.SEVERE, "Json-file " + nameString + ".json did not load correctly from jar. Skipping loading of this template.", ex); - return new ArrayList(); + return new ArrayList<>(); } jsonString = writer.toString(); } else if (jsonFile.exists()) { @@ -152,11 +149,11 @@ public class SchematicHandler { jsonString = readFile(jsonFile.getAbsolutePath(), StandardCharsets.UTF_8); } catch (IOException ex) { Logger.getLogger(SchematicHandler.class.getName()).log(Level.SEVERE, "Json-file " + nameString + ".json did not load correctly from config folder. Skipping loading of this template.", ex); - return new ArrayList(); + return new ArrayList<>(); } } else { DimDoors.warn(SchematicHandler.class, "Json-file " + nameString + ".json was not found in the jar or config directory. Skipping loading of this template."); - return new ArrayList(); + return new ArrayList<>(); } JsonParser parser = new JsonParser(); JsonElement jsonElement = parser.parse(jsonString); @@ -245,10 +242,10 @@ public class SchematicHandler { final EnumPocketType pocketType = EnumPocketType.getFromInt(jsonTemplate.get("pocketType").getAsInt()); final JsonArray variations = jsonTemplate.getAsJsonArray("variations"); - List pocketTemplates = new ArrayList(); + List pocketTemplates = new ArrayList<>(); JsonObject chosenVariation = null; //only applicable if jsonType == "Singular" int chosenVariationSize = -1; //only applicable if jsonType == "Singular" - List validVariations = new ArrayList(); + List validVariations = new ArrayList<>(); //put all valid variation JsonObjects into an array list for (int i = 0; i < variations.size(); i++) { JsonObject variation = variations.get(i).getAsJsonObject(); @@ -321,11 +318,11 @@ public class SchematicHandler { } public ArrayList getDungeonTemplateGroups() { - return new ArrayList(dungeonNameMap.keySet()); + return new ArrayList<>(dungeonNameMap.keySet()); } public ArrayList getDungeonTemplateNames(String directory) { - return new ArrayList(dungeonNameMap.get(directory).keySet()); + return new ArrayList<>(dungeonNameMap.get(directory).keySet()); } /** diff --git a/src/main/java/com/zixiken/dimdoors/shared/TeleporterDimDoors.java b/src/main/java/com/zixiken/dimdoors/shared/TeleporterDimDoors.java index 5333d24f..cd001e1a 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/TeleporterDimDoors.java +++ b/src/main/java/com/zixiken/dimdoors/shared/TeleporterDimDoors.java @@ -4,9 +4,7 @@ import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.DimDoors; import java.util.EnumSet; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.play.server.SPacketChangeGameState; import net.minecraft.network.play.server.SPacketEntityEffect; import net.minecraft.network.play.server.SPacketPlayerAbilities; import net.minecraft.util.math.BlockPos; @@ -16,6 +14,7 @@ import net.minecraft.network.play.server.SPacketPlayerPosLook; import net.minecraft.network.play.server.SPacketRespawn; import net.minecraft.potion.PotionEffect; import net.minecraft.server.management.PlayerList; +import net.minecraftforge.fml.common.FMLCommonHandler; //ref: https://github.com/WayofTime/BloodMagic/blob/1.11/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java public class TeleporterDimDoors extends Teleporter { @@ -31,7 +30,7 @@ public class TeleporterDimDoors extends Teleporter { } @Override - public boolean makePortal(Entity entity) { + public boolean makePortal(Entity entityIn) { return true; } @@ -53,7 +52,7 @@ public class TeleporterDimDoors extends Teleporter { } @Override - public void placeInPortal(Entity entity, float rotationYaw) { + public void placeInPortal(Entity entityIn, float rotationYaw) { } public boolean teleport(Entity entity, Location location) { //@todo add float playerRotationYaw as a parameter @@ -81,7 +80,7 @@ public class TeleporterDimDoors extends Teleporter { int oldDimID = entity.dimension; WorldServer oldWorldserver = DimDoors.proxy.getWorldServer(oldDimID); WorldServer newWorldserver = DimDoors.proxy.getWorldServer(newDimID); - if (entity instanceof EntityPlayer) { + if (entity instanceof EntityPlayerMP) { // TODO: this was EntityPlayer, but I changed this to EntityPlayerMP because that's what the cast assumes DimDoors.log(TeleporterDimDoors.class, "Teleporting Player to new dimension."); EntityPlayerMP player = (EntityPlayerMP) entity; float playerRotationYaw = player.rotationYaw; //@todo make this a parameter? @@ -104,7 +103,7 @@ public class TeleporterDimDoors extends Teleporter { oldWorldserver.profiler.startSection("placing"); if (player.isEntityAlive()) { - DimDoors.log(this.getClass(), "Placing the player entity at " + pos.toString()); + DimDoors.log(getClass(), "Placing the player entity at " + pos); player.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, playerRotationYaw, player.rotationPitch); player.motionX = 0; player.motionZ = 0; @@ -125,7 +124,7 @@ public class TeleporterDimDoors extends Teleporter { for (PotionEffect potioneffect : player.getActivePotionEffects()) { player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect)); } - net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimID, newDimID); + FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimID, newDimID); } else { DimDoors.log(TeleporterDimDoors.class, "Teleporting non-Player to new dimension."); @@ -138,7 +137,7 @@ public class TeleporterDimDoors extends Teleporter { private void teleportLocal(Entity entity, BlockPos pos) { WorldServer worldserver = (WorldServer) entity.world; - if (entity instanceof EntityPlayer) { + if (entity instanceof EntityPlayerMP) { // TODO: this was EntityPlayer, but I changed this to EntityPlayerMP because that's what the cast assumes DimDoors.log(TeleporterDimDoors.class, "Teleporting Player within same dimension."); EntityPlayerMP player = (EntityPlayerMP) entity; @@ -150,7 +149,7 @@ public class TeleporterDimDoors extends Teleporter { worldserver.profiler.startSection("moving"); player.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, playerRotationYaw, player.rotationPitch); //playerList.preparePlayer(player, worldserver); //This makes the player stutter heavily on teleport - player.connection.setPlayerLocation(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, playerRotationYaw, player.rotationPitch, EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class + player.connection.setPlayerLocation(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, playerRotationYaw, player.rotationPitch, EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class )); worldserver.profiler.endSection(); player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities)); diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorBase.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorBase.java index 2eb32669..902ff61b 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorBase.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorBase.java @@ -32,36 +32,36 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT } @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { - IBlockState down = world.getBlockState(pos.down()); - if (!world.isRemote && down.getBlock() == this) { //should only teleport when colliding with top part of the door to prevent double teleportation from being triggered + public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { + IBlockState down = worldIn.getBlockState(pos.down()); + if (!worldIn.isRemote && down.getBlock() == this) { //should only teleport when colliding with top part of the door to prevent double teleportation from being triggered if (down.getValue(BlockDoor.OPEN) - && entity instanceof EntityPlayer //@todo remove this so any entity can go through? - && (entity.timeUntilPortal < 1) //to prevent the player from teleporting all over the place we have a 50-tick cooldown - && isEntityFacingDoor(down, (EntityLivingBase) entity)) { - this.toggleDoor(world, pos, false); - enterDimDoor(world, pos, entity); + && entityIn instanceof EntityPlayer //@todo remove this so any entity can go through? + && entityIn.timeUntilPortal < 1 //to prevent the player from teleporting all over the place we have a 50-tick cooldown + && isEntityFacingDoor(down, (EntityLivingBase) entityIn)) { + toggleDoor(worldIn, pos, false); + enterDimDoor(worldIn, pos, entityIn); } } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - if (!checkCanOpen(world, pos, player)) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (!checkCanOpen(worldIn, pos, playerIn)) { return false; } if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) { pos = pos.down(); - state = world.getBlockState(pos); + state = worldIn.getBlockState(pos); } if (state.getBlock() != this) { return false; } else { state = state.cycleProperty(BlockDoor.OPEN); - world.setBlockState(pos, state, 2); - world.markBlockRangeForRenderUpdate(pos, pos.up()); - world.playEvent(player, (state.getValue(OPEN)) ? this.getOpenSound() : this.getCloseSound(), pos, 0); + worldIn.setBlockState(pos, state, 2); + worldIn.markBlockRangeForRenderUpdate(pos, pos.up()); + worldIn.playEvent(playerIn, state.getValue(OPEN) ? getOpenSound() : getCloseSound(), pos, 0); return true; } } @@ -73,9 +73,8 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT //Called to update the render information on the tile entity. Could probably implement a data watcher, //but this works fine and is more versatile I think. - public BlockDimDoorBase updateAttachedTile(World world, BlockPos pos) { + public void updateAttachedTile(World world, BlockPos pos) { DimDoors.proxy.updateDoorTE(this, world, pos); - return this; } @Override @@ -84,8 +83,8 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT } @Override - public void updateTick(World par1World, BlockPos pos, IBlockState state, Random rand) { - updateAttachedTile(par1World, pos); + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + updateAttachedTile(worldIn, pos); } /** @@ -95,25 +94,25 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT @Override @SideOnly(Side.CLIENT) public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { - return new ItemStack(this.getItemDoor(), 1, 0); + return new ItemStack(getItemDoor(), 1, 0); } /** * Returns the ID of the items to drop on destruction. */ @Override - public Item getItemDropped(IBlockState state, Random random, int fortune) { - return isUpperDoorBlock(state) ? null : this.getItemDoor(); + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return isUpperDoorBlock(state) ? null : getItemDoor(); } @Override @SideOnly(Side.CLIENT) - public ItemStack getItem(World world, BlockPos pos, IBlockState state) { - return new ItemStack(this.getItemDoor(), 1, 0); + public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { + return new ItemStack(getItemDoor(), 1, 0); } @Override - public TileEntity createNewTileEntity(World world, int metadata) { //gets called upon world load as well + public TileEntity createNewTileEntity(World worldIn, int meta) { //gets called upon world load as well return new TileEntityDimDoor(); } @@ -136,16 +135,16 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT // Although any entity has the proper fields for this check, // we should only apply it to living entities since things // like Minecarts might come in backwards. - return (state.getValue(BlockDoor.FACING) == EnumFacing.fromAngle(entity.rotationYaw)); + return state.getValue(BlockDoor.FACING) == EnumFacing.fromAngle(entity.rotationYaw); } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) { + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { DDTileEntityBase origRift = null; boolean isTopHalf = state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER; boolean shouldPlaceRift = false; if (isTopHalf) { - origRift = (DDTileEntityBase) world.getTileEntity(pos); + origRift = (DDTileEntityBase) worldIn.getTileEntity(pos); if (origRift.isPaired()) { shouldPlaceRift = true; RiftRegistry.INSTANCE.setLastChangedRift(origRift); //@todo this is a crude workaround @@ -153,10 +152,10 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT RiftRegistry.INSTANCE.unregisterRift(origRift.getRiftID()); } } - super.breakBlock(world, pos, state); + super.breakBlock(worldIn, pos, state); if (shouldPlaceRift) { - world.setBlockState(pos, ModBlocks.RIFT.getDefaultState()); - DDTileEntityBase newRift = (DDTileEntityBase) world.getTileEntity(pos); + worldIn.setBlockState(pos, ModBlocks.RIFT.getDefaultState()); + DDTileEntityBase newRift = (DDTileEntityBase) worldIn.getTileEntity(pos); newRift.loadDataFrom(origRift); //@todo this does not work here, or does it? } } @@ -183,20 +182,18 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT } private boolean canPlaceBottomAt(IBlockState state) { - return (state.equals(Blocks.AIR) || state.getMaterial().isReplaceable()); + return state.equals(Blocks.AIR) || state.getMaterial().isReplaceable(); } private boolean canPlaceTopAt(IBlockState state) { - return (state.getBlock() == ModBlocks.RIFT || state.equals(Blocks.AIR) || state.getMaterial().isReplaceable()); + return state.getBlock() == ModBlocks.RIFT || state.equals(Blocks.AIR) || state.getMaterial().isReplaceable(); } - protected int getCloseSound() - { - return this.blockMaterial == Material.IRON ? 1011 : 1012; + protected int getCloseSound() { + return blockMaterial == Material.IRON ? 1011 : 1012; } - protected int getOpenSound() - { - return this.blockMaterial == Material.IRON ? 1005 : 1006; + protected int getOpenSound() { + return blockMaterial == Material.IRON ? 1005 : 1006; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorGold.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorGold.java index 420c025d..5efa8046 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorGold.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorGold.java @@ -26,8 +26,7 @@ public class BlockDimDoorGold extends BlockDimDoorBase { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityDimDoorGold(); } - } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorPersonal.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorPersonal.java index 3c418a63..e9e5a233 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorPersonal.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorPersonal.java @@ -26,8 +26,7 @@ public class BlockDimDoorPersonal extends BlockDimDoorBase { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityDimDoorPersonal(); } - } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorUnstable.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorUnstable.java index aa63f36b..8ad705b6 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorUnstable.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorUnstable.java @@ -2,7 +2,7 @@ package com.zixiken.dimdoors.shared.blocks; import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.shared.items.ModItems; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorChaos; +import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorUnstable; import java.util.Random; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -30,12 +30,12 @@ public class BlockDimDoorUnstable extends BlockDimDoorBase { } @Override - public Item getItemDropped(IBlockState state, Random random, int fortune) { + public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Items.IRON_DOOR; } @Override - public TileEntity createNewTileEntity(World world, int metadata) { - return new TileEntityDimDoorChaos(); + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new TileEntityDimDoorUnstable(); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorWarp.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorWarp.java index 1284f402..14b53248 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorWarp.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDimDoorWarp.java @@ -26,7 +26,7 @@ public class BlockDimDoorWarp extends BlockDimDoorBase { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityDimDoorWarp(); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDoorQuartz.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDoorQuartz.java index 6470929b..061c3349 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDoorQuartz.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockDoorQuartz.java @@ -33,7 +33,7 @@ public class BlockDoorQuartz extends BlockDoor { @Override @SideOnly(Side.CLIENT) - public ItemStack getItem(World world, BlockPos pos, IBlockState state) { + public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return new ItemStack(ModItems.QUARTZ_DOOR); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockFabric.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockFabric.java index e4532285..c6fc11af 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockFabric.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockFabric.java @@ -1,12 +1,11 @@ package com.zixiken.dimdoors.shared.blocks; -import java.util.List; import java.util.Random; import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.shared.DDConfig; import com.zixiken.dimdoors.shared.TeleporterDimDoors; -import com.zixiken.dimdoors.shared.util.DDRandomUtils; +import com.zixiken.dimdoors.shared.util.RandomUtils; import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.world.limbodimension.LimboDecay; import com.zixiken.dimdoors.shared.world.limbodimension.WorldProviderLimbo; @@ -30,20 +29,18 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nullable; - @SuppressWarnings("deprecation") public class BlockFabric extends Block { public static final String ID = "fabric"; - public static final PropertyEnum TYPE = PropertyEnum.create("type", BlockFabric.EnumType.class); + public static final PropertyEnum TYPE = PropertyEnum.create("type", BlockFabric.EnumType.class); private static final float SUPER_HIGH_HARDNESS = 10000000000000F; private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F; public BlockFabric() { super(Material.IRON); - this.setCreativeTab(DimDoors.dimDoorsCreativeTab); + setCreativeTab(DimDoors.dimDoorsCreativeTab); setLightLevel(1.0F); setHardness(0.1F); setUnlocalizedName(ID); @@ -73,11 +70,11 @@ public class BlockFabric extends Block { } @Override - public float getBlockHardness(IBlockState state, World world, BlockPos pos) { - if (state.getValue(TYPE).equals(EnumType.ANCIENT) || state.getValue(TYPE).equals(EnumType.ETERNAL)) { + public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) { + if (blockState.getValue(TYPE).equals(EnumType.ANCIENT) || blockState.getValue(TYPE).equals(EnumType.ETERNAL)) { return SUPER_HIGH_HARDNESS; } else { - return this.blockHardness; + return blockHardness; } } @@ -103,9 +100,9 @@ public class BlockFabric extends Block { @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(CreativeTabs tab, NonNullList subItems) { + public void getSubBlocks(CreativeTabs itemIn, NonNullList items) { for(BlockFabric.EnumType type : EnumType.values()) { - subItems.add(new ItemStack(this, 1)); + items.add(new ItemStack(this, 1)); } } @@ -120,7 +117,7 @@ public class BlockFabric extends Block { } @Override - public int quantityDropped(Random par1Random) { + public int quantityDropped(Random random) { return 0; } @@ -128,12 +125,12 @@ public class BlockFabric extends Block { * replaces the block clicked with the held block, instead of placing the * block on top of it. Shift click to disable. * - * @param world the world that this block is in + * @param worldIn the world that this block is in * @param pos the position this block is at * @param state the state this block is in - * @param player the player right-clicking the block + * @param playerIn the player right-clicking the block * @param hand the hand the player is using - * @param side the side of the block that is being clicked + * @param facing the side of the block that is being clicked * @param hitX the x coordinate of the exact place the player is clicking on * the block * @param hitY the y coordinate ... @@ -142,22 +139,22 @@ public class BlockFabric extends Block { * not? */ @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack heldItem = player.getHeldItem(hand); + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack heldItem = playerIn.getHeldItem(hand); - if (heldItem != null && heldItem.getItem() instanceof ItemBlock + if (heldItem.getItem() instanceof ItemBlock && (state.getValue(TYPE).equals(EnumType.REALITY) || state.getValue(TYPE).equals(EnumType.ALTERED))) { Block block = Block.getBlockFromItem(heldItem.getItem()); if (!state.isNormalCube() || block.hasTileEntity(block.getDefaultState()) || block == this //this also keeps it from being replaced by Ancient Fabric - || player.isSneaking()) { + || playerIn.isSneaking()) { return false; } - if (!world.isRemote) { //@todo on a server, returning false or true determines where the block gets placed? - if (!player.isCreative()) { + if (!worldIn.isRemote) { //@todo on a server, returning false or true determines where the block gets placed? + if (!playerIn.isCreative()) { heldItem.setCount(heldItem.getCount()-1); } - world.setBlockState(pos, block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, heldItem.getMetadata(), player)); //choosing getStateForPlacement over getDefaultState, because it will cause directional blocks, like logs to rotate correctly + worldIn.setBlockState(pos, block.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, heldItem.getMetadata(), playerIn)); //choosing getStateForPlacement over getDefaultState, because it will cause directional blocks, like logs to rotate correctly } return true; } @@ -178,33 +175,33 @@ public class BlockFabric extends Block { } public String toString() { - return this.name; + return name; } @Override public String getName() { - return this.name; + return name; } } @Override - public void onEntityWalk(World world, BlockPos pos, Entity entity) { - IBlockState state = world.getBlockState(pos); - if (state.getValue(TYPE) == EnumType.ETERNAL && world.provider instanceof WorldProviderLimbo && entity instanceof EntityPlayer) { - Location origLocation = new Location(world, pos); - Location transFormedLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), DDConfig.getMaxDungeonDepth(), origLocation); + public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) { + IBlockState state = worldIn.getBlockState(pos); + if (state.getValue(TYPE) == EnumType.ETERNAL && worldIn.provider instanceof WorldProviderLimbo && entityIn instanceof EntityPlayer) { + Location origLocation = new Location(worldIn, pos); + Location transFormedLocation = RandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), DDConfig.getMaxDungeonDepth(), origLocation); BlockPos correctedPos = DimDoors.proxy.getWorldServer(0).getTopSolidOrLiquidBlock(transFormedLocation.getPos()); Location correctedLocation = new Location(0, correctedPos); - TeleporterDimDoors.instance().teleport(entity, correctedLocation); + TeleporterDimDoors.instance().teleport(entityIn, correctedLocation); } } @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { //if this creates more problems, because everything ticks, we should probably move this to its own class again + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { //if this creates more problems, because everything ticks, we should probably move this to its own class again //Make sure this block is unraveled fabric in Limbo - if (state.getValue(TYPE) == EnumType.UNRAVELED && world.provider instanceof WorldProviderLimbo) { - LimboDecay.applySpreadDecay(world, pos); + if (state.getValue(TYPE) == EnumType.UNRAVELED && worldIn.provider instanceof WorldProviderLimbo) { + LimboDecay.applySpreadDecay(worldIn, pos); } } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockRift.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockRift.java index 1bcddd4d..536e8098 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockRift.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockRift.java @@ -35,7 +35,6 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("deprecation") public class BlockRift extends Block implements ITileEntityProvider { - private static final float MIN_IMMUNE_RESISTANCE = 5000.0F; public static final String ID = "rift"; private final ArrayList blocksImmuneToRift; // List of Vanilla blocks immune to rifts @@ -48,7 +47,7 @@ public class BlockRift extends Block implements ITileEntityProvider { setUnlocalizedName(ID); setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); - modBlocksImmuneToRift = new ArrayList(); + modBlocksImmuneToRift = new ArrayList<>(); modBlocksImmuneToRift.add(ModBlocks.FABRIC); modBlocksImmuneToRift.add(ModBlocks.DIMENSIONAL_DOOR); modBlocksImmuneToRift.add(ModBlocks.WARP_DIMENSIONAL_DOOR); @@ -61,7 +60,7 @@ public class BlockRift extends Block implements ITileEntityProvider { modBlocksImmuneToRift.add(ModBlocks.PERSONAL_DIMENSIONAL_DOOR); modBlocksImmuneToRift.add(ModBlocks.QUARTZ_DOOR); - blocksImmuneToRift = new ArrayList(); + blocksImmuneToRift = new ArrayList<>(); blocksImmuneToRift.add(Blocks.LAPIS_BLOCK); blocksImmuneToRift.add(Blocks.IRON_BLOCK); blocksImmuneToRift.add(Blocks.GOLD_BLOCK); @@ -85,7 +84,7 @@ public class BlockRift extends Block implements ITileEntityProvider { } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return null; } @@ -104,7 +103,7 @@ public class BlockRift extends Block implements ITileEntityProvider { * coordinates. Args: blockAccess, x, y, z, side */ @Override - public boolean isSideSolid(IBlockState base_state, IBlockAccess worldIn, BlockPos pos, EnumFacing side) { + public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) { return false; } @@ -137,7 +136,7 @@ public class BlockRift extends Block implements ITileEntityProvider { */ @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World worldIn, BlockPos pos, Random rand) { + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { //ArrayList targets = findReachableBlocks(worldIn, pos, 2, false); //TODO: implement the parts specified in the method comment? int x = pos.getX(), y = pos.getY(), z = pos.getZ(); @@ -170,10 +169,7 @@ public class BlockRift extends Block implements ITileEntityProvider { // may have low hardness to make them easier to build with. However, block.getExplosionResistance() // is designed to receive an entity, the source of the blast. We have no entity so // I've set this to access blockResistance directly. Might need changing later. - return block != null - /*&& - (block >= MIN_IMMUNE_RESISTANCE*/ || modBlocksImmuneToRift.contains(block) - || blocksImmuneToRift.contains(block); + return block != null /* && block >= MIN_IMMUNE_RESISTANCE */ || modBlocksImmuneToRift.contains(block) || blocksImmuneToRift.contains(block); } public boolean isModBlockImmune(World world, BlockPos pos) { @@ -194,21 +190,21 @@ public class BlockRift extends Block implements ITileEntityProvider { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityRift(); } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) { - TileEntityRift riftTile = (TileEntityRift) world.getTileEntity(pos); + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + TileEntityRift riftTile = (TileEntityRift) worldIn.getTileEntity(pos); if (riftTile == null || !riftTile.placingDoorOnRift) { - DimDoors.log(this.getClass(), "Unregistering rift at position " + pos.toString() + ", because it is destroyed (creative) or has closed."); + DimDoors.log(getClass(), "Unregistering rift at position " + pos + ", because it is destroyed (creative) or has closed."); RiftRegistry.INSTANCE.unregisterLastChangedRift(); } else { - DimDoors.log(this.getClass(), "Not unregistering rift at position " + pos.toString() + ", because it is being replaced by a door."); + DimDoors.log(getClass(), "Not unregistering rift at position " + pos + ", because it is being replaced by a door."); riftTile.placingDoorOnRift = false; //probably not needed, but it shouldn't hurt to do this } - world.removeTileEntity(pos); + worldIn.removeTileEntity(pos); } @Override diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockTransTrapdoor.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockTransTrapdoor.java index 232ee580..a2fe95ec 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockTransTrapdoor.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/BlockTransTrapdoor.java @@ -31,7 +31,7 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile public BlockTransTrapdoor() { super(Material.WOOD); - this.setCreativeTab(DimDoors.dimDoorsCreativeTab); + setCreativeTab(DimDoors.dimDoorsCreativeTab); setHardness(1.0F); setUnlocalizedName(ID); setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); @@ -40,12 +40,12 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile //Teleports the player to the exit link of that dimension, assuming it is a pocket @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { - enterDimDoor(world, pos, entity); + public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { + enterDimDoor(worldIn, pos, entityIn); } public boolean checkCanOpen(World world, BlockPos pos) { - return this.checkCanOpen(world, pos, null); + return checkCanOpen(world, pos, null); } public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) { @@ -53,15 +53,15 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { return checkCanOpen(worldIn, pos, playerIn) - && super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ); + && super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); } @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock, BlockPos fromPos) { + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if (checkCanOpen(worldIn, pos)) { - super.neighborChanged(state, worldIn, pos, neighborBlock, fromPos); + super.neighborChanged(state, worldIn, pos, blockIn, fromPos); } } @@ -77,18 +77,18 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityTransTrapdoor(); } @Override @SideOnly(Side.CLIENT) public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { - return new ItemStack(this.getItemDoor(), 1, 0); + return new ItemStack(getItemDoor(), 1, 0); } @Override - public Item getItemDropped(IBlockState state, Random random, int fortuneLevel) { + public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(Blocks.TRAPDOOR); } @@ -107,9 +107,9 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) { + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { // This function runs on the server side after a block is replaced // We MUST call super.breakBlock() since it involves removing tile entities - super.breakBlock(world, pos, state); + super.breakBlock(worldIn, pos, state); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/IDimDoor.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/IDimDoor.java index 2b350880..c0a45b15 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/IDimDoor.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/IDimDoor.java @@ -27,5 +27,4 @@ public interface IDimDoor { * @return */ public boolean isDoorOnRift(World world, BlockPos pos); - } diff --git a/src/main/java/com/zixiken/dimdoors/shared/blocks/ModBlocks.java b/src/main/java/com/zixiken/dimdoors/shared/blocks/ModBlocks.java index 71bec6ac..e148e336 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/blocks/ModBlocks.java +++ b/src/main/java/com/zixiken/dimdoors/shared/blocks/ModBlocks.java @@ -7,34 +7,35 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ModBlocks { // Regular doors - public final static BlockDoorGold GOLD_DOOR = new BlockDoorGold(); - public final static BlockDoorQuartz QUARTZ_DOOR = new BlockDoorQuartz(); + public static final BlockDoorGold GOLD_DOOR = new BlockDoorGold(); + public static final BlockDoorQuartz QUARTZ_DOOR = new BlockDoorQuartz(); // Dimensional doors - public final static BlockDimDoor DIMENSIONAL_DOOR = new BlockDimDoor(); - public final static BlockDimDoorGold GOLD_DIMENSIONAL_DOOR = new BlockDimDoorGold(); - public final static BlockDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new BlockDimDoorPersonal(); - public final static BlockDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new BlockDimDoorUnstable(); - public final static BlockDimDoorTransient TRANSIENT_DIMENSIONAL_DOOR = new BlockDimDoorTransient(); - public final static BlockDimDoorWarp WARP_DIMENSIONAL_DOOR = new BlockDimDoorWarp(); - public final static BlockTransTrapdoor DIMENSIONAL_TRAPDOOR = new BlockTransTrapdoor(); + public static final BlockDimDoor DIMENSIONAL_DOOR = new BlockDimDoor(); + public static final BlockDimDoorGold GOLD_DIMENSIONAL_DOOR = new BlockDimDoorGold(); + public static final BlockDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new BlockDimDoorPersonal(); + public static final BlockDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new BlockDimDoorUnstable(); + public static final BlockDimDoorTransient TRANSIENT_DIMENSIONAL_DOOR = new BlockDimDoorTransient(); + public static final BlockDimDoorWarp WARP_DIMENSIONAL_DOOR = new BlockDimDoorWarp(); + public static final BlockTransTrapdoor DIMENSIONAL_TRAPDOOR = new BlockTransTrapdoor(); // Blocks - public final static BlockFabric FABRIC = new BlockFabric(); - public final static BlockRift RIFT = new BlockRift(); + public static final BlockFabric FABRIC = new BlockFabric(); + public static final BlockRift RIFT = new BlockRift(); @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { - event.getRegistry().register(QUARTZ_DOOR); - event.getRegistry().register(PERSONAL_DIMENSIONAL_DOOR); - event.getRegistry().register(GOLD_DOOR); - event.getRegistry().register(GOLD_DIMENSIONAL_DOOR); - event.getRegistry().register(UNSTABLE_DIMENSIONAL_DOOR); - event.getRegistry().register(WARP_DIMENSIONAL_DOOR); - event.getRegistry().register(DIMENSIONAL_DOOR); - event.getRegistry().register(DIMENSIONAL_TRAPDOOR); - event.getRegistry().register(FABRIC); - event.getRegistry().register(TRANSIENT_DIMENSIONAL_DOOR); - event.getRegistry().register(RIFT); + event.getRegistry().registerAll( + GOLD_DOOR, + QUARTZ_DOOR, + DIMENSIONAL_DOOR, + GOLD_DIMENSIONAL_DOOR, + PERSONAL_DIMENSIONAL_DOOR, + UNSTABLE_DIMENSIONAL_DOOR, + TRANSIENT_DIMENSIONAL_DOOR, + WARP_DIMENSIONAL_DOOR, + DIMENSIONAL_TRAPDOOR, + FABRIC, + RIFT); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/commands/PocketCommand.java b/src/main/java/com/zixiken/dimdoors/shared/commands/PocketCommand.java index d4adcaac..1a69dffd 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/commands/PocketCommand.java +++ b/src/main/java/com/zixiken/dimdoors/shared/commands/PocketCommand.java @@ -2,8 +2,7 @@ package com.zixiken.dimdoors.shared.commands; import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.shared.*; -import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor; -import com.zixiken.dimdoors.shared.util.DDStringUtils; +import com.zixiken.dimdoors.shared.util.StringUtils; import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import net.minecraft.command.CommandBase; @@ -24,7 +23,6 @@ public class PocketCommand extends CommandBase { public PocketCommand() { aliases = new ArrayList<>(); - aliases.add("dimpocket"); } @@ -45,11 +43,10 @@ public class PocketCommand extends CommandBase { @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { - if (sender instanceof EntityPlayerMP) { EntityPlayerMP player = getCommandSenderAsPlayer(sender); if (areArgumentsValid(args, player)) { - DimDoors.log(this.getClass(), "Executing command"); + DimDoors.log(getClass(), "Executing command"); BlockPos pos = player.getPosition(); World world = player.world; @@ -69,23 +66,19 @@ public class PocketCommand extends CommandBase { RiftRegistry.INSTANCE.setLastGeneratedEntranceDoorID(entranceDoorID); } } else { - DimDoors.log(this.getClass(), "Not executing command, because it wasn't sent by a player."); + DimDoors.log("Not executing command /" + getName() + " because it wasn't sent by a player."); } } @Override - public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { - List list = new ArrayList(); - if (args == null || args.length < 2) { //counts an empty ("") argument as an argument as well... + public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { + List list = new ArrayList<>(); + if (args.length < 2) { //counts an empty ("") argument as an argument as well... list = SchematicHandler.INSTANCE.getDungeonTemplateGroups(); - list = DDStringUtils.getMatchingStrings(args[0], list, false); + list = StringUtils.getMatchingStrings(args[0], list, false); } else if (args.length == 2) { list = SchematicHandler.INSTANCE.getDungeonTemplateNames(args[0]); - list = DDStringUtils.getMatchingStrings(args[1], list, false); - } else if (args.length == 3) { - list.add("Remove_this"); - } else { - list.add("No_seriously"); + list = StringUtils.getMatchingStrings(args[1], list, false); } return list; } diff --git a/src/main/java/com/zixiken/dimdoors/shared/commands/TeleportCommand.java b/src/main/java/com/zixiken/dimdoors/shared/commands/TeleportCommand.java index 5b878e52..5645fee3 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/commands/TeleportCommand.java +++ b/src/main/java/com/zixiken/dimdoors/shared/commands/TeleportCommand.java @@ -1,7 +1,8 @@ package com.zixiken.dimdoors.shared.commands; +import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.shared.TeleporterDimDoors; -import com.zixiken.dimdoors.shared.util.DDStringUtils; +import com.zixiken.dimdoors.shared.util.StringUtils; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; @@ -11,6 +12,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.DimensionManager; public class TeleportCommand extends CommandBase { @@ -19,7 +21,6 @@ public class TeleportCommand extends CommandBase { public TeleportCommand() { aliases = new ArrayList<>(); - aliases.add("dimteleport"); } @@ -40,19 +41,27 @@ public class TeleportCommand extends CommandBase { @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { - int id = Integer.parseInt(args[0]); + int id; + try { + id = Integer.parseInt(args[0]); + } catch (ArrayIndexOutOfBoundsException|NumberFormatException e) { + sender.sendMessage(new TextComponentString("[DimDoors] Incorrect usage.")); + return; + } if (sender instanceof EntityPlayerMP) { server.getPlayerList().transferPlayerToDimension((EntityPlayerMP) sender, id, TeleporterDimDoors.instance()); + } else { + DimDoors.log("Not executing command /" + getName() + " because it wasn't sent by a player."); } } @Override - public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { - List list = new ArrayList(); - if (args == null || args.length < 2) { //counts an empty ("") argument as an argument as well... - list = DDStringUtils.getAsStringList(DimensionManager.getIDs()); - list = DDStringUtils.getMatchingStrings(args[0], list, false); + public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { + List list = new ArrayList<>(); + if (args.length < 2) { //counts an empty ("") argument as an argument as well... + list = StringUtils.getAsStringList(DimensionManager.getIDs()); + list = StringUtils.getMatchingStrings(args[0], list, false); } return list; } diff --git a/src/main/java/com/zixiken/dimdoors/shared/entities/MobMonolith.java b/src/main/java/com/zixiken/dimdoors/shared/entities/MobMonolith.java index be804a48..68a77fae 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/entities/MobMonolith.java +++ b/src/main/java/com/zixiken/dimdoors/shared/entities/MobMonolith.java @@ -1,11 +1,9 @@ package com.zixiken.dimdoors.shared.entities; -import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.server.sound.DDSounds; import com.zixiken.dimdoors.shared.DDConfig; import com.zixiken.dimdoors.shared.TeleporterDimDoors; import com.zixiken.dimdoors.shared.util.Location; -import com.zixiken.dimdoors.shared.world.PocketProvider; import com.zixiken.dimdoors.shared.world.limbodimension.WorldProviderLimbo; import com.zixiken.dimdoors.shared.world.pocketdimension.WorldProviderDungeonPocket; import com.zixiken.dimdoors.shared.world.pocketdimension.WorldProviderPublicPocket; @@ -16,12 +14,10 @@ import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; -import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -31,15 +27,15 @@ import java.util.List; import static net.minecraft.network.datasync.DataSerializers.*; -public class MobMonolith extends EntityFlying implements IMob -{ +public class MobMonolith extends EntityFlying implements IMob { + private static final int MAX_AGGRO = 250; private static final int MAX_AGGRO_CAP = 100; private static final int MIN_AGGRO_CAP = 25; private static final int MAX_TEXTURE_STATE = 18; private static final int MAX_SOUND_COOLDOWN = 200; private static final int MAX_AGGRO_RANGE = 35; - private static final DataParameter AGGRO = EntityDataManager.createKey(MobMonolith.class, VARINT); + private static final DataParameter AGGRO = EntityDataManager.createKey(MobMonolith.class, VARINT); private static final float WIDTH = 3f; private static final float HEIGHT = 3f; @@ -53,9 +49,9 @@ public class MobMonolith extends EntityFlying implements IMob public MobMonolith(World world) { super(world); - this.setSize(WIDTH, HEIGHT); - this.noClip = true; - this.aggroCap = MathHelper.getInt(this.rand, MIN_AGGRO_CAP, MAX_AGGRO_CAP); + setSize(WIDTH, HEIGHT); + noClip = true; + aggroCap = MathHelper.getInt(rand, MIN_AGGRO_CAP, MAX_AGGRO_CAP); } public boolean isDangerous() { @@ -63,12 +59,12 @@ public class MobMonolith extends EntityFlying implements IMob } @Override - protected void damageEntity(DamageSource par1DamageSource, float par2) {} + protected void damageEntity(DamageSource damageSrc, float damageAmount) {} @Override - public boolean attackEntityFrom(DamageSource damageSource, float par2) { - if (damageSource != DamageSource.IN_WALL) { - this.aggro = MAX_AGGRO; + public boolean attackEntityFrom(DamageSource source, float amount) { + if (source != DamageSource.IN_WALL) { + aggro = MAX_AGGRO; } return false; } @@ -84,7 +80,7 @@ public class MobMonolith extends EntityFlying implements IMob } @Override - public AxisAlignedBB getCollisionBox(Entity par1Entity) { + public AxisAlignedBB getCollisionBox(Entity entityIn) { return null; } @@ -96,7 +92,7 @@ public class MobMonolith extends EntityFlying implements IMob @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(57005); + getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(57005); } @Override @@ -113,7 +109,7 @@ public class MobMonolith extends EntityFlying implements IMob protected void entityInit() { super.entityInit(); // Add a short for the aggro level - this.dataManager.register(AGGRO, 0); + dataManager.register(AGGRO, 0); } @Override @@ -125,8 +121,8 @@ public class MobMonolith extends EntityFlying implements IMob @Override public void onEntityUpdate() { // Remove this Monolith if it's not in Limbo or in a pocket dungeon TODO: any pocket dim? - if (!(this.world.provider instanceof WorldProviderLimbo || this.world.provider instanceof WorldProviderDungeonPocket)) { - this.setDead(); + if (!(world.provider instanceof WorldProviderLimbo || world.provider instanceof WorldProviderDungeonPocket)) { + setDead(); super.onEntityUpdate(); return; } @@ -134,15 +130,15 @@ public class MobMonolith extends EntityFlying implements IMob super.onEntityUpdate(); // Check for players and update aggro levels even if there are no players in range - EntityPlayer player = this.world.getClosestPlayerToEntity(this, MAX_AGGRO_RANGE); - boolean visibility = (player != null) && player.canEntityBeSeen(this); - this.updateAggroLevel(player, visibility); + EntityPlayer player = world.getClosestPlayerToEntity(this, MAX_AGGRO_RANGE); + boolean visibility = player != null && player.canEntityBeSeen(this); + updateAggroLevel(player, visibility); // Change orientation and face a player if one is in range if (player != null) { - this.facePlayer(player); - if (!this.world.isRemote && isDangerous()) + facePlayer(player); + if (!world.isRemote && isDangerous()) { // Play sounds on the server side, if the player isn't in Limbo. // Limbo is excluded to avoid drowning out its background music. @@ -156,12 +152,12 @@ public class MobMonolith extends EntityFlying implements IMob { // Only spawn particles on the client side and outside Limbo if (world.isRemote && isDangerous()) { - this.spawnParticles(player); + spawnParticles(player); } // Teleport the target player if various conditions are met if (aggro >= MAX_AGGRO && !world.isRemote && DDConfig.isMonolithTeleportationEnabled() && !player.capabilities.isCreativeMode && isDangerous()) { - this.aggro = 0; + aggro = 0; Location destination = WorldProviderLimbo.getLimboSkySpawn(player); TeleporterDimDoors.instance().teleport(player, destination); player.world.playSound(player, player.getPosition(), DDSounds.CRACK, SoundCategory.HOSTILE, 13, 1); @@ -173,15 +169,16 @@ public class MobMonolith extends EntityFlying implements IMob private void updateAggroLevel(EntityPlayer player, boolean visibility) { // If we're working on the server side, adjust aggro level // If we're working on the client side, retrieve aggro level from dataWatcher - if (!this.world.isRemote) { + if (!world.isRemote) { // Server side... // Rapidly increase the aggro level if this Monolith can see the player if (visibility) { if (world.provider instanceof WorldProviderLimbo) { - if (isDangerous()) + if (isDangerous()) { aggro++; - else + } else { aggro += 36; + } } else { // Aggro increases faster outside of Limbo aggro += 3; @@ -191,25 +188,25 @@ public class MobMonolith extends EntityFlying implements IMob if (aggro > aggroCap) { // Decrease aggro over time aggro--; - } else if (player != null && (aggro < aggroCap)) { + } else if (player != null && aggro < aggroCap) { // Increase aggro if a player is within range and aggro < aggroCap aggro++; } - } else + } else { aggro -= 3; + } } // Clamp the aggro level int maxAggro = isDangerous()?MAX_AGGRO:180; aggro = (short) MathHelper.clamp(aggro, 0, maxAggro); - this.dataManager.set(AGGRO, aggro); + dataManager.set(AGGRO, aggro); } else { // Client side... - aggro = this.dataManager.get(AGGRO); + aggro = dataManager.get(AGGRO); } } - public int getTextureState() - { + public int getTextureState() { // Determine texture state from aggro progress return MathHelper.clamp(MAX_TEXTURE_STATE * aggro / MAX_AGGRO, 0, MAX_TEXTURE_STATE); } @@ -220,22 +217,22 @@ public class MobMonolith extends EntityFlying implements IMob */ private void playSounds(EntityPlayer entityPlayer) { - float aggroPercent = this.getAggroProgress(); - if (this.soundTime <= 0) + float aggroPercent = getAggroProgress(); + if (soundTime <= 0) { playSound(DDSounds.MONK, 1F, 1F); - this.soundTime = 100; + soundTime = 100; } - if ((aggroPercent > 0.70) && this.soundTime < 100) + if (aggroPercent > 0.70 && soundTime < 100) { - world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + this.rand.nextGaussian())); - this.soundTime = 100 + this.rand.nextInt(75); + world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian())); + soundTime = 100 + rand.nextInt(75); } - if ((aggroPercent > 0.80) && this.soundTime < MAX_SOUND_COOLDOWN) { + if (aggroPercent > 0.80 && soundTime < MAX_SOUND_COOLDOWN) { world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 7, 1F); - this.soundTime = 250; + soundTime = 250; } - this.soundTime--; + soundTime--; } private void spawnParticles(EntityPlayer player) @@ -243,60 +240,56 @@ public class MobMonolith extends EntityFlying implements IMob int count = 10 * aggro / MAX_AGGRO; for (int i = 1; i < count; ++i) { - player.world.spawnParticle(EnumParticleTypes.PORTAL, player.posX + (this.rand.nextDouble() - 0.5D) * this.width, - player.posY + this.rand.nextDouble() * player.height - 0.75D, - player.posZ + (this.rand.nextDouble() - 0.5D) * player.width, - (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), - (this.rand.nextDouble() - 0.5D) * 2.0D); + player.world.spawnParticle(EnumParticleTypes.PORTAL, player.posX + (rand.nextDouble() - 0.5D) * width, + player.posY + rand.nextDouble() * player.height - 0.75D, + player.posZ + (rand.nextDouble() - 0.5D) * player.width, + (rand.nextDouble() - 0.5D) * 2.0D, -rand.nextDouble(), + (rand.nextDouble() - 0.5D) * 2.0D); } } public float getAggroProgress() { - return ((float) aggro) / MAX_AGGRO; + return (float) aggro / MAX_AGGRO; } private void facePlayer(EntityPlayer player) { - double d0 = player.posX - this.posX; - double d1 = player.posZ - this.posZ; - double d2 = (player.posY + player.getEyeHeight()) - (this.posY + this.getEyeHeight()); + double d0 = player.posX - posX; + double d1 = player.posZ - posZ; + double d2 = player.posY + player.getEyeHeight() - (posY + getEyeHeight()); double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1); float f2 = (float)(Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; - this.pitchLevel = (float) -((Math.atan(d2/d3) )* 180.0D / Math.PI); - this.rotationYaw = f2; - this.rotationYawHead = f2; - this.renderYawOffset = this.rotationYaw; + pitchLevel = (float) -(Math.atan(d2/d3) * 180.0D / Math.PI); + rotationYaw = f2; + rotationYawHead = f2; + renderYawOffset = rotationYaw; } @Override - public void writeEntityToNBT(NBTTagCompound rootTag) - { - super.writeEntityToNBT(rootTag); - rootTag.setInteger("Aggro", this.aggro); + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setInteger("Aggro", aggro); } @Override - public void readEntityFromNBT(NBTTagCompound rootTag) + public void readEntityFromNBT(NBTTagCompound nbt) { - super.readEntityFromNBT(rootTag); + super.readEntityFromNBT(nbt); // Load Monoliths with half aggro so they don't teleport players instantly - aggro = rootTag.getInteger("Aggro") / 2; + aggro = nbt.getInteger("Aggro") / 2; } @Override public boolean getCanSpawnHere() { - List list = world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15)); + List list = world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(posX -15, posY-4, posZ -15, posX +15, posY +15, posZ +15)); if (world.provider instanceof WorldProviderLimbo) { if(list.size() > 0) { return false; } - - } - else if(world.provider instanceof WorldProviderPublicPocket) - { + } else if(world.provider instanceof WorldProviderPublicPocket) { if (list.size() > 5 || world.canBlockSeeSky(new BlockPos(posX, posY, posZ))) { return false; } @@ -304,4 +297,4 @@ public class MobMonolith extends EntityFlying implements IMob return world.checkNoEntityCollision(getCollisionBoundingBox()) && world.getCollisionBoxes(this, getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(getCollisionBoundingBox()); } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/entities/ModelMobObelisk.java b/src/main/java/com/zixiken/dimdoors/shared/entities/ModelMobObelisk.java index 0afdead1..1a0a3914 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/entities/ModelMobObelisk.java +++ b/src/main/java/com/zixiken/dimdoors/shared/entities/ModelMobObelisk.java @@ -1,6 +1,5 @@ package com.zixiken.dimdoors.shared.entities; - import java.util.Random; import net.minecraftforge.fml.relauncher.Side; @@ -13,22 +12,24 @@ import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) public class ModelMobObelisk extends ModelBase { - ModelRenderer wholemonolith; + + ModelRenderer wholeMonolith; Random rand = new Random(); public ModelMobObelisk() { textureWidth = 256; textureHeight = 256; - wholemonolith = new ModelRenderer(this, 0, 0); - wholemonolith.addBox(-24F,-108F/1.3F, -6F, 48, 108, 12); + wholeMonolith = new ModelRenderer(this, 0, 0); + wholeMonolith.addBox(-24F,-108F/1.3F, -6F, 48, 108, 12); } @Override - public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - this.setRotationAngles(0, 0, 0, 0, 0,0, entity); + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + MobMonolith monolith = (MobMonolith) entityIn; - GL11.glScalef(((MobMonolith) entity).getRenderSizeModifier(), ((MobMonolith) entity).getRenderSizeModifier(), ((MobMonolith) entity).getRenderSizeModifier()); - wholemonolith.render(scale); + setRotationAngles(0, 0, 0, 0, 0,0, monolith); + GL11.glScalef(monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier()); + wholeMonolith.render(scale); } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/entities/RenderMobObelisk.java b/src/main/java/com/zixiken/dimdoors/shared/entities/RenderMobObelisk.java index c1ddfbb8..5c45000f 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/entities/RenderMobObelisk.java +++ b/src/main/java/com/zixiken/dimdoors/shared/entities/RenderMobObelisk.java @@ -5,8 +5,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.common.MinecraftForge; @@ -20,6 +18,7 @@ import java.util.List; @SideOnly(Side.CLIENT) public class RenderMobObelisk extends RenderLiving { + protected ModelMobObelisk obeliskModel; protected static final List monolith_textures = Arrays.asList( @@ -45,11 +44,11 @@ public class RenderMobObelisk extends RenderLiving { public RenderMobObelisk(RenderManager manager, float f) { super(manager, new ModelMobObelisk(), f); - this.obeliskModel = (ModelMobObelisk)this.mainModel; + obeliskModel = (ModelMobObelisk) mainModel; } @Override - public void doRender(MobMonolith monolith, double x, double y, double z, float par8, float par9) { + public void doRender(MobMonolith monolith, double x, double y, double z, float entityYaw, float partialTicks) { final float minScaling = 0; final float maxScaling = 0.1f; @@ -68,13 +67,13 @@ public class RenderMobObelisk extends RenderLiving { double zJitter = aggroScaling * Math.sin(1.3f * time) * Math.sin(0.7f * time); // Render with jitter - this.render(monolith, x + xJitter, y + yJitter, z + zJitter, par8, par9); + render(monolith, x + xJitter, y + yJitter, z + zJitter, entityYaw, partialTicks); //this.renderLeash(entity, x, y, z, par8, par9); } public void render(MobMonolith par1EntityLivingBase, double x, double y, double z, float par8, float par9) { - if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this, x, y, z))) return; + if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre<>(par1EntityLivingBase, this, 1, x, y, z))) return; GL11.glPushMatrix(); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); @@ -89,15 +88,15 @@ public class RenderMobObelisk extends RenderLiving { float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9; renderLivingAt(par1EntityLivingBase, x, y, z); - rotation = this.handleRotationFloat(par1EntityLivingBase, par9); - this.applyRotations(par1EntityLivingBase, rotation, interpolatedYaw, par9); + rotation = handleRotationFloat(par1EntityLivingBase, par9); + applyRotations(par1EntityLivingBase, rotation, interpolatedYaw, par9); float f6 = 0.0625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(-1.0F, -1.0F, 1.0F); - this.preRenderCallback(par1EntityLivingBase, par9); - GL11.glRotatef(((MobMonolith)par1EntityLivingBase).pitchLevel , 1.0F, 0.0F, 0.0F); + preRenderCallback(par1EntityLivingBase, par9); + GL11.glRotatef(par1EntityLivingBase.pitchLevel , 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.0F, 24.0F * f6 - 0.0078125F, 0.0F); @@ -108,8 +107,8 @@ public class RenderMobObelisk extends RenderLiving { OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } catch (Exception exception) { - exception.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); @@ -119,11 +118,11 @@ public class RenderMobObelisk extends RenderLiving { GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); - MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this, x, y, z)); + MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post<>(par1EntityLivingBase, this, 1, x, y, z)); } @Override protected ResourceLocation getEntityTexture(MobMonolith monolith) { return monolith_textures.get(monolith.getTextureState()); //return new ResourceLocation(DimDoors.MODID + ":textures/mobs/monolith/monolith" + monolith.getTextureState() + ".png"); } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemBlockFabric.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemBlockFabric.java index a48501e8..bdf0ecd6 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemBlockFabric.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemBlockFabric.java @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack; public class ItemBlockFabric extends ItemBlock { - private final static String[] subNames = {"_reality", "_ancient", "_altered", "_unraveled", "_eternal"}; + private static final String[] subNames = {"_reality", "_ancient", "_altered", "_unraveled", "_eternal"}; public ItemBlockFabric() { super(ModBlocks.FABRIC); @@ -19,12 +19,12 @@ public class ItemBlockFabric extends ItemBlock { } @Override - public int getMetadata(int damageValue) { - return damageValue; + public int getMetadata(int damage) { + return damage; } @Override public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + subNames[this.getDamage(stack)]; + return super.getUnlocalizedName() + subNames[getDamage(stack)]; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoor.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoor.java index 229069ee..5c9ea5e8 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoor.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoor.java @@ -24,7 +24,7 @@ public class ItemDimDoor extends ItemDoorBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { translateAndAdd("info.dimensional_door", tooltip); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorGold.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorGold.java index 64738f35..d8dc2bf1 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorGold.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorGold.java @@ -22,7 +22,7 @@ public class ItemDimDoorGold extends ItemDoorBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { translateAndAdd("info.gold_dimensional_door", tooltip); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorPersonal.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorPersonal.java index 1dc4d218..a6ed6f2a 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorPersonal.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorPersonal.java @@ -22,7 +22,7 @@ public class ItemDimDoorPersonal extends ItemDoorBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { translateAndAdd("info.quartz_dimensional_door", tooltip); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorUnstable.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorUnstable.java index b4506029..7e4c0454 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorUnstable.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorUnstable.java @@ -22,7 +22,7 @@ public class ItemDimDoorUnstable extends ItemDoorBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { translateAndAdd("info.unstable_dimensional_door", tooltip); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorWarp.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorWarp.java index 9ec5d22c..bbd6272d 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorWarp.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDimDoorWarp.java @@ -24,7 +24,7 @@ public class ItemDimDoorWarp extends ItemDoorBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { translateAndAdd("info.warp_dimensional_door", tooltip); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDoorBase.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDoorBase.java index 38922d4a..d1e98fc1 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemDoorBase.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemDoorBase.java @@ -18,14 +18,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraft.block.SoundType; -import static net.minecraft.item.ItemDoor.placeDoor; import net.minecraft.tileentity.TileEntity; public abstract class ItemDoorBase extends ItemDoor { // Maps non-dimensional door items to their corresponding dimensional door item // Also maps dimensional door items to themselves for simplicity - private static HashMap doorItemMapping = new HashMap(); + private static HashMap doorItemMapping = new HashMap<>(); /** * door represents the non-dimensional door this item is associated with. @@ -35,8 +34,8 @@ public abstract class ItemDoorBase extends ItemDoor { */ public ItemDoorBase(Block block, ItemDoor vanillaDoor) { super(block); - this.setMaxStackSize(64); - this.setCreativeTab(DimDoors.dimDoorsCreativeTab); + setMaxStackSize(64); + setCreativeTab(DimDoors.dimDoorsCreativeTab); doorItemMapping.put(this, this); //@todo Why? if (vanillaDoor != null) { @@ -45,7 +44,7 @@ public abstract class ItemDoorBase extends ItemDoor { } @Override - public abstract void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced); + public abstract void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn); /** * Overridden in subclasses to specify which door block that door item will @@ -57,16 +56,16 @@ public abstract class ItemDoorBase extends ItemDoor { //onItemUse gets fired before onItemRightClick and if it returns "success", onItemRightClick gets skipped. @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); - if (world.isRemote) { + if (worldIn.isRemote) { return new ActionResult<>(EnumActionResult.FAIL, stack); } - RayTraceResult hit = rayTrace(world, player, true); - if (RayTraceHelper.isRift(hit, world)) { + RayTraceResult hit = rayTrace(worldIn, playerIn, true); + if (RayTraceHelper.isRift(hit, worldIn)) { EnumActionResult canDoorBePlacedOnGroundBelowRift - = tryPlaceDoorOnTopOfBlock(stack, player, world, hit.getBlockPos().down(2), hand, + = tryPlaceDoorOnTopOfBlock(stack, playerIn, worldIn, hit.getBlockPos().down(2), handIn, (float) hit.hitVec.x, (float) hit.hitVec.y, (float) hit.hitVec.z); //stack may be changed by this method return new ActionResult<>(canDoorBePlacedOnGroundBelowRift, stack); } @@ -76,21 +75,21 @@ public abstract class ItemDoorBase extends ItemDoor { } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - if (world.isRemote) { + public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (worldIn.isRemote) { return EnumActionResult.SUCCESS; } - Block block = world.getBlockState(pos).getBlock(); - if (!block.isReplaceable(world, pos)) { - if (side != EnumFacing.UP) { + Block block = worldIn.getBlockState(pos).getBlock(); + if (!block.isReplaceable(worldIn, pos)) { + if (facing != EnumFacing.UP) { return EnumActionResult.FAIL; } } else { pos = pos.offset(EnumFacing.DOWN); //the bottom part of the door can replace this block, so we will try to place it on the block under it } - return tryPlaceDoorOnTopOfBlock(player.getHeldItem(hand), player, world, pos, hand, hitX, hitY, hitZ); + return tryPlaceDoorOnTopOfBlock(player.getHeldItem(hand), player, worldIn, pos, hand, hitX, hitY, hitZ); } //pos = position of block, the door gets placed on @@ -100,7 +99,7 @@ public abstract class ItemDoorBase extends ItemDoor { // return null, just as if the item was an unrecognized door type. ItemDoorBase mappedItem = doorItemMapping.get(stack.getItem()); if (mappedItem == null) { - DimDoors.warn(ItemDoorBase.class, "Item " + stack.getItem().toString() + " does not seem to have a valid mapped ItemDoor."); + DimDoors.warn(ItemDoorBase.class, "Item " + stack.getItem() + " does not seem to have a valid mapped ItemDoor."); return EnumActionResult.FAIL; } @@ -115,7 +114,7 @@ public abstract class ItemDoorBase extends ItemDoor { boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F; //Vanilla Minecraft code not consistently using EnumFacing //fetch "the" tile entity at the top block of where the door is going to be placed TileEntity possibleOldRift = world.getTileEntity(pos.up()); - if (possibleOldRift != null && possibleOldRift instanceof TileEntityRift) { + if (possibleOldRift instanceof TileEntityRift) { TileEntityRift oldRift = (TileEntityRift) possibleOldRift; oldRift.placingDoorOnRift = true; } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftBlade.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftBlade.java index bd975497..0012e476 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftBlade.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftBlade.java @@ -36,7 +36,7 @@ public class ItemRiftBlade extends ItemSword { @Override @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack par1ItemStack) { + public boolean hasEffect(ItemStack stack) { return true; } @@ -49,26 +49,26 @@ public class ItemRiftBlade extends ItemSword { } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); - if (world.isRemote) { + if (worldIn.isRemote) { return new ActionResult<>(EnumActionResult.FAIL, stack); } //SchematicHandler.Instance.getPersonalPocketTemplate().place(0, 20, 0, 20, 0, 0, 1, EnumPocketType.DUNGEON); //this line can be activated for testing purposes - RayTraceResult hit = rayTrace(world, player, true); - if (RayTraceHelper.isRift(hit, world)) { - TileEntityRift rift = (TileEntityRift) world.getTileEntity(hit.getBlockPos()); + RayTraceResult hit = rayTrace(worldIn, playerIn, true); + if (RayTraceHelper.isRift(hit, worldIn)) { + TileEntityRift rift = (TileEntityRift) worldIn.getTileEntity(hit.getBlockPos()); rift.isTeleporting = true; - rift.teleportingEntity = player; + rift.teleportingEntity = playerIn; - stack.damageItem(1, player); + stack.damageItem(1, playerIn); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } else if (RayTraceHelper.isLivingEntity(hit)) { - EnumActionResult teleportResult = TeleporterDimDoors.instance().teleport(player, new Location(world, hit.getBlockPos())) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; //@todo teleport to a location 1 or 2 blocks distance from the entity + EnumActionResult teleportResult = TeleporterDimDoors.instance().teleport(playerIn, new Location(worldIn, hit.getBlockPos())) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; //@todo teleport to a location 1 or 2 blocks distance from the entity if (teleportResult == EnumActionResult.SUCCESS) { - stack.damageItem(1, player); + stack.damageItem(1, playerIn); } return new ActionResult<>(teleportResult, stack); } @@ -77,7 +77,7 @@ public class ItemRiftBlade extends ItemSword { } @Override - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag advanced) { - DimDoors.translateAndAdd("info.rift_blade", list); + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + DimDoors.translateAndAdd("info.rift_blade", tooltip); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftConnectionTool.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftConnectionTool.java index e5c60d3e..b4982152 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftConnectionTool.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftConnectionTool.java @@ -30,19 +30,19 @@ public class ItemRiftConnectionTool extends ItemTool { public static final String ID = "rift_connection_tool"; ItemRiftConnectionTool() { - super(1.0F, -2.8F, ToolMaterial.WOOD, new HashSet()); + super(1.0F, -2.8F, ToolMaterial.WOOD, new HashSet<>()); //@todo add extra stuff? - this.setMaxDamage(16); + setMaxDamage(16); setCreativeTab(DimDoors.dimDoorsCreativeTab); setUnlocalizedName(ID); setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); - if (world.isRemote) { + if (worldIn.isRemote) { return new ActionResult<>(EnumActionResult.FAIL, stack); } if (!stack.hasTagCompound()) { @@ -51,14 +51,14 @@ public class ItemRiftConnectionTool extends ItemTool { stack.setTagCompound(compound); } - RayTraceResult hit = rayTrace(world, player, true); - if (RayTraceHelper.isAbstractRift(hit, world)) { - DDTileEntityBase rift = (DDTileEntityBase) world.getTileEntity(hit.getBlockPos()); - if (player.isSneaking()) { - return selectRift(stack, world, rift, player); //new ActionResult(EnumActionResult.PASS, stack)); + RayTraceResult hit = rayTrace(worldIn, playerIn, true); + if (RayTraceHelper.isAbstractRift(hit, worldIn)) { + DDTileEntityBase rift = (DDTileEntityBase) worldIn.getTileEntity(hit.getBlockPos()); + if (playerIn.isSneaking()) { + return selectRift(stack, worldIn, rift, playerIn); //new ActionResult(EnumActionResult.PASS, stack)); } } else { - return changeMode(stack, player); + return changeMode(stack, playerIn); } return new ActionResult<>(EnumActionResult.FAIL, stack); @@ -88,7 +88,7 @@ public class ItemRiftConnectionTool extends ItemTool { } stack.damageItem(1, playerIn); } - return new ActionResult(EnumActionResult.SUCCESS, stack); + return new ActionResult<>(EnumActionResult.SUCCESS, stack); } private ActionResult changeMode(ItemStack stack, EntityPlayer player) { diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftSignature.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftSignature.java index ba5613e0..966ef617 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftSignature.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemRiftSignature.java @@ -2,7 +2,6 @@ package com.zixiken.dimdoors.shared.items; import com.zixiken.dimdoors.DimDoors; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -16,14 +15,13 @@ public class ItemRiftSignature extends Item { public static final String ID = "rift_signature"; public ItemRiftSignature() { - super(); setCreativeTab(DimDoors.dimDoorsCreativeTab); setUnlocalizedName(ID); setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); } @Override - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag advanced) { - translateAndAdd("info.rift_signature.unbound", list); + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + translateAndAdd("info.rift_signature.unbound", tooltip); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemStableFabric.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemStableFabric.java index bdbcd3a6..6950f01f 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemStableFabric.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemStableFabric.java @@ -9,7 +9,6 @@ public class ItemStableFabric extends Item { public static final String ID = "stable_fabric"; public ItemStableFabric() { - super(); setCreativeTab(DimDoors.dimDoorsCreativeTab); setUnlocalizedName(ID); setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ItemWorldThread.java b/src/main/java/com/zixiken/dimdoors/shared/items/ItemWorldThread.java index 8b377e4d..55189add 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ItemWorldThread.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ItemWorldThread.java @@ -9,7 +9,6 @@ public class ItemWorldThread extends Item { public static final String ID = "world_thread"; public ItemWorldThread() { - super(); setCreativeTab(DimDoors.dimDoorsCreativeTab); setUnlocalizedName(ID); setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); diff --git a/src/main/java/com/zixiken/dimdoors/shared/items/ModItems.java b/src/main/java/com/zixiken/dimdoors/shared/items/ModItems.java index e8703ecf..22328459 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/items/ModItems.java +++ b/src/main/java/com/zixiken/dimdoors/shared/items/ModItems.java @@ -9,44 +9,43 @@ import com.zixiken.dimdoors.shared.blocks.ModBlocks; public class ModItems { // Regular doors - public final static ItemDoorGold GOLD_DOOR = new ItemDoorGold(); - public final static ItemDoorQuartz QUARTZ_DOOR = new ItemDoorQuartz(); + public static final ItemDoorGold GOLD_DOOR = new ItemDoorGold(); + public static final ItemDoorQuartz QUARTZ_DOOR = new ItemDoorQuartz(); // Dimensional doors - public final static ItemDimDoor DIMENSIONAL_DOOR = new ItemDimDoor(); - public final static ItemDimDoorGold GOLD_DIMENSIONAL_DOOR = new ItemDimDoorGold(); - public final static ItemDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new ItemDimDoorPersonal(); - public final static ItemDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new ItemDimDoorUnstable(); - public final static ItemDimDoorWarp WARP_DIMENSIONAL_DOOR = new ItemDimDoorWarp(); + public static final ItemDimDoor DIMENSIONAL_DOOR = new ItemDimDoor(); + public static final ItemDimDoorGold GOLD_DIMENSIONAL_DOOR = new ItemDimDoorGold(); + public static final ItemDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new ItemDimDoorPersonal(); + public static final ItemDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new ItemDimDoorUnstable(); + public static final ItemDimDoorWarp WARP_DIMENSIONAL_DOOR = new ItemDimDoorWarp(); // Fabric - public final static ItemWorldThread WORLD_THREAD = new ItemWorldThread(); - public final static ItemBlockFabric FABRIC = new ItemBlockFabric(); - public final static ItemStableFabric STABLE_FABRIC = new ItemStableFabric(); + public static final ItemWorldThread WORLD_THREAD = new ItemWorldThread(); + public static final ItemStableFabric STABLE_FABRIC = new ItemStableFabric(); // Tools - public final static ItemRiftConnectionTool RIFT_CONNECTION_TOOL = new ItemRiftConnectionTool(); - public final static ItemRiftBlade RIFT_BLADE = new ItemRiftBlade(); + public static final ItemRiftConnectionTool RIFT_CONNECTION_TOOL = new ItemRiftConnectionTool(); + public static final ItemRiftBlade RIFT_BLADE = new ItemRiftBlade(); @SubscribeEvent public static void registerItems(RegistryEvent.Register event) { - event.getRegistry().register(QUARTZ_DOOR); - event.getRegistry().register(PERSONAL_DIMENSIONAL_DOOR); - event.getRegistry().register(GOLD_DOOR); - event.getRegistry().register(GOLD_DIMENSIONAL_DOOR); - event.getRegistry().register(DIMENSIONAL_DOOR); - event.getRegistry().register(WARP_DIMENSIONAL_DOOR); - event.getRegistry().register(STABLE_FABRIC); - event.getRegistry().register(UNSTABLE_DIMENSIONAL_DOOR); - event.getRegistry().register(WORLD_THREAD); - event.getRegistry().register(RIFT_CONNECTION_TOOL); - event.getRegistry().register(RIFT_BLADE); + event.getRegistry().registerAll( + QUARTZ_DOOR, + PERSONAL_DIMENSIONAL_DOOR, + GOLD_DOOR, + GOLD_DIMENSIONAL_DOOR, + DIMENSIONAL_DOOR, + WARP_DIMENSIONAL_DOOR, + STABLE_FABRIC, + UNSTABLE_DIMENSIONAL_DOOR, + WORLD_THREAD, + RIFT_CONNECTION_TOOL, + RIFT_BLADE); // ItemBlocks - event.getRegistry().register(FABRIC); - event.getRegistry().register(new ItemBlock(ModBlocks.DIMENSIONAL_TRAPDOOR) - .setRegistryName(ModBlocks.DIMENSIONAL_TRAPDOOR.getRegistryName())); - event.getRegistry().register(new ItemBlock(ModBlocks.RIFT) - .setRegistryName(ModBlocks.RIFT.getRegistryName())); + event.getRegistry().registerAll( + new ItemBlockFabric(), + new ItemBlock(ModBlocks.DIMENSIONAL_TRAPDOOR).setRegistryName(ModBlocks.DIMENSIONAL_TRAPDOOR.getRegistryName()), + new ItemBlock(ModBlocks.RIFT).setRegistryName(ModBlocks.RIFT.getRegistryName())); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/DDTileEntityBase.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/DDTileEntityBase.java index 0ad0f446..df31891a 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/DDTileEntityBase.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/DDTileEntityBase.java @@ -6,7 +6,6 @@ import com.zixiken.dimdoors.shared.Pocket; import com.zixiken.dimdoors.shared.PocketRegistry; import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.RiftRegistry; -import com.zixiken.dimdoors.shared.blocks.IDimDoor; import java.util.Random; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -58,7 +57,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { pairedRiftID = otherRiftID; isPaired = true; RiftRegistry.INSTANCE.pair(pairedRiftID, riftID); //make sure it gets paired the other way around - this.markDirty(); + markDirty(); return false; } @@ -68,7 +67,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { } else { isPaired = false; RiftRegistry.INSTANCE.unpair(pairedRiftID); - this.markDirty(); + markDirty(); } return false; } @@ -76,25 +75,25 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { public void register(int depth) { //if (riftID == -1) { //this check only causes problems? riftID = RiftRegistry.INSTANCE.registerNewRift(this, depth); - DimDoors.log(this.getClass(), "Finished registering rift as ID: " + riftID); + DimDoors.log(getClass(), "Finished registering rift as ID: " + riftID); - this.markDirty(); + markDirty(); //} } @Override - public void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); try { - isPaired = nbt.getBoolean("isPaired"); - riftID = nbt.getInteger("riftID"); - pairedRiftID = nbt.getInteger("pairedRiftID"); - isInPocket = nbt.getBoolean("isInPocket"); - pocketID = nbt.getInteger("pocketID"); - if (nbt.hasKey("pocketType")) { - pocketType = EnumPocketType.valueOf(nbt.getString("pocketType")); + isPaired = compound.getBoolean("isPaired"); + riftID = compound.getInteger("riftID"); + pairedRiftID = compound.getInteger("pairedRiftID"); + isInPocket = compound.getBoolean("isInPocket"); + pocketID = compound.getInteger("pocketID"); + if (compound.hasKey("pocketType")) { + pocketType = EnumPocketType.valueOf(compound.getString("pocketType")); } - depth = nbt.getInteger("depth"); + depth = compound.getInteger("depth"); } catch (Exception e) { //reading these values should only fail on loading old saves, or loading old schematics, in which case the default values will do } @@ -103,15 +102,15 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setBoolean("isPaired", this.isPaired); - nbt.setInteger("riftID", this.riftID); - nbt.setInteger("pairedRiftID", this.pairedRiftID); - nbt.setBoolean("isInPocket", this.isInPocket); - nbt.setInteger("pocketID", this.pocketID); + nbt.setBoolean("isPaired", isPaired); + nbt.setInteger("riftID", riftID); + nbt.setInteger("pairedRiftID", pairedRiftID); + nbt.setBoolean("isInPocket", isInPocket); + nbt.setInteger("pocketID", pocketID); if (pocketType != null) { - nbt.setString("pocketType", this.pocketType.name()); + nbt.setString("pocketType", pocketType.name()); } - nbt.setInteger("depth", this.depth); + nbt.setInteger("depth", depth); return nbt; } @@ -126,7 +125,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { pocketType = rift2.pocketType; depth = rift2.depth; - this.markDirty(); + markDirty(); } } @@ -147,26 +146,26 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { } public Location getTeleportTargetLocation() { - return new Location(this.getWorld().provider.getDimension(), this.getPos()); + return new Location(getWorld().provider.getDimension(), getPos()); } public abstract boolean tryTeleport(Entity entity); - public void setPocket(int ID, EnumPocketType type) { - pocketID = ID; + public void setPocket(int id, EnumPocketType type) { + pocketID = id; pocketType = type; isInPocket = true; - this.markDirty(); + markDirty(); } public void setIsInPocket() { isInPocket = true; - this.markDirty(); + markDirty(); } public void setDepth(int depth) { this.depth = depth; - this.markDirty(); + markDirty(); } protected EnumPocketType getPocketType() { @@ -174,9 +173,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { } public void validatePlayerPocketEntry(EntityPlayer player) { - if (!isInPocket || pocketType == EnumPocketType.PRIVATE) { - return; - } else { + if (isInPocket && pocketType != EnumPocketType.PRIVATE) { Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, pocketType); pocket.validatePlayerEntry(player); } @@ -185,13 +182,11 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable { @Override public void update() { if (isTeleporting && teleportingEntity != null) { - if (tryTeleport(teleportingEntity)) { - //player is succesfully teleported - } else { - //probably should only happen on personal dimdoors? + if (!tryTeleport(teleportingEntity)) { if (teleportingEntity instanceof EntityPlayer) { EntityPlayer entityPlayer = (EntityPlayer) teleportingEntity; DimDoors.chat(entityPlayer, "Teleporting failed, but since mod is still in alpha, stuff like that might simply happen."); + // TODO: It's normal for teleportation to sometimes fail, for example for an unlinked warp door. Change this to an exception-based system to print error only when it really fails? } } isTeleporting = false; diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoor.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoor.java index 37708f14..42e29040 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoor.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoor.java @@ -9,7 +9,7 @@ import com.zixiken.dimdoors.shared.blocks.BlockDimDoor; import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.RiftRegistry; import com.zixiken.dimdoors.shared.TeleporterDimDoors; -import com.zixiken.dimdoors.shared.util.DDRandomUtils; +import com.zixiken.dimdoors.shared.util.RandomUtils; import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import java.util.Random; import javax.annotation.Nullable; @@ -29,11 +29,11 @@ public class TileEntityDimDoor extends DDTileEntityBase { super.readFromNBT(nbt); try { - this.doorIsOpen = nbt.getBoolean("doorIsOpen"); - this.orientation = EnumFacing.getFront(nbt.getInteger("orientation")); - this.lockStatus = nbt.getByte("lockStatus"); + doorIsOpen = nbt.getBoolean("doorIsOpen"); + orientation = EnumFacing.getFront(nbt.getInteger("orientation")); + lockStatus = nbt.getByte("lockStatus"); } catch (Exception e) { - DimDoors.warn(this.getClass(), "An error occured while trying to read this object from NBT."); + DimDoors.warn(getClass(), "An error occured while trying to read this object from NBT."); } } @@ -41,8 +41,8 @@ public class TileEntityDimDoor extends DDTileEntityBase { public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setBoolean("doorIsOpen", this.doorIsOpen); - nbt.setInteger("orientation", this.orientation.getIndex()); + nbt.setBoolean("doorIsOpen", doorIsOpen); + nbt.setInteger("orientation", orientation.getIndex()); nbt.setByte("lockStatus", lockStatus); return nbt; } @@ -50,7 +50,7 @@ public class TileEntityDimDoor extends DDTileEntityBase { @Override public float[] getRenderColor(Random rand) { float[] rgbaColor = {1, 1, 1, 1}; - if (this.world.provider.getDimension() == -1) { + if (world.provider.getDimension() == -1) { rgbaColor[0] = rand.nextFloat() * 0.5F + 0.4F; rgbaColor[1] = rand.nextFloat() * 0.05F; rgbaColor[2] = rand.nextFloat() * 0.05F; @@ -65,7 +65,7 @@ public class TileEntityDimDoor extends DDTileEntityBase { @Override public Location getTeleportTargetLocation() { - return new Location(this.getWorld().provider.getDimension(), this.getPos().offset(orientation).down()); + return new Location(getWorld().provider.getDimension(), getPos().offset(orientation).down()); } @Override @@ -78,7 +78,7 @@ public class TileEntityDimDoor extends DDTileEntityBase { } Location tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID); if (tpLocation == null) { - DimDoors.warn(this.getClass(), "Location of rift teleporting to is null."); + DimDoors.warn(getClass(), "Location of rift teleporting to is null."); return false; } RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID); @@ -109,31 +109,31 @@ public class TileEntityDimDoor extends DDTileEntityBase { } } //storing the orientation inside the tile-entity, because that thing can actually save the orientation in the worldsave, unlike the block itself, which fail at that stuff somehow - this.orientation = this.getWorld().getBlockState(this.getPos()).getValue(BlockDimDoor.FACING).getOpposite(); //@todo since this is used to determine the render of the "portal, this gets reset to the "wrong" side every time the door gets updated + orientation = getWorld().getBlockState(getPos()).getValue(BlockDimDoor.FACING).getOpposite(); //@todo since this is used to determine the render of the "portal, this gets reset to the "wrong" side every time the door gets updated } protected int getNewTeleportDestination() { int otherRiftID; - Location locationOfThisRift = RiftRegistry.INSTANCE.getRiftLocation(this.riftID); //returns null if this rift isn't registered + Location locationOfThisRift = RiftRegistry.INSTANCE.getRiftLocation(riftID); //returns null if this rift isn't registered - if (this.isInPocket && this.pocketType ==EnumPocketType.DUNGEON) { + if (isInPocket && pocketType == EnumPocketType.DUNGEON) { Location origLocation = PocketRegistry.INSTANCE.getPocket(pocketID, pocketType).getDepthZeroLocation(); //choose between generating a new pocket or connecting to another door on a similar or close depth - if (DDRandomUtils.weightedBoolean(20, 80)) { //@todo make this configurable + if (RandomUtils.weightedBoolean(20, 80)) { //@todo make this configurable otherRiftID = RiftRegistry.INSTANCE.getRandomUnpairedRiftIDAroundDepth(getRiftID(), depth); if (otherRiftID < 0) { //ergo: no other rift can be found //@todo, this should rarely happen. Put in an easter egg? - otherRiftID = PocketRegistry.INSTANCE.getEntranceDoorIDOfNewPocket(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation); + otherRiftID = PocketRegistry.INSTANCE.generateRandomPocketAt(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation).getEntranceDoorID(); } } else { - otherRiftID = PocketRegistry.INSTANCE.getEntranceDoorIDOfNewPocket(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation); + otherRiftID = PocketRegistry.INSTANCE.generateRandomPocketAt(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation).getEntranceDoorID(); } } else { - otherRiftID = PocketRegistry.INSTANCE.getEntranceDoorIDOfNewPocket(EnumPocketType.PUBLIC, 0, locationOfThisRift); //@todo should this depth be 1 instead? + otherRiftID = PocketRegistry.INSTANCE.generateRandomPocketAt(EnumPocketType.PUBLIC, 0, locationOfThisRift).getEntranceDoorID(); //@todo should this depth be 1 instead? } if (otherRiftID < 0) { - DimDoors.warn(this.getClass(), "No suitable destination rift was found. This probably means that a pocket was created without any Doors."); + DimDoors.warn(getClass(), "No suitable destination rift was found. This probably means that a pocket was created without any Doors."); } else { //@todo (should the other rift get loaded?) RiftRegistry.INSTANCE.pair(getRiftID(), otherRiftID); @@ -143,6 +143,6 @@ public class TileEntityDimDoor extends DDTileEntityBase { } protected int getRandomlyTransFormedDepth() { - return DDRandomUtils.transformRandomly(depth, DDConfig.getDoorRelativeDepths(), DDConfig.getDoorRelativeDepthWeights()); + return RandomUtils.transformRandomly(depth, DDConfig.getDoorRelativeDepths(), DDConfig.getDoorRelativeDepthWeights()); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorGold.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorGold.java index 402a1bdb..5918cdbb 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorGold.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorGold.java @@ -26,35 +26,35 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo chunkTicket = ticket; /* - // Only do anything if this function is running on the server side - // NOTE: We don't have to check whether this block is the upper door - // block or the lower one because only one of them should have a - // link associated with it. - if (!worldObj.isRemote) { - DimData dimension = PocketManager.createDimensionData(worldObj); + // Only do anything if this function is running on the server side + // NOTE: We don't have to check whether this block is the upper door + // block or the lower one because only one of them should have a + // link associated with it. + if (!worldObj.isRemote) { + DimData dimension = PocketManager.createDimensionData(worldObj); - // Check whether a ticket has already been assigned to this door - if (chunkTicket == null) { - // No ticket yet. - // Check if this area should be loaded and request a new ticket. - if (isValidChunkLoaderSetup(dimension)) { - chunkTicket = ChunkLoaderHelper.createTicket(pos, worldObj); - } - } else { - // A ticket has already been provided. - // Check if this area should be loaded. If not, release the ticket. - if (!isValidChunkLoaderSetup(dimension)) { - ForgeChunkManager.releaseTicket(chunkTicket); - chunkTicket = null; - } - } + // Check whether a ticket has already been assigned to this door + if (chunkTicket == null) { + // No ticket yet. + // Check if this area should be loaded and request a new ticket. + if (isValidChunkLoaderSetup(dimension)) { + chunkTicket = ChunkLoaderHelper.createTicket(pos, worldObj); + } + } else { + // A ticket has already been provided. + // Check if this area should be loaded. If not, release the ticket. + if (!isValidChunkLoaderSetup(dimension)) { + ForgeChunkManager.releaseTicket(chunkTicket); + chunkTicket = null; + } + } - // If chunkTicket isn't null at this point, then this is a valid door setup. - // The last step is to request force loading of the pocket's chunks. - if (chunkTicket != null) { - ChunkLoaderHelper.forcePocketChunks(dimension, chunkTicket); - } - } + // If chunkTicket isn't null at this point, then this is a valid door setup. + // The last step is to request force loading of the pocket's chunks. + if (chunkTicket != null) { + ChunkLoaderHelper.forcePocketChunks(dimension, chunkTicket); + } + } */ } @@ -69,15 +69,15 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo //DimDoors.log(this.getClass(), "Trying to find suitable destination rift."); int otherRiftID = RiftRegistry.INSTANCE.getRandomUnpairedRiftIDAtDepth(getRiftID(), depth); if (otherRiftID < 0) { - Location origLocation = RiftRegistry.INSTANCE.getRiftLocation(this.riftID); + Location origLocation = RiftRegistry.INSTANCE.getRiftLocation(riftID); if (origLocation.getDimensionID() == DimDoorDimensions.getPocketDimensionType(EnumPocketType.DUNGEON).getId()) { //if this dimdoor is a pocket Dungeon origLocation = PocketRegistry.INSTANCE.getPocket(pocketID, pocketType).getDepthZeroLocation(); } - otherRiftID = PocketRegistry.INSTANCE.getEntranceDoorIDOfNewPocket(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation); + otherRiftID = PocketRegistry.INSTANCE.generateRandomPocketAt(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation).getEntranceDoorID(); } if (otherRiftID < 0) { - DimDoors.warn(this.getClass(), "No suitable destination rift was found. This probably means that a pocket was created without any Doors."); + DimDoors.warn(getClass(), "No suitable destination rift was found. This probably means that a pocket was created without any Doors."); } else { RiftRegistry.INSTANCE.pair(getRiftID(), otherRiftID); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorPersonal.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorPersonal.java index 32622f86..0da6d95c 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorPersonal.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorPersonal.java @@ -26,17 +26,17 @@ public class TileEntityDimDoorPersonal extends TileEntityDimDoor { @Override public boolean tryTeleport(Entity entity) { //this door is never paired - Location locationOfThisRift = RiftRegistry.INSTANCE.getRiftLocation(this.riftID); + Location locationOfThisRift = RiftRegistry.INSTANCE.getRiftLocation(riftID); Location tpLocation; if (entity instanceof EntityPlayer) { EntityPlayer entityPlayer = (EntityPlayer) entity; if (locationOfThisRift.getDimensionID() == DimDoorDimensions.getPocketDimensionType(EnumPocketType.PRIVATE).getId()) { - tpLocation = PocketRegistry.INSTANCE.getPocket(this.pocketID, EnumPocketType.PRIVATE).getDepthZeroLocation(); + tpLocation = PocketRegistry.INSTANCE.getPocket(pocketID, EnumPocketType.PRIVATE).getDepthZeroLocation(); } else { int otherDoorID = PocketRegistry.INSTANCE.getPrivateDimDoorID(entityPlayer.getCachedUniqueIdString()); tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherDoorID); int privatePocketID = RiftRegistry.INSTANCE.getPocketID(otherDoorID); - PocketRegistry.INSTANCE.getPocket(privatePocketID, EnumPocketType.PRIVATE).setDepthZeroLocation(this.getTeleportTargetLocation()); + PocketRegistry.INSTANCE.getPocket(privatePocketID, EnumPocketType.PRIVATE).setDepthZeroLocation(getTeleportTargetLocation()); } } else { return false; diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorChaos.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorUnstable.java similarity index 89% rename from src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorChaos.java rename to src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorUnstable.java index e35eac53..994849a0 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorChaos.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorUnstable.java @@ -14,9 +14,9 @@ import net.minecraft.entity.Entity; * * @author Robijnvogel */ -public class TileEntityDimDoorChaos extends TileEntityDimDoor { +public class TileEntityDimDoorUnstable extends TileEntityDimDoor { - public TileEntityDimDoorChaos() { + public TileEntityDimDoorUnstable() { canRiftBePaired = false; } diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorWarp.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorWarp.java index 9d210f5a..a66d2352 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorWarp.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityDimDoorWarp.java @@ -16,10 +16,10 @@ public class TileEntityDimDoorWarp extends TileEntityDimDoor { int otherRiftID = getPairedRiftID(); tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID); RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID); - } else if (!(this.isInPocket)) { + } else if (!isInPocket) { return false; } else { - Pocket pocket = PocketRegistry.INSTANCE.getPocket(this.pocketID, this.getPocketType()); + Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, getPocketType()); tpLocation = pocket.getDepthZeroLocation(); } return TeleporterDimDoors.instance().teleport(entity, tpLocation); diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityRift.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityRift.java index 378c5ab4..3a907cd4 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityRift.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityRift.java @@ -36,8 +36,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable { public float growth = 0; public TileEntityRift() { - super(); - this.loadDataFrom(RiftRegistry.INSTANCE.getLastChangedRift()); //@todo this should absolutely not be done in this constructor... + loadDataFrom(RiftRegistry.INSTANCE.getLastChangedRift()); //@todo this should absolutely not be done in this constructor... // Vary the update times of rifts to prevent all the rifts in a cluster // from updating at the same time. @@ -74,8 +73,8 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable { } // Ensure that this rift is only spawning one Enderman at a time, to prevent hordes of Endermen - Entity entity = world.getEntityByID(this.spawnedEndermenID); - if (entity != null && entity instanceof EntityEnderman) { + Entity entity = world.getEntityByID(spawnedEndermenID); + if (entity instanceof EntityEnderman) { return; } @@ -91,7 +90,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable { world.spawnEntity(enderman); if (random.nextInt(MAX_HOSTILE_ENDERMAN_CHANCE) < HOSTILE_ENDERMAN_CHANCE) { - EntityPlayer player = this.world.getClosestPlayerToEntity(enderman, 50); + EntityPlayer player = world.getClosestPlayerToEntity(enderman, 50); if (player != null) { enderman.setAttackTarget(player); } @@ -118,25 +117,25 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable { @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - this.updateTimer = nbt.getInteger("updateTimer"); - this.offset = new BlockPos(nbt.getInteger("xOffset"), nbt.getInteger("yOffset"), nbt.getInteger("zOffset")); - this.shouldClose = nbt.getBoolean("shouldClose"); - this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID"); - this.riftRotation = nbt.getInteger("riftRotation"); - this.growth = nbt.getFloat("growth"); + updateTimer = nbt.getInteger("updateTimer"); + offset = new BlockPos(nbt.getInteger("xOffset"), nbt.getInteger("yOffset"), nbt.getInteger("zOffset")); + shouldClose = nbt.getBoolean("shouldClose"); + spawnedEndermenID = nbt.getInteger("spawnedEndermenID"); + riftRotation = nbt.getInteger("riftRotation"); + growth = nbt.getFloat("growth"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("updateTimer", this.updateTimer); - nbt.setInteger("xOffset", this.offset.getX()); - nbt.setInteger("yOffset", this.offset.getY()); - nbt.setInteger("zOffset", this.offset.getZ()); - nbt.setBoolean("shouldClose", this.shouldClose); - nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID); - nbt.setInteger("riftRotation", this.riftRotation); - nbt.setFloat("growth", this.growth); + nbt.setInteger("updateTimer", updateTimer); + nbt.setInteger("xOffset", offset.getX()); + nbt.setInteger("yOffset", offset.getY()); + nbt.setInteger("zOffset", offset.getZ()); + nbt.setBoolean("shouldClose", shouldClose); + nbt.setInteger("spawnedEndermenID", spawnedEndermenID); + nbt.setInteger("riftRotation", riftRotation); + nbt.setFloat("growth", growth); return nbt; } @@ -150,7 +149,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable { public boolean tryTeleport(Entity entity) { int otherRiftID; if (!isPaired()) { - DimDoors.warn(this.getClass(), "Rift " + this.getRiftID() + " was not paired and thus, should not exist as a Rift, unless it was unpaired after the door was destroyed, in which case you should contact the developers and tell them to fix stuff."); + DimDoors.warn(getClass(), "Rift " + getRiftID() + " was not paired and thus, should not exist as a Rift, unless it was unpaired after the door was destroyed, in which case you should contact the developers and tell them to fix stuff."); return false; } else { otherRiftID = getPairedRiftID(); diff --git a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityTransTrapdoor.java b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityTransTrapdoor.java index ad4a772d..c1fe72a6 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityTransTrapdoor.java +++ b/src/main/java/com/zixiken/dimdoors/shared/tileentities/TileEntityTransTrapdoor.java @@ -13,7 +13,7 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase { @Override public float[] getRenderColor(Random rand) { float[] rgbaColor = {1, 1, 1, 1}; - if (this.world.provider.getDimension() == -1) { + if (world.provider.getDimension() == -1) { rgbaColor[0] = world.rand.nextFloat() * 0.5F + 0.4F; rgbaColor[1] = world.rand.nextFloat() * 0.05F; rgbaColor[2] = world.rand.nextFloat() * 0.05F; @@ -27,7 +27,7 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase { @Override public Location getTeleportTargetLocation() { - return new Location(this.getWorld().provider.getDimension(), this.getPos().up()); + return new Location(getWorld().provider.getDimension(), getPos().up()); } @Override @@ -37,10 +37,10 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase { int otherRiftID = getPairedRiftID(); tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID); RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID); - } else if (!(this.isInPocket)) { + } else if (!isInPocket) { return false; } else { - Pocket pocket = PocketRegistry.INSTANCE.getPocket(this.pocketID, this.getPocketType()); + Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, getPocketType()); tpLocation = pocket.getDepthZeroLocation(); } return TeleporterDimDoors.instance().teleport(entity, tpLocation); diff --git a/src/main/java/com/zixiken/dimdoors/shared/util/Location.java b/src/main/java/com/zixiken/dimdoors/shared/util/Location.java index 7c694bf3..391a4599 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/util/Location.java +++ b/src/main/java/com/zixiken/dimdoors/shared/util/Location.java @@ -33,7 +33,7 @@ public class Location implements Serializable { } public Location(int dimID, BlockPos pos) { - this.dimensionID = dimID; + dimensionID = dimID; this.pos = pos; //copyOf } @@ -88,29 +88,29 @@ public class Location implements Serializable { } @Override - public boolean equals(Object o) { - if (o == null || !(o instanceof Location)) { + public boolean equals(Object obj) { + if (!(obj instanceof Location)) { return false; } - Location other = (Location) o; - return other.dimensionID == this.dimensionID && other.pos.equals(this.pos); + Location other = (Location) obj; + return other.dimensionID == dimensionID && other.pos.equals(pos); } @Override public int hashCode() { int hash = 5; - hash = 89 * hash + this.dimensionID; - hash = 89 * hash + Objects.hashCode(this.pos); + hash = 89 * hash + dimensionID; + hash = 89 * hash + Objects.hashCode(pos); return hash; } @Override public String toString() { - return "Location: dimID: " + this.dimensionID + " position: " + this.pos.toString(); + return "Location: dimID: " + dimensionID + " position: " + pos; } public void loadfrom(Location location) { - this.dimensionID = location.dimensionID; - this.pos = location.pos; + dimensionID = location.dimensionID; + pos = location.pos; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/util/DDMathUtils.java b/src/main/java/com/zixiken/dimdoors/shared/util/MathUtils.java similarity index 89% rename from src/main/java/com/zixiken/dimdoors/shared/util/DDMathUtils.java rename to src/main/java/com/zixiken/dimdoors/shared/util/MathUtils.java index 40dc90e2..38f2e0ed 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/util/DDMathUtils.java +++ b/src/main/java/com/zixiken/dimdoors/shared/util/MathUtils.java @@ -9,7 +9,7 @@ package com.zixiken.dimdoors.shared.util; * * @author Robijnvogel */ -public class DDMathUtils { +public class MathUtils { /** * Compares the integers in two arrays and returns true if any integer in @@ -27,9 +27,9 @@ public class DDMathUtils { if (difference < 0) { throw new IllegalArgumentException("precondition was violated"); } - for (int One : setOne) { - for (int Two : setTwo) { - if ((Math.max(One, Two) - Math.min(One, Two)) < difference) { + for (int one : setOne) { + for (int two : setTwo) { + if (Math.max(one, two) - Math.min(one, two) < difference) { return true; } } @@ -51,9 +51,9 @@ public class DDMathUtils { public static int arraySum(int[] intArray, short flag) { int r = 0; for (int i : intArray) { //check flag - if (flag == 0 && i < 0) { // + if (flag == 0 && i < 0) { throw new IllegalArgumentException("all integers in array must be positive"); - } else if (flag == 1 && i > 0) { // + } else if (flag == 1 && i > 0) { throw new IllegalArgumentException("all integers in array must be negative"); } r += i; diff --git a/src/main/java/com/zixiken/dimdoors/shared/util/DDRandomUtils.java b/src/main/java/com/zixiken/dimdoors/shared/util/RandomUtils.java similarity index 90% rename from src/main/java/com/zixiken/dimdoors/shared/util/DDRandomUtils.java rename to src/main/java/com/zixiken/dimdoors/shared/util/RandomUtils.java index 9356fcf1..b90cf372 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/util/DDRandomUtils.java +++ b/src/main/java/com/zixiken/dimdoors/shared/util/RandomUtils.java @@ -13,7 +13,7 @@ import net.minecraft.util.EnumFacing; * * @author Robijnvogel */ -public class DDRandomUtils { +public class RandomUtils { /** * Returns either true or false, based on a weighted random, taking in @@ -32,7 +32,7 @@ public class DDRandomUtils { throw new IllegalArgumentException("Either of both weights were 0 or lower. Both should be at least 1."); } Random random = new Random(); - return (random.nextInt(trueWeight + falseWeight) < trueWeight); + return random.nextInt(trueWeight + falseWeight) < trueWeight; } /** @@ -43,7 +43,7 @@ public class DDRandomUtils { * @param transformations the possible transformations * @param weights the chance-weight of those transformations * @pre {@code transformations.length = weights.length} && {@code (\forall i; intArray.has(i); i >= 0)} - * && {@code DDMathUtils.arraySum(weights, 1) > 0} + * && {@code MathUtils.arraySum(weights, 1) > 0} * @throws IllegalArgumentException if precondition is violated * @return the sum of {@code base} and the value of an element in * {@code transformations} @@ -53,9 +53,9 @@ public class DDRandomUtils { throw new IllegalArgumentException("pre was violated, transformations.length != weights.length"); } Random random = new Random(); - int weightSum = DDMathUtils.arraySum(weights, (short) 0); + int weightSum = MathUtils.arraySum(weights, (short) 0); if (weightSum <= 0) { - throw new IllegalArgumentException("pre was violated, DDMathUtils.arraySum(weights, 1) <= 0"); + throw new IllegalArgumentException("pre was violated, MathUtils.arraySum(weights, 1) <= 0"); } int choice = random.nextInt(weightSum); for (int i = 0; i < weights.length; i++) { @@ -90,10 +90,9 @@ public class DDRandomUtils { throw new IllegalArgumentException("pre was violated"); } Random random = new Random(); - DimDoors.log(DDRandomUtils.class, "base = " + base + ", power = " + power + ", depth = " + depth + " and power is " + Math.pow(base * depth, power)); + DimDoors.log(RandomUtils.class, "base = " + base + ", power = " + power + ", depth = " + depth + " and power is " + Math.pow(base * depth, power)); int xOffset = random.nextInt((int) Math.pow(base * depth, power)) * (random.nextBoolean() ? 1 : -1); int zOffset = random.nextInt((int) Math.pow(base * depth, power)) * (random.nextBoolean() ? 1 : -1); return new Location(origLocation.getWorld(), origLocation.getPos().offset(EnumFacing.EAST, xOffset).offset(EnumFacing.SOUTH, zOffset)); } - } diff --git a/src/main/java/com/zixiken/dimdoors/shared/util/Schematic.java b/src/main/java/com/zixiken/dimdoors/shared/util/Schematic.java index 8e4b82b9..8f367276 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/util/Schematic.java +++ b/src/main/java/com/zixiken/dimdoors/shared/util/Schematic.java @@ -34,31 +34,31 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries; */ public class Schematic { - private static final String[] OLDDIMDOORBLOCKNAMES = new String[]{ - "Dimensional Door", - "Fabric of Reality", - "transientDoor", //only used in the two old Overworld gateway (worldgen) structures - "Warp Door"}; + private static final String[] OLDDIMDOORBLOCKNAMES = { + "Dimensional Door", + "Fabric of Reality", + "transientDoor", //only used in the two old Overworld gateway (worldgen) structures + "Warp Door"}; - private static final String[] NEWDIMDOORBLOCKNAMES = new String[]{ - "dimensional_door", - "fabric", //[type=fabric] is the default blockstate - "transient_dimensional_door", - "warp_dimensional_door"}; + private static final String[] NEWDIMDOORBLOCKNAMES = { + "dimensional_door", + "fabric", //[type=fabric] is the default blockstate + "transient_dimensional_door", + "warp_dimensional_door"}; int version = Integer.parseInt("1"); //@todo set in build.gradle ${spongeSchematicVersion} String author = "DimDoors"; //@todo set in build.gradle ${modID} String schematicName = "Unknown"; long creationDate; - String[] requiredMods = new String[0]; + String[] requiredMods = {}; short width; short height; short length; - int[] offset = new int[]{0, 0, 0}; + int[] offset = {0, 0, 0}; int paletteMax; - List pallette = new ArrayList(); + List pallette = new ArrayList<>(); int[][][] blockData; //[x][y][z] - List tileEntities = new ArrayList(); + List tileEntities = new ArrayList<>(); private Schematic() { } @@ -84,7 +84,7 @@ public class Schematic { schematic.creationDate = metadataCompound.getLong("Date"); } if (nbt.hasKey("RequiredMods")) { //RequiredMods is not required (ironically) - NBTTagList requiredModsTagList = ((NBTTagList) metadataCompound.getTag("RequiredMods")); + NBTTagList requiredModsTagList = (NBTTagList) metadataCompound.getTag("RequiredMods"); schematic.requiredMods = new String[requiredModsTagList.tagCount()]; for (int i = 0; i < requiredModsTagList.tagCount(); i++) { schematic.requiredMods[i] = requiredModsTagList.getStringTagAt(i); @@ -101,7 +101,7 @@ public class Schematic { } NBTTagCompound paletteNBT = nbt.getCompoundTag("Palette"); //Palette is not required, however since we assume that the schematic contains at least some blocks, we can also assume that thee has to be a Palette - Map paletteMap = new HashMap(); + Map paletteMap = new HashMap<>(); for (String key : paletteNBT.getKeySet()) { int paletteID = paletteNBT.getInteger(key); paletteMap.put(paletteID, key); //basically use the reversed order (key becomes value and value becomes key) @@ -126,7 +126,6 @@ public class Schematic { if (!stateString.equals("")) { String[] properties = stateString.split(","); blockstate = getBlockStateWithProperties(block, properties); - } else { } schematic.pallette.add(blockstate); //@todo, can we assume that a schematic file always has all palette integers used from 0 to pallettemax-1? } @@ -179,10 +178,9 @@ public class Schematic { nbt.setInteger("PaletteMax", schematic.paletteMax); NBTTagCompound paletteNBT = new NBTTagCompound(); - Map paletteMap = new HashMap(); for (int i = 0; i < schematic.pallette.size(); i++) { IBlockState state = schematic.pallette.get(i); - DimDoors.log(Schematic.class, "Saving BlockState: " + state.toString()); + DimDoors.log(Schematic.class, "Saving BlockState: " + state); String blockStateString = getBlockStateStringFromState(state); paletteNBT.setInteger(blockStateString, i); } @@ -209,10 +207,9 @@ public class Schematic { } private static IBlockState getBlockStateWithProperties(Block block, String[] properties) { - Map propertyAndBlockStringsMap = new HashMap(); - for (int i = 0; i < properties.length; i++) { - String propertyString = properties[i]; - String[] propertyAndBlockStrings = propertyString.split("="); + Map propertyAndBlockStringsMap = new HashMap<>(); + for (String property : properties) { + String[] propertyAndBlockStrings = property.split("="); propertyAndBlockStringsMap.put(propertyAndBlockStrings[0], propertyAndBlockStrings[1]); } BlockStateContainer container = block.getBlockState(); @@ -238,7 +235,7 @@ public class Schematic { private static String getBlockStateStringFromState(IBlockState state) { Block block = state.getBlock(); String blockNameString = "" + Block.REGISTRY.getNameForObject(block); - String blockStateString = ""; + StringBuilder blockStateString = new StringBuilder(); String totalString; IBlockState defaultState = block.getDefaultState(); if (state == defaultState) { @@ -248,16 +245,14 @@ public class Schematic { for (IProperty property : container.getProperties()) { //for every property that is valid for this type of Block String defaultPropertyValue = defaultState.getProperties().get(property).toString(); String thisPropertyValue = state.getProperties().get(property).toString(); - if (defaultPropertyValue.equals(thisPropertyValue)) { - //do nothing - } else { + if (!defaultPropertyValue.equals(thisPropertyValue)) { String firstHalf = property.getName(); String secondHalf = state.getProperties().get(property).toString(); String propertyString = firstHalf + "=" + secondHalf; - blockStateString += propertyString + ","; + blockStateString.append(propertyString).append(","); } } - blockStateString = blockStateString.substring(0, blockStateString.length() - 1); //removes the last comma + blockStateString = new StringBuilder(blockStateString.substring(0, blockStateString.length() - 1)); //removes the last comma totalString = blockNameString + "[" + blockStateString + "]"; } return totalString; @@ -365,12 +360,12 @@ public class Schematic { IBlockState baseState = schematic.pallette.get(blockInt); //this is the default blockstate except for ancient fabric if (baseState == baseState.getBlock().getDefaultState()) { //should only be false if {@code baseState} is ancient fabric - IBlockState additionalState = baseState.getBlock().getStateFromMeta(metadata); + IBlockState additionalState = baseState.getBlock().getStateFromMeta(metadata); // TODO: this was getStateFromMeta(metadata), but that method got deprecated and just calls getDefaultState(). Is this right? if (schematic.pallette.contains(additionalState)) { //check whether or not this blockstate is already in the list blockInt = schematic.pallette.indexOf(additionalState); } else { schematic.pallette.add(additionalState); - DimDoors.log(Schematic.class, "New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState.toString()); + DimDoors.log(Schematic.class, "New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState); blockInt = schematic.pallette.size() - 1; } } else { //if this is ancient fabric @@ -419,7 +414,7 @@ public class Schematic { } private static void generateDefaultSchematic(String baseName, int pocketSize, IBlockState innerWallBlockState, Block doorBlock) { - int maxbound = ((pocketSize + 1) * 16) - 1; + int maxbound = (pocketSize + 1) * 16 - 1; Schematic schematic = new Schematic(); schematic.version = 1; @@ -434,7 +429,7 @@ public class Schematic { schematic.offset = new int[]{0, 0, 0}; schematic.paletteMax = 4; - schematic.pallette = new ArrayList(); + schematic.pallette = new ArrayList<>(); schematic.pallette.add(Blocks.AIR.getDefaultState()); schematic.pallette.add(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT)); schematic.pallette.add(innerWallBlockState); @@ -449,7 +444,7 @@ public class Schematic { || y == 0 || y == maxbound - 1 || z == 0 || z == maxbound - 1) { schematic.blockData[x][y][z] = 1; //outer dim wall - } else if (DDMathUtils.withinDistanceOf(new int[]{x, y, z}, 5, new int[]{0, maxbound})) { + } else if (MathUtils.withinDistanceOf(new int[]{x, y, z}, 5, new int[]{0, maxbound})) { if (z == 4 && x == (maxbound - 1) / 2 && y > 4 && y < 7) { if (y == 5) { schematic.blockData[x][y][z] = 3; //door bottom @@ -466,7 +461,7 @@ public class Schematic { } } - schematic.tileEntities = new ArrayList(); + schematic.tileEntities = new ArrayList<>(); TileEntity tileEntity = doorBlock.createTileEntity(DimDoors.proxy.getDefWorld(), doorBlock.getDefaultState()); NBTTagCompound tileNBT = tileEntity.serializeNBT(); tileNBT.setInteger("x", (maxbound - 1) / 2); diff --git a/src/main/java/com/zixiken/dimdoors/shared/util/DDStringUtils.java b/src/main/java/com/zixiken/dimdoors/shared/util/StringUtils.java similarity index 82% rename from src/main/java/com/zixiken/dimdoors/shared/util/DDStringUtils.java rename to src/main/java/com/zixiken/dimdoors/shared/util/StringUtils.java index ccbfe14d..9da055a5 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/util/DDStringUtils.java +++ b/src/main/java/com/zixiken/dimdoors/shared/util/StringUtils.java @@ -12,7 +12,7 @@ import java.util.List; * * @author Robijnvogel */ -public class DDStringUtils { +public class StringUtils { public static char flipCase(char in) { if (Character.isUpperCase(in)) { @@ -23,7 +23,7 @@ public class DDStringUtils { } public static List getAsStringList(Integer[] integers) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (int integer : integers) { list.add("" + integer); } @@ -34,7 +34,7 @@ public class DDStringUtils { if (template.equals("")) { return comparables; } - List results = new ArrayList(); + List results = new ArrayList<>(); for (String comparable : comparables) { if (isStartOfString(template, comparable, caseSensitive)) { results.add(comparable); @@ -53,11 +53,7 @@ public class DDStringUtils { for (int i = 0; i < template.length(); i++) { char tChar = template.charAt(i); char cChar = comparable.charAt(i); - if (tChar == cChar) { - //this matches, so continue the loop - } else if (!caseSensitive && flipCase(tChar) == cChar) { - //this matches, so continue the loop - } else { + if (tChar != cChar && !caseSensitive && flipCase(tChar) == cChar) { return false; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/BiomeGenPocket.java b/src/main/java/com/zixiken/dimdoors/shared/world/BiomeGenPocket.java deleted file mode 100644 index c37e41c9..00000000 --- a/src/main/java/com/zixiken/dimdoors/shared/world/BiomeGenPocket.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.zixiken.dimdoors.shared.world; - -/** - * Created by Jared Johnson on 1/24/2017. - */ -public class BiomeGenPocket { -} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/CustomSkyProvider.java b/src/main/java/com/zixiken/dimdoors/shared/world/CustomSkyProvider.java index 80ac1434..c1ef5408 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/CustomSkyProvider.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/CustomSkyProvider.java @@ -30,11 +30,11 @@ public class CustomSkyProvider extends IRenderHandler { @SideOnly(Side.CLIENT) @Override - public void render(float par1, WorldClient world, Minecraft mc) { + public void render(float partialTicks, WorldClient world, Minecraft mc) { starGLCallList = GLAllocation.generateDisplayLists(3); - glSkyList = this.starGLCallList + 1; - glSkyList2 = this.starGLCallList + 2; + glSkyList = starGLCallList + 1; + glSkyList2 = starGLCallList + 2; GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); @@ -42,11 +42,11 @@ public class CustomSkyProvider extends IRenderHandler { RenderHelper.disableStandardItemLighting(); GL11.glDepthMask(false); - mc.renderEngine.bindTexture((locationEndSkyPng)); + mc.renderEngine.bindTexture(locationEndSkyPng); if (mc.world.provider.isSurfaceWorld()) { GL11.glDisable(GL11.GL_TEXTURE_2D); - final Vec3d vec3 = world.getSkyColor(mc.getRenderViewEntity(), par1); + final Vec3d vec3 = world.getSkyColor(mc.getRenderViewEntity(), partialTicks); float f1 = (float) vec3.x; float f2 = (float) vec3.y; float f3 = (float) vec3.z; @@ -67,13 +67,13 @@ public class CustomSkyProvider extends IRenderHandler { GL11.glDepthMask(false); GL11.glEnable(GL11.GL_FOG); GL11.glColor3f(f1, f2, f3); - GL11.glCallList(this.glSkyList); + GL11.glCallList(glSkyList); GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.disableStandardItemLighting(); - float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(par1), par1); + float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); float f7; float f8; float f9; @@ -84,7 +84,7 @@ public class CustomSkyProvider extends IRenderHandler { GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); f4 = afloat[0]; f7 = afloat[1]; @@ -119,16 +119,16 @@ public class CustomSkyProvider extends IRenderHandler { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glPushMatrix(); - f4 = 1.0F - world.getRainStrength(par1); + f4 = 1.0F - world.getRainStrength(partialTicks); f7 = 0.0F; f8 = 0.0F; f9 = 0.0F; GL11.glColor4f(1.0F, 1.0F, 1.0F, f4); GL11.glTranslatef(f7, f8, f9); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(world.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); f10 = 30.0F; - mc.renderEngine.bindTexture(this.getSunRenderPath()); + mc.renderEngine.bindTexture(getSunRenderPath()); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(-f10, 100, -f10).tex(0, 0).endVertex(); buffer.pos(f10, 100, -f10).tex(1, 0).endVertex(); @@ -137,26 +137,24 @@ public class CustomSkyProvider extends IRenderHandler { tessellator.draw(); f10 = 20.0F; - mc.renderEngine.bindTexture(this.getMoonRenderPath()); + mc.renderEngine.bindTexture(getMoonRenderPath()); int k = world.getMoonPhase(); - int l = k % 4; + int i = k % 4; int i1 = k / 4 % 2; - float f14 = l + 0; - float f15 = i1 + 0; - float f16 = l + 1; + float f16 = i + 1; float f17 = i1 + 1; buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(-f10, -100, f10).tex(f16, f17).endVertex(); - buffer.pos(f10, -100, f10).tex(f14, f17).endVertex(); - buffer.pos(f10, -100, -f10).tex(f14, f15).endVertex(); - buffer.pos(-f10, -100, -f10).tex(f16, f15).endVertex(); + buffer.pos(f10, -100, f10).tex((float) i, f17).endVertex(); + buffer.pos(f10, -100, -f10).tex((float) i, (float) i1).endVertex(); + buffer.pos(-f10, -100, -f10).tex(f16, (float) i1).endVertex(); tessellator.draw(); GL11.glDisable(GL11.GL_TEXTURE_2D); - float f18 = world.getStarBrightness(par1) * f4; + float f18 = world.getStarBrightness(partialTicks) * f4; if (f18 > 0.0F) { GL11.glColor4f(f18, f18, f18, f18); - GL11.glCallList(this.starGLCallList); + GL11.glCallList(starGLCallList); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -166,12 +164,12 @@ public class CustomSkyProvider extends IRenderHandler { GL11.glPopMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0.0F, 0.0F, 0.0F); - double d0 = mc.player.getLook(par1).y - world.getHorizon(); + double d0 = mc.player.getLook(partialTicks).y - world.getHorizon(); if (d0 < 0.0D) { GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 12.0F, 0.0F); - GL11.glCallList(this.glSkyList2); + GL11.glCallList(glSkyList2); GL11.glPopMatrix(); f8 = 1.0F; f9 = -((float) (d0 + 65.0D)); @@ -209,11 +207,10 @@ public class CustomSkyProvider extends IRenderHandler { GL11.glPushMatrix(); GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F); - GL11.glCallList(this.glSkyList2); + GL11.glCallList(glSkyList2); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); } - } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/DimDoorDimensions.java b/src/main/java/com/zixiken/dimdoors/shared/world/DimDoorDimensions.java index 9c1660a1..8e96e8b8 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/DimDoorDimensions.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/DimDoorDimensions.java @@ -11,12 +11,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import net.minecraft.world.DimensionType; -import net.minecraft.world.WorldProvider; import net.minecraftforge.common.DimensionManager; public class DimDoorDimensions { - public static DimensionType LIMBO; + public static DimensionType LIMBO = null; private static int minPocketDimID; private static int maxPocketDimID; private static final List pocketTypes = new ArrayList<>(); @@ -43,12 +42,13 @@ public class DimDoorDimensions { registerDimension(pocketDimensionTypes.get(pocketType)); } - for (int i = 0; i < 0; i++) { //@todo: For future use? Like, server owners can add their own set of DimDoors DimensionTypes via the configs? Or is this nonsense? - dimID++; - DimensionType tempType = DimensionType.register("Name", "_name", dimID, WorldProvider.class, false); - CUSTOM.add(tempType); - registerDimension(tempType); - } + // TODO: For future use? Like, server owners can add their own set of DimDoors DimensionTypes via the configs? Or is this nonsense? + // for (int i = 0; i < 0; i++) { + // dimID++; + // DimensionType tempType = DimensionType.register("Name", "_name", dimID, WorldProvider.class, false); + // CUSTOM.add(tempType); + // registerDimension(tempType); + //} } public static void registerDimension(DimensionType dimension) { diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/biomes/DimDoorsBiome.java b/src/main/java/com/zixiken/dimdoors/shared/world/biomes/DimDoorsBiome.java index 3c36a212..18d36e8f 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/biomes/DimDoorsBiome.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/biomes/DimDoorsBiome.java @@ -5,22 +5,22 @@ import net.minecraft.world.biome.Biome; /** * Created by Jared Johnson on 1/24/2017. */ -public class DimDoorsBiome extends Biome -{ +public class DimDoorsBiome extends Biome { + public DimDoorsBiome(String name) { super(new BiomeProperties(name)); - this.decorator.treesPerChunk = 0; - this.decorator.flowersPerChunk = 0; - this.decorator.grassPerChunk = 0; + decorator.treesPerChunk = 0; + decorator.flowersPerChunk = 0; + decorator.grassPerChunk = 0; - this.spawnableMonsterList.clear(); - this.spawnableCreatureList.clear(); - this.spawnableWaterCreatureList.clear(); - this.spawnableCaveCreatureList.clear(); + spawnableMonsterList.clear(); + spawnableCreatureList.clear(); + spawnableWaterCreatureList.clear(); + spawnableCaveCreatureList.clear(); } @Override public boolean canRain() { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboBiome.java b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboBiome.java index b6f7ac2b..54bab2aa 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboBiome.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboBiome.java @@ -3,7 +3,8 @@ package com.zixiken.dimdoors.shared.world.limbodimension; import com.zixiken.dimdoors.shared.world.biomes.DimDoorsBiome; public class LimboBiome extends DimDoorsBiome { + public LimboBiome() { super("limbo"); } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboDecay.java b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboDecay.java index 0aba33db..ebe05777 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboDecay.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboDecay.java @@ -167,6 +167,6 @@ public class LimboDecay { } } - return (block == null || !(block instanceof BlockContainer)); + return !(block instanceof BlockContainer); } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboGenerator.java b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboGenerator.java index 2c53da1c..57037f77 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboGenerator.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboGenerator.java @@ -19,9 +19,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -public class LimboGenerator implements IChunkGenerator -{ - private static Random rand; +public class LimboGenerator implements IChunkGenerator { + + private Random rand; /** A NoiseGeneratorOctaves used in generating terrain */ private NoiseGeneratorOctaves noiseGen1; @@ -75,44 +75,44 @@ public class LimboGenerator implements IChunkGenerator */ float[] parabolicField; int[][] field_73219_j = new int[32][32]; - { - // caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); - } + //{ + // caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); + //} //private CustomLimboPopulator spawner; public LimboGenerator(World world, long seed /*CustomLimboPopulator spawner*/) { - this.worldObj = world; - LimboGenerator.rand = new Random(seed); - this.noiseGen1 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //base terrain - this.noiseGen2 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //hillyness - this.noiseGen3 = new NoiseGeneratorOctaves(LimboGenerator.rand, 80); //seems to adjust the size of features, how stretched things are -default 8 - this.noiseGen4 = new NoiseGeneratorOctaves(LimboGenerator.rand, 4); - this.noiseGen5 = new NoiseGeneratorOctaves(LimboGenerator.rand, 10); - this.noiseGen6 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); - this.mobSpawnerNoise = new NoiseGeneratorOctaves(LimboGenerator.rand, 8); + worldObj = world; + rand = new Random(seed); + noiseGen1 = new NoiseGeneratorOctaves(rand, 16); //base terrain + noiseGen2 = new NoiseGeneratorOctaves(rand, 16); //hillyness + noiseGen3 = new NoiseGeneratorOctaves(rand, 80); //seems to adjust the size of features, how stretched things are -default 8 + noiseGen4 = new NoiseGeneratorOctaves(rand, 4); + noiseGen5 = new NoiseGeneratorOctaves(rand, 10); + noiseGen6 = new NoiseGeneratorOctaves(rand, 16); + mobSpawnerNoise = new NoiseGeneratorOctaves(rand, 8); NoiseGeneratorOctaves[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise}; // noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); - this.noiseGen1 = noiseGens[0]; - this.noiseGen2 = noiseGens[1]; - this.noiseGen3 = noiseGens[2]; - this.noiseGen4 = noiseGens[3]; - this.noiseGen5 = noiseGens[4]; - this.noiseGen6 = noiseGens[5]; - this.mobSpawnerNoise = noiseGens[6]; + noiseGen1 = noiseGens[0]; + noiseGen2 = noiseGens[1]; + noiseGen3 = noiseGens[2]; + noiseGen4 = noiseGens[3]; + noiseGen5 = noiseGens[4]; + noiseGen6 = noiseGens[5]; + mobSpawnerNoise = noiseGens[6]; - this.worldObj = world; + worldObj = world; //this.spawner = spawner; } @Override - public Chunk generateChunk(int chunkX, int chunkZ) { + public Chunk generateChunk(int x, int z) { //TODO: Wtf? Why do you reinitialize the seed when we already initialized it in the constructor?! ~SenseiKiwi - LimboGenerator.rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L); + rand.setSeed(x * 341873128712L + z * 132897987541L); ChunkPrimer primer = new ChunkPrimer(); - this.scale(chunkX, chunkZ, primer); - Chunk chunk = new Chunk(this.worldObj, primer, chunkX, chunkZ); + scale(x, z, primer); + Chunk chunk = new Chunk(worldObj, primer, x, z); chunk.generateSkylightMap(); if (!chunk.isTerrainPopulated()) { @@ -124,7 +124,7 @@ public class LimboGenerator implements IChunkGenerator } @Override - public void populate(int var2, int var3) { + public void populate(int x, int z) { } @@ -138,24 +138,24 @@ public class LimboGenerator implements IChunkGenerator par1ArrayOfDouble = new double[par5 * par6 * par7]; } - if (this.parabolicField == null) { - this.parabolicField = new float[25]; + if (parabolicField == null) { + parabolicField = new float[25]; for (int var8 = -2; var8 <= 2; ++var8) { for (int var9 = -2; var9 <= 2; ++var9) { float var10 = 10.0F / MathHelper.sqrt(var8 * var8 + var9 * var9 + 0.2F); - this.parabolicField[var8 + 2 + (var9 + 2) * 5] = var10; + parabolicField[var8 + 2 + (var9 + 2) * 5] = var10; } } } double var44 = 884.412D; //large values here create spiky land. add a 0, good -default 884 double var45 = 9840.412D; //large values here make sheets- default - 684 - this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D); - this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D); - this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D); - this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44); - this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44); + noise5 = noiseGen5.generateNoiseOctaves(noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D); + noise6 = noiseGen6.generateNoiseOctaves(noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D); + noise3 = noiseGen3.generateNoiseOctaves(noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D); + noise1 = noiseGen1.generateNoiseOctaves(noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44); + noise2 = noiseGen2.generateNoiseOctaves(noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44); int var12 = 0; int var13 = 0; @@ -169,7 +169,7 @@ public class LimboGenerator implements IChunkGenerator for (int var21 = -var19; var21 <= var19; ++var21) { for (int var22 = -var19; var22 <= var19; ++var22) { - float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (Biomes.PLAINS.getBaseHeight() + 9.0F); + float var24 = parabolicField[var21 + 2 + (var22 + 2) * 5] / (Biomes.PLAINS.getBaseHeight() + 9.0F); //this adjusts the height of the terrain @@ -182,9 +182,9 @@ public class LimboGenerator implements IChunkGenerator var16 /= var18; var17 /= var18; - var16 = (var16 * 0.9F + 0.1F); + var16 = var16 * 0.9F + 0.1F; var17 = (var17 * 4.0F - 1.0F) / 8.0F; - double var47 = this.noise6[var13] / 8000.0D; + double var47 = noise6[var13] / 8000.0D; if (var47 < 0.0D) { var47 = -var47 * 0.3D; @@ -214,20 +214,19 @@ public class LimboGenerator implements IChunkGenerator for (int var46 = 0; var46 < par6; ++var46) { double var48 = var17; - double var26 = var16; var48 += var47 * 0.2D; var48 = var48 * par6 / 16.0D; double var28 = par6 / 2.0D + var48 * 4.0D; - double var30 = 0.0D; - double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / var26; + double var30; + double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / (double) var16; if (var32 < 0.0D) { var32 *= 4.0D; } - double var34 = this.noise1[var12] / 512.0D; - double var36 = this.noise2[var12] / 512.0D; - double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D; + double var34 = noise1[var12] / 512.0D; + double var36 = noise2[var12] / 512.0D; + double var38 = (noise3[var12] / 10.0D + 1.0D) / 2.0D; if (var38 < 0.0D) { var30 = var34; @@ -257,8 +256,8 @@ public class LimboGenerator implements IChunkGenerator public void scale(int x, int z, ChunkPrimer primer) { //Coursty of // TODO: this: - this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); - this.noiseArray = this.initializeNoiseField(this.noiseArray, x * 4, 0, z * 4, 5, 17, 5); + biomesForGeneration = worldObj.getBiomeProvider().getBiomesForGeneration(biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); + noiseArray = initializeNoiseField(noiseArray, x * 4, 0, z * 4, 5, 17, 5); int xzSections = 4; int xzSectionSize = 4; @@ -281,14 +280,14 @@ public class LimboGenerator implements IChunkGenerator for (int sectionY = 0; sectionY < ySections; ++sectionY) { int ySectionPart = sectionY * ySectionSize; - double v0y0 = this.noiseArray[i0_0 + sectionY]; - double v0y1 = this.noiseArray[i0_1 + sectionY]; - double v1y0 = this.noiseArray[i1_0 + sectionY]; - double v1y1 = this.noiseArray[i1_1 + sectionY]; - double d0y0 = (this.noiseArray[i0_0 + sectionY + 1] - v0y0) * yScale; - double d0y1 = (this.noiseArray[i0_1 + sectionY + 1] - v0y1) * yScale; - double d1y0 = (this.noiseArray[i1_0 + sectionY + 1] - v1y0) * yScale; - double d1y1 = (this.noiseArray[i1_1 + sectionY + 1] - v1y1) * yScale; + double v0y0 = noiseArray[i0_0 + sectionY]; + double v0y1 = noiseArray[i0_1 + sectionY]; + double v1y0 = noiseArray[i1_0 + sectionY]; + double v1y1 = noiseArray[i1_1 + sectionY]; + double d0y0 = (noiseArray[i0_0 + sectionY + 1] - v0y0) * yScale; + double d0y1 = (noiseArray[i0_1 + sectionY + 1] - v0y1) * yScale; + double d1y0 = (noiseArray[i1_0 + sectionY + 1] - v1y0) * yScale; + double d1y1 = (noiseArray[i1_1 + sectionY + 1] - v1y1) * yScale; for (int yRel = 0; yRel < ySectionSize; ++yRel) { int yCoord = ySectionPart + yRel; @@ -328,8 +327,8 @@ public class LimboGenerator implements IChunkGenerator } @Override - public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, BlockPos pos) { - return new ArrayList(); + public List getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { + return new ArrayList<>(); } @Nullable @@ -347,4 +346,4 @@ public class LimboGenerator implements IChunkGenerator public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos) { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboSkyProvider.java b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboSkyProvider.java index 9cdac6cc..40862a0e 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboSkyProvider.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/LimboSkyProvider.java @@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation; * Created by Jared Johnson on 1/24/2017. */ public class LimboSkyProvider extends CustomSkyProvider { + private static final ResourceLocation limboMoonResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_moon.png"); private static final ResourceLocation limboSunResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_sun.png"); diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/WorldProviderLimbo.java b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/WorldProviderLimbo.java index ccfd4fbd..d139270c 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/WorldProviderLimbo.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/limbodimension/WorldProviderLimbo.java @@ -12,7 +12,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.DimensionType; -import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.IChunkGenerator; @@ -21,12 +20,13 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class WorldProviderLimbo extends WorldProvider { + private IRenderHandler skyRenderer; private LimboBiome limboBiome; public WorldProviderLimbo() { - this.hasSkyLight = false; - this.skyRenderer = new LimboSkyProvider(); + hasSkyLight = false; + skyRenderer = new LimboSkyProvider(); limboBiome = new LimboBiome(); //this.spawner } @@ -43,8 +43,7 @@ public class WorldProviderLimbo extends WorldProvider { } @Override - public boolean canRespawnHere() - { + public boolean canRespawnHere() { return false; //properties.HardcoreLimboEnabled; } @@ -65,18 +64,18 @@ public class WorldProviderLimbo extends WorldProvider { for (int steps = 0; steps <= 15; ++steps) { float var3 = 1.0F - steps / 15.0F; - this.lightBrightnessTable[steps] = ((0.0F + var3) / (var3 * 3.0F + 1.0F) * (1.0F - modifier) + modifier)*3; + lightBrightnessTable[steps] = ((0.0F + var3) / (var3 * 3.0F + 1.0F) * (1.0F - modifier) + modifier)*3; // System.out.println( this.lightBrightnessTable[steps]+"light"); } } @Override public BlockPos getSpawnPoint() { - return this.getRandomizedSpawnPoint(); + return getRandomizedSpawnPoint(); } @Override - public float calculateCelestialAngle(long par1, float par3) { + public float calculateCelestialAngle(long worldTime, float partialTicks) { return 0; } @@ -87,18 +86,18 @@ public class WorldProviderLimbo extends WorldProvider { @Override public String getSaveFolder() { - return ("DIM" + getDimension() + "DimDoorsLimbo"); + return "DIM" + getDimension() + "DimDoorsLimbo"; } @Override public boolean canCoordinateBeSpawn(int x, int z) { - BlockPos pos = this.world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)); + BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)); return world.getBlockState(pos).equals(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.UNRAVELED)); } @Override public double getHorizon() { - return world.getHeight()/4-800; + return (double) world.getHeight() / 4 - 800; } @SideOnly(Side.CLIENT) @@ -111,7 +110,7 @@ public class WorldProviderLimbo extends WorldProvider { } @SideOnly(Side.CLIENT) @Override - public Vec3d getFogColor(float par1, float par2) { + public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { return new Vec3d(.2, .2, .2); } @@ -131,15 +130,15 @@ public class WorldProviderLimbo extends WorldProvider { } public static Location getLimboSkySpawn(EntityPlayer player) { - int x = (int) (player.posX) + MathHelper.clamp(player.world.rand.nextInt(), -100, 100); //-properties.LimboEntryRange, properties.LimboEntryRange); - int z = (int) (player.posZ) + MathHelper.clamp(player.world.rand.nextInt(), -100, 100); //-properties.LimboEntryRange, properties.LimboEntryRange); + int x = (int) player.posX + MathHelper.clamp(player.world.rand.nextInt(), -100, 100); //-properties.LimboEntryRange, properties.LimboEntryRange); + int z = (int) player.posZ + MathHelper.clamp(player.world.rand.nextInt(), -100, 100); //-properties.LimboEntryRange, properties.LimboEntryRange); return new Location(DimDoorDimensions.LIMBO.getId(), x, 700, z); } @Override public BlockPos getRandomizedSpawnPoint() { - int x = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); - int z = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); + int x = MathHelper.clamp(world.rand.nextInt(), -500, 500); + int z = MathHelper.clamp(world.rand.nextInt(), -500, 500); return new BlockPos(x, 700, z); } diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/PocketChunkGenerator.java b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/PocketChunkGenerator.java index 02ebaff7..f53b3b2b 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/PocketChunkGenerator.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/PocketChunkGenerator.java @@ -13,20 +13,21 @@ import java.util.ArrayList; import java.util.List; public class PocketChunkGenerator implements IChunkGenerator { + private World worldObj; //private CustomLimboPopulator spawner; public PocketChunkGenerator(World world, long seed /*CustomLimboPopulator spawner*/) { - this.worldObj = world; + worldObj = world; //this.spawner = spawner; } @Override - public Chunk generateChunk(int chunkX, int chunkZ) { + public Chunk generateChunk(int x, int z) { ChunkPrimer primer = new ChunkPrimer(); - Chunk chunk = new Chunk(worldObj, primer, chunkX, chunkZ); + Chunk chunk = new Chunk(worldObj, primer, x, z); if(!chunk.isTerrainPopulated()) { chunk.setTerrainPopulated(true); @@ -36,7 +37,7 @@ public class PocketChunkGenerator implements IChunkGenerator { } @Override - public void populate(int chunkX, int chunkZ) { + public void populate(int x, int z) { } @@ -47,7 +48,7 @@ public class PocketChunkGenerator implements IChunkGenerator { @Override public List getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { - return new ArrayList(); + return new ArrayList<>(); } @Nullable @@ -65,4 +66,4 @@ public class PocketChunkGenerator implements IChunkGenerator { public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos) { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderDungeonPocket.java b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderDungeonPocket.java index 0e9bf85c..8000d2e4 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderDungeonPocket.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderDungeonPocket.java @@ -13,7 +13,7 @@ public class WorldProviderDungeonPocket extends WorldProviderPublicPocket { @Override public String getSaveFolder() { - return ("DIM" + getDimension() + "DimDoorsDungeon"); + return "DIM" + getDimension() + "DimDoorsDungeon"; } @Override diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPersonalPocket.java b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPersonalPocket.java index 8d6d878f..86b7b5f0 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPersonalPocket.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPersonalPocket.java @@ -33,7 +33,7 @@ public class WorldProviderPersonalPocket extends WorldProviderPublicPocket { @SideOnly(Side.CLIENT) @Override - public Vec3d getFogColor(float par1, float par2) { + public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { return new Vec3d(1, 1, 1); } @@ -49,6 +49,6 @@ public class WorldProviderPersonalPocket extends WorldProviderPublicPocket { @Override public String getSaveFolder() { - return ("DIM" + getDimension() + "DimDoorsPersonal"); + return "DIM" + getDimension() + "DimDoorsPersonal"; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPublicPocket.java b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPublicPocket.java index ebca674e..b1511ef9 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPublicPocket.java +++ b/src/main/java/com/zixiken/dimdoors/shared/world/pocketdimension/WorldProviderPublicPocket.java @@ -4,7 +4,6 @@ import com.zixiken.dimdoors.client.CloudRenderBlank; import com.zixiken.dimdoors.shared.EnumPocketType; import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.DimensionType; @@ -14,13 +13,13 @@ import net.minecraftforge.client.IRenderHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might want an abstract super class to this one? +public class WorldProviderPublicPocket extends WorldProvider { //@todo, we might want an abstract super class to this one? //protected CustomLimboPopulator spawner; protected IRenderHandler skyRenderer; public WorldProviderPublicPocket() { - this.hasSkyLight = true; + hasSkyLight = true; } @SideOnly(Side.CLIENT) @@ -32,7 +31,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might @SideOnly(Side.CLIENT) @Override - public Vec3d getFogColor(float par1, float par2) { + public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { return Vec3d.ZERO; } @@ -47,7 +46,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might } @Override - public boolean canSnowAt(BlockPos pos, boolean light) { + public boolean canSnowAt(BlockPos pos, boolean checkLight) { return false; } @@ -57,7 +56,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might } @Override - public float calculateCelestialAngle(long par1, float par3) { + public float calculateCelestialAngle(long worldTime, float partialTicks) { return .5F; } @@ -91,7 +90,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might @Override public String getSaveFolder() { - return ("DIM" + getDimension() + "DimDoorsPublic"); + return "DIM" + getDimension() + "DimDoorsPublic"; } @Override diff --git a/src/main/resources/assets/dimdoors/blockstates/fabric.json b/src/main/resources/assets/dimdoors/blockstates/fabric.json index a1bd0580..4779d408 100644 --- a/src/main/resources/assets/dimdoors/blockstates/fabric.json +++ b/src/main/resources/assets/dimdoors/blockstates/fabric.json @@ -6,4 +6,4 @@ "type=unraveled": { "model": "dimdoors:fabric_unraveled" }, "type=eternal": { "model": "dimdoors:fabric_eternal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/lang/de_DE.lang b/src/main/resources/assets/dimdoors/lang/de_DE.lang index 997d4a3f..9e0c7731 100644 --- a/src/main/resources/assets/dimdoors/lang/de_DE.lang +++ b/src/main/resources/assets/dimdoors/lang/de_DE.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=Spalts, um ein Portal zu erstellen, info.warp_dimensional_door2=oder platziere irgendwo in einer info.warp_dimensional_door3=kleinen Dimension, um sie zu verlassen. -entity.dimdoors.monolith.name=Monolith \ No newline at end of file +entity.dimdoors.monolith.name=Monolith diff --git a/src/main/resources/assets/dimdoors/lang/en_US.lang b/src/main/resources/assets/dimdoors/lang/en_US.lang index f7609c20..783882a4 100644 --- a/src/main/resources/assets/dimdoors/lang/en_US.lang +++ b/src/main/resources/assets/dimdoors/lang/en_US.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=a rift to create a portal, info.warp_dimensional_door2=or place anywhere in a info.warp_dimensional_door3=pocket dimension to exit. -entity.dimdoors.monolith.name=Monolith \ No newline at end of file +entity.dimdoors.monolith.name=Monolith diff --git a/src/main/resources/assets/dimdoors/lang/fr_CA.lang b/src/main/resources/assets/dimdoors/lang/fr_CA.lang index 438280c2..0e912a2e 100644 --- a/src/main/resources/assets/dimdoors/lang/fr_CA.lang +++ b/src/main/resources/assets/dimdoors/lang/fr_CA.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=fissure pour créer un portail, info.warp_dimensional_door2=ou placez n'importe où dans une info.warp_dimensional_door3=dimension de poche pour sortir. -entity.dimdoors.monolith.name=Monolithe \ No newline at end of file +entity.dimdoors.monolith.name=Monolithe diff --git a/src/main/resources/assets/dimdoors/lang/it_IT.lang b/src/main/resources/assets/dimdoors/lang/it_IT.lang index 29bfd842..d6af09f4 100644 --- a/src/main/resources/assets/dimdoors/lang/it_IT.lang +++ b/src/main/resources/assets/dimdoors/lang/it_IT.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=frattura per creare un portale, info.warp_dimensional_door2=o piazzalo da qualunque altra parte info.warp_dimensional_door3=in una dimensione tascabile per uscire. -entity.dimdoors.monolith.name=Monolito \ No newline at end of file +entity.dimdoors.monolith.name=Monolito diff --git a/src/main/resources/assets/dimdoors/lang/nl_NL.lang b/src/main/resources/assets/dimdoors/lang/nl_NL.lang index 735c570a..444c9611 100644 --- a/src/main/resources/assets/dimdoors/lang/nl_NL.lang +++ b/src/main/resources/assets/dimdoors/lang/nl_NL.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=om een portaal te creëren, info.warp_dimensional_door2=of plaats het ergens in een info.warp_dimensional_door3=broekzak dimensie om deze te verlaten. -entity.dimdoors.monolith.name=Monoliet \ No newline at end of file +entity.dimdoors.monolith.name=Monoliet diff --git a/src/main/resources/assets/dimdoors/lang/ru_RU.lang b/src/main/resources/assets/dimdoors/lang/ru_RU.lang index a22d65d3..1027af34 100644 --- a/src/main/resources/assets/dimdoors/lang/ru_RU.lang +++ b/src/main/resources/assets/dimdoors/lang/ru_RU.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=разломом, чтобы создать порт info.warp_dimensional_door2=или поставьте куда угодно в info.warp_dimensional_door3=карманном измерении, чтобы выйти из него. -entity.dimdoors.monolith.name=Монолит \ No newline at end of file +entity.dimdoors.monolith.name=Монолит diff --git a/src/main/resources/assets/dimdoors/lang/zh_CN.lang b/src/main/resources/assets/dimdoors/lang/zh_CN.lang index c338151f..1534ae6b 100644 --- a/src/main/resources/assets/dimdoors/lang/zh_CN.lang +++ b/src/main/resources/assets/dimdoors/lang/zh_CN.lang @@ -76,4 +76,4 @@ info.warp_dimensional_door1=来制造传送门, info.warp_dimensional_door2=放在口袋次元中 info.warp_dimensional_door3=以退出空间. -entity.dimdoors.monolith.name=巨石 \ No newline at end of file +entity.dimdoors.monolith.name=巨石 diff --git a/src/main/resources/assets/dimdoors/models/block/fabric_altered.json b/src/main/resources/assets/dimdoors/models/block/fabric_altered.json index 22c7b6ee..e81f4e7c 100644 --- a/src/main/resources/assets/dimdoors/models/block/fabric_altered.json +++ b/src/main/resources/assets/dimdoors/models/block/fabric_altered.json @@ -1,4 +1,4 @@ { "parent": "block/cube_all", "textures": { "all": "dimdoors:blocks/fabric_altered" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/block/fabric_ancient.json b/src/main/resources/assets/dimdoors/models/block/fabric_ancient.json index cb864180..3e4a50eb 100644 --- a/src/main/resources/assets/dimdoors/models/block/fabric_ancient.json +++ b/src/main/resources/assets/dimdoors/models/block/fabric_ancient.json @@ -1,4 +1,4 @@ { "parent": "block/cube_all", "textures": { "all": "dimdoors:blocks/fabric_ancient" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/block/fabric_eternal.json b/src/main/resources/assets/dimdoors/models/block/fabric_eternal.json index 2a78e70b..4cf3389e 100644 --- a/src/main/resources/assets/dimdoors/models/block/fabric_eternal.json +++ b/src/main/resources/assets/dimdoors/models/block/fabric_eternal.json @@ -1,4 +1,4 @@ { "parent": "block/cube_all", "textures": { "all": "dimdoors:blocks/fabric_eternal" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/block/fabric_reality.json b/src/main/resources/assets/dimdoors/models/block/fabric_reality.json index 7301f2f5..335a4dd9 100644 --- a/src/main/resources/assets/dimdoors/models/block/fabric_reality.json +++ b/src/main/resources/assets/dimdoors/models/block/fabric_reality.json @@ -1,4 +1,4 @@ { "parent": "block/cube_all", "textures": { "all": "dimdoors:blocks/fabric_reality" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/block/fabric_unraveled.json b/src/main/resources/assets/dimdoors/models/block/fabric_unraveled.json index 190487f9..3355e028 100644 --- a/src/main/resources/assets/dimdoors/models/block/fabric_unraveled.json +++ b/src/main/resources/assets/dimdoors/models/block/fabric_unraveled.json @@ -1,4 +1,4 @@ { "parent": "block/cube_all", "textures": { "all": "dimdoors:blocks/fabric_unraveled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/block/no_texture.json b/src/main/resources/assets/dimdoors/models/block/no_texture.json index ed756b69..600757a6 100644 --- a/src/main/resources/assets/dimdoors/models/block/no_texture.json +++ b/src/main/resources/assets/dimdoors/models/block/no_texture.json @@ -1,3 +1,3 @@ { "parent": "builtin/missing" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/dimensional_trapdoor.json b/src/main/resources/assets/dimdoors/models/item/dimensional_trapdoor.json index cff98a2b..e34957e4 100644 --- a/src/main/resources/assets/dimdoors/models/item/dimensional_trapdoor.json +++ b/src/main/resources/assets/dimdoors/models/item/dimensional_trapdoor.json @@ -1,3 +1,3 @@ { "parent": "dimdoors:block/dimensional_trapdoor_bottom" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/fabric_altered.json b/src/main/resources/assets/dimdoors/models/item/fabric_altered.json index 09699624..e4d0e196 100644 --- a/src/main/resources/assets/dimdoors/models/item/fabric_altered.json +++ b/src/main/resources/assets/dimdoors/models/item/fabric_altered.json @@ -7,4 +7,4 @@ "scale": [ 0.375, 0.375, 0.375 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/fabric_ancient.json b/src/main/resources/assets/dimdoors/models/item/fabric_ancient.json index 6ba76017..a76cff15 100644 --- a/src/main/resources/assets/dimdoors/models/item/fabric_ancient.json +++ b/src/main/resources/assets/dimdoors/models/item/fabric_ancient.json @@ -7,4 +7,4 @@ "scale": [ 0.375, 0.375, 0.375 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/fabric_eternal.json b/src/main/resources/assets/dimdoors/models/item/fabric_eternal.json index 6261fa85..930ae47e 100644 --- a/src/main/resources/assets/dimdoors/models/item/fabric_eternal.json +++ b/src/main/resources/assets/dimdoors/models/item/fabric_eternal.json @@ -7,4 +7,4 @@ "scale": [ 0.375, 0.375, 0.375 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/fabric_reality.json b/src/main/resources/assets/dimdoors/models/item/fabric_reality.json index 8440c5b1..fef4def9 100644 --- a/src/main/resources/assets/dimdoors/models/item/fabric_reality.json +++ b/src/main/resources/assets/dimdoors/models/item/fabric_reality.json @@ -7,4 +7,4 @@ "scale": [ 0.375, 0.375, 0.375 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/fabric_unraveled.json b/src/main/resources/assets/dimdoors/models/item/fabric_unraveled.json index cfa25d96..7cfab7cc 100644 --- a/src/main/resources/assets/dimdoors/models/item/fabric_unraveled.json +++ b/src/main/resources/assets/dimdoors/models/item/fabric_unraveled.json @@ -7,4 +7,4 @@ "scale": [ 0.375, 0.375, 0.375 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/rift.json b/src/main/resources/assets/dimdoors/models/item/rift.json index ed756b69..600757a6 100644 --- a/src/main/resources/assets/dimdoors/models/item/rift.json +++ b/src/main/resources/assets/dimdoors/models/item/rift.json @@ -1,3 +1,3 @@ { "parent": "builtin/missing" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/models/item/transient_dimensional_door.json b/src/main/resources/assets/dimdoors/models/item/transient_dimensional_door.json index ed756b69..600757a6 100644 --- a/src/main/resources/assets/dimdoors/models/item/transient_dimensional_door.json +++ b/src/main/resources/assets/dimdoors/models/item/transient_dimensional_door.json @@ -1,3 +1,3 @@ { "parent": "builtin/missing" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/pockets/json/default_private.json b/src/main/resources/assets/dimdoors/pockets/json/default_private.json index 5f99955c..18da8ba8 100644 --- a/src/main/resources/assets/dimdoors/pockets/json/default_private.json +++ b/src/main/resources/assets/dimdoors/pockets/json/default_private.json @@ -38,14 +38,14 @@ "maxDepth": 0, "weights": [100] }, - { + { "variantName": "defaultPrivate_5", "size": 5, "minDepth": 0, "maxDepth": 0, "weights": [100] }, - { + { "variantName": "defaultPrivate_6", "size": 6, "minDepth": 0, diff --git a/src/main/resources/assets/dimdoors/sounds.json b/src/main/resources/assets/dimdoors/sounds.json index 14d08315..380e7edf 100644 --- a/src/main/resources/assets/dimdoors/sounds.json +++ b/src/main/resources/assets/dimdoors/sounds.json @@ -12,4 +12,4 @@ "riftEnd": { "sounds" : [ "dimdoors:rift_end" ] }, "riftStart": { "sounds" : [ "dimdoors:rift_start" ] }, "tearing": { "sounds" : [ "dimdoors:tearing"] } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/dimdoors/textures/blocks/fabric_ancient.png.mcmeta b/src/main/resources/assets/dimdoors/textures/blocks/fabric_ancient.png.mcmeta index 7c10f7b7..6ea4af5e 100644 --- a/src/main/resources/assets/dimdoors/textures/blocks/fabric_ancient.png.mcmeta +++ b/src/main/resources/assets/dimdoors/textures/blocks/fabric_ancient.png.mcmeta @@ -1,3 +1,3 @@ { - "animation": { "frametime": 2 } + "animation": { "frametime": 2 } } \ No newline at end of file diff --git a/src/main/resources/assets/dimdoors/textures/blocks/fabric_unraveled.png.mcmeta b/src/main/resources/assets/dimdoors/textures/blocks/fabric_unraveled.png.mcmeta index 69accca7..736f5127 100644 --- a/src/main/resources/assets/dimdoors/textures/blocks/fabric_unraveled.png.mcmeta +++ b/src/main/resources/assets/dimdoors/textures/blocks/fabric_unraveled.png.mcmeta @@ -1,3 +1,3 @@ { - "animation": { "frametime": 10 } + "animation": { "frametime": 10 } } \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 4ed7a559..0d78970b 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,5 +1,5 @@ { - "modListVersion":2, + "modListVersion": 2, "modList": [ { @@ -10,7 +10,7 @@ "credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu, Recent updates by Zixiken and Waterpicker", "logoFile": "/dimdoors_logo.png", "mcversion": "1.12.2", - "url": "http://www.minecraftforum.net/topic/1650007", + "url": "https://github.com/DimensionalDevelopment/DimDoors", "updateUrl": "", "authorList": [ "StevenRS11", "SenseiKiwi", "Zixiken", "WaterPicker", "Robijnvogel" ], "parent":"", @@ -18,4 +18,4 @@ "dependencies": [ "forge" ] } ] -} \ No newline at end of file +}