Merge pull request #12 from Runemoro/1.12-WIP

Code clean up
This commit is contained in:
ZombieHDGaming 2017-12-05 20:32:27 -05:00 committed by GitHub
commit b48c31817b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 948 additions and 1097 deletions

View file

@ -24,7 +24,7 @@ Linux/Mac OS: "./gradlew setupDecompWorkspace"
Step 3: After all that finished, you're left with a choice. 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) 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. 1. Open IDEA, and import project.
2. Select your build.gradle file and have it import. 2. Select your build.gradle file and have it import.
3. Once it's finished you must close IntelliJ and run the following command: 3. Once it's finished you must close IntelliJ and run the following command:

View file

@ -10,7 +10,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge' 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. //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.mcversion = "1.12.2"
ext.forgeversion = "14.23.1.2555" ext.forgeversion = "14.23.1.2555"
//spongeSchematicVersion = "1" //spongeSchematicVersion = "1"
@ -46,8 +46,7 @@ jar {
from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }
} }
processResources processResources {
{
// this will ensure that this task is redone when the versions change. // this will ensure that this task is redone when the versions change.
inputs.property "version", project.version inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version inputs.property "mcversion", project.minecraft.version

View file

@ -10,7 +10,6 @@ import com.zixiken.dimdoors.shared.RiftRegistry;
import com.zixiken.dimdoors.shared.SchematicHandler; import com.zixiken.dimdoors.shared.SchematicHandler;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
@ -27,8 +26,8 @@ import java.util.List;
@Mod(modid = DimDoors.MODID, name = "Dimensional Doors", version = DimDoors.VERSION, dependencies = "required-after:forge@[14.23.0.2517,)") @Mod(modid = DimDoors.MODID, name = "Dimensional Doors", version = DimDoors.VERSION, dependencies = "required-after:forge@[14.23.0.2517,)")
public class DimDoors { public class DimDoors {
public static final String VERSION = "${version}";
public static final String MODID = "dimdoors"; public static final String MODID = "dimdoors";
public static final String VERSION = "${version}";
@SidedProxy(clientSide = "com.zixiken.dimdoors.client.DDProxyClient", @SidedProxy(clientSide = "com.zixiken.dimdoors.client.DDProxyClient",
serverSide = "com.zixiken.dimdoors.server.DDProxyServer") serverSide = "com.zixiken.dimdoors.server.DDProxyServer")
@ -67,7 +66,6 @@ public class DimDoors {
private void registerCommands(FMLServerStartingEvent event) { private void registerCommands(FMLServerStartingEvent event) {
event.registerServerCommand(new TeleportCommand()); event.registerServerCommand(new TeleportCommand());
event.registerServerCommand(new PocketCommand()); event.registerServerCommand(new PocketCommand());
//@todo event.registerServerCommand( new DDCommand() ); //to register commands that this mod offers?
} }
public static boolean isClient() { public static boolean isClient() {
@ -86,14 +84,31 @@ public class DimDoors {
player.sendMessage(new TextComponentString("[DimDoors] " + text)); player.sendMessage(new TextComponentString("[DimDoors] " + text));
} }
public static void warn(Class classFiredFrom, String text) { public static void warn(String text) {
FMLLog.warning("[DimDoors] " + text + " (" + classFiredFrom.toString() + " )", 0); warn(null, text);
} }
public static void log(Class classFiredFrom, String text) { public static void warn(Class<?> classFiredFrom, String text) {
FMLLog.info("[DimDoors] " + text + " (" + classFiredFrom.toString() + " )", 0); 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<String> list) { public static void translateAndAdd(String key, List<String> list) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
if (I18n.canTranslate(key + Integer.toString(i))) { if (I18n.canTranslate(key + Integer.toString(i))) {

View file

@ -19,23 +19,19 @@ public class ClosingRiftFX extends Particle {
private boolean hasFadeColour; private boolean hasFadeColour;
public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) { public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z); super(world, x, y, z);
this.motionX = motionX; this.motionX = motionX;
this.motionY = motionY; this.motionY = motionY;
this.motionZ = motionZ; this.motionZ = motionZ;
this.particleScale *= .55F; particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16); particleMaxAge = 30 + rand.nextInt(16);
} }
@Override @Override
public void renderParticle(BufferBuilder worldRenderer, Entity entityIn, float partialTicks, float p_180434_4_, public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX,
float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
if (!this.twinkle if (!twinkle || particleAge < particleMaxAge / 3 || (particleAge + particleMaxAge) / 3 % 2 == 0) {
|| this.particleAge < this.particleMaxAge / 3 doRenderParticle(buffer, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
|| (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_);
} }
} }
@ -43,29 +39,29 @@ public class ClosingRiftFX extends Particle {
float par5, float par6, float par7) { float par5, float par6, float par7) {
float var8 = super.particleTextureIndexX % 16 / 16.0F; float var8 = super.particleTextureIndexX % 16 / 16.0F;
float var9 = var8 + 0.0624375F; float var9 = var8 + 0.0624375F;
float var10 = this.particleTextureIndexX / 16 / 16.0F; float var10 = particleTextureIndexX / 16 / 16.0F;
float var11 = var10 + 0.0624375F; float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale; float var12 = 0.1F * particleScale;
float var13 = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX); float var13 = (float) (prevPosX + (posX - prevPosX) * par2 - interpPosX);
float var14 = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY); float var14 = (float) (prevPosY + (posY - prevPosY) * par2 - interpPosY);
float var15 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); float var15 = (float) (prevPosZ + (posZ - prevPosZ) * par2 - interpPosZ);
float var16 = 0.8F; float var16 = 0.8F;
worldRenderer.pos(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12) worldRenderer.pos(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12)
.tex(var9, var11) .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(); .endVertex();
worldRenderer.pos(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12) worldRenderer.pos(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12)
.tex(var9, var10) .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(); .endVertex();
worldRenderer.pos(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12) worldRenderer.pos(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12)
.tex(var8, var10) .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(); .endVertex();
worldRenderer.pos(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12) worldRenderer.pos(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12)
.tex(var8, var11) .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(); .endVertex();
} }
@ -74,48 +70,49 @@ public class ClosingRiftFX extends Particle {
*/ */
@Override @Override
public void onUpdate() { public void onUpdate() {
this.prevPosX = this.posX; prevPosX = posX;
this.prevPosY = this.posY; prevPosY = posY;
this.prevPosZ = this.posZ; prevPosZ = posZ;
particleAge++;
if (this.particleAge++ >= this.particleMaxAge) { if (particleAge >= particleMaxAge) {
this.setExpired(); setExpired();
} }
if (this.particleAge > this.particleMaxAge / 2) { if (particleAge > particleMaxAge / 2) {
this.setAlphaF(1.0F - ((float) this.particleAge - (float) (this.particleMaxAge / 2)) / this.particleMaxAge); setAlphaF(1.0F - ((float) particleAge - (float) (particleMaxAge / 2)) / particleMaxAge);
if (this.hasFadeColour) { if (hasFadeColour) {
this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F; particleRed += (fadeColourRed - particleRed) * 0.2F;
this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F; particleGreen += (fadeColourGreen - particleGreen) * 0.2F;
this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 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.motionY -= 0.004D;
this.move(this.motionX, this.motionY, this.motionZ); move(motionX, motionY, motionZ);
this.motionX *= 0.9100000262260437D; motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D; motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D; motionZ *= 0.9100000262260437D;
if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) { if (trail && particleAge < particleMaxAge / 2 && (particleAge + particleMaxAge) % 2 == 0) {
ClosingRiftFX var1 = new ClosingRiftFX(this.world, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); ClosingRiftFX var1 = new ClosingRiftFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue); var1.setRBGColorF(particleRed, particleGreen, particleBlue);
var1.particleAge = var1.particleMaxAge / 2; var1.particleAge = var1.particleMaxAge / 2;
if (this.hasFadeColour) { if (hasFadeColour) {
var1.hasFadeColour = true; var1.hasFadeColour = true;
var1.fadeColourRed = this.fadeColourRed; var1.fadeColourRed = fadeColourRed;
var1.fadeColourGreen = this.fadeColourGreen; var1.fadeColourGreen = fadeColourGreen;
var1.fadeColourBlue = this.fadeColourBlue; var1.fadeColourBlue = fadeColourBlue;
} }
var1.twinkle = this.twinkle; var1.twinkle = twinkle;
} }
} }
@Override @Override
public int getBrightnessForRender(float par1) { public int getBrightnessForRender(float p_189214_1_) {
return 15728880; return 15728880;
} }
} }

View file

@ -10,8 +10,7 @@ public class CloudRenderBlank extends IRenderHandler
{ {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void render(float partialTicks, WorldClient world, Minecraft mc) public void render(float partialTicks, WorldClient world, Minecraft mc) {
{
} }
} }

View file

@ -9,19 +9,14 @@ import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor;
import com.zixiken.dimdoors.shared.tileentities.TileEntityRift; import com.zixiken.dimdoors.shared.tileentities.TileEntityRift;
import com.zixiken.dimdoors.shared.tileentities.TileEntityTransTrapdoor; import com.zixiken.dimdoors.shared.tileentities.TileEntityTransTrapdoor;
import net.minecraft.client.Minecraft; 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.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry; 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.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"})
public class DDProxyClient extends DDProxyCommon { public class DDProxyClient extends DDProxyCommon {
@Override @Override
@ -45,13 +40,7 @@ public class DDProxyClient extends DDProxyCommon {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDimDoor.class, new RenderDimDoor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDimDoor.class, new RenderDimDoor());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransTrapdoor.class, new RenderTransTrapdoor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransTrapdoor.class, new RenderTransTrapdoor());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRift.class, new RenderRift()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRift.class, new RenderRift());
RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, new IRenderFactory<MobMonolith>() RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, manager -> new RenderMobObelisk(manager, 0.5f));
{
@Override
public Render<? super MobMonolith> createRenderFor(RenderManager manager) {
return new RenderMobObelisk(manager, 0.5f);
}
});
} }
@Override @Override
@ -64,11 +53,6 @@ public class DDProxyClient extends DDProxyCommon {
return Minecraft.getMinecraft().player; return Minecraft.getMinecraft().player;
} }
@Override
public World getDefWorld() {
return getWorldServer(0); //gets the client world dim 0 handler
}
@Override @Override
public WorldServer getWorldServer(int dimId) { public WorldServer getWorldServer(int dimId) {
return Minecraft.getMinecraft().getIntegratedServer().getWorld(dimId); return Minecraft.getMinecraft().getIntegratedServer().getWorld(dimId);

View file

@ -8,9 +8,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GoggleRiftFX extends ParticleCloud { public class GoggleRiftFX extends ParticleCloud {
public GoggleRiftFX(World par1World, double par2, double par4, double par6, public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) {
double par8, double par10, double par12) {
super(par1World, par2, par4, par6, par12, par12, par12); super(par1World, par2, par4, par6, par12, par12, par12);
this.particleMaxAge = 40 + this.rand.nextInt(26); particleMaxAge = 40 + rand.nextInt(26);
} }
} }

View file

@ -1,7 +1,5 @@
package com.zixiken.dimdoors.client; 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.nio.FloatBuffer;
import java.util.Random; import java.util.Random;
@ -42,7 +40,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
float var16 = 0.2625F; float var16 = 0.2625F;
float var17 = 1.0F / (var15 + .80F); float var17 = 1.0F / (var15 + .80F);
this.bindTexture(warpPath); bindTexture(warpPath);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
if (count == 0) { if (count == 0) {
@ -72,28 +70,28 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
switch (orientation) { switch (orientation) {
case SOUTH: 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.S, GL11.GL_OBJECT_PLANE, 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.T, GL11.GL_OBJECT_PLANE, 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.R, GL11.GL_OBJECT_PLANE, 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.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
break; break;
case WEST: 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.S, GL11.GL_OBJECT_PLANE, 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.T, GL11.GL_OBJECT_PLANE, 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.R, GL11.GL_OBJECT_PLANE, 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.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
break; break;
case NORTH: 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.S, GL11.GL_OBJECT_PLANE, 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.T, GL11.GL_OBJECT_PLANE, 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.R, GL11.GL_OBJECT_PLANE, 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.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
break; break;
case EAST: 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.S, GL11.GL_OBJECT_PLANE, 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.T, GL11.GL_OBJECT_PLANE, 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.R, GL11.GL_OBJECT_PLANE, 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.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
break; break;
} }
@ -265,7 +263,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
renderDimDoorTileEntity(te, x, y, z); renderDimDoorTileEntity(te, x, y, z);
if (te.lockStatus >= 1) { if (te.lockStatus >= 1) {
for (int i = 0; i < 1 + te.lockStatus; i++) { for (int i = 0; i < 1 + te.lockStatus; i++) {
this.renderKeyHole(te, x, y, z, i); renderKeyHole(te, x, y, z, i);
} }
} }

View file

@ -4,25 +4,20 @@ import com.flowpowered.math.TrigMath;
import com.flowpowered.math.vector.Vector3f; import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector4f; import com.flowpowered.math.vector.Vector4f;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.items.ModItems;
import com.zixiken.dimdoors.shared.tileentities.TileEntityRift; import com.zixiken.dimdoors.shared.tileentities.TileEntityRift;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class RenderRift extends TileEntitySpecialRenderer<TileEntityRift> { public class RenderRift extends TileEntitySpecialRenderer<TileEntityRift> {
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 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), 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<TileEntityRift> {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.disableCull(); GlStateManager.disableCull();
this.bindTexture(tesseract_path); bindTexture(tesseract_path);
GlStateManager.translate(x+0.5,y+0.5,z+0.5); GlStateManager.translate(x+0.5,y+0.5,z+0.5);
GlStateManager.scale(0.25,0.25,0.25); GlStateManager.scale(0.25,0.25,0.25);
@ -180,7 +175,8 @@ public class RenderRift extends TileEntitySpecialRenderer<TileEntityRift> {
} }
private double update(float partialTicks) { 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) { private Vector4f rotation(Vector4f v, double angle) {

View file

@ -15,7 +15,6 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexBuffer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -45,7 +44,7 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
float var17 = 1.0F / (var15 + 1.0F); float var17 = 1.0F / (var15 + 1.0F);
if (count == 0) { if (count == 0) {
this.bindTexture(riftPath); bindTexture(riftPath);
var17 = 0.1F; var17 = 0.1F;
var15 = 25.0F; var15 = 25.0F;
var16 = 0.125F; var16 = 0.125F;
@ -54,7 +53,7 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
} }
if (count == 1) { if (count == 1) {
this.bindTexture(warpPath); bindTexture(warpPath);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE); GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
var16 = .5F; var16 = .5F;
@ -70,10 +69,10 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.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.T, GL11.GL_OBJECT_PLANE, 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.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
@ -144,14 +143,14 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
} }
private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) { private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) {
this.buffer.clear(); buffer.clear();
this.buffer.put(par1).put(par2).put(par3).put(par4); buffer.put(par1).put(par2).put(par3).put(par4);
this.buffer.flip(); buffer.flip();
return this.buffer; return buffer;
} }
@Override @Override
public void render(TileEntityTransTrapdoor te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { public void render(TileEntityTransTrapdoor te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
this.renderTransTrapdoorTileEntity(te, x, y, z, partialTicks, alpha); renderTransTrapdoorTileEntity(te, x, y, z, partialTicks, alpha);
} }
} }

View file

@ -7,7 +7,6 @@ package com.zixiken.dimdoors.server;
import com.zixiken.dimdoors.shared.DDProxyCommon; import com.zixiken.dimdoors.shared.DDProxyCommon;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
@ -27,14 +26,8 @@ public class DDProxyServer extends DDProxyCommon {
return null; return null;
} }
@Override
public World getDefWorld() {
return getWorldServer(0); //gets the server world dim 0 handler
}
@Override @Override
public WorldServer getWorldServer(int dimId) { public WorldServer getWorldServer(int dimId) {
return DimensionManager.getWorld(dimId); return DimensionManager.getWorld(dimId);
} }
} }

View file

@ -1,47 +1,30 @@
package com.zixiken.dimdoors.server.sound; package com.zixiken.dimdoors.server.sound;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class DDSounds { public class DDSounds {
private DDSounds() {}
public static SoundEvent CRACK = create("crack"); public static final SoundEvent CRACK = create("crack");
public static final SoundEvent CREEPY = create("creepy");
public static SoundEvent CREEPY = create("creepy"); public static final SoundEvent DOOR_LOCKED = create("door_locked");
public static final SoundEvent DOOR_LOCK_REMOVED = create("door_lock_removed");
public static SoundEvent DOOR_LOCKED = create("door_locked"); public static final SoundEvent KEY_LOCK = create("key");
public static final SoundEvent KEY_UNLOCKED = create("key_unlock");
public static SoundEvent DOOR_LOCK_REMOVED = create("door_lock_removed"); public static final SoundEvent MONK = create("monk");
public static final SoundEvent RIFT = create("rift");
public static SoundEvent KEY_LOCK = create("key"); public static final SoundEvent RIFT_CLOSE = create("rift_close");
public static final SoundEvent RIFT_DOOR = create("rift_door");
public static SoundEvent KEY_UNLOCKED = create("key_unlock"); public static final SoundEvent RIFT_END = create("rift_end");
public static final SoundEvent RIFT_START = create("rift_start");
public static SoundEvent MONK = create("monk"); public static final SoundEvent TEARING = create("tearing");
public static SoundEvent RIFT = create("rift");
public static SoundEvent RIFT_CLOSE = create("rift_close");
public static SoundEvent RIFT_DOOR = create("rift_door");
public static SoundEvent RIFT_END = create("rift_end");
public static SoundEvent RIFT_START = create("rift_start");
public static SoundEvent TEARING = create("tearing");
private static SoundEvent create(String name) { private static SoundEvent create(String name) {
ResourceLocation id = new ResourceLocation(DimDoors.MODID, name); ResourceLocation id = new ResourceLocation(DimDoors.MODID, name);
SoundEvent sound = new SoundEvent(id).setRegistryName(name); return new SoundEvent(id).setRegistryName(name);
// GameRegistry.register(sound);
return sound;
} }
@SubscribeEvent @SubscribeEvent

View file

@ -16,6 +16,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.GameData;
public class CraftingManager { public class CraftingManager {
public static ResourceLocation getNameForRecipe(ItemStack output) { public static ResourceLocation getNameForRecipe(ItemStack output) {
ResourceLocation baseLoc = new ResourceLocation(DimDoors.MODID, output.getItem().getRegistryName().getResourcePath()); ResourceLocation baseLoc = new ResourceLocation(DimDoors.MODID, output.getItem().getRegistryName().getResourcePath());
ResourceLocation recipeLoc = baseLoc; ResourceLocation recipeLoc = baseLoc;
@ -45,7 +46,7 @@ public class CraftingManager {
} }
@SubscribeEvent @SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) { public static void registerRecipes(RegistryEvent.Register<IRecipe> event) { // TODO
event.getRegistry().register(makeShapedRecipe(new ItemStack(ModItems.STABLE_FABRIC, 1), event.getRegistry().register(makeShapedRecipe(new ItemStack(ModItems.STABLE_FABRIC, 1),
"yxy", 'x', Items.ENDER_PEARL, 'y', ModItems.WORLD_THREAD)); "yxy", 'x', Items.ENDER_PEARL, 'y', ModItems.WORLD_THREAD));

View file

@ -8,6 +8,7 @@ package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
@ -35,8 +36,8 @@ public class DDConfig {
private static int maxDungeonDepth = 8; private static int maxDungeonDepth = 8;
private static int owCoordinateOffsetBase = 64; private static int owCoordinateOffsetBase = 64;
private static double owCoordinateOffsetPower = 1.3; private static double owCoordinateOffsetPower = 1.3;
private static int[] doorRelativeDepths = new int[]{-1, 0, 1}; private static int[] doorRelativeDepths = {-1, 0, 1};
private static int[] doorRelativeDepthWeights = new int[]{20, 30, 50}; private static int[] doorRelativeDepthWeights = {20, 30, 50};
private static boolean dangerousLimboMonolithsEnabled = false; private static boolean dangerousLimboMonolithsEnabled = false;
private static boolean monolithTeleportationEnabled = true; private static boolean monolithTeleportationEnabled = true;
@ -113,7 +114,7 @@ public class DDConfig {
DimDoors.log(DDConfig.class, "pocketGridSize was set to " + pocketGridSize); DimDoors.log(DDConfig.class, "pocketGridSize was set to " + pocketGridSize);
maxPocketSize = setConfigIntWithMaxAndMin(config, "pocket_dimension", "maxPocketSize", maxPocketSize, 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, 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); "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<String> getDungeonSchematicNames() { public static List<String> getDungeonSchematicNames() {
List<String> dungeonSchematicNamesArrayList = new ArrayList<>(); List<String> dungeonSchematicNamesArrayList = new ArrayList<>();
for (String dungeonSchematicName : dungeonSchematicNames) { Collections.addAll(dungeonSchematicNamesArrayList, dungeonSchematicNames);
dungeonSchematicNamesArrayList.add(dungeonSchematicName);
}
return dungeonSchematicNamesArrayList; return dungeonSchematicNamesArrayList;
} }

View file

@ -16,27 +16,16 @@ import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
/**
*
* @author Robijnvogel
*/
public class DDEventHandler { public class DDEventHandler {
@SubscribeEvent @SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event) { 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(); Entity entity = event.getEntity();
World world = entity.world; if(entity instanceof EntityPlayer && !entity.world.isRemote) { // check that it's a player first to avoid calling String.contains for every entity
if (!world.isRemote) { if (!DDConfig.HAVE_CONFIG_DEFAULTS_BEEN_CHECKED_FOR_CORRECTNESS && !DimDoors.VERSION.contains("a")) { // default values were not checked in non-alpha version
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity; 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."); 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 @SubscribeEvent
public void onEntityEnterChunk(EntityEvent.EnteringChunk event) { public void onEntityEnterChunk(EntityEvent.EnteringChunk event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof EntityPlayerMP) { if (entity instanceof EntityPlayerMP) {
World world = entity.world;
if (!world.isRemote && DimDoorDimensions.isPocketDimensionID(world.provider.getDimension())) {
EntityPlayerMP player = (EntityPlayerMP) entity; EntityPlayerMP player = (EntityPlayerMP) entity;
checkPlayerLocationPermission(player); World world = entity.world;
} 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
*
* @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.");
} }
} }
} }

View file

@ -5,13 +5,7 @@ import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
import com.zixiken.dimdoors.shared.blocks.ModBlocks; import com.zixiken.dimdoors.shared.blocks.ModBlocks;
import com.zixiken.dimdoors.shared.entities.MobMonolith; import com.zixiken.dimdoors.shared.entities.MobMonolith;
import com.zixiken.dimdoors.shared.items.ModItems; import com.zixiken.dimdoors.shared.items.ModItems;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor; import com.zixiken.dimdoors.shared.tileentities.*;
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.world.DimDoorDimensions; import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -36,19 +30,20 @@ public abstract class DDProxyCommon implements IDDProxy {
DimDoorDimensions.init(); DimDoorDimensions.init();
GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor"); GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor"); // TODO: use new registry
GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift"); GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift");
GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityTransTrapdoor"); GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityTransTrapdoor");
GameRegistry.registerTileEntity(TileEntityDimDoorGold.class, "TileEntityDimDoorGold"); GameRegistry.registerTileEntity(TileEntityDimDoorGold.class, "TileEntityDimDoorGold");
GameRegistry.registerTileEntity(TileEntityDimDoorPersonal.class, "TileEntityDimDoorPersonal"); GameRegistry.registerTileEntity(TileEntityDimDoorPersonal.class, "TileEntityDimDoorPersonal");
GameRegistry.registerTileEntity(TileEntityDimDoorChaos.class, "TileEntityDimDoorChaos"); GameRegistry.registerTileEntity(TileEntityDimDoorUnstable.class, "TileEntityDimDoorUnstable");
GameRegistry.registerTileEntity(TileEntityDimDoorWarp.class, "TileEntityDimDoorWarp"); 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 @Override
public void onInitialization(FMLInitializationEvent event) { 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) { public void updateDoorTE(BlockDimDoorBase door, World world, BlockPos pos) {
@ -66,5 +61,7 @@ public abstract class DDProxyCommon implements IDDProxy {
} }
@Override @Override
public abstract boolean isClient(); public World getDefWorld() {
return getWorldServer(0); //gets the client world dim 0 handler
}
} }

View file

@ -23,5 +23,4 @@ abstract class DDSavedData extends WorldSavedData {
File saveDir = world.getSaveHandler().getWorldDirectory(); File saveDir = world.getSaveHandler().getWorldDirectory();
return new File(saveDir, "dimdoors/"); return new File(saveDir, "dimdoors/");
} }
} }

View file

@ -10,6 +10,7 @@ package com.zixiken.dimdoors.shared;
* @author s101426 * @author s101426
*/ */
public enum EnumPocketType { public enum EnumPocketType {
PRIVATE, PUBLIC, DUNGEON; PRIVATE, PUBLIC, DUNGEON;
static EnumPocketType getFromInt(int integer) { static EnumPocketType getFromInt(int integer) {

View file

@ -13,7 +13,6 @@ import net.minecraftforge.client.model.ModelLoader;
import static net.minecraft.item.Item.getItemFromBlock; import static net.minecraft.item.Item.getItemFromBlock;
@SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"})
public class ModelManager { public class ModelManager {
public static void registerModels() { public static void registerModels() {
@ -60,7 +59,6 @@ public class ModelManager {
new ModelResourceLocation(item.getRegistryName() + "_" + name, "inventory")); new ModelResourceLocation(item.getRegistryName() + "_" + name, "inventory"));
} }
@SuppressWarnings("LocalVariableDeclarationSideOnly")
public static void addCustomStateMappers() { public static void addCustomStateMappers() {
StateMap map = new StateMap.Builder().ignore(BlockDoor.POWERED).build(); StateMap map = new StateMap.Builder().ignore(BlockDoor.POWERED).build();

View file

@ -27,7 +27,7 @@ import net.minecraft.world.WorldServer;
*/ */
public class Pocket { 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 size; //in chunks 0 -> 1*1 chunk, 1 -> 2*2 chunks
private final int depth; private final int depth;
private final EnumPocketType typeID; // dungeon, pocket, or personal pocket private final EnumPocketType typeID; // dungeon, pocket, or personal pocket
@ -46,11 +46,11 @@ public class Pocket {
this.z = z; this.z = z;
this.riftIDs = riftIDs; this.riftIDs = riftIDs;
this.depthZeroLocation = depthZeroLocation; this.depthZeroLocation = depthZeroLocation;
playerUUIDs = new ArrayList(); playerUUIDs = new ArrayList<>();
} }
public int getID() { public int getID() {
return ID; return id;
} }
public int getX() { public int getX() {
@ -77,15 +77,15 @@ public class Pocket {
} }
public void setID(int newID) { 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) { for (int riftID : riftIDs) {
Location riftLocation = RiftRegistry.INSTANCE.getRiftLocation(riftID); Location riftLocation = RiftRegistry.INSTANCE.getRiftLocation(riftID);
WorldServer worldServer = DimDoors.proxy.getWorldServer(riftLocation.getDimensionID()); WorldServer worldServer = DimDoors.proxy.getWorldServer(riftLocation.getDimensionID());
if (!worldServer.isRemote) { if (!worldServer.isRemote) {
DDTileEntityBase rift = (DDTileEntityBase) riftLocation.getTileEntity(); 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")); EnumPocketType typeID = EnumPocketType.getFromInt(pocketNBT.getInteger("typeID"));
int x = pocketNBT.getInteger("x"); int x = pocketNBT.getInteger("x");
int z = pocketNBT.getInteger("z"); int z = pocketNBT.getInteger("z");
List<Integer> riftIDs = new ArrayList(); List<Integer> riftIDs = new ArrayList<>();
NBTTagList doorsTagList = (NBTTagList) pocketNBT.getTag("doorIDs"); NBTTagList doorsTagList = (NBTTagList) pocketNBT.getTag("doorIDs");
for (int i = 0; i < doorsTagList.tagCount(); i++) { for (int i = 0; i < doorsTagList.tagCount(); i++) {
int doorID = doorsTagList.getIntAt(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 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"); NBTTagList playersTagList = (NBTTagList) pocketNBT.getTag("playerUUIDs");
for (int i = 0; i < playersTagList.tagCount(); i++) { for (int i = 0; i < playersTagList.tagCount(); i++) {
String playerUUID = playersTagList.getStringTagAt(i); String playerUUID = playersTagList.getStringTagAt(i);
@ -117,7 +117,7 @@ public class Pocket {
static NBTBase writeToNBT(Pocket pocket) { static NBTBase writeToNBT(Pocket pocket) {
NBTTagCompound pocketNBT = new NBTTagCompound(); NBTTagCompound pocketNBT = new NBTTagCompound();
pocketNBT.setInteger("ID", pocket.ID); pocketNBT.setInteger("id", pocket.id);
pocketNBT.setInteger("size", pocket.size); pocketNBT.setInteger("size", pocket.size);
pocketNBT.setInteger("depth", pocket.depth); pocketNBT.setInteger("depth", pocket.depth);
pocketNBT.setInteger("typeID", pocket.typeID.getIntValue()); pocketNBT.setInteger("typeID", pocket.typeID.getIntValue());
@ -150,7 +150,7 @@ public class Pocket {
int riftID = riftIDs.get(i); int riftID = riftIDs.get(i);
//DimDoors.log(Pocket.class, "findWarpDoorIndex: i = " + i + " riftID = " + riftID); //for troubleshooting purposes //DimDoors.log(Pocket.class, "findWarpDoorIndex: i = " + i + " riftID = " + riftID); //for troubleshooting purposes
TileEntity tileEntity = RiftRegistry.INSTANCE.getRiftLocation(riftID).getTileEntity(); TileEntity tileEntity = RiftRegistry.INSTANCE.getRiftLocation(riftID).getTileEntity();
if (tileEntity != null && tileEntity instanceof TileEntityDimDoorWarp) { if (tileEntity instanceof TileEntityDimDoorWarp) {
index = i; index = i;
break; break;
} }
@ -195,17 +195,11 @@ public class Pocket {
boolean isLocationWithinPocketBounds(final Location location, final int gridSize) { boolean isLocationWithinPocketBounds(final Location location, final int gridSize) {
int locX = location.getPos().getX(); int locX = location.getPos().getX();
int locZ = location.getPos().getY(); int locZ = location.getPos().getY();
//minimum bounds of the pocket // pocket bounds
int pocX = x * gridSize; int pocMinX = x * gridSize;
int pocZ = z * gridSize; int pocMinZ = z * gridSize;
if (pocX <= locX && pocZ <= locZ) { int pocMaxX = pocMinX + (size + 1) * 16;
//convert to maximum bounds of the pocket int pocMaxZ = pocMinX + (size + 1) * 16;
pocX = pocX + (size + 1) * 16; return pocMinX <= locX && pocMinZ <= locZ && locX < pocMaxX && locZ < pocMaxZ;
pocZ = pocZ + (size + 1) * 16;
if (locX < pocX && locZ < pocZ) {
return true;
}
}
return false;
} }
} }

View file

@ -7,7 +7,7 @@ package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.DimDoors; 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 com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -38,16 +38,16 @@ public class PocketRegistry {
// Methods // Methods
private PocketRegistry() { private PocketRegistry() {
nextUnusedIDs = new HashMap(); nextUnusedIDs = new HashMap<>();
for (EnumPocketType pocketType : EnumPocketType.values()) { for (EnumPocketType pocketType : EnumPocketType.values()) {
nextUnusedIDs.put(pocketType, 0); nextUnusedIDs.put(pocketType, 0);
} }
privatePockets = new HashMap(); privatePockets = new HashMap<>();
pocketLists = new HashMap(); pocketLists = new HashMap<>();
for (EnumPocketType pocketType : EnumPocketType.values()) { for (EnumPocketType pocketType : EnumPocketType.values()) {
pocketLists.put(pocketType, new HashMap()); pocketLists.put(pocketType, new HashMap<>());
} }
pocketListsPerDepth = new ArrayList(); pocketListsPerDepth = new ArrayList<>();
} }
public int getGridSize() { public int getGridSize() {
@ -99,8 +99,8 @@ public class PocketRegistry {
if (nbt.hasKey("privatePockets")) { if (nbt.hasKey("privatePockets")) {
NBTTagCompound privatePocketsTagCompound = nbt.getCompoundTag("privatePockets"); NBTTagCompound privatePocketsTagCompound = nbt.getCompoundTag("privatePockets");
privatePockets.clear(); privatePockets.clear();
for (String UUID : privatePocketsTagCompound.getKeySet()) { for (String uuid : privatePocketsTagCompound.getKeySet()) {
privatePockets.put(UUID, privatePocketsTagCompound.getInteger(UUID)); privatePockets.put(uuid, privatePocketsTagCompound.getInteger(uuid));
} }
} }
if (nbt.hasKey("pocketData")) { if (nbt.hasKey("pocketData")) {
@ -109,7 +109,7 @@ public class PocketRegistry {
for (EnumPocketType pocketType : EnumPocketType.values()) { for (EnumPocketType pocketType : EnumPocketType.values()) {
String tagListName = pocketType.toString(); String tagListName = pocketType.toString();
if (pocketsTagCompound.hasKey(tagListName)) { if (pocketsTagCompound.hasKey(tagListName)) {
Map<Integer, Pocket> pocketList = new HashMap(); Map<Integer, Pocket> pocketList = new HashMap<>();
NBTTagList pocketTagList = (NBTTagList) pocketsTagCompound.getTag(tagListName); 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) 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); NBTTagCompound pocketTag = pocketTagList.getCompoundTagAt(j);
@ -137,8 +137,8 @@ public class PocketRegistry {
nbt.setTag("nextUnusedIDs", nextUnusedIDTagCompound); nbt.setTag("nextUnusedIDs", nextUnusedIDTagCompound);
NBTTagCompound privatePocketsTagCompound = new NBTTagCompound(); NBTTagCompound privatePocketsTagCompound = new NBTTagCompound();
for (String UUID : privatePockets.keySet()) { for (String uuid : privatePockets.keySet()) {
privatePocketsTagCompound.setInteger(UUID, privatePockets.get(UUID)); privatePocketsTagCompound.setInteger(uuid, privatePockets.get(uuid));
} }
nbt.setTag("privatePockets", privatePocketsTagCompound); nbt.setTag("privatePockets", privatePocketsTagCompound);
@ -171,17 +171,11 @@ public class PocketRegistry {
} }
} }
public Pocket getPocket(int ID, EnumPocketType pocketType) { public Pocket getPocket(int id, EnumPocketType pocketType) {
return pocketLists.get(pocketType).get(ID); 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 public Pocket generateRandomPocketAt(EnumPocketType typeID, int depth, Location origRiftLocation) {
Pocket pocket = generateRandomPocketAt(typeID, depth, origRiftLocation);
int entranceDoorID = pocket.getEntranceDoorID();
return entranceDoorID;
}
private Pocket generateRandomPocketAt(EnumPocketType typeID, int depth, Location origRiftLocation) {
//Correcting the depth. Just in case... //Correcting the depth. Just in case...
if (typeID == EnumPocketType.DUNGEON) { if (typeID == EnumPocketType.DUNGEON) {
if (depth <= 0) { if (depth <= 0) {
@ -193,7 +187,7 @@ public class PocketRegistry {
depth = 0; depth = 0;
} }
//Fetching the pocket template // Fetch the pocket template
PocketTemplate pocketTemplate = getRandomPocketTemplate(typeID, depth, maxPocketSize); PocketTemplate pocketTemplate = getRandomPocketTemplate(typeID, depth, maxPocketSize);
return generatePocketAt(typeID, depth, origRiftLocation, pocketTemplate); return generatePocketAt(typeID, depth, origRiftLocation, pocketTemplate);
@ -206,12 +200,17 @@ public class PocketRegistry {
int shortenedZ = shortenedLocation.getPos().getZ(); int shortenedZ = shortenedLocation.getPos().getZ();
int dimID = shortenedLocation.getDimensionID(); int dimID = shortenedLocation.getDimensionID();
Location depthZeroLocation; Location depthZeroLocation;
if (typeID == EnumPocketType.DUNGEON) { switch (typeID) {
depthZeroLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), depth, origRiftLocation); case DUNGEON:
} else if (typeID == EnumPocketType.PUBLIC) { depthZeroLocation = RandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), depth, origRiftLocation);
depthZeroLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), 1, origRiftLocation); break;
} else { //PRIVATE case PUBLIC:
depthZeroLocation = RandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), 1, origRiftLocation);
break;
case PRIVATE:
default:
depthZeroLocation = origRiftLocation; depthZeroLocation = origRiftLocation;
break;
} }
Pocket pocket = pocketTemplate.place(shortenedX, 0, shortenedZ, gridSize, dimID, nextUnusedIDs.get(typeID), depth, typeID, depthZeroLocation); 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) { public int getPrivateDimDoorID(String playerUUID) {
if (!privatePockets.containsKey(playerUUID)) { if (!privatePockets.containsKey(playerUUID)) {
//generate a new private pocket //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); privatePockets.put(playerUUID, doorID);
return doorID; return doorID;
} }
@ -239,17 +238,16 @@ public class PocketRegistry {
z = 0; z = 0;
} else { } else {
int radius = (int) Math.sqrt(nextUnusedID); //casting to int rounds down the double resulting from taking the square root int radius = (int) Math.sqrt(nextUnusedID); //casting to int rounds down the double resulting from taking the square root
int radiusNumber = nextUnusedID - (radius * radius); int radiusNumber = nextUnusedID - radius * radius;
double splitter = ((double) radiusNumber) / ((double) radius); //always between 0 and 2 double splitter = (double) radiusNumber / (double) radius; //always between 0 and 2
DimDoors.log(this.getClass(), "id is " + nextUnusedID); DimDoors.log(getClass(), "id is " + nextUnusedID);
DimDoors.log(this.getClass(), "Radius is " + radius); DimDoors.log(getClass(), "Radius is " + radius);
DimDoors.log(this.getClass(), "Radius number is " + radiusNumber); DimDoors.log(getClass(), "Radius number is " + radiusNumber);
DimDoors.log(this.getClass(), "Splitter is " + splitter); DimDoors.log(getClass(), "Splitter is " + splitter);
x = splitter <= 1.0 ? radius : radius - (radiusNumber - radius); x = splitter <= 1.0 ? radius : radius - (radiusNumber - radius);
z = splitter >= 1.0 ? radius : radiusNumber; z = splitter >= 1.0 ? radius : radiusNumber;
} }
Location location = new Location(dimID, x, y, z); return new Location(dimID, x, y, z);
return location;
} }
private PocketTemplate getRandomPocketTemplate(EnumPocketType typeID, int depth, int maxPocketSize) { 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) { public boolean isPlayerAllowedToBeHere(final EntityPlayerMP player, final Location location) {
if (player.isCreative()) {
return true;
} else {
int pocketID = getPocketIDFromCoords(location); int pocketID = getPocketIDFromCoords(location);
if (pocketID < 0) { // not in a pocket dimension if (pocketID < 0) { // not in a pocket dimension
return true; return true;
} else { } else {
EnumPocketType type = DimDoorDimensions.getPocketType(location.getDimensionID()); EnumPocketType type = DimDoorDimensions.getPocketType(location.getDimensionID());
Pocket pocket = pocketLists.get(type).get(pocketID); Pocket pocket = pocketLists.get(type).get(pocketID);
if (pocket.isPlayerAllowedInPocket(player) && pocket.isLocationWithinPocketBounds(location, gridSize)) { return pocket.isPlayerAllowedInPocket(player) && pocket.isLocationWithinPocketBounds(location, gridSize);
return true;
}
return false;
}
} }
} }
} }

View file

@ -43,21 +43,21 @@ public class PocketSavedData extends DDSavedData {
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound pocketnbt) { public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
NBTTagCompound pockets = new NBTTagCompound(); NBTTagCompound pockets = new NBTTagCompound();
PocketRegistry.INSTANCE.writeToNBT(pockets); PocketRegistry.INSTANCE.writeToNBT(pockets);
pocketnbt.setTag("pockets", pockets); nbt.setTag("pockets", pockets);
return pocketnbt; return nbt;
} }
@Override @Override
public void readFromNBT(NBTTagCompound pocketnbt) { public void readFromNBT(NBTTagCompound nbt) {
// Load NBT // Load NBT
if (pocketnbt != null) { if (nbt != null) {
if (pocketnbt.hasKey("pockets")) { if (nbt.hasKey("pockets")) {
NBTTagCompound pockets = pocketnbt.getCompoundTag("pockets"); NBTTagCompound pockets = nbt.getCompoundTag("pockets");
PocketRegistry.INSTANCE.readFromNBT(pockets); PocketRegistry.INSTANCE.readFromNBT(pockets);
} }
} }

View file

@ -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 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 xBase = shortenedX * gridSize * 16;
int zBase = shortenedZ * gridSize * 16; int zBase = shortenedZ * gridSize * 16;
DimDoors.log(this.getClass(), "Placing new pocket at x = " + xBase + ", z = " + zBase); DimDoors.log(getClass(), "Placing new pocket at x = " + xBase + ", z = " + zBase);
DimDoors.log(this.getClass(), "Name of new pocket schematic is " + schematic.getSchematicName()); DimDoors.log(getClass(), "Name of new pocket schematic is " + schematic.getSchematicName());
if (schematic == null) { 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; return null;
} }
//@todo make sure that the door tile entities get registered! //@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 //Load TileEntity Data
List<DDTileEntityBase> rifts = new ArrayList(); List<DDTileEntityBase> rifts = new ArrayList<>();
for (NBTTagCompound tileEntityNBT : schematic.getTileEntities()) { for (NBTTagCompound tileEntityNBT : schematic.getTileEntities()) {
BlockPos pos = new BlockPos(xBase + tileEntityNBT.getInteger("x"), yBase + tileEntityNBT.getInteger("y"), zBase + tileEntityNBT.getInteger("z")); 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); TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity != null) { if (tileEntity != null) {
if (tileEntity instanceof DDTileEntityBase) { 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; DDTileEntityBase rift = (DDTileEntityBase) tileEntity;
rifts.add(rift); rifts.add(rift);
if (rift instanceof TileEntityDimDoor) { if (rift instanceof TileEntityDimDoor) {
@ -133,7 +133,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
try { try {
tileEntity.readFromNBT(tileEntityNBT); //this reads in the wrong blockPos tileEntity.readFromNBT(tileEntityNBT); //this reads in the wrong blockPos
} catch(Exception e) { } 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 tileEntity.setPos(pos); //correct the position
@ -141,7 +141,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
} }
} }
List<Integer> riftIDs = new ArrayList(); List<Integer> riftIDs = new ArrayList<>();
for (DDTileEntityBase rift : rifts) { for (DDTileEntityBase rift : rifts) {
rift.register(depth); rift.register(depth);
rift.setIsInPocket(); rift.setIsInPocket();

View file

@ -5,10 +5,10 @@
*/ */
package com.zixiken.dimdoors.shared; package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorUnstable;
import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.tileentities.DDTileEntityBase; import com.zixiken.dimdoors.shared.tileentities.DDTileEntityBase;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorChaos;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorPersonal; import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorPersonal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -44,12 +44,12 @@ public class RiftRegistry {
// Methods // Methods
private RiftRegistry() { private RiftRegistry() {
nextRiftID = 0; nextRiftID = 0;
rifts = new HashMap(); rifts = new HashMap<>();
personalDoors = new ArrayList(); //@todo read from and write to NBT personalDoors = new ArrayList<>(); //@todo read from and write to NBT
unpairedRifts = new ArrayList(); unpairedRifts = new ArrayList<>();
unpairedRiftsPerDepth = new ArrayList(); unpairedRiftsPerDepth = new ArrayList<>();
for (int i = 0; i <= maximumDungeonDepth; i++) { 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"); NBTTagList riftListsNBT = (NBTTagList) nbt.getTag("unpairedDepthRiftList");
maximumDungeonDepth = riftListsNBT.tagCount(); //makes sure both are synched maximumDungeonDepth = riftListsNBT.tagCount(); //makes sure both are synched
for (int i = 0; i < riftListsNBT.tagCount(); i++) { for (int i = 0; i < riftListsNBT.tagCount(); i++) {
unpairedRiftsPerDepth.add(new ArrayList()); unpairedRiftsPerDepth.add(new ArrayList<>());
NBTTagList riftsNBT = (NBTTagList) riftListsNBT.get(i); NBTTagList riftsNBT = (NBTTagList) riftListsNBT.get(i);
for (int j = 0; j < riftsNBT.tagCount(); j++) { for (int j = 0; j < riftsNBT.tagCount(); j++) {
NBTTagCompound riftTag = riftsNBT.getCompoundTagAt(j); NBTTagCompound riftTag = riftsNBT.getCompoundTagAt(j);
@ -160,15 +160,15 @@ public class RiftRegistry {
public int registerNewRift(DDTileEntityBase rift, final int depth) { public int registerNewRift(DDTileEntityBase rift, final int depth) {
Location riftLocation = Location.getLocation(rift); Location riftLocation = Location.getLocation(rift);
final int assignedID = nextRiftID; 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); rifts.put(assignedID, riftLocation);
if (rift instanceof TileEntityDimDoorPersonal || rift instanceof TileEntityDimDoorChaos) { if (rift instanceof TileEntityDimDoorPersonal || rift instanceof TileEntityDimDoorUnstable) {
if (rift instanceof TileEntityDimDoorPersonal) { if (rift instanceof TileEntityDimDoorPersonal) {
personalDoors.add(assignedID); personalDoors.add(assignedID);
} }
} else { } 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); unpairedRifts.add(assignedID);
registerUnpairedRiftAtDepth(assignedID, depth); registerUnpairedRiftAtDepth(assignedID, depth);
} }
@ -179,13 +179,13 @@ public class RiftRegistry {
} }
public void unregisterRift(int riftID) { public void unregisterRift(int riftID) {
DimDoors.log(this.getClass(), "unregistering rift " + riftID); DimDoors.log(getClass(), "unregistering rift " + riftID);
unpair(riftID); unpair(riftID);
unRegisterUnpairedRiftAtDepth(riftID); //@todo, will this crash if it doesn't find that value? unRegisterUnpairedRiftAtDepth(riftID); //@todo, will this crash if it doesn't find that value?
unpairedRifts.remove((Integer) riftID); unpairedRifts.remove((Integer) riftID);
personalDoors.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 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) { void unRegisterUnpairedRiftAtDepth(DDTileEntityBase rift) {
int depth = rift.getDepth(); 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) { if (depth < maximumDungeonDepth) {
List<Integer> unpairedRiftListAtDepth = unpairedRiftsPerDepth.get(depth); List<Integer> unpairedRiftListAtDepth = unpairedRiftsPerDepth.get(depth);
unpairedRiftListAtDepth.remove((Integer) rift.getRiftID()); unpairedRiftListAtDepth.remove((Integer) rift.getRiftID());
} }
} }
public Location getRiftLocation(int ID) { public Location getRiftLocation(int id) {
return rifts.get(ID); return rifts.get(id);
} }
public void pair(int riftID, int riftID2) { public void pair(int riftID, int riftID2) {
@ -223,12 +223,12 @@ public class RiftRegistry {
} }
Location location = rifts.get(riftID); Location location = rifts.get(riftID);
TileEntity tileEntity = location.getTileEntity(); //@todo this method might need to be in another class? 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; 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); boolean alreadyPaired = rift.pair(riftID2);
if (!alreadyPaired) { 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); unpairedRifts.remove((Integer) riftID);
unRegisterUnpairedRiftAtDepth(riftID); unRegisterUnpairedRiftAtDepth(riftID);
} }
@ -241,10 +241,10 @@ public class RiftRegistry {
} }
Location location = rifts.get(riftID); Location location = rifts.get(riftID);
if (location == null) { if (location == null) {
DimDoors.warn(this.getClass(), "RiftID with null location: rift " + riftID); DimDoors.warn(getClass(), "RiftID with null location: rift " + riftID);
} else { } else {
TileEntity tileEntity = location.getTileEntity(); TileEntity tileEntity = location.getTileEntity();
if (tileEntity != null && tileEntity instanceof DDTileEntityBase) { if (tileEntity instanceof DDTileEntityBase) {
DDTileEntityBase rift = (DDTileEntityBase) tileEntity; DDTileEntityBase rift = (DDTileEntityBase) tileEntity;
boolean alreadyUnPaired = rift.unpair(); boolean alreadyUnPaired = rift.unpair();
if (!alreadyUnPaired) { 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 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) { 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; return false;
} }
Location destinationRiftLocation = getRiftLocation(pairedRiftID); Location destinationRiftLocation = getRiftLocation(pairedRiftID);
DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity(); DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity();
if (destinationRift == null) { 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()); return TeleporterDimDoors.instance().teleport(entity, destinationRift.getTeleportTargetLocation());
} }
@ -298,7 +298,7 @@ public class RiftRegistry {
int returnID = -1; 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 //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; returnID = lastGeneratedEntranceDoorID;
lastGeneratedEntranceDoorID = -1; lastGeneratedEntranceDoorID = -1;
return returnID; return returnID;
@ -308,15 +308,14 @@ public class RiftRegistry {
List<Integer> rifts = unpairedRiftsPerDepth.get(depth); List<Integer> rifts = unpairedRiftsPerDepth.get(depth);
int numberOfUnpairedRifts = rifts.size(); int numberOfUnpairedRifts = rifts.size();
if (numberOfUnpairedRifts > 1) { 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(); Random random = new Random();
int indexOforigRiftID = -1;
int randomRiftIDIndex; int randomRiftIDIndex;
boolean origRiftIsOnSameDepth = rifts.contains(origRiftID); boolean origRiftIsOnSameDepth = rifts.contains(origRiftID);
if (origRiftIsOnSameDepth) { 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 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++; randomRiftIDIndex++;
} }
} else { } else {
@ -325,7 +324,7 @@ public class RiftRegistry {
returnID = rifts.get(randomRiftIDIndex); 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; return returnID;
} }
@ -377,7 +376,7 @@ public class RiftRegistry {
} }
public int getRandomNonPersonalRiftID() { public int getRandomNonPersonalRiftID() {
List<Integer> nonPersonalRiftIDs = new ArrayList(rifts.keySet()); List<Integer> nonPersonalRiftIDs = new ArrayList<>(rifts.keySet());
for (int persRiftID : personalDoors) { for (int persRiftID : personalDoors) {
//DimDoors.log(this.getClass(), "Removing personal rift: " + persRiftID + " from nonPersonalRiftIDs. nPRI size = " + nonPersonalRiftIDs.size()); //DimDoors.log(this.getClass(), "Removing personal rift: " + persRiftID + " from nonPersonalRiftIDs. nPRI size = " + nonPersonalRiftIDs.size());
nonPersonalRiftIDs.remove((Integer) persRiftID); nonPersonalRiftIDs.remove((Integer) persRiftID);
@ -393,13 +392,13 @@ public class RiftRegistry {
public Location getTeleportLocation(int riftId) { public Location getTeleportLocation(int riftId) {
if (riftId < 0) { 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; return null;
} }
Location destinationRiftLocation = getRiftLocation(riftId); Location destinationRiftLocation = getRiftLocation(riftId);
DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity(); DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity();
if (destinationRift == null) { 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(); return destinationRift.getTeleportTargetLocation();
} }
@ -409,7 +408,7 @@ public class RiftRegistry {
Location riftLocation = getRiftLocation(riftID); Location riftLocation = getRiftLocation(riftID);
if (riftLocation != null) { if (riftLocation != null) {
TileEntity tileEntity = riftLocation.getTileEntity(); TileEntity tileEntity = riftLocation.getTileEntity();
if (tileEntity != null && tileEntity instanceof DDTileEntityBase) { if (tileEntity instanceof DDTileEntityBase) {
DDTileEntityBase rift = (DDTileEntityBase) tileEntity; DDTileEntityBase rift = (DDTileEntityBase) tileEntity;
EntityPlayer player = (EntityPlayer) entity; EntityPlayer player = (EntityPlayer) entity;
rift.validatePlayerPocketEntry(player); 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) { public void setLastGeneratedEntranceDoorID(int id) {
this.lastGeneratedEntranceDoorID = ID; lastGeneratedEntranceDoorID = id;
} }
} }

View file

@ -43,21 +43,21 @@ public class RiftSavedData extends DDSavedData {
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound riftnbt) { public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
NBTTagCompound rifts = new NBTTagCompound(); NBTTagCompound rifts = new NBTTagCompound();
RiftRegistry.INSTANCE.writeToNBT(rifts); RiftRegistry.INSTANCE.writeToNBT(rifts);
riftnbt.setTag("rifts", rifts); nbt.setTag("rifts", rifts);
return riftnbt; return nbt;
} }
@Override @Override
public void readFromNBT(NBTTagCompound riftnbt) { public void readFromNBT(NBTTagCompound nbt) {
// Load NBT // Load NBT
if (riftnbt != null) { if (nbt != null) {
if (riftnbt.hasKey("rifts")) { if (nbt.hasKey("rifts")) {
NBTTagCompound rifts = riftnbt.getCompoundTag("rifts"); NBTTagCompound rifts = nbt.getCompoundTag("rifts");
RiftRegistry.INSTANCE.readFromNBT(rifts); RiftRegistry.INSTANCE.readFromNBT(rifts);
} }
} }

View file

@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -46,21 +45,19 @@ public class SchematicHandler {
private PocketTemplate personalPocketTemplate; private PocketTemplate personalPocketTemplate;
private PocketTemplate publicPocketTemplate; private PocketTemplate publicPocketTemplate;
private List<PocketTemplate> dungeonTemplates; //@todo should this be a Map? Does it need to? It gets reloaded from scratch on ServerStart every time, so... private List<PocketTemplate> dungeonTemplates; //@todo should this be a Map? Does it need to? It gets reloaded from scratch on ServerStart every time, so...
final private Map<String, Map<String, Integer>> dungeonNameMap = new HashMap(); final private Map<String, Map<String, Integer>> 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 //@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... 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<PocketTemplate> validTemplates = new ArrayList(); List<PocketTemplate> validTemplates = new ArrayList<>();
int totalWeight = 0; int totalWeight = 0;
for (PocketTemplate template : dungeonTemplates) { for (PocketTemplate template : dungeonTemplates) {
if (template.getMinDepth() > depth || template.getMaxDepth() < depth) { if (depth >= template.getMinDepth() && depth <= template.getMaxDepth()) {
//do nothing
} else {
validTemplates.add(template); validTemplates.add(template);
totalWeight += template.getWeight(depth); totalWeight += template.getWeight(depth);
} }
} }
DimDoors.log(this.getClass(), "depth = " + depth + ". totalWeight = " + totalWeight); DimDoors.log(getClass(), "depth = " + depth + ". totalWeight = " + totalWeight);
Random random = new Random(); Random random = new Random();
int chosenTemplatePointer = random.nextInt(totalWeight); int chosenTemplatePointer = random.nextInt(totalWeight);
@ -70,14 +67,14 @@ public class SchematicHandler {
return template; 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; return null;
} }
public void loadSchematics() { public void loadSchematics() {
personalPocketTemplate = loadTemplatesFromJson("default_private", PocketRegistry.INSTANCE.getPrivatePocketSize()).get(0); personalPocketTemplate = loadTemplatesFromJson("default_private", PocketRegistry.INSTANCE.getPrivatePocketSize()).get(0);
publicPocketTemplate = loadTemplatesFromJson("default_public", PocketRegistry.INSTANCE.getPublicPocketSize()).get(0); publicPocketTemplate = loadTemplatesFromJson("default_public", PocketRegistry.INSTANCE.getPublicPocketSize()).get(0);
dungeonTemplates = new ArrayList(); dungeonTemplates = new ArrayList<>();
List<String> dungeonSchematicNameStrings = DDConfig.getDungeonSchematicNames(); List<String> dungeonSchematicNameStrings = DDConfig.getDungeonSchematicNames();
int maxPocketSize = PocketRegistry.INSTANCE.getMaxPocketSize(); int maxPocketSize = PocketRegistry.INSTANCE.getMaxPocketSize();
for (String nameString : dungeonSchematicNameStrings) { for (String nameString : dungeonSchematicNameStrings) {
@ -112,7 +109,7 @@ public class SchematicHandler {
bufferedMap = dungeonNameMap.get(dirName); bufferedMap = dungeonNameMap.get(dirName);
bufferedMap.put(template.getName(), dungeonTemplates.indexOf(template)); bufferedMap.put(template.getName(), dungeonTemplates.indexOf(template));
} else { } else {
bufferedMap = new HashMap(); bufferedMap = new HashMap<>();
bufferedMap.put(template.getName(), dungeonTemplates.indexOf(template)); bufferedMap.put(template.getName(), dungeonTemplates.indexOf(template));
dungeonNameMap.put(dirName, bufferedMap); dungeonNameMap.put(dirName, bufferedMap);
} }
@ -143,7 +140,7 @@ public class SchematicHandler {
IOUtils.copy(jsonJarStream, writer, StandardCharsets.UTF_8); IOUtils.copy(jsonJarStream, writer, StandardCharsets.UTF_8);
} catch (IOException ex) { } 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); 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(); jsonString = writer.toString();
} else if (jsonFile.exists()) { } else if (jsonFile.exists()) {
@ -152,11 +149,11 @@ public class SchematicHandler {
jsonString = readFile(jsonFile.getAbsolutePath(), StandardCharsets.UTF_8); jsonString = readFile(jsonFile.getAbsolutePath(), StandardCharsets.UTF_8);
} catch (IOException ex) { } 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); 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 { } else {
DimDoors.warn(SchematicHandler.class, "Json-file " + nameString + ".json was not found in the jar or config directory. Skipping loading of this template."); 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(); JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(jsonString); JsonElement jsonElement = parser.parse(jsonString);
@ -245,10 +242,10 @@ public class SchematicHandler {
final EnumPocketType pocketType = EnumPocketType.getFromInt(jsonTemplate.get("pocketType").getAsInt()); final EnumPocketType pocketType = EnumPocketType.getFromInt(jsonTemplate.get("pocketType").getAsInt());
final JsonArray variations = jsonTemplate.getAsJsonArray("variations"); final JsonArray variations = jsonTemplate.getAsJsonArray("variations");
List<PocketTemplate> pocketTemplates = new ArrayList(); List<PocketTemplate> pocketTemplates = new ArrayList<>();
JsonObject chosenVariation = null; //only applicable if jsonType == "Singular" JsonObject chosenVariation = null; //only applicable if jsonType == "Singular"
int chosenVariationSize = -1; //only applicable if jsonType == "Singular" int chosenVariationSize = -1; //only applicable if jsonType == "Singular"
List<JsonObject> validVariations = new ArrayList(); List<JsonObject> validVariations = new ArrayList<>();
//put all valid variation JsonObjects into an array list //put all valid variation JsonObjects into an array list
for (int i = 0; i < variations.size(); i++) { for (int i = 0; i < variations.size(); i++) {
JsonObject variation = variations.get(i).getAsJsonObject(); JsonObject variation = variations.get(i).getAsJsonObject();
@ -321,11 +318,11 @@ public class SchematicHandler {
} }
public ArrayList<String> getDungeonTemplateGroups() { public ArrayList<String> getDungeonTemplateGroups() {
return new ArrayList(dungeonNameMap.keySet()); return new ArrayList<>(dungeonNameMap.keySet());
} }
public ArrayList<String> getDungeonTemplateNames(String directory) { public ArrayList<String> getDungeonTemplateNames(String directory) {
return new ArrayList(dungeonNameMap.get(directory).keySet()); return new ArrayList<>(dungeonNameMap.get(directory).keySet());
} }
/** /**

View file

@ -4,9 +4,7 @@ import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import java.util.EnumSet; import java.util.EnumSet;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; 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.SPacketEntityEffect;
import net.minecraft.network.play.server.SPacketPlayerAbilities; import net.minecraft.network.play.server.SPacketPlayerAbilities;
import net.minecraft.util.math.BlockPos; 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.network.play.server.SPacketRespawn;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.server.management.PlayerList; 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 //ref: https://github.com/WayofTime/BloodMagic/blob/1.11/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java
public class TeleporterDimDoors extends Teleporter { public class TeleporterDimDoors extends Teleporter {
@ -31,7 +30,7 @@ public class TeleporterDimDoors extends Teleporter {
} }
@Override @Override
public boolean makePortal(Entity entity) { public boolean makePortal(Entity entityIn) {
return true; return true;
} }
@ -53,7 +52,7 @@ public class TeleporterDimDoors extends Teleporter {
} }
@Override @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 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; int oldDimID = entity.dimension;
WorldServer oldWorldserver = DimDoors.proxy.getWorldServer(oldDimID); WorldServer oldWorldserver = DimDoors.proxy.getWorldServer(oldDimID);
WorldServer newWorldserver = DimDoors.proxy.getWorldServer(newDimID); 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."); DimDoors.log(TeleporterDimDoors.class, "Teleporting Player to new dimension.");
EntityPlayerMP player = (EntityPlayerMP) entity; EntityPlayerMP player = (EntityPlayerMP) entity;
float playerRotationYaw = player.rotationYaw; //@todo make this a parameter? float playerRotationYaw = player.rotationYaw; //@todo make this a parameter?
@ -104,7 +103,7 @@ public class TeleporterDimDoors extends Teleporter {
oldWorldserver.profiler.startSection("placing"); oldWorldserver.profiler.startSection("placing");
if (player.isEntityAlive()) { 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.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, playerRotationYaw, player.rotationPitch);
player.motionX = 0; player.motionX = 0;
player.motionZ = 0; player.motionZ = 0;
@ -125,7 +124,7 @@ public class TeleporterDimDoors extends Teleporter {
for (PotionEffect potioneffect : player.getActivePotionEffects()) { for (PotionEffect potioneffect : player.getActivePotionEffects()) {
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect)); 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 { } else {
DimDoors.log(TeleporterDimDoors.class, "Teleporting non-Player to new dimension."); 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) { private void teleportLocal(Entity entity, BlockPos pos) {
WorldServer worldserver = (WorldServer) entity.world; 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, DimDoors.log(TeleporterDimDoors.class,
"Teleporting Player within same dimension."); "Teleporting Player within same dimension.");
EntityPlayerMP player = (EntityPlayerMP) entity; EntityPlayerMP player = (EntityPlayerMP) entity;
@ -150,7 +149,7 @@ public class TeleporterDimDoors extends Teleporter {
worldserver.profiler.startSection("moving"); worldserver.profiler.startSection("moving");
player.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, playerRotationYaw, player.rotationPitch); 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 //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.<SPacketPlayerPosLook.EnumFlags>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(); worldserver.profiler.endSection();
player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities)); player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));

View file

@ -32,36 +32,36 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
} }
@Override @Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
IBlockState down = world.getBlockState(pos.down()); IBlockState down = worldIn.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 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) if (down.getValue(BlockDoor.OPEN)
&& entity instanceof EntityPlayer //@todo remove this so any entity can go through? && entityIn 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 && entityIn.timeUntilPortal < 1 //to prevent the player from teleporting all over the place we have a 50-tick cooldown
&& isEntityFacingDoor(down, (EntityLivingBase) entity)) { && isEntityFacingDoor(down, (EntityLivingBase) entityIn)) {
this.toggleDoor(world, pos, false); toggleDoor(worldIn, pos, false);
enterDimDoor(world, pos, entity); enterDimDoor(worldIn, pos, entityIn);
} }
} }
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, 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) {
if (!checkCanOpen(world, pos, player)) { if (!checkCanOpen(worldIn, pos, playerIn)) {
return false; return false;
} }
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) { if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) {
pos = pos.down(); pos = pos.down();
state = world.getBlockState(pos); state = worldIn.getBlockState(pos);
} }
if (state.getBlock() != this) { if (state.getBlock() != this) {
return false; return false;
} else { } else {
state = state.cycleProperty(BlockDoor.OPEN); state = state.cycleProperty(BlockDoor.OPEN);
world.setBlockState(pos, state, 2); worldIn.setBlockState(pos, state, 2);
world.markBlockRangeForRenderUpdate(pos, pos.up()); worldIn.markBlockRangeForRenderUpdate(pos, pos.up());
world.playEvent(player, (state.getValue(OPEN)) ? this.getOpenSound() : this.getCloseSound(), pos, 0); worldIn.playEvent(playerIn, state.getValue(OPEN) ? getOpenSound() : getCloseSound(), pos, 0);
return true; 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, //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. //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); DimDoors.proxy.updateDoorTE(this, world, pos);
return this;
} }
@Override @Override
@ -84,8 +83,8 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
} }
@Override @Override
public void updateTick(World par1World, BlockPos pos, IBlockState state, Random rand) { public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
updateAttachedTile(par1World, pos); updateAttachedTile(worldIn, pos);
} }
/** /**
@ -95,25 +94,25 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { 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. * Returns the ID of the items to drop on destruction.
*/ */
@Override @Override
public Item getItemDropped(IBlockState state, Random random, int fortune) { public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return isUpperDoorBlock(state) ? null : this.getItemDoor(); return isUpperDoorBlock(state) ? null : getItemDoor();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public ItemStack getItem(World world, BlockPos pos, IBlockState state) { public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
return new ItemStack(this.getItemDoor(), 1, 0); return new ItemStack(getItemDoor(), 1, 0);
} }
@Override @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(); 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, // Although any entity has the proper fields for this check,
// we should only apply it to living entities since things // we should only apply it to living entities since things
// like Minecarts might come in backwards. // 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 @Override
public void breakBlock(World world, BlockPos pos, IBlockState state) { public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
DDTileEntityBase origRift = null; DDTileEntityBase origRift = null;
boolean isTopHalf = state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER; boolean isTopHalf = state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER;
boolean shouldPlaceRift = false; boolean shouldPlaceRift = false;
if (isTopHalf) { if (isTopHalf) {
origRift = (DDTileEntityBase) world.getTileEntity(pos); origRift = (DDTileEntityBase) worldIn.getTileEntity(pos);
if (origRift.isPaired()) { if (origRift.isPaired()) {
shouldPlaceRift = true; shouldPlaceRift = true;
RiftRegistry.INSTANCE.setLastChangedRift(origRift); //@todo this is a crude workaround 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()); RiftRegistry.INSTANCE.unregisterRift(origRift.getRiftID());
} }
} }
super.breakBlock(world, pos, state); super.breakBlock(worldIn, pos, state);
if (shouldPlaceRift) { if (shouldPlaceRift) {
world.setBlockState(pos, ModBlocks.RIFT.getDefaultState()); worldIn.setBlockState(pos, ModBlocks.RIFT.getDefaultState());
DDTileEntityBase newRift = (DDTileEntityBase) world.getTileEntity(pos); DDTileEntityBase newRift = (DDTileEntityBase) worldIn.getTileEntity(pos);
newRift.loadDataFrom(origRift); //@todo this does not work here, or does it? 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) { 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) { 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() protected int getCloseSound() {
{ return blockMaterial == Material.IRON ? 1011 : 1012;
return this.blockMaterial == Material.IRON ? 1011 : 1012;
} }
protected int getOpenSound() protected int getOpenSound() {
{ return blockMaterial == Material.IRON ? 1005 : 1006;
return this.blockMaterial == Material.IRON ? 1005 : 1006;
} }
} }

View file

@ -26,8 +26,7 @@ public class BlockDimDoorGold extends BlockDimDoorBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int metadata) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityDimDoorGold(); return new TileEntityDimDoorGold();
} }
} }

View file

@ -26,8 +26,7 @@ public class BlockDimDoorPersonal extends BlockDimDoorBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int metadata) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityDimDoorPersonal(); return new TileEntityDimDoorPersonal();
} }
} }

View file

@ -2,7 +2,7 @@ package com.zixiken.dimdoors.shared.blocks;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.items.ModItems; 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 java.util.Random;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -30,12 +30,12 @@ public class BlockDimDoorUnstable extends BlockDimDoorBase {
} }
@Override @Override
public Item getItemDropped(IBlockState state, Random random, int fortune) { public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Items.IRON_DOOR; return Items.IRON_DOOR;
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int metadata) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityDimDoorChaos(); return new TileEntityDimDoorUnstable();
} }
} }

View file

@ -26,7 +26,7 @@ public class BlockDimDoorWarp extends BlockDimDoorBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int metadata) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityDimDoorWarp(); return new TileEntityDimDoorWarp();
} }
} }

View file

@ -33,7 +33,7 @@ public class BlockDoorQuartz extends BlockDoor {
@Override @Override
@SideOnly(Side.CLIENT) @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); return new ItemStack(ModItems.QUARTZ_DOOR);
} }
} }

View file

@ -1,12 +1,11 @@
package com.zixiken.dimdoors.shared.blocks; package com.zixiken.dimdoors.shared.blocks;
import java.util.List;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.DDConfig; import com.zixiken.dimdoors.shared.DDConfig;
import com.zixiken.dimdoors.shared.TeleporterDimDoors; 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.util.Location;
import com.zixiken.dimdoors.shared.world.limbodimension.LimboDecay; import com.zixiken.dimdoors.shared.world.limbodimension.LimboDecay;
import com.zixiken.dimdoors.shared.world.limbodimension.WorldProviderLimbo; 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.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BlockFabric extends Block { public class BlockFabric extends Block {
public static final String ID = "fabric"; public static final String ID = "fabric";
public static final PropertyEnum<BlockFabric.EnumType> TYPE = PropertyEnum.<BlockFabric.EnumType>create("type", BlockFabric.EnumType.class); public static final PropertyEnum<BlockFabric.EnumType> TYPE = PropertyEnum.create("type", BlockFabric.EnumType.class);
private static final float SUPER_HIGH_HARDNESS = 10000000000000F; private static final float SUPER_HIGH_HARDNESS = 10000000000000F;
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F; private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
public BlockFabric() { public BlockFabric() {
super(Material.IRON); super(Material.IRON);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setLightLevel(1.0F); setLightLevel(1.0F);
setHardness(0.1F); setHardness(0.1F);
setUnlocalizedName(ID); setUnlocalizedName(ID);
@ -73,11 +70,11 @@ public class BlockFabric extends Block {
} }
@Override @Override
public float getBlockHardness(IBlockState state, World world, BlockPos pos) { public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
if (state.getValue(TYPE).equals(EnumType.ANCIENT) || state.getValue(TYPE).equals(EnumType.ETERNAL)) { if (blockState.getValue(TYPE).equals(EnumType.ANCIENT) || blockState.getValue(TYPE).equals(EnumType.ETERNAL)) {
return SUPER_HIGH_HARDNESS; return SUPER_HIGH_HARDNESS;
} else { } else {
return this.blockHardness; return blockHardness;
} }
} }
@ -103,9 +100,9 @@ public class BlockFabric extends Block {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> subItems) { public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) {
for(BlockFabric.EnumType type : EnumType.values()) { 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 @Override
public int quantityDropped(Random par1Random) { public int quantityDropped(Random random) {
return 0; return 0;
} }
@ -128,12 +125,12 @@ public class BlockFabric extends Block {
* replaces the block clicked with the held block, instead of placing the * replaces the block clicked with the held block, instead of placing the
* block on top of it. Shift click to disable. * 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 pos the position this block is at
* @param state the state this block is in * @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 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 * @param hitX the x coordinate of the exact place the player is clicking on
* the block * the block
* @param hitY the y coordinate ... * @param hitY the y coordinate ...
@ -142,22 +139,22 @@ public class BlockFabric extends Block {
* not? * not?
*/ */
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, 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) {
ItemStack heldItem = player.getHeldItem(hand); 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))) { && (state.getValue(TYPE).equals(EnumType.REALITY) || state.getValue(TYPE).equals(EnumType.ALTERED))) {
Block block = Block.getBlockFromItem(heldItem.getItem()); Block block = Block.getBlockFromItem(heldItem.getItem());
if (!state.isNormalCube() || block.hasTileEntity(block.getDefaultState()) if (!state.isNormalCube() || block.hasTileEntity(block.getDefaultState())
|| block == this //this also keeps it from being replaced by Ancient Fabric || block == this //this also keeps it from being replaced by Ancient Fabric
|| player.isSneaking()) { || playerIn.isSneaking()) {
return false; return false;
} }
if (!world.isRemote) { //@todo on a server, returning false or true determines where the block gets placed? if (!worldIn.isRemote) { //@todo on a server, returning false or true determines where the block gets placed?
if (!player.isCreative()) { if (!playerIn.isCreative()) {
heldItem.setCount(heldItem.getCount()-1); 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; return true;
} }
@ -178,33 +175,33 @@ public class BlockFabric extends Block {
} }
public String toString() { public String toString() {
return this.name; return name;
} }
@Override @Override
public String getName() { public String getName() {
return this.name; return name;
} }
} }
@Override @Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) { public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) {
IBlockState state = world.getBlockState(pos); IBlockState state = worldIn.getBlockState(pos);
if (state.getValue(TYPE) == EnumType.ETERNAL && world.provider instanceof WorldProviderLimbo && entity instanceof EntityPlayer) { if (state.getValue(TYPE) == EnumType.ETERNAL && worldIn.provider instanceof WorldProviderLimbo && entityIn instanceof EntityPlayer) {
Location origLocation = new Location(world, pos); Location origLocation = new Location(worldIn, pos);
Location transFormedLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), DDConfig.getMaxDungeonDepth(), origLocation); Location transFormedLocation = RandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), DDConfig.getMaxDungeonDepth(), origLocation);
BlockPos correctedPos = DimDoors.proxy.getWorldServer(0).getTopSolidOrLiquidBlock(transFormedLocation.getPos()); BlockPos correctedPos = DimDoors.proxy.getWorldServer(0).getTopSolidOrLiquidBlock(transFormedLocation.getPos());
Location correctedLocation = new Location(0, correctedPos); Location correctedLocation = new Location(0, correctedPos);
TeleporterDimDoors.instance().teleport(entity, correctedLocation); TeleporterDimDoors.instance().teleport(entityIn, correctedLocation);
} }
} }
@Override @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 //Make sure this block is unraveled fabric in Limbo
if (state.getValue(TYPE) == EnumType.UNRAVELED && world.provider instanceof WorldProviderLimbo) { if (state.getValue(TYPE) == EnumType.UNRAVELED && worldIn.provider instanceof WorldProviderLimbo) {
LimboDecay.applySpreadDecay(world, pos); LimboDecay.applySpreadDecay(worldIn, pos);
} }
} }
} }

View file

@ -35,7 +35,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BlockRift extends Block implements ITileEntityProvider { public class BlockRift extends Block implements ITileEntityProvider {
private static final float MIN_IMMUNE_RESISTANCE = 5000.0F;
public static final String ID = "rift"; public static final String ID = "rift";
private final ArrayList<Block> blocksImmuneToRift; // List of Vanilla blocks immune to rifts private final ArrayList<Block> blocksImmuneToRift; // List of Vanilla blocks immune to rifts
@ -48,7 +47,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
modBlocksImmuneToRift = new ArrayList<Block>(); modBlocksImmuneToRift = new ArrayList<>();
modBlocksImmuneToRift.add(ModBlocks.FABRIC); modBlocksImmuneToRift.add(ModBlocks.FABRIC);
modBlocksImmuneToRift.add(ModBlocks.DIMENSIONAL_DOOR); modBlocksImmuneToRift.add(ModBlocks.DIMENSIONAL_DOOR);
modBlocksImmuneToRift.add(ModBlocks.WARP_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.PERSONAL_DIMENSIONAL_DOOR);
modBlocksImmuneToRift.add(ModBlocks.QUARTZ_DOOR); modBlocksImmuneToRift.add(ModBlocks.QUARTZ_DOOR);
blocksImmuneToRift = new ArrayList<Block>(); blocksImmuneToRift = new ArrayList<>();
blocksImmuneToRift.add(Blocks.LAPIS_BLOCK); blocksImmuneToRift.add(Blocks.LAPIS_BLOCK);
blocksImmuneToRift.add(Blocks.IRON_BLOCK); blocksImmuneToRift.add(Blocks.IRON_BLOCK);
blocksImmuneToRift.add(Blocks.GOLD_BLOCK); blocksImmuneToRift.add(Blocks.GOLD_BLOCK);
@ -85,7 +84,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return null; return null;
} }
@ -104,7 +103,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
* coordinates. Args: blockAccess, x, y, z, side * coordinates. Args: blockAccess, x, y, z, side
*/ */
@Override @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; return false;
} }
@ -137,7 +136,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
*/ */
@Override @Override
@SideOnly(Side.CLIENT) @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<BlockPos> targets = findReachableBlocks(worldIn, pos, 2, false); //ArrayList<BlockPos> targets = findReachableBlocks(worldIn, pos, 2, false);
//TODO: implement the parts specified in the method comment? //TODO: implement the parts specified in the method comment?
int x = pos.getX(), y = pos.getY(), z = pos.getZ(); 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() // 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 // 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. // I've set this to access blockResistance directly. Might need changing later.
return block != null return block != null /* && block >= MIN_IMMUNE_RESISTANCE */ || modBlocksImmuneToRift.contains(block) || blocksImmuneToRift.contains(block);
/*&&
(block >= MIN_IMMUNE_RESISTANCE*/ || modBlocksImmuneToRift.contains(block)
|| blocksImmuneToRift.contains(block);
} }
public boolean isModBlockImmune(World world, BlockPos pos) { public boolean isModBlockImmune(World world, BlockPos pos) {
@ -194,21 +190,21 @@ public class BlockRift extends Block implements ITileEntityProvider {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int metadata) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityRift(); return new TileEntityRift();
} }
@Override @Override
public void breakBlock(World world, BlockPos pos, IBlockState state) { public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntityRift riftTile = (TileEntityRift) world.getTileEntity(pos); TileEntityRift riftTile = (TileEntityRift) worldIn.getTileEntity(pos);
if (riftTile == null || !riftTile.placingDoorOnRift) { 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(); RiftRegistry.INSTANCE.unregisterLastChangedRift();
} else { } 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 riftTile.placingDoorOnRift = false; //probably not needed, but it shouldn't hurt to do this
} }
world.removeTileEntity(pos); worldIn.removeTileEntity(pos);
} }
@Override @Override

View file

@ -31,7 +31,7 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
public BlockTransTrapdoor() { public BlockTransTrapdoor() {
super(Material.WOOD); super(Material.WOOD);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setHardness(1.0F); setHardness(1.0F);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, 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 //Teleports the player to the exit link of that dimension, assuming it is a pocket
@Override @Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
enterDimDoor(world, pos, entity); enterDimDoor(worldIn, pos, entityIn);
} }
public boolean checkCanOpen(World world, BlockPos pos) { 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) { public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) {
@ -53,15 +53,15 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
} }
@Override @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) 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 @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)) { 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 @Override
public TileEntity createNewTileEntity(World world, int metadata) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityTransTrapdoor(); return new TileEntityTransTrapdoor();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { 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 @Override
public Item getItemDropped(IBlockState state, Random random, int fortuneLevel) { public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Item.getItemFromBlock(Blocks.TRAPDOOR); return Item.getItemFromBlock(Blocks.TRAPDOOR);
} }
@ -107,9 +107,9 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
} }
@Override @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 // This function runs on the server side after a block is replaced
// We MUST call super.breakBlock() since it involves removing tile entities // We MUST call super.breakBlock() since it involves removing tile entities
super.breakBlock(world, pos, state); super.breakBlock(worldIn, pos, state);
} }
} }

View file

@ -27,5 +27,4 @@ public interface IDimDoor {
* @return * @return
*/ */
public boolean isDoorOnRift(World world, BlockPos pos); public boolean isDoorOnRift(World world, BlockPos pos);
} }

View file

@ -7,34 +7,35 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class ModBlocks { public class ModBlocks {
// Regular doors // Regular doors
public final static BlockDoorGold GOLD_DOOR = new BlockDoorGold(); public static final BlockDoorGold GOLD_DOOR = new BlockDoorGold();
public final static BlockDoorQuartz QUARTZ_DOOR = new BlockDoorQuartz(); public static final BlockDoorQuartz QUARTZ_DOOR = new BlockDoorQuartz();
// Dimensional doors // Dimensional doors
public final static BlockDimDoor DIMENSIONAL_DOOR = new BlockDimDoor(); public static final BlockDimDoor DIMENSIONAL_DOOR = new BlockDimDoor();
public final static BlockDimDoorGold GOLD_DIMENSIONAL_DOOR = new BlockDimDoorGold(); public static final BlockDimDoorGold GOLD_DIMENSIONAL_DOOR = new BlockDimDoorGold();
public final static BlockDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new BlockDimDoorPersonal(); public static final BlockDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new BlockDimDoorPersonal();
public final static BlockDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new BlockDimDoorUnstable(); public static final BlockDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new BlockDimDoorUnstable();
public final static BlockDimDoorTransient TRANSIENT_DIMENSIONAL_DOOR = new BlockDimDoorTransient(); public static final BlockDimDoorTransient TRANSIENT_DIMENSIONAL_DOOR = new BlockDimDoorTransient();
public final static BlockDimDoorWarp WARP_DIMENSIONAL_DOOR = new BlockDimDoorWarp(); public static final BlockDimDoorWarp WARP_DIMENSIONAL_DOOR = new BlockDimDoorWarp();
public final static BlockTransTrapdoor DIMENSIONAL_TRAPDOOR = new BlockTransTrapdoor(); public static final BlockTransTrapdoor DIMENSIONAL_TRAPDOOR = new BlockTransTrapdoor();
// Blocks // Blocks
public final static BlockFabric FABRIC = new BlockFabric(); public static final BlockFabric FABRIC = new BlockFabric();
public final static BlockRift RIFT = new BlockRift(); public static final BlockRift RIFT = new BlockRift();
@SubscribeEvent @SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) { public static void registerBlocks(RegistryEvent.Register<Block> event) {
event.getRegistry().register(QUARTZ_DOOR); event.getRegistry().registerAll(
event.getRegistry().register(PERSONAL_DIMENSIONAL_DOOR); GOLD_DOOR,
event.getRegistry().register(GOLD_DOOR); QUARTZ_DOOR,
event.getRegistry().register(GOLD_DIMENSIONAL_DOOR); DIMENSIONAL_DOOR,
event.getRegistry().register(UNSTABLE_DIMENSIONAL_DOOR); GOLD_DIMENSIONAL_DOOR,
event.getRegistry().register(WARP_DIMENSIONAL_DOOR); PERSONAL_DIMENSIONAL_DOOR,
event.getRegistry().register(DIMENSIONAL_DOOR); UNSTABLE_DIMENSIONAL_DOOR,
event.getRegistry().register(DIMENSIONAL_TRAPDOOR); TRANSIENT_DIMENSIONAL_DOOR,
event.getRegistry().register(FABRIC); WARP_DIMENSIONAL_DOOR,
event.getRegistry().register(TRANSIENT_DIMENSIONAL_DOOR); DIMENSIONAL_TRAPDOOR,
event.getRegistry().register(RIFT); FABRIC,
RIFT);
} }
} }

View file

@ -2,8 +2,7 @@ package com.zixiken.dimdoors.shared.commands;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.*; import com.zixiken.dimdoors.shared.*;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor; import com.zixiken.dimdoors.shared.util.StringUtils;
import com.zixiken.dimdoors.shared.util.DDStringUtils;
import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import net.minecraft.command.CommandBase; import net.minecraft.command.CommandBase;
@ -24,7 +23,6 @@ public class PocketCommand extends CommandBase {
public PocketCommand() { public PocketCommand() {
aliases = new ArrayList<>(); aliases = new ArrayList<>();
aliases.add("dimpocket"); aliases.add("dimpocket");
} }
@ -45,11 +43,10 @@ public class PocketCommand extends CommandBase {
@Override @Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (sender instanceof EntityPlayerMP) { if (sender instanceof EntityPlayerMP) {
EntityPlayerMP player = getCommandSenderAsPlayer(sender); EntityPlayerMP player = getCommandSenderAsPlayer(sender);
if (areArgumentsValid(args, player)) { if (areArgumentsValid(args, player)) {
DimDoors.log(this.getClass(), "Executing command"); DimDoors.log(getClass(), "Executing command");
BlockPos pos = player.getPosition(); BlockPos pos = player.getPosition();
World world = player.world; World world = player.world;
@ -69,23 +66,19 @@ public class PocketCommand extends CommandBase {
RiftRegistry.INSTANCE.setLastGeneratedEntranceDoorID(entranceDoorID); RiftRegistry.INSTANCE.setLastGeneratedEntranceDoorID(entranceDoorID);
} }
} else { } 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 @Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) {
List<String> list = new ArrayList(); List<String> list = new ArrayList<>();
if (args == null || args.length < 2) { //counts an empty ("") argument as an argument as well... if (args.length < 2) { //counts an empty ("") argument as an argument as well...
list = SchematicHandler.INSTANCE.getDungeonTemplateGroups(); list = SchematicHandler.INSTANCE.getDungeonTemplateGroups();
list = DDStringUtils.getMatchingStrings(args[0], list, false); list = StringUtils.getMatchingStrings(args[0], list, false);
} else if (args.length == 2) { } else if (args.length == 2) {
list = SchematicHandler.INSTANCE.getDungeonTemplateNames(args[0]); list = SchematicHandler.INSTANCE.getDungeonTemplateNames(args[0]);
list = DDStringUtils.getMatchingStrings(args[1], list, false); list = StringUtils.getMatchingStrings(args[1], list, false);
} else if (args.length == 3) {
list.add("Remove_this");
} else {
list.add("No_seriously");
} }
return list; return list;
} }

View file

@ -1,7 +1,8 @@
package com.zixiken.dimdoors.shared.commands; package com.zixiken.dimdoors.shared.commands;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.TeleporterDimDoors; 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.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -11,6 +12,7 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
public class TeleportCommand extends CommandBase { public class TeleportCommand extends CommandBase {
@ -19,7 +21,6 @@ public class TeleportCommand extends CommandBase {
public TeleportCommand() { public TeleportCommand() {
aliases = new ArrayList<>(); aliases = new ArrayList<>();
aliases.add("dimteleport"); aliases.add("dimteleport");
} }
@ -40,19 +41,27 @@ public class TeleportCommand extends CommandBase {
@Override @Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { 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) { if (sender instanceof EntityPlayerMP) {
server.getPlayerList().transferPlayerToDimension((EntityPlayerMP) sender, id, TeleporterDimDoors.instance()); server.getPlayerList().transferPlayerToDimension((EntityPlayerMP) sender, id, TeleporterDimDoors.instance());
} else {
DimDoors.log("Not executing command /" + getName() + " because it wasn't sent by a player.");
} }
} }
@Override @Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) {
List<String> list = new ArrayList(); List<String> list = new ArrayList<>();
if (args == null || args.length < 2) { //counts an empty ("") argument as an argument as well... if (args.length < 2) { //counts an empty ("") argument as an argument as well...
list = DDStringUtils.getAsStringList(DimensionManager.getIDs()); list = StringUtils.getAsStringList(DimensionManager.getIDs());
list = DDStringUtils.getMatchingStrings(args[0], list, false); list = StringUtils.getMatchingStrings(args[0], list, false);
} }
return list; return list;
} }

View file

@ -1,11 +1,9 @@
package com.zixiken.dimdoors.shared.entities; package com.zixiken.dimdoors.shared.entities;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.server.sound.DDSounds; import com.zixiken.dimdoors.server.sound.DDSounds;
import com.zixiken.dimdoors.shared.DDConfig; import com.zixiken.dimdoors.shared.DDConfig;
import com.zixiken.dimdoors.shared.TeleporterDimDoors; import com.zixiken.dimdoors.shared.TeleporterDimDoors;
import com.zixiken.dimdoors.shared.util.Location; 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.limbodimension.WorldProviderLimbo;
import com.zixiken.dimdoors.shared.world.pocketdimension.WorldProviderDungeonPocket; import com.zixiken.dimdoors.shared.world.pocketdimension.WorldProviderDungeonPocket;
import com.zixiken.dimdoors.shared.world.pocketdimension.WorldProviderPublicPocket; 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.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -31,15 +27,15 @@ import java.util.List;
import static net.minecraft.network.datasync.DataSerializers.*; 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 = 250;
private static final int MAX_AGGRO_CAP = 100; private static final int MAX_AGGRO_CAP = 100;
private static final int MIN_AGGRO_CAP = 25; private static final int MIN_AGGRO_CAP = 25;
private static final int MAX_TEXTURE_STATE = 18; private static final int MAX_TEXTURE_STATE = 18;
private static final int MAX_SOUND_COOLDOWN = 200; private static final int MAX_SOUND_COOLDOWN = 200;
private static final int MAX_AGGRO_RANGE = 35; private static final int MAX_AGGRO_RANGE = 35;
private static final DataParameter<Integer> AGGRO = EntityDataManager.<Integer>createKey(MobMonolith.class, VARINT); private static final DataParameter<Integer> AGGRO = EntityDataManager.createKey(MobMonolith.class, VARINT);
private static final float WIDTH = 3f; private static final float WIDTH = 3f;
private static final float HEIGHT = 3f; private static final float HEIGHT = 3f;
@ -53,9 +49,9 @@ public class MobMonolith extends EntityFlying implements IMob
public MobMonolith(World world) public MobMonolith(World world)
{ {
super(world); super(world);
this.setSize(WIDTH, HEIGHT); setSize(WIDTH, HEIGHT);
this.noClip = true; noClip = true;
this.aggroCap = MathHelper.getInt(this.rand, MIN_AGGRO_CAP, MAX_AGGRO_CAP); aggroCap = MathHelper.getInt(rand, MIN_AGGRO_CAP, MAX_AGGRO_CAP);
} }
public boolean isDangerous() { public boolean isDangerous() {
@ -63,12 +59,12 @@ public class MobMonolith extends EntityFlying implements IMob
} }
@Override @Override
protected void damageEntity(DamageSource par1DamageSource, float par2) {} protected void damageEntity(DamageSource damageSrc, float damageAmount) {}
@Override @Override
public boolean attackEntityFrom(DamageSource damageSource, float par2) { public boolean attackEntityFrom(DamageSource source, float amount) {
if (damageSource != DamageSource.IN_WALL) { if (source != DamageSource.IN_WALL) {
this.aggro = MAX_AGGRO; aggro = MAX_AGGRO;
} }
return false; return false;
} }
@ -84,7 +80,7 @@ public class MobMonolith extends EntityFlying implements IMob
} }
@Override @Override
public AxisAlignedBB getCollisionBox(Entity par1Entity) { public AxisAlignedBB getCollisionBox(Entity entityIn) {
return null; return null;
} }
@ -96,7 +92,7 @@ public class MobMonolith extends EntityFlying implements IMob
@Override @Override
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(57005); getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(57005);
} }
@Override @Override
@ -113,7 +109,7 @@ public class MobMonolith extends EntityFlying implements IMob
protected void entityInit() { protected void entityInit() {
super.entityInit(); super.entityInit();
// Add a short for the aggro level // Add a short for the aggro level
this.dataManager.register(AGGRO, 0); dataManager.register(AGGRO, 0);
} }
@Override @Override
@ -125,8 +121,8 @@ public class MobMonolith extends EntityFlying implements IMob
@Override @Override
public void onEntityUpdate() { public void onEntityUpdate() {
// Remove this Monolith if it's not in Limbo or in a pocket dungeon TODO: any pocket dim? // 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)) { if (!(world.provider instanceof WorldProviderLimbo || world.provider instanceof WorldProviderDungeonPocket)) {
this.setDead(); setDead();
super.onEntityUpdate(); super.onEntityUpdate();
return; return;
} }
@ -134,15 +130,15 @@ public class MobMonolith extends EntityFlying implements IMob
super.onEntityUpdate(); super.onEntityUpdate();
// Check for players and update aggro levels even if there are no players in range // Check for players and update aggro levels even if there are no players in range
EntityPlayer player = this.world.getClosestPlayerToEntity(this, MAX_AGGRO_RANGE); EntityPlayer player = world.getClosestPlayerToEntity(this, MAX_AGGRO_RANGE);
boolean visibility = (player != null) && player.canEntityBeSeen(this); boolean visibility = player != null && player.canEntityBeSeen(this);
this.updateAggroLevel(player, visibility); updateAggroLevel(player, visibility);
// Change orientation and face a player if one is in range // Change orientation and face a player if one is in range
if (player != null) if (player != null)
{ {
this.facePlayer(player); facePlayer(player);
if (!this.world.isRemote && isDangerous()) if (!world.isRemote && isDangerous())
{ {
// Play sounds on the server side, if the player isn't in Limbo. // Play sounds on the server side, if the player isn't in Limbo.
// Limbo is excluded to avoid drowning out its background music. // 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 // Only spawn particles on the client side and outside Limbo
if (world.isRemote && isDangerous()) { if (world.isRemote && isDangerous()) {
this.spawnParticles(player); spawnParticles(player);
} }
// Teleport the target player if various conditions are met // Teleport the target player if various conditions are met
if (aggro >= MAX_AGGRO && !world.isRemote && DDConfig.isMonolithTeleportationEnabled() && !player.capabilities.isCreativeMode && isDangerous()) { if (aggro >= MAX_AGGRO && !world.isRemote && DDConfig.isMonolithTeleportationEnabled() && !player.capabilities.isCreativeMode && isDangerous()) {
this.aggro = 0; aggro = 0;
Location destination = WorldProviderLimbo.getLimboSkySpawn(player); Location destination = WorldProviderLimbo.getLimboSkySpawn(player);
TeleporterDimDoors.instance().teleport(player, destination); TeleporterDimDoors.instance().teleport(player, destination);
player.world.playSound(player, player.getPosition(), DDSounds.CRACK, SoundCategory.HOSTILE, 13, 1); 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) { private void updateAggroLevel(EntityPlayer player, boolean visibility) {
// If we're working on the server side, adjust aggro level // 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 we're working on the client side, retrieve aggro level from dataWatcher
if (!this.world.isRemote) { if (!world.isRemote) {
// Server side... // Server side...
// Rapidly increase the aggro level if this Monolith can see the player // Rapidly increase the aggro level if this Monolith can see the player
if (visibility) { if (visibility) {
if (world.provider instanceof WorldProviderLimbo) { if (world.provider instanceof WorldProviderLimbo) {
if (isDangerous()) if (isDangerous()) {
aggro++; aggro++;
else } else {
aggro += 36; aggro += 36;
}
} else { } else {
// Aggro increases faster outside of Limbo // Aggro increases faster outside of Limbo
aggro += 3; aggro += 3;
@ -191,25 +188,25 @@ public class MobMonolith extends EntityFlying implements IMob
if (aggro > aggroCap) { if (aggro > aggroCap) {
// Decrease aggro over time // Decrease aggro over time
aggro--; aggro--;
} else if (player != null && (aggro < aggroCap)) { } else if (player != null && aggro < aggroCap) {
// Increase aggro if a player is within range and aggro < aggroCap // Increase aggro if a player is within range and aggro < aggroCap
aggro++; aggro++;
} }
} else } else {
aggro -= 3; aggro -= 3;
} }
}
// Clamp the aggro level // Clamp the aggro level
int maxAggro = isDangerous()?MAX_AGGRO:180; int maxAggro = isDangerous()?MAX_AGGRO:180;
aggro = (short) MathHelper.clamp(aggro, 0, maxAggro); aggro = (short) MathHelper.clamp(aggro, 0, maxAggro);
this.dataManager.set(AGGRO, aggro); dataManager.set(AGGRO, aggro);
} else { } else {
// Client side... // Client side...
aggro = this.dataManager.get(AGGRO); aggro = dataManager.get(AGGRO);
} }
} }
public int getTextureState() public int getTextureState() {
{
// Determine texture state from aggro progress // Determine texture state from aggro progress
return MathHelper.clamp(MAX_TEXTURE_STATE * aggro / MAX_AGGRO, 0, MAX_TEXTURE_STATE); 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) private void playSounds(EntityPlayer entityPlayer)
{ {
float aggroPercent = this.getAggroProgress(); float aggroPercent = getAggroProgress();
if (this.soundTime <= 0) if (soundTime <= 0)
{ {
playSound(DDSounds.MONK, 1F, 1F); 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())); world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian()));
this.soundTime = 100 + this.rand.nextInt(75); 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); world.playSound(entityPlayer, entityPlayer.getPosition(), DDSounds.TEARING, SoundCategory.HOSTILE, 7, 1F);
this.soundTime = 250; soundTime = 250;
} }
this.soundTime--; soundTime--;
} }
private void spawnParticles(EntityPlayer player) private void spawnParticles(EntityPlayer player)
@ -243,60 +240,56 @@ public class MobMonolith extends EntityFlying implements IMob
int count = 10 * aggro / MAX_AGGRO; int count = 10 * aggro / MAX_AGGRO;
for (int i = 1; i < count; ++i) for (int i = 1; i < count; ++i)
{ {
player.world.spawnParticle(EnumParticleTypes.PORTAL, player.posX + (this.rand.nextDouble() - 0.5D) * this.width, player.world.spawnParticle(EnumParticleTypes.PORTAL, player.posX + (rand.nextDouble() - 0.5D) * width,
player.posY + this.rand.nextDouble() * player.height - 0.75D, player.posY + rand.nextDouble() * player.height - 0.75D,
player.posZ + (this.rand.nextDouble() - 0.5D) * player.width, player.posZ + (rand.nextDouble() - 0.5D) * player.width,
(this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2.0D, -rand.nextDouble(),
(this.rand.nextDouble() - 0.5D) * 2.0D); (rand.nextDouble() - 0.5D) * 2.0D);
} }
} }
public float getAggroProgress() public float getAggroProgress()
{ {
return ((float) aggro) / MAX_AGGRO; return (float) aggro / MAX_AGGRO;
} }
private void facePlayer(EntityPlayer player) private void facePlayer(EntityPlayer player)
{ {
double d0 = player.posX - this.posX; double d0 = player.posX - posX;
double d1 = player.posZ - this.posZ; double d1 = player.posZ - posZ;
double d2 = (player.posY + player.getEyeHeight()) - (this.posY + this.getEyeHeight()); double d2 = player.posY + player.getEyeHeight() - (posY + getEyeHeight());
double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1); double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1);
float f2 = (float)(Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; float f2 = (float)(Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F;
this.pitchLevel = (float) -((Math.atan(d2/d3) )* 180.0D / Math.PI); pitchLevel = (float) -(Math.atan(d2/d3) * 180.0D / Math.PI);
this.rotationYaw = f2; rotationYaw = f2;
this.rotationYawHead = f2; rotationYawHead = f2;
this.renderYawOffset = this.rotationYaw; renderYawOffset = rotationYaw;
} }
@Override @Override
public void writeEntityToNBT(NBTTagCompound rootTag) public void writeEntityToNBT(NBTTagCompound nbt) {
{ super.writeEntityToNBT(nbt);
super.writeEntityToNBT(rootTag); nbt.setInteger("Aggro", aggro);
rootTag.setInteger("Aggro", this.aggro);
} }
@Override @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 // Load Monoliths with half aggro so they don't teleport players instantly
aggro = rootTag.getInteger("Aggro") / 2; aggro = nbt.getInteger("Aggro") / 2;
} }
@Override @Override
public boolean getCanSpawnHere() { 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<Entity> list = world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(posX -15, posY-4, posZ -15, posX +15, posY +15, posZ +15));
if (world.provider instanceof WorldProviderLimbo) { if (world.provider instanceof WorldProviderLimbo) {
if(list.size() > 0) { if(list.size() > 0) {
return false; 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))) { if (list.size() > 5 || world.canBlockSeeSky(new BlockPos(posX, posY, posZ))) {
return false; return false;
} }

View file

@ -1,6 +1,5 @@
package com.zixiken.dimdoors.shared.entities; package com.zixiken.dimdoors.shared.entities;
import java.util.Random; import java.util.Random;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -13,22 +12,24 @@ import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ModelMobObelisk extends ModelBase { public class ModelMobObelisk extends ModelBase {
ModelRenderer wholemonolith;
ModelRenderer wholeMonolith;
Random rand = new Random(); Random rand = new Random();
public ModelMobObelisk() { public ModelMobObelisk() {
textureWidth = 256; textureWidth = 256;
textureHeight = 256; textureHeight = 256;
wholemonolith = new ModelRenderer(this, 0, 0); wholeMonolith = new ModelRenderer(this, 0, 0);
wholemonolith.addBox(-24F,-108F/1.3F, -6F, 48, 108, 12); wholeMonolith.addBox(-24F,-108F/1.3F, -6F, 48, 108, 12);
} }
@Override @Override
public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
this.setRotationAngles(0, 0, 0, 0, 0,0, entity); MobMonolith monolith = (MobMonolith) entityIn;
GL11.glScalef(((MobMonolith) entity).getRenderSizeModifier(), ((MobMonolith) entity).getRenderSizeModifier(), ((MobMonolith) entity).getRenderSizeModifier()); setRotationAngles(0, 0, 0, 0, 0,0, monolith);
wholemonolith.render(scale); GL11.glScalef(monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier());
wholeMonolith.render(scale);
} }
} }

View file

@ -5,8 +5,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -20,6 +18,7 @@ import java.util.List;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderMobObelisk extends RenderLiving<MobMonolith> { public class RenderMobObelisk extends RenderLiving<MobMonolith> {
protected ModelMobObelisk obeliskModel; protected ModelMobObelisk obeliskModel;
protected static final List<ResourceLocation> monolith_textures = Arrays.asList( protected static final List<ResourceLocation> monolith_textures = Arrays.asList(
@ -45,11 +44,11 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
public RenderMobObelisk(RenderManager manager, float f) { public RenderMobObelisk(RenderManager manager, float f) {
super(manager, new ModelMobObelisk(), f); super(manager, new ModelMobObelisk(), f);
this.obeliskModel = (ModelMobObelisk)this.mainModel; obeliskModel = (ModelMobObelisk) mainModel;
} }
@Override @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 minScaling = 0;
final float maxScaling = 0.1f; final float maxScaling = 0.1f;
@ -68,13 +67,13 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
double zJitter = aggroScaling * Math.sin(1.3f * time) * Math.sin(0.7f * time); double zJitter = aggroScaling * Math.sin(1.3f * time) * Math.sin(0.7f * time);
// Render with jitter // 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); //this.renderLeash(entity, x, y, z, par8, par9);
} }
public void render(MobMonolith par1EntityLivingBase, double x, double y, double z, float par8, float 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.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
@ -89,15 +88,15 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9; float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
renderLivingAt(par1EntityLivingBase, x, y, z); renderLivingAt(par1EntityLivingBase, x, y, z);
rotation = this.handleRotationFloat(par1EntityLivingBase, par9); rotation = handleRotationFloat(par1EntityLivingBase, par9);
this.applyRotations(par1EntityLivingBase, rotation, interpolatedYaw, par9); applyRotations(par1EntityLivingBase, rotation, interpolatedYaw, par9);
float f6 = 0.0625F; float f6 = 0.0625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glScalef(-1.0F, -1.0F, 1.0F); GL11.glScalef(-1.0F, -1.0F, 1.0F);
this.preRenderCallback(par1EntityLivingBase, par9); preRenderCallback(par1EntityLivingBase, par9);
GL11.glRotatef(((MobMonolith)par1EntityLivingBase).pitchLevel , 1.0F, 0.0F, 0.0F); GL11.glRotatef(par1EntityLivingBase.pitchLevel , 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, 24.0F * f6 - 0.0078125F, 0.0F); GL11.glTranslatef(0.0F, 24.0F * f6 - 0.0078125F, 0.0F);
@ -108,8 +107,8 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glDisable(GL12.GL_RESCALE_NORMAL);
} catch (Exception exception) { } catch (Exception e) {
exception.printStackTrace(); e.printStackTrace();
} }
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
@ -119,7 +118,7 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith> {
GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix(); 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 @Override

View file

@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
public class ItemBlockFabric extends ItemBlock { 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() { public ItemBlockFabric() {
super(ModBlocks.FABRIC); super(ModBlocks.FABRIC);
@ -19,12 +19,12 @@ public class ItemBlockFabric extends ItemBlock {
} }
@Override @Override
public int getMetadata(int damageValue) { public int getMetadata(int damage) {
return damageValue; return damage;
} }
@Override @Override
public String getUnlocalizedName(ItemStack stack) { public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName() + subNames[this.getDamage(stack)]; return super.getUnlocalizedName() + subNames[getDamage(stack)];
} }
} }

View file

@ -24,7 +24,7 @@ public class ItemDimDoor extends ItemDoorBase {
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
translateAndAdd("info.dimensional_door", tooltip); translateAndAdd("info.dimensional_door", tooltip);
} }

View file

@ -22,7 +22,7 @@ public class ItemDimDoorGold extends ItemDoorBase {
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
translateAndAdd("info.gold_dimensional_door", tooltip); translateAndAdd("info.gold_dimensional_door", tooltip);
} }

View file

@ -22,7 +22,7 @@ public class ItemDimDoorPersonal extends ItemDoorBase {
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
translateAndAdd("info.quartz_dimensional_door", tooltip); translateAndAdd("info.quartz_dimensional_door", tooltip);
} }

View file

@ -22,7 +22,7 @@ public class ItemDimDoorUnstable extends ItemDoorBase {
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
translateAndAdd("info.unstable_dimensional_door", tooltip); translateAndAdd("info.unstable_dimensional_door", tooltip);
} }

View file

@ -24,7 +24,7 @@ public class ItemDimDoorWarp extends ItemDoorBase {
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
translateAndAdd("info.warp_dimensional_door", tooltip); translateAndAdd("info.warp_dimensional_door", tooltip);
} }

View file

@ -18,14 +18,13 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import static net.minecraft.item.ItemDoor.placeDoor;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
public abstract class ItemDoorBase extends ItemDoor { public abstract class ItemDoorBase extends ItemDoor {
// Maps non-dimensional door items to their corresponding dimensional door item // Maps non-dimensional door items to their corresponding dimensional door item
// Also maps dimensional door items to themselves for simplicity // Also maps dimensional door items to themselves for simplicity
private static HashMap<ItemDoor, ItemDoorBase> doorItemMapping = new HashMap<ItemDoor, ItemDoorBase>(); private static HashMap<ItemDoor, ItemDoorBase> doorItemMapping = new HashMap<>();
/** /**
* door represents the non-dimensional door this item is associated with. * 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) { public ItemDoorBase(Block block, ItemDoor vanillaDoor) {
super(block); super(block);
this.setMaxStackSize(64); setMaxStackSize(64);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
doorItemMapping.put(this, this); //@todo Why? doorItemMapping.put(this, this); //@todo Why?
if (vanillaDoor != null) { if (vanillaDoor != null) {
@ -45,7 +44,7 @@ public abstract class ItemDoorBase extends ItemDoor {
} }
@Override @Override
public abstract void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced); public abstract void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn);
/** /**
* Overridden in subclasses to specify which door block that door item will * 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. //onItemUse gets fired before onItemRightClick and if it returns "success", onItemRightClick gets skipped.
@Override @Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack stack = player.getHeldItem(hand); ItemStack stack = playerIn.getHeldItem(handIn);
if (world.isRemote) { if (worldIn.isRemote) {
return new ActionResult<>(EnumActionResult.FAIL, stack); return new ActionResult<>(EnumActionResult.FAIL, stack);
} }
RayTraceResult hit = rayTrace(world, player, true); RayTraceResult hit = rayTrace(worldIn, playerIn, true);
if (RayTraceHelper.isRift(hit, world)) { if (RayTraceHelper.isRift(hit, worldIn)) {
EnumActionResult canDoorBePlacedOnGroundBelowRift 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 (float) hit.hitVec.x, (float) hit.hitVec.y, (float) hit.hitVec.z); //stack may be changed by this method
return new ActionResult<>(canDoorBePlacedOnGroundBelowRift, stack); return new ActionResult<>(canDoorBePlacedOnGroundBelowRift, stack);
} }
@ -76,21 +75,21 @@ public abstract class ItemDoorBase extends ItemDoor {
} }
@Override @Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (world.isRemote) { if (worldIn.isRemote) {
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }
Block block = world.getBlockState(pos).getBlock(); Block block = worldIn.getBlockState(pos).getBlock();
if (!block.isReplaceable(world, pos)) { if (!block.isReplaceable(worldIn, pos)) {
if (side != EnumFacing.UP) { if (facing != EnumFacing.UP) {
return EnumActionResult.FAIL; return EnumActionResult.FAIL;
} }
} else { } 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 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 //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. // return null, just as if the item was an unrecognized door type.
ItemDoorBase mappedItem = doorItemMapping.get(stack.getItem()); ItemDoorBase mappedItem = doorItemMapping.get(stack.getItem());
if (mappedItem == null) { 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; 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 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 //fetch "the" tile entity at the top block of where the door is going to be placed
TileEntity possibleOldRift = world.getTileEntity(pos.up()); TileEntity possibleOldRift = world.getTileEntity(pos.up());
if (possibleOldRift != null && possibleOldRift instanceof TileEntityRift) { if (possibleOldRift instanceof TileEntityRift) {
TileEntityRift oldRift = (TileEntityRift) possibleOldRift; TileEntityRift oldRift = (TileEntityRift) possibleOldRift;
oldRift.placingDoorOnRift = true; oldRift.placingDoorOnRift = true;
} }

View file

@ -36,7 +36,7 @@ public class ItemRiftBlade extends ItemSword {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack par1ItemStack) { public boolean hasEffect(ItemStack stack) {
return true; return true;
} }
@ -49,26 +49,26 @@ public class ItemRiftBlade extends ItemSword {
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack stack = player.getHeldItem(hand); ItemStack stack = playerIn.getHeldItem(handIn);
if (world.isRemote) { if (worldIn.isRemote) {
return new ActionResult<>(EnumActionResult.FAIL, stack); 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 //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); RayTraceResult hit = rayTrace(worldIn, playerIn, true);
if (RayTraceHelper.isRift(hit, world)) { if (RayTraceHelper.isRift(hit, worldIn)) {
TileEntityRift rift = (TileEntityRift) world.getTileEntity(hit.getBlockPos()); TileEntityRift rift = (TileEntityRift) worldIn.getTileEntity(hit.getBlockPos());
rift.isTeleporting = true; rift.isTeleporting = true;
rift.teleportingEntity = player; rift.teleportingEntity = playerIn;
stack.damageItem(1, player); stack.damageItem(1, playerIn);
return new ActionResult<>(EnumActionResult.SUCCESS, stack); return new ActionResult<>(EnumActionResult.SUCCESS, stack);
} else if (RayTraceHelper.isLivingEntity(hit)) { } 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) { if (teleportResult == EnumActionResult.SUCCESS) {
stack.damageItem(1, player); stack.damageItem(1, playerIn);
} }
return new ActionResult<>(teleportResult, stack); return new ActionResult<>(teleportResult, stack);
} }
@ -77,7 +77,7 @@ public class ItemRiftBlade extends ItemSword {
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
DimDoors.translateAndAdd("info.rift_blade", list); DimDoors.translateAndAdd("info.rift_blade", tooltip);
} }
} }

View file

@ -30,19 +30,19 @@ public class ItemRiftConnectionTool extends ItemTool {
public static final String ID = "rift_connection_tool"; public static final String ID = "rift_connection_tool";
ItemRiftConnectionTool() { ItemRiftConnectionTool() {
super(1.0F, -2.8F, ToolMaterial.WOOD, new HashSet()); super(1.0F, -2.8F, ToolMaterial.WOOD, new HashSet<>());
//@todo add extra stuff? //@todo add extra stuff?
this.setMaxDamage(16); setMaxDamage(16);
setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack stack = player.getHeldItem(hand); ItemStack stack = playerIn.getHeldItem(handIn);
if (world.isRemote) { if (worldIn.isRemote) {
return new ActionResult<>(EnumActionResult.FAIL, stack); return new ActionResult<>(EnumActionResult.FAIL, stack);
} }
if (!stack.hasTagCompound()) { if (!stack.hasTagCompound()) {
@ -51,14 +51,14 @@ public class ItemRiftConnectionTool extends ItemTool {
stack.setTagCompound(compound); stack.setTagCompound(compound);
} }
RayTraceResult hit = rayTrace(world, player, true); RayTraceResult hit = rayTrace(worldIn, playerIn, true);
if (RayTraceHelper.isAbstractRift(hit, world)) { if (RayTraceHelper.isAbstractRift(hit, worldIn)) {
DDTileEntityBase rift = (DDTileEntityBase) world.getTileEntity(hit.getBlockPos()); DDTileEntityBase rift = (DDTileEntityBase) worldIn.getTileEntity(hit.getBlockPos());
if (player.isSneaking()) { if (playerIn.isSneaking()) {
return selectRift(stack, world, rift, player); //new ActionResult(EnumActionResult.PASS, stack)); return selectRift(stack, worldIn, rift, playerIn); //new ActionResult(EnumActionResult.PASS, stack));
} }
} else { } else {
return changeMode(stack, player); return changeMode(stack, playerIn);
} }
return new ActionResult<>(EnumActionResult.FAIL, stack); return new ActionResult<>(EnumActionResult.FAIL, stack);
@ -88,7 +88,7 @@ public class ItemRiftConnectionTool extends ItemTool {
} }
stack.damageItem(1, playerIn); stack.damageItem(1, playerIn);
} }
return new ActionResult(EnumActionResult.SUCCESS, stack); return new ActionResult<>(EnumActionResult.SUCCESS, stack);
} }
private ActionResult<ItemStack> changeMode(ItemStack stack, EntityPlayer player) { private ActionResult<ItemStack> changeMode(ItemStack stack, EntityPlayer player) {

View file

@ -2,7 +2,6 @@ package com.zixiken.dimdoors.shared.items;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -16,14 +15,13 @@ public class ItemRiftSignature extends Item {
public static final String ID = "rift_signature"; public static final String ID = "rift_signature";
public ItemRiftSignature() { public ItemRiftSignature() {
super();
setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
} }
@Override @Override
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag advanced) { public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
translateAndAdd("info.rift_signature.unbound", list); translateAndAdd("info.rift_signature.unbound", tooltip);
} }
} }

View file

@ -9,7 +9,6 @@ public class ItemStableFabric extends Item {
public static final String ID = "stable_fabric"; public static final String ID = "stable_fabric";
public ItemStableFabric() { public ItemStableFabric() {
super();
setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); setRegistryName(new ResourceLocation(DimDoors.MODID, ID));

View file

@ -9,7 +9,6 @@ public class ItemWorldThread extends Item {
public static final String ID = "world_thread"; public static final String ID = "world_thread";
public ItemWorldThread() { public ItemWorldThread() {
super();
setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); setRegistryName(new ResourceLocation(DimDoors.MODID, ID));

View file

@ -9,44 +9,43 @@ import com.zixiken.dimdoors.shared.blocks.ModBlocks;
public class ModItems { public class ModItems {
// Regular doors // Regular doors
public final static ItemDoorGold GOLD_DOOR = new ItemDoorGold(); public static final ItemDoorGold GOLD_DOOR = new ItemDoorGold();
public final static ItemDoorQuartz QUARTZ_DOOR = new ItemDoorQuartz(); public static final ItemDoorQuartz QUARTZ_DOOR = new ItemDoorQuartz();
// Dimensional doors // Dimensional doors
public final static ItemDimDoor DIMENSIONAL_DOOR = new ItemDimDoor(); public static final ItemDimDoor DIMENSIONAL_DOOR = new ItemDimDoor();
public final static ItemDimDoorGold GOLD_DIMENSIONAL_DOOR = new ItemDimDoorGold(); public static final ItemDimDoorGold GOLD_DIMENSIONAL_DOOR = new ItemDimDoorGold();
public final static ItemDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new ItemDimDoorPersonal(); public static final ItemDimDoorPersonal PERSONAL_DIMENSIONAL_DOOR = new ItemDimDoorPersonal();
public final static ItemDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new ItemDimDoorUnstable(); public static final ItemDimDoorUnstable UNSTABLE_DIMENSIONAL_DOOR = new ItemDimDoorUnstable();
public final static ItemDimDoorWarp WARP_DIMENSIONAL_DOOR = new ItemDimDoorWarp(); public static final ItemDimDoorWarp WARP_DIMENSIONAL_DOOR = new ItemDimDoorWarp();
// Fabric // Fabric
public final static ItemWorldThread WORLD_THREAD = new ItemWorldThread(); public static final ItemWorldThread WORLD_THREAD = new ItemWorldThread();
public final static ItemBlockFabric FABRIC = new ItemBlockFabric(); public static final ItemStableFabric STABLE_FABRIC = new ItemStableFabric();
public final static ItemStableFabric STABLE_FABRIC = new ItemStableFabric();
// Tools // Tools
public final static ItemRiftConnectionTool RIFT_CONNECTION_TOOL = new ItemRiftConnectionTool(); public static final ItemRiftConnectionTool RIFT_CONNECTION_TOOL = new ItemRiftConnectionTool();
public final static ItemRiftBlade RIFT_BLADE = new ItemRiftBlade(); public static final ItemRiftBlade RIFT_BLADE = new ItemRiftBlade();
@SubscribeEvent @SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) { public static void registerItems(RegistryEvent.Register<Item> event) {
event.getRegistry().register(QUARTZ_DOOR); event.getRegistry().registerAll(
event.getRegistry().register(PERSONAL_DIMENSIONAL_DOOR); QUARTZ_DOOR,
event.getRegistry().register(GOLD_DOOR); PERSONAL_DIMENSIONAL_DOOR,
event.getRegistry().register(GOLD_DIMENSIONAL_DOOR); GOLD_DOOR,
event.getRegistry().register(DIMENSIONAL_DOOR); GOLD_DIMENSIONAL_DOOR,
event.getRegistry().register(WARP_DIMENSIONAL_DOOR); DIMENSIONAL_DOOR,
event.getRegistry().register(STABLE_FABRIC); WARP_DIMENSIONAL_DOOR,
event.getRegistry().register(UNSTABLE_DIMENSIONAL_DOOR); STABLE_FABRIC,
event.getRegistry().register(WORLD_THREAD); UNSTABLE_DIMENSIONAL_DOOR,
event.getRegistry().register(RIFT_CONNECTION_TOOL); WORLD_THREAD,
event.getRegistry().register(RIFT_BLADE); RIFT_CONNECTION_TOOL,
RIFT_BLADE);
// ItemBlocks // ItemBlocks
event.getRegistry().register(FABRIC); event.getRegistry().registerAll(
event.getRegistry().register(new ItemBlock(ModBlocks.DIMENSIONAL_TRAPDOOR) new ItemBlockFabric(),
.setRegistryName(ModBlocks.DIMENSIONAL_TRAPDOOR.getRegistryName())); new ItemBlock(ModBlocks.DIMENSIONAL_TRAPDOOR).setRegistryName(ModBlocks.DIMENSIONAL_TRAPDOOR.getRegistryName()),
event.getRegistry().register(new ItemBlock(ModBlocks.RIFT) new ItemBlock(ModBlocks.RIFT).setRegistryName(ModBlocks.RIFT.getRegistryName()));
.setRegistryName(ModBlocks.RIFT.getRegistryName()));
} }
} }

View file

@ -6,7 +6,6 @@ import com.zixiken.dimdoors.shared.Pocket;
import com.zixiken.dimdoors.shared.PocketRegistry; import com.zixiken.dimdoors.shared.PocketRegistry;
import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.shared.RiftRegistry; import com.zixiken.dimdoors.shared.RiftRegistry;
import com.zixiken.dimdoors.shared.blocks.IDimDoor;
import java.util.Random; import java.util.Random;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -58,7 +57,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
pairedRiftID = otherRiftID; pairedRiftID = otherRiftID;
isPaired = true; isPaired = true;
RiftRegistry.INSTANCE.pair(pairedRiftID, riftID); //make sure it gets paired the other way around RiftRegistry.INSTANCE.pair(pairedRiftID, riftID); //make sure it gets paired the other way around
this.markDirty(); markDirty();
return false; return false;
} }
@ -68,7 +67,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
} else { } else {
isPaired = false; isPaired = false;
RiftRegistry.INSTANCE.unpair(pairedRiftID); RiftRegistry.INSTANCE.unpair(pairedRiftID);
this.markDirty(); markDirty();
} }
return false; return false;
} }
@ -76,25 +75,25 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
public void register(int depth) { public void register(int depth) {
//if (riftID == -1) { //this check only causes problems? //if (riftID == -1) { //this check only causes problems?
riftID = RiftRegistry.INSTANCE.registerNewRift(this, depth); 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 @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(nbt); super.readFromNBT(compound);
try { try {
isPaired = nbt.getBoolean("isPaired"); isPaired = compound.getBoolean("isPaired");
riftID = nbt.getInteger("riftID"); riftID = compound.getInteger("riftID");
pairedRiftID = nbt.getInteger("pairedRiftID"); pairedRiftID = compound.getInteger("pairedRiftID");
isInPocket = nbt.getBoolean("isInPocket"); isInPocket = compound.getBoolean("isInPocket");
pocketID = nbt.getInteger("pocketID"); pocketID = compound.getInteger("pocketID");
if (nbt.hasKey("pocketType")) { if (compound.hasKey("pocketType")) {
pocketType = EnumPocketType.valueOf(nbt.getString("pocketType")); pocketType = EnumPocketType.valueOf(compound.getString("pocketType"));
} }
depth = nbt.getInteger("depth"); depth = compound.getInteger("depth");
} catch (Exception e) { } 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 //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 @Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) { public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setBoolean("isPaired", this.isPaired); nbt.setBoolean("isPaired", isPaired);
nbt.setInteger("riftID", this.riftID); nbt.setInteger("riftID", riftID);
nbt.setInteger("pairedRiftID", this.pairedRiftID); nbt.setInteger("pairedRiftID", pairedRiftID);
nbt.setBoolean("isInPocket", this.isInPocket); nbt.setBoolean("isInPocket", isInPocket);
nbt.setInteger("pocketID", this.pocketID); nbt.setInteger("pocketID", pocketID);
if (pocketType != null) { 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; return nbt;
} }
@ -126,7 +125,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
pocketType = rift2.pocketType; pocketType = rift2.pocketType;
depth = rift2.depth; depth = rift2.depth;
this.markDirty(); markDirty();
} }
} }
@ -147,26 +146,26 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
} }
public Location getTeleportTargetLocation() { 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 abstract boolean tryTeleport(Entity entity);
public void setPocket(int ID, EnumPocketType type) { public void setPocket(int id, EnumPocketType type) {
pocketID = ID; pocketID = id;
pocketType = type; pocketType = type;
isInPocket = true; isInPocket = true;
this.markDirty(); markDirty();
} }
public void setIsInPocket() { public void setIsInPocket() {
isInPocket = true; isInPocket = true;
this.markDirty(); markDirty();
} }
public void setDepth(int depth) { public void setDepth(int depth) {
this.depth = depth; this.depth = depth;
this.markDirty(); markDirty();
} }
protected EnumPocketType getPocketType() { protected EnumPocketType getPocketType() {
@ -174,9 +173,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
} }
public void validatePlayerPocketEntry(EntityPlayer player) { public void validatePlayerPocketEntry(EntityPlayer player) {
if (!isInPocket || pocketType == EnumPocketType.PRIVATE) { if (isInPocket && pocketType != EnumPocketType.PRIVATE) {
return;
} else {
Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, pocketType); Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, pocketType);
pocket.validatePlayerEntry(player); pocket.validatePlayerEntry(player);
} }
@ -185,13 +182,11 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
@Override @Override
public void update() { public void update() {
if (isTeleporting && teleportingEntity != null) { if (isTeleporting && teleportingEntity != null) {
if (tryTeleport(teleportingEntity)) { if (!tryTeleport(teleportingEntity)) {
//player is succesfully teleported
} else {
//probably should only happen on personal dimdoors?
if (teleportingEntity instanceof EntityPlayer) { if (teleportingEntity instanceof EntityPlayer) {
EntityPlayer entityPlayer = (EntityPlayer) teleportingEntity; EntityPlayer entityPlayer = (EntityPlayer) teleportingEntity;
DimDoors.chat(entityPlayer, "Teleporting failed, but since mod is still in alpha, stuff like that might simply happen."); 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; isTeleporting = false;

View file

@ -9,7 +9,7 @@ import com.zixiken.dimdoors.shared.blocks.BlockDimDoor;
import com.zixiken.dimdoors.shared.util.Location; import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.shared.RiftRegistry; import com.zixiken.dimdoors.shared.RiftRegistry;
import com.zixiken.dimdoors.shared.TeleporterDimDoors; 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 com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import java.util.Random; import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -29,11 +29,11 @@ public class TileEntityDimDoor extends DDTileEntityBase {
super.readFromNBT(nbt); super.readFromNBT(nbt);
try { try {
this.doorIsOpen = nbt.getBoolean("doorIsOpen"); doorIsOpen = nbt.getBoolean("doorIsOpen");
this.orientation = EnumFacing.getFront(nbt.getInteger("orientation")); orientation = EnumFacing.getFront(nbt.getInteger("orientation"));
this.lockStatus = nbt.getByte("lockStatus"); lockStatus = nbt.getByte("lockStatus");
} catch (Exception e) { } 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) { public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setBoolean("doorIsOpen", this.doorIsOpen); nbt.setBoolean("doorIsOpen", doorIsOpen);
nbt.setInteger("orientation", this.orientation.getIndex()); nbt.setInteger("orientation", orientation.getIndex());
nbt.setByte("lockStatus", lockStatus); nbt.setByte("lockStatus", lockStatus);
return nbt; return nbt;
} }
@ -50,7 +50,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
@Override @Override
public float[] getRenderColor(Random rand) { public float[] getRenderColor(Random rand) {
float[] rgbaColor = {1, 1, 1, 1}; 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[0] = rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = rand.nextFloat() * 0.05F; rgbaColor[1] = rand.nextFloat() * 0.05F;
rgbaColor[2] = rand.nextFloat() * 0.05F; rgbaColor[2] = rand.nextFloat() * 0.05F;
@ -65,7 +65,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
@Override @Override
public Location getTeleportTargetLocation() { 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 @Override
@ -78,7 +78,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
} }
Location tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID); Location tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID);
if (tpLocation == null) { 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; return false;
} }
RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID); 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 //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() { protected int getNewTeleportDestination() {
int otherRiftID; 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(); 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 //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); otherRiftID = RiftRegistry.INSTANCE.getRandomUnpairedRiftIDAroundDepth(getRiftID(), depth);
if (otherRiftID < 0) { //ergo: no other rift can be found if (otherRiftID < 0) { //ergo: no other rift can be found
//@todo, this should rarely happen. Put in an easter egg? //@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 { } else {
otherRiftID = PocketRegistry.INSTANCE.getEntranceDoorIDOfNewPocket(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation); otherRiftID = PocketRegistry.INSTANCE.generateRandomPocketAt(EnumPocketType.DUNGEON, getRandomlyTransFormedDepth(), origLocation).getEntranceDoorID();
} }
} else { } 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) { 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 { } else {
//@todo (should the other rift get loaded?) //@todo (should the other rift get loaded?)
RiftRegistry.INSTANCE.pair(getRiftID(), otherRiftID); RiftRegistry.INSTANCE.pair(getRiftID(), otherRiftID);
@ -143,6 +143,6 @@ public class TileEntityDimDoor extends DDTileEntityBase {
} }
protected int getRandomlyTransFormedDepth() { protected int getRandomlyTransFormedDepth() {
return DDRandomUtils.transformRandomly(depth, DDConfig.getDoorRelativeDepths(), DDConfig.getDoorRelativeDepthWeights()); return RandomUtils.transformRandomly(depth, DDConfig.getDoorRelativeDepths(), DDConfig.getDoorRelativeDepthWeights());
} }
} }

View file

@ -69,15 +69,15 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo
//DimDoors.log(this.getClass(), "Trying to find suitable destination rift."); //DimDoors.log(this.getClass(), "Trying to find suitable destination rift.");
int otherRiftID = RiftRegistry.INSTANCE.getRandomUnpairedRiftIDAtDepth(getRiftID(), depth); int otherRiftID = RiftRegistry.INSTANCE.getRandomUnpairedRiftIDAtDepth(getRiftID(), depth);
if (otherRiftID < 0) { 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 if (origLocation.getDimensionID() == DimDoorDimensions.getPocketDimensionType(EnumPocketType.DUNGEON).getId()) { //if this dimdoor is a pocket Dungeon
origLocation = PocketRegistry.INSTANCE.getPocket(pocketID, pocketType).getDepthZeroLocation(); 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) { 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 { } else {
RiftRegistry.INSTANCE.pair(getRiftID(), otherRiftID); RiftRegistry.INSTANCE.pair(getRiftID(), otherRiftID);
} }

View file

@ -26,17 +26,17 @@ public class TileEntityDimDoorPersonal extends TileEntityDimDoor {
@Override @Override
public boolean tryTeleport(Entity entity) { //this door is never paired 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; Location tpLocation;
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
EntityPlayer entityPlayer = (EntityPlayer) entity; EntityPlayer entityPlayer = (EntityPlayer) entity;
if (locationOfThisRift.getDimensionID() == DimDoorDimensions.getPocketDimensionType(EnumPocketType.PRIVATE).getId()) { 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 { } else {
int otherDoorID = PocketRegistry.INSTANCE.getPrivateDimDoorID(entityPlayer.getCachedUniqueIdString()); int otherDoorID = PocketRegistry.INSTANCE.getPrivateDimDoorID(entityPlayer.getCachedUniqueIdString());
tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherDoorID); tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherDoorID);
int privatePocketID = RiftRegistry.INSTANCE.getPocketID(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 { } else {
return false; return false;

View file

@ -14,9 +14,9 @@ import net.minecraft.entity.Entity;
* *
* @author Robijnvogel * @author Robijnvogel
*/ */
public class TileEntityDimDoorChaos extends TileEntityDimDoor { public class TileEntityDimDoorUnstable extends TileEntityDimDoor {
public TileEntityDimDoorChaos() { public TileEntityDimDoorUnstable() {
canRiftBePaired = false; canRiftBePaired = false;
} }

View file

@ -16,10 +16,10 @@ public class TileEntityDimDoorWarp extends TileEntityDimDoor {
int otherRiftID = getPairedRiftID(); int otherRiftID = getPairedRiftID();
tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID); tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID);
RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID); RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID);
} else if (!(this.isInPocket)) { } else if (!isInPocket) {
return false; return false;
} else { } else {
Pocket pocket = PocketRegistry.INSTANCE.getPocket(this.pocketID, this.getPocketType()); Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, getPocketType());
tpLocation = pocket.getDepthZeroLocation(); tpLocation = pocket.getDepthZeroLocation();
} }
return TeleporterDimDoors.instance().teleport(entity, tpLocation); return TeleporterDimDoors.instance().teleport(entity, tpLocation);

View file

@ -36,8 +36,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
public float growth = 0; public float growth = 0;
public TileEntityRift() { public TileEntityRift() {
super(); loadDataFrom(RiftRegistry.INSTANCE.getLastChangedRift()); //@todo this should absolutely not be done in this constructor...
this.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 // Vary the update times of rifts to prevent all the rifts in a cluster
// from updating at the same time. // 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 // Ensure that this rift is only spawning one Enderman at a time, to prevent hordes of Endermen
Entity entity = world.getEntityByID(this.spawnedEndermenID); Entity entity = world.getEntityByID(spawnedEndermenID);
if (entity != null && entity instanceof EntityEnderman) { if (entity instanceof EntityEnderman) {
return; return;
} }
@ -91,7 +90,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
world.spawnEntity(enderman); world.spawnEntity(enderman);
if (random.nextInt(MAX_HOSTILE_ENDERMAN_CHANCE) < HOSTILE_ENDERMAN_CHANCE) { 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) { if (player != null) {
enderman.setAttackTarget(player); enderman.setAttackTarget(player);
} }
@ -118,25 +117,25 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.updateTimer = nbt.getInteger("updateTimer"); updateTimer = nbt.getInteger("updateTimer");
this.offset = new BlockPos(nbt.getInteger("xOffset"), nbt.getInteger("yOffset"), nbt.getInteger("zOffset")); offset = new BlockPos(nbt.getInteger("xOffset"), nbt.getInteger("yOffset"), nbt.getInteger("zOffset"));
this.shouldClose = nbt.getBoolean("shouldClose"); shouldClose = nbt.getBoolean("shouldClose");
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID"); spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
this.riftRotation = nbt.getInteger("riftRotation"); riftRotation = nbt.getInteger("riftRotation");
this.growth = nbt.getFloat("growth"); growth = nbt.getFloat("growth");
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) { public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setInteger("updateTimer", this.updateTimer); nbt.setInteger("updateTimer", updateTimer);
nbt.setInteger("xOffset", this.offset.getX()); nbt.setInteger("xOffset", offset.getX());
nbt.setInteger("yOffset", this.offset.getY()); nbt.setInteger("yOffset", offset.getY());
nbt.setInteger("zOffset", this.offset.getZ()); nbt.setInteger("zOffset", offset.getZ());
nbt.setBoolean("shouldClose", this.shouldClose); nbt.setBoolean("shouldClose", shouldClose);
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID); nbt.setInteger("spawnedEndermenID", spawnedEndermenID);
nbt.setInteger("riftRotation", this.riftRotation); nbt.setInteger("riftRotation", riftRotation);
nbt.setFloat("growth", this.growth); nbt.setFloat("growth", growth);
return nbt; return nbt;
} }
@ -150,7 +149,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
public boolean tryTeleport(Entity entity) { public boolean tryTeleport(Entity entity) {
int otherRiftID; int otherRiftID;
if (!isPaired()) { 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; return false;
} else { } else {
otherRiftID = getPairedRiftID(); otherRiftID = getPairedRiftID();

View file

@ -13,7 +13,7 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase {
@Override @Override
public float[] getRenderColor(Random rand) { public float[] getRenderColor(Random rand) {
float[] rgbaColor = {1, 1, 1, 1}; 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[0] = world.rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = world.rand.nextFloat() * 0.05F; rgbaColor[1] = world.rand.nextFloat() * 0.05F;
rgbaColor[2] = world.rand.nextFloat() * 0.05F; rgbaColor[2] = world.rand.nextFloat() * 0.05F;
@ -27,7 +27,7 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase {
@Override @Override
public Location getTeleportTargetLocation() { public Location getTeleportTargetLocation() {
return new Location(this.getWorld().provider.getDimension(), this.getPos().up()); return new Location(getWorld().provider.getDimension(), getPos().up());
} }
@Override @Override
@ -37,10 +37,10 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase {
int otherRiftID = getPairedRiftID(); int otherRiftID = getPairedRiftID();
tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID); tpLocation = RiftRegistry.INSTANCE.getTeleportLocation(otherRiftID);
RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID); RiftRegistry.INSTANCE.validatePlayerPocketEntry(entity, otherRiftID);
} else if (!(this.isInPocket)) { } else if (!isInPocket) {
return false; return false;
} else { } else {
Pocket pocket = PocketRegistry.INSTANCE.getPocket(this.pocketID, this.getPocketType()); Pocket pocket = PocketRegistry.INSTANCE.getPocket(pocketID, getPocketType());
tpLocation = pocket.getDepthZeroLocation(); tpLocation = pocket.getDepthZeroLocation();
} }
return TeleporterDimDoors.instance().teleport(entity, tpLocation); return TeleporterDimDoors.instance().teleport(entity, tpLocation);

View file

@ -33,7 +33,7 @@ public class Location implements Serializable {
} }
public Location(int dimID, BlockPos pos) { public Location(int dimID, BlockPos pos) {
this.dimensionID = dimID; dimensionID = dimID;
this.pos = pos; //copyOf this.pos = pos; //copyOf
} }
@ -88,29 +88,29 @@ public class Location implements Serializable {
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object obj) {
if (o == null || !(o instanceof Location)) { if (!(obj instanceof Location)) {
return false; return false;
} }
Location other = (Location) o; Location other = (Location) obj;
return other.dimensionID == this.dimensionID && other.pos.equals(this.pos); return other.dimensionID == dimensionID && other.pos.equals(pos);
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 5; int hash = 5;
hash = 89 * hash + this.dimensionID; hash = 89 * hash + dimensionID;
hash = 89 * hash + Objects.hashCode(this.pos); hash = 89 * hash + Objects.hashCode(pos);
return hash; return hash;
} }
@Override @Override
public String toString() { public String toString() {
return "Location: dimID: " + this.dimensionID + " position: " + this.pos.toString(); return "Location: dimID: " + dimensionID + " position: " + pos;
} }
public void loadfrom(Location location) { public void loadfrom(Location location) {
this.dimensionID = location.dimensionID; dimensionID = location.dimensionID;
this.pos = location.pos; pos = location.pos;
} }
} }

View file

@ -9,7 +9,7 @@ package com.zixiken.dimdoors.shared.util;
* *
* @author Robijnvogel * @author Robijnvogel
*/ */
public class DDMathUtils { public class MathUtils {
/** /**
* Compares the integers in two arrays and returns true if any integer in * Compares the integers in two arrays and returns true if any integer in
@ -27,9 +27,9 @@ public class DDMathUtils {
if (difference < 0) { if (difference < 0) {
throw new IllegalArgumentException("precondition was violated"); throw new IllegalArgumentException("precondition was violated");
} }
for (int One : setOne) { for (int one : setOne) {
for (int Two : setTwo) { for (int two : setTwo) {
if ((Math.max(One, Two) - Math.min(One, Two)) < difference) { if (Math.max(one, two) - Math.min(one, two) < difference) {
return true; return true;
} }
} }
@ -51,9 +51,9 @@ public class DDMathUtils {
public static int arraySum(int[] intArray, short flag) { public static int arraySum(int[] intArray, short flag) {
int r = 0; int r = 0;
for (int i : intArray) { //check flag 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"); 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"); throw new IllegalArgumentException("all integers in array must be negative");
} }
r += i; r += i;

View file

@ -13,7 +13,7 @@ import net.minecraft.util.EnumFacing;
* *
* @author Robijnvogel * @author Robijnvogel
*/ */
public class DDRandomUtils { public class RandomUtils {
/** /**
* Returns either true or false, based on a weighted random, taking in * 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."); throw new IllegalArgumentException("Either of both weights were 0 or lower. Both should be at least 1.");
} }
Random random = new Random(); 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 transformations the possible transformations
* @param weights the chance-weight of those transformations * @param weights the chance-weight of those transformations
* @pre {@code transformations.length = weights.length} && {@code (\forall i; intArray.has(i); i >= 0)} * @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 * @throws IllegalArgumentException if precondition is violated
* @return the sum of {@code base} and the value of an element in * @return the sum of {@code base} and the value of an element in
* {@code transformations} * {@code transformations}
@ -53,9 +53,9 @@ public class DDRandomUtils {
throw new IllegalArgumentException("pre was violated, transformations.length != weights.length"); throw new IllegalArgumentException("pre was violated, transformations.length != weights.length");
} }
Random random = new Random(); Random random = new Random();
int weightSum = DDMathUtils.arraySum(weights, (short) 0); int weightSum = MathUtils.arraySum(weights, (short) 0);
if (weightSum <= 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); int choice = random.nextInt(weightSum);
for (int i = 0; i < weights.length; i++) { for (int i = 0; i < weights.length; i++) {
@ -90,10 +90,9 @@ public class DDRandomUtils {
throw new IllegalArgumentException("pre was violated"); throw new IllegalArgumentException("pre was violated");
} }
Random random = new Random(); 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 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); 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)); return new Location(origLocation.getWorld(), origLocation.getPos().offset(EnumFacing.EAST, xOffset).offset(EnumFacing.SOUTH, zOffset));
} }
} }

View file

@ -34,13 +34,13 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
*/ */
public class Schematic { public class Schematic {
private static final String[] OLDDIMDOORBLOCKNAMES = new String[]{ private static final String[] OLDDIMDOORBLOCKNAMES = {
"Dimensional Door", "Dimensional Door",
"Fabric of Reality", "Fabric of Reality",
"transientDoor", //only used in the two old Overworld gateway (worldgen) structures "transientDoor", //only used in the two old Overworld gateway (worldgen) structures
"Warp Door"}; "Warp Door"};
private static final String[] NEWDIMDOORBLOCKNAMES = new String[]{ private static final String[] NEWDIMDOORBLOCKNAMES = {
"dimensional_door", "dimensional_door",
"fabric", //[type=fabric] is the default blockstate "fabric", //[type=fabric] is the default blockstate
"transient_dimensional_door", "transient_dimensional_door",
@ -50,15 +50,15 @@ public class Schematic {
String author = "DimDoors"; //@todo set in build.gradle ${modID} String author = "DimDoors"; //@todo set in build.gradle ${modID}
String schematicName = "Unknown"; String schematicName = "Unknown";
long creationDate; long creationDate;
String[] requiredMods = new String[0]; String[] requiredMods = {};
short width; short width;
short height; short height;
short length; short length;
int[] offset = new int[]{0, 0, 0}; int[] offset = {0, 0, 0};
int paletteMax; int paletteMax;
List<IBlockState> pallette = new ArrayList(); List<IBlockState> pallette = new ArrayList<>();
int[][][] blockData; //[x][y][z] int[][][] blockData; //[x][y][z]
List<NBTTagCompound> tileEntities = new ArrayList(); List<NBTTagCompound> tileEntities = new ArrayList<>();
private Schematic() { private Schematic() {
} }
@ -84,7 +84,7 @@ public class Schematic {
schematic.creationDate = metadataCompound.getLong("Date"); schematic.creationDate = metadataCompound.getLong("Date");
} }
if (nbt.hasKey("RequiredMods")) { //RequiredMods is not required (ironically) 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()]; schematic.requiredMods = new String[requiredModsTagList.tagCount()];
for (int i = 0; i < requiredModsTagList.tagCount(); i++) { for (int i = 0; i < requiredModsTagList.tagCount(); i++) {
schematic.requiredMods[i] = requiredModsTagList.getStringTagAt(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 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<Integer, String> paletteMap = new HashMap(); Map<Integer, String> paletteMap = new HashMap<>();
for (String key : paletteNBT.getKeySet()) { for (String key : paletteNBT.getKeySet()) {
int paletteID = paletteNBT.getInteger(key); int paletteID = paletteNBT.getInteger(key);
paletteMap.put(paletteID, key); //basically use the reversed order (key becomes value and value becomes 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("")) { if (!stateString.equals("")) {
String[] properties = stateString.split(","); String[] properties = stateString.split(",");
blockstate = getBlockStateWithProperties(block, properties); 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? 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); nbt.setInteger("PaletteMax", schematic.paletteMax);
NBTTagCompound paletteNBT = new NBTTagCompound(); NBTTagCompound paletteNBT = new NBTTagCompound();
Map<Integer, String> paletteMap = new HashMap();
for (int i = 0; i < schematic.pallette.size(); i++) { for (int i = 0; i < schematic.pallette.size(); i++) {
IBlockState state = schematic.pallette.get(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); String blockStateString = getBlockStateStringFromState(state);
paletteNBT.setInteger(blockStateString, i); paletteNBT.setInteger(blockStateString, i);
} }
@ -209,10 +207,9 @@ public class Schematic {
} }
private static IBlockState getBlockStateWithProperties(Block block, String[] properties) { private static IBlockState getBlockStateWithProperties(Block block, String[] properties) {
Map<String, String> propertyAndBlockStringsMap = new HashMap(); Map<String, String> propertyAndBlockStringsMap = new HashMap<>();
for (int i = 0; i < properties.length; i++) { for (String property : properties) {
String propertyString = properties[i]; String[] propertyAndBlockStrings = property.split("=");
String[] propertyAndBlockStrings = propertyString.split("=");
propertyAndBlockStringsMap.put(propertyAndBlockStrings[0], propertyAndBlockStrings[1]); propertyAndBlockStringsMap.put(propertyAndBlockStrings[0], propertyAndBlockStrings[1]);
} }
BlockStateContainer container = block.getBlockState(); BlockStateContainer container = block.getBlockState();
@ -238,7 +235,7 @@ public class Schematic {
private static String getBlockStateStringFromState(IBlockState state) { private static String getBlockStateStringFromState(IBlockState state) {
Block block = state.getBlock(); Block block = state.getBlock();
String blockNameString = "" + Block.REGISTRY.getNameForObject(block); String blockNameString = "" + Block.REGISTRY.getNameForObject(block);
String blockStateString = ""; StringBuilder blockStateString = new StringBuilder();
String totalString; String totalString;
IBlockState defaultState = block.getDefaultState(); IBlockState defaultState = block.getDefaultState();
if (state == defaultState) { 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 for (IProperty property : container.getProperties()) { //for every property that is valid for this type of Block
String defaultPropertyValue = defaultState.getProperties().get(property).toString(); String defaultPropertyValue = defaultState.getProperties().get(property).toString();
String thisPropertyValue = state.getProperties().get(property).toString(); String thisPropertyValue = state.getProperties().get(property).toString();
if (defaultPropertyValue.equals(thisPropertyValue)) { if (!defaultPropertyValue.equals(thisPropertyValue)) {
//do nothing
} else {
String firstHalf = property.getName(); String firstHalf = property.getName();
String secondHalf = state.getProperties().get(property).toString(); String secondHalf = state.getProperties().get(property).toString();
String propertyString = firstHalf + "=" + secondHalf; 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 + "]"; totalString = blockNameString + "[" + blockStateString + "]";
} }
return totalString; return totalString;
@ -365,12 +360,12 @@ public class Schematic {
IBlockState baseState = schematic.pallette.get(blockInt); //this is the default blockstate except for ancient fabric 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 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 if (schematic.pallette.contains(additionalState)) { //check whether or not this blockstate is already in the list
blockInt = schematic.pallette.indexOf(additionalState); blockInt = schematic.pallette.indexOf(additionalState);
} else { } else {
schematic.pallette.add(additionalState); 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; blockInt = schematic.pallette.size() - 1;
} }
} else { //if this is ancient fabric } 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) { 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 schematic = new Schematic();
schematic.version = 1; schematic.version = 1;
@ -434,7 +429,7 @@ public class Schematic {
schematic.offset = new int[]{0, 0, 0}; schematic.offset = new int[]{0, 0, 0};
schematic.paletteMax = 4; schematic.paletteMax = 4;
schematic.pallette = new ArrayList(); schematic.pallette = new ArrayList<>();
schematic.pallette.add(Blocks.AIR.getDefaultState()); schematic.pallette.add(Blocks.AIR.getDefaultState());
schematic.pallette.add(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT)); schematic.pallette.add(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT));
schematic.pallette.add(innerWallBlockState); schematic.pallette.add(innerWallBlockState);
@ -449,7 +444,7 @@ public class Schematic {
|| y == 0 || y == maxbound - 1 || y == 0 || y == maxbound - 1
|| z == 0 || z == maxbound - 1) { || z == 0 || z == maxbound - 1) {
schematic.blockData[x][y][z] = 1; //outer dim wall 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 (z == 4 && x == (maxbound - 1) / 2 && y > 4 && y < 7) {
if (y == 5) { if (y == 5) {
schematic.blockData[x][y][z] = 3; //door bottom 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()); TileEntity tileEntity = doorBlock.createTileEntity(DimDoors.proxy.getDefWorld(), doorBlock.getDefaultState());
NBTTagCompound tileNBT = tileEntity.serializeNBT(); NBTTagCompound tileNBT = tileEntity.serializeNBT();
tileNBT.setInteger("x", (maxbound - 1) / 2); tileNBT.setInteger("x", (maxbound - 1) / 2);

View file

@ -12,7 +12,7 @@ import java.util.List;
* *
* @author Robijnvogel * @author Robijnvogel
*/ */
public class DDStringUtils { public class StringUtils {
public static char flipCase(char in) { public static char flipCase(char in) {
if (Character.isUpperCase(in)) { if (Character.isUpperCase(in)) {
@ -23,7 +23,7 @@ public class DDStringUtils {
} }
public static List<String> getAsStringList(Integer[] integers) { public static List<String> getAsStringList(Integer[] integers) {
List<String> list = new ArrayList(); List<String> list = new ArrayList<>();
for (int integer : integers) { for (int integer : integers) {
list.add("" + integer); list.add("" + integer);
} }
@ -34,7 +34,7 @@ public class DDStringUtils {
if (template.equals("")) { if (template.equals("")) {
return comparables; return comparables;
} }
List<String> results = new ArrayList(); List<String> results = new ArrayList<>();
for (String comparable : comparables) { for (String comparable : comparables) {
if (isStartOfString(template, comparable, caseSensitive)) { if (isStartOfString(template, comparable, caseSensitive)) {
results.add(comparable); results.add(comparable);
@ -53,11 +53,7 @@ public class DDStringUtils {
for (int i = 0; i < template.length(); i++) { for (int i = 0; i < template.length(); i++) {
char tChar = template.charAt(i); char tChar = template.charAt(i);
char cChar = comparable.charAt(i); char cChar = comparable.charAt(i);
if (tChar == cChar) { if (tChar != cChar && !caseSensitive && flipCase(tChar) == cChar) {
//this matches, so continue the loop
} else if (!caseSensitive && flipCase(tChar) == cChar) {
//this matches, so continue the loop
} else {
return false; return false;
} }
} }

View file

@ -1,7 +0,0 @@
package com.zixiken.dimdoors.shared.world;
/**
* Created by Jared Johnson on 1/24/2017.
*/
public class BiomeGenPocket {
}

View file

@ -30,11 +30,11 @@ public class CustomSkyProvider extends IRenderHandler {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void render(float par1, WorldClient world, Minecraft mc) { public void render(float partialTicks, WorldClient world, Minecraft mc) {
starGLCallList = GLAllocation.generateDisplayLists(3); starGLCallList = GLAllocation.generateDisplayLists(3);
glSkyList = this.starGLCallList + 1; glSkyList = starGLCallList + 1;
glSkyList2 = this.starGLCallList + 2; glSkyList2 = starGLCallList + 2;
GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
@ -42,11 +42,11 @@ public class CustomSkyProvider extends IRenderHandler {
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
GL11.glDepthMask(false); GL11.glDepthMask(false);
mc.renderEngine.bindTexture((locationEndSkyPng)); mc.renderEngine.bindTexture(locationEndSkyPng);
if (mc.world.provider.isSurfaceWorld()) { if (mc.world.provider.isSurfaceWorld()) {
GL11.glDisable(GL11.GL_TEXTURE_2D); 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 f1 = (float) vec3.x;
float f2 = (float) vec3.y; float f2 = (float) vec3.y;
float f3 = (float) vec3.z; float f3 = (float) vec3.z;
@ -67,13 +67,13 @@ public class CustomSkyProvider extends IRenderHandler {
GL11.glDepthMask(false); GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_FOG); GL11.glEnable(GL11.GL_FOG);
GL11.glColor3f(f1, f2, f3); GL11.glColor3f(f1, f2, f3);
GL11.glCallList(this.glSkyList); GL11.glCallList(glSkyList);
GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(par1), par1); float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks);
float f7; float f7;
float f8; float f8;
float f9; float f9;
@ -84,7 +84,7 @@ public class CustomSkyProvider extends IRenderHandler {
GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); 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); GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
f4 = afloat[0]; f4 = afloat[0];
f7 = afloat[1]; f7 = afloat[1];
@ -119,16 +119,16 @@ public class CustomSkyProvider extends IRenderHandler {
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glPushMatrix(); GL11.glPushMatrix();
f4 = 1.0F - world.getRainStrength(par1); f4 = 1.0F - world.getRainStrength(partialTicks);
f7 = 0.0F; f7 = 0.0F;
f8 = 0.0F; f8 = 0.0F;
f9 = 0.0F; f9 = 0.0F;
GL11.glColor4f(1.0F, 1.0F, 1.0F, f4); GL11.glColor4f(1.0F, 1.0F, 1.0F, f4);
GL11.glTranslatef(f7, f8, f9); GL11.glTranslatef(f7, f8, f9);
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); 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; f10 = 30.0F;
mc.renderEngine.bindTexture(this.getSunRenderPath()); mc.renderEngine.bindTexture(getSunRenderPath());
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buffer.pos(-f10, 100, -f10).tex(0, 0).endVertex(); buffer.pos(-f10, 100, -f10).tex(0, 0).endVertex();
buffer.pos(f10, 100, -f10).tex(1, 0).endVertex(); buffer.pos(f10, 100, -f10).tex(1, 0).endVertex();
@ -137,26 +137,24 @@ public class CustomSkyProvider extends IRenderHandler {
tessellator.draw(); tessellator.draw();
f10 = 20.0F; f10 = 20.0F;
mc.renderEngine.bindTexture(this.getMoonRenderPath()); mc.renderEngine.bindTexture(getMoonRenderPath());
int k = world.getMoonPhase(); int k = world.getMoonPhase();
int l = k % 4; int i = k % 4;
int i1 = k / 4 % 2; int i1 = k / 4 % 2;
float f14 = l + 0; float f16 = i + 1;
float f15 = i1 + 0;
float f16 = l + 1;
float f17 = i1 + 1; float f17 = i1 + 1;
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buffer.pos(-f10, -100, f10).tex(f16, f17).endVertex(); buffer.pos(-f10, -100, f10).tex(f16, f17).endVertex();
buffer.pos(f10, -100, f10).tex(f14, f17).endVertex(); buffer.pos(f10, -100, f10).tex((float) i, f17).endVertex();
buffer.pos(f10, -100, -f10).tex(f14, f15).endVertex(); buffer.pos(f10, -100, -f10).tex((float) i, (float) i1).endVertex();
buffer.pos(-f10, -100, -f10).tex(f16, f15).endVertex(); buffer.pos(-f10, -100, -f10).tex(f16, (float) i1).endVertex();
tessellator.draw(); tessellator.draw();
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
float f18 = world.getStarBrightness(par1) * f4; float f18 = world.getStarBrightness(partialTicks) * f4;
if (f18 > 0.0F) { if (f18 > 0.0F) {
GL11.glColor4f(f18, f18, f18, f18); GL11.glColor4f(f18, f18, f18, f18);
GL11.glCallList(this.starGLCallList); GL11.glCallList(starGLCallList);
} }
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@ -166,12 +164,12 @@ public class CustomSkyProvider extends IRenderHandler {
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(0.0F, 0.0F, 0.0F); 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) { if (d0 < 0.0D) {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 12.0F, 0.0F); GL11.glTranslatef(0.0F, 12.0F, 0.0F);
GL11.glCallList(this.glSkyList2); GL11.glCallList(glSkyList2);
GL11.glPopMatrix(); GL11.glPopMatrix();
f8 = 1.0F; f8 = 1.0F;
f9 = -((float) (d0 + 65.0D)); f9 = -((float) (d0 + 65.0D));
@ -209,11 +207,10 @@ public class CustomSkyProvider extends IRenderHandler {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F); GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
GL11.glCallList(this.glSkyList2); GL11.glCallList(glSkyList2);
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true); GL11.glDepthMask(true);
} }
} }
} }

View file

@ -11,12 +11,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.world.DimensionType; import net.minecraft.world.DimensionType;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
public class DimDoorDimensions { public class DimDoorDimensions {
public static DimensionType LIMBO; public static DimensionType LIMBO = null;
private static int minPocketDimID; private static int minPocketDimID;
private static int maxPocketDimID; private static int maxPocketDimID;
private static final List<EnumPocketType> pocketTypes = new ArrayList<>(); private static final List<EnumPocketType> pocketTypes = new ArrayList<>();
@ -43,12 +42,13 @@ public class DimDoorDimensions {
registerDimension(pocketDimensionTypes.get(pocketType)); 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? // TODO: For future use? Like, server owners can add their own set of DimDoors DimensionTypes via the configs? Or is this nonsense?
dimID++; // for (int i = 0; i < 0; i++) {
DimensionType tempType = DimensionType.register("Name", "_name", dimID, WorldProvider.class, false); // dimID++;
CUSTOM.add(tempType); // DimensionType tempType = DimensionType.register("Name", "_name", dimID, WorldProvider.class, false);
registerDimension(tempType); // CUSTOM.add(tempType);
} // registerDimension(tempType);
//}
} }
public static void registerDimension(DimensionType dimension) { public static void registerDimension(DimensionType dimension) {

View file

@ -5,18 +5,18 @@ import net.minecraft.world.biome.Biome;
/** /**
* Created by Jared Johnson on 1/24/2017. * Created by Jared Johnson on 1/24/2017.
*/ */
public class DimDoorsBiome extends Biome public class DimDoorsBiome extends Biome {
{
public DimDoorsBiome(String name) { public DimDoorsBiome(String name) {
super(new BiomeProperties(name)); super(new BiomeProperties(name));
this.decorator.treesPerChunk = 0; decorator.treesPerChunk = 0;
this.decorator.flowersPerChunk = 0; decorator.flowersPerChunk = 0;
this.decorator.grassPerChunk = 0; decorator.grassPerChunk = 0;
this.spawnableMonsterList.clear(); spawnableMonsterList.clear();
this.spawnableCreatureList.clear(); spawnableCreatureList.clear();
this.spawnableWaterCreatureList.clear(); spawnableWaterCreatureList.clear();
this.spawnableCaveCreatureList.clear(); spawnableCaveCreatureList.clear();
} }
@Override @Override

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.shared.world.limbodimension;
import com.zixiken.dimdoors.shared.world.biomes.DimDoorsBiome; import com.zixiken.dimdoors.shared.world.biomes.DimDoorsBiome;
public class LimboBiome extends DimDoorsBiome { public class LimboBiome extends DimDoorsBiome {
public LimboBiome() { public LimboBiome() {
super("limbo"); super("limbo");
} }

View file

@ -167,6 +167,6 @@ public class LimboDecay {
} }
} }
return (block == null || !(block instanceof BlockContainer)); return !(block instanceof BlockContainer);
} }
} }

View file

@ -19,9 +19,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class LimboGenerator implements IChunkGenerator public class LimboGenerator implements IChunkGenerator {
{
private static Random rand; private Random rand;
/** A NoiseGeneratorOctaves used in generating terrain */ /** A NoiseGeneratorOctaves used in generating terrain */
private NoiseGeneratorOctaves noiseGen1; private NoiseGeneratorOctaves noiseGen1;
@ -75,44 +75,44 @@ public class LimboGenerator implements IChunkGenerator
*/ */
float[] parabolicField; float[] parabolicField;
int[][] field_73219_j = new int[32][32]; int[][] field_73219_j = new int[32][32];
{ //{
// caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); // caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE);
} //}
//private CustomLimboPopulator spawner; //private CustomLimboPopulator spawner;
public LimboGenerator(World world, long seed /*CustomLimboPopulator spawner*/) { public LimboGenerator(World world, long seed /*CustomLimboPopulator spawner*/) {
this.worldObj = world; worldObj = world;
LimboGenerator.rand = new Random(seed); rand = new Random(seed);
this.noiseGen1 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //base terrain noiseGen1 = new NoiseGeneratorOctaves(rand, 16); //base terrain
this.noiseGen2 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //hillyness noiseGen2 = new NoiseGeneratorOctaves(rand, 16); //hillyness
this.noiseGen3 = new NoiseGeneratorOctaves(LimboGenerator.rand, 80); //seems to adjust the size of features, how stretched things are -default 8 noiseGen3 = new NoiseGeneratorOctaves(rand, 80); //seems to adjust the size of features, how stretched things are -default 8
this.noiseGen4 = new NoiseGeneratorOctaves(LimboGenerator.rand, 4); noiseGen4 = new NoiseGeneratorOctaves(rand, 4);
this.noiseGen5 = new NoiseGeneratorOctaves(LimboGenerator.rand, 10); noiseGen5 = new NoiseGeneratorOctaves(rand, 10);
this.noiseGen6 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); noiseGen6 = new NoiseGeneratorOctaves(rand, 16);
this.mobSpawnerNoise = new NoiseGeneratorOctaves(LimboGenerator.rand, 8); mobSpawnerNoise = new NoiseGeneratorOctaves(rand, 8);
NoiseGeneratorOctaves[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise}; NoiseGeneratorOctaves[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise};
// noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); // noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens);
this.noiseGen1 = noiseGens[0]; noiseGen1 = noiseGens[0];
this.noiseGen2 = noiseGens[1]; noiseGen2 = noiseGens[1];
this.noiseGen3 = noiseGens[2]; noiseGen3 = noiseGens[2];
this.noiseGen4 = noiseGens[3]; noiseGen4 = noiseGens[3];
this.noiseGen5 = noiseGens[4]; noiseGen5 = noiseGens[4];
this.noiseGen6 = noiseGens[5]; noiseGen6 = noiseGens[5];
this.mobSpawnerNoise = noiseGens[6]; mobSpawnerNoise = noiseGens[6];
this.worldObj = world; worldObj = world;
//this.spawner = spawner; //this.spawner = spawner;
} }
@Override @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 //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(); ChunkPrimer primer = new ChunkPrimer();
this.scale(chunkX, chunkZ, primer); scale(x, z, primer);
Chunk chunk = new Chunk(this.worldObj, primer, chunkX, chunkZ); Chunk chunk = new Chunk(worldObj, primer, x, z);
chunk.generateSkylightMap(); chunk.generateSkylightMap();
if (!chunk.isTerrainPopulated()) { if (!chunk.isTerrainPopulated()) {
@ -124,7 +124,7 @@ public class LimboGenerator implements IChunkGenerator
} }
@Override @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]; par1ArrayOfDouble = new double[par5 * par6 * par7];
} }
if (this.parabolicField == null) { if (parabolicField == null) {
this.parabolicField = new float[25]; parabolicField = new float[25];
for (int var8 = -2; var8 <= 2; ++var8) { for (int var8 = -2; var8 <= 2; ++var8) {
for (int var9 = -2; var9 <= 2; ++var9) { for (int var9 = -2; var9 <= 2; ++var9) {
float var10 = 10.0F / MathHelper.sqrt(var8 * var8 + var9 * var9 + 0.2F); 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 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 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); noise5 = noiseGen5.generateNoiseOctaves(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); noise6 = noiseGen6.generateNoiseOctaves(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); noise3 = noiseGen3.generateNoiseOctaves(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); noise1 = noiseGen1.generateNoiseOctaves(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); noise2 = noiseGen2.generateNoiseOctaves(noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44);
int var12 = 0; int var12 = 0;
int var13 = 0; int var13 = 0;
@ -169,7 +169,7 @@ public class LimboGenerator implements IChunkGenerator
for (int var21 = -var19; var21 <= var19; ++var21) { for (int var21 = -var19; var21 <= var19; ++var21) {
for (int var22 = -var19; var22 <= var19; ++var22) { 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 //this adjusts the height of the terrain
@ -182,9 +182,9 @@ public class LimboGenerator implements IChunkGenerator
var16 /= var18; var16 /= var18;
var17 /= var18; var17 /= var18;
var16 = (var16 * 0.9F + 0.1F); var16 = var16 * 0.9F + 0.1F;
var17 = (var17 * 4.0F - 1.0F) / 8.0F; 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) { if (var47 < 0.0D) {
var47 = -var47 * 0.3D; var47 = -var47 * 0.3D;
@ -214,20 +214,19 @@ public class LimboGenerator implements IChunkGenerator
for (int var46 = 0; var46 < par6; ++var46) { for (int var46 = 0; var46 < par6; ++var46) {
double var48 = var17; double var48 = var17;
double var26 = var16;
var48 += var47 * 0.2D; var48 += var47 * 0.2D;
var48 = var48 * par6 / 16.0D; var48 = var48 * par6 / 16.0D;
double var28 = par6 / 2.0D + var48 * 4.0D; double var28 = par6 / 2.0D + var48 * 4.0D;
double var30 = 0.0D; double var30;
double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / var26; double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / (double) var16;
if (var32 < 0.0D) { if (var32 < 0.0D) {
var32 *= 4.0D; var32 *= 4.0D;
} }
double var34 = this.noise1[var12] / 512.0D; double var34 = noise1[var12] / 512.0D;
double var36 = this.noise2[var12] / 512.0D; double var36 = noise2[var12] / 512.0D;
double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D; double var38 = (noise3[var12] / 10.0D + 1.0D) / 2.0D;
if (var38 < 0.0D) { if (var38 < 0.0D) {
var30 = var34; var30 = var34;
@ -257,8 +256,8 @@ public class LimboGenerator implements IChunkGenerator
public void scale(int x, int z, ChunkPrimer primer) { //Coursty of public void scale(int x, int z, ChunkPrimer primer) { //Coursty of
// TODO: this: // TODO: this:
this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); biomesForGeneration = worldObj.getBiomeProvider().getBiomesForGeneration(biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10);
this.noiseArray = this.initializeNoiseField(this.noiseArray, x * 4, 0, z * 4, 5, 17, 5); noiseArray = initializeNoiseField(noiseArray, x * 4, 0, z * 4, 5, 17, 5);
int xzSections = 4; int xzSections = 4;
int xzSectionSize = 4; int xzSectionSize = 4;
@ -281,14 +280,14 @@ public class LimboGenerator implements IChunkGenerator
for (int sectionY = 0; sectionY < ySections; ++sectionY) { for (int sectionY = 0; sectionY < ySections; ++sectionY) {
int ySectionPart = sectionY * ySectionSize; int ySectionPart = sectionY * ySectionSize;
double v0y0 = this.noiseArray[i0_0 + sectionY]; double v0y0 = noiseArray[i0_0 + sectionY];
double v0y1 = this.noiseArray[i0_1 + sectionY]; double v0y1 = noiseArray[i0_1 + sectionY];
double v1y0 = this.noiseArray[i1_0 + sectionY]; double v1y0 = noiseArray[i1_0 + sectionY];
double v1y1 = this.noiseArray[i1_1 + sectionY]; double v1y1 = noiseArray[i1_1 + sectionY];
double d0y0 = (this.noiseArray[i0_0 + sectionY + 1] - v0y0) * yScale; double d0y0 = (noiseArray[i0_0 + sectionY + 1] - v0y0) * yScale;
double d0y1 = (this.noiseArray[i0_1 + sectionY + 1] - v0y1) * yScale; double d0y1 = (noiseArray[i0_1 + sectionY + 1] - v0y1) * yScale;
double d1y0 = (this.noiseArray[i1_0 + sectionY + 1] - v1y0) * yScale; double d1y0 = (noiseArray[i1_0 + sectionY + 1] - v1y0) * yScale;
double d1y1 = (this.noiseArray[i1_1 + sectionY + 1] - v1y1) * yScale; double d1y1 = (noiseArray[i1_1 + sectionY + 1] - v1y1) * yScale;
for (int yRel = 0; yRel < ySectionSize; ++yRel) { for (int yRel = 0; yRel < ySectionSize; ++yRel) {
int yCoord = ySectionPart + yRel; int yCoord = ySectionPart + yRel;
@ -328,8 +327,8 @@ public class LimboGenerator implements IChunkGenerator
} }
@Override @Override
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType par1EnumCreatureType, BlockPos pos) { public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
return new ArrayList<Biome.SpawnListEntry>(); return new ArrayList<>();
} }
@Nullable @Nullable

View file

@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation;
* Created by Jared Johnson on 1/24/2017. * Created by Jared Johnson on 1/24/2017.
*/ */
public class LimboSkyProvider extends CustomSkyProvider { public class LimboSkyProvider extends CustomSkyProvider {
private static final ResourceLocation limboMoonResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_moon.png"); 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"); private static final ResourceLocation limboSunResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_sun.png");

View file

@ -12,7 +12,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.DimensionType; import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldProvider;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.gen.IChunkGenerator;
@ -21,12 +20,13 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public class WorldProviderLimbo extends WorldProvider { public class WorldProviderLimbo extends WorldProvider {
private IRenderHandler skyRenderer; private IRenderHandler skyRenderer;
private LimboBiome limboBiome; private LimboBiome limboBiome;
public WorldProviderLimbo() { public WorldProviderLimbo() {
this.hasSkyLight = false; hasSkyLight = false;
this.skyRenderer = new LimboSkyProvider(); skyRenderer = new LimboSkyProvider();
limboBiome = new LimboBiome(); limboBiome = new LimboBiome();
//this.spawner //this.spawner
} }
@ -43,8 +43,7 @@ public class WorldProviderLimbo extends WorldProvider {
} }
@Override @Override
public boolean canRespawnHere() public boolean canRespawnHere() {
{
return false; //properties.HardcoreLimboEnabled; return false; //properties.HardcoreLimboEnabled;
} }
@ -65,18 +64,18 @@ public class WorldProviderLimbo extends WorldProvider {
for (int steps = 0; steps <= 15; ++steps) { for (int steps = 0; steps <= 15; ++steps) {
float var3 = 1.0F - steps / 15.0F; 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"); // System.out.println( this.lightBrightnessTable[steps]+"light");
} }
} }
@Override @Override
public BlockPos getSpawnPoint() { public BlockPos getSpawnPoint() {
return this.getRandomizedSpawnPoint(); return getRandomizedSpawnPoint();
} }
@Override @Override
public float calculateCelestialAngle(long par1, float par3) { public float calculateCelestialAngle(long worldTime, float partialTicks) {
return 0; return 0;
} }
@ -87,18 +86,18 @@ public class WorldProviderLimbo extends WorldProvider {
@Override @Override
public String getSaveFolder() { public String getSaveFolder() {
return ("DIM" + getDimension() + "DimDoorsLimbo"); return "DIM" + getDimension() + "DimDoorsLimbo";
} }
@Override @Override
public boolean canCoordinateBeSpawn(int x, int z) { 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)); return world.getBlockState(pos).equals(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.UNRAVELED));
} }
@Override @Override
public double getHorizon() { public double getHorizon() {
return world.getHeight()/4-800; return (double) world.getHeight() / 4 - 800;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -111,7 +110,7 @@ public class WorldProviderLimbo extends WorldProvider {
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @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); return new Vec3d(.2, .2, .2);
} }
@ -131,15 +130,15 @@ public class WorldProviderLimbo extends WorldProvider {
} }
public static Location getLimboSkySpawn(EntityPlayer player) { public static Location getLimboSkySpawn(EntityPlayer player) {
int x = (int) (player.posX) + 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); 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); return new Location(DimDoorDimensions.LIMBO.getId(), x, 700, z);
} }
@Override @Override
public BlockPos getRandomizedSpawnPoint() { public BlockPos getRandomizedSpawnPoint() {
int x = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); int x = MathHelper.clamp(world.rand.nextInt(), -500, 500);
int z = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); int z = MathHelper.clamp(world.rand.nextInt(), -500, 500);
return new BlockPos(x, 700, z); return new BlockPos(x, 700, z);
} }

View file

@ -13,20 +13,21 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PocketChunkGenerator implements IChunkGenerator { public class PocketChunkGenerator implements IChunkGenerator {
private World worldObj; private World worldObj;
//private CustomLimboPopulator spawner; //private CustomLimboPopulator spawner;
public PocketChunkGenerator(World world, long seed /*CustomLimboPopulator spawner*/) { public PocketChunkGenerator(World world, long seed /*CustomLimboPopulator spawner*/) {
this.worldObj = world; worldObj = world;
//this.spawner = spawner; //this.spawner = spawner;
} }
@Override @Override
public Chunk generateChunk(int chunkX, int chunkZ) { public Chunk generateChunk(int x, int z) {
ChunkPrimer primer = new ChunkPrimer(); ChunkPrimer primer = new ChunkPrimer();
Chunk chunk = new Chunk(worldObj, primer, chunkX, chunkZ); Chunk chunk = new Chunk(worldObj, primer, x, z);
if(!chunk.isTerrainPopulated()) { if(!chunk.isTerrainPopulated()) {
chunk.setTerrainPopulated(true); chunk.setTerrainPopulated(true);
@ -36,7 +37,7 @@ public class PocketChunkGenerator implements IChunkGenerator {
} }
@Override @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 @Override
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
return new ArrayList(); return new ArrayList<>();
} }
@Nullable @Nullable

View file

@ -13,7 +13,7 @@ public class WorldProviderDungeonPocket extends WorldProviderPublicPocket {
@Override @Override
public String getSaveFolder() { public String getSaveFolder() {
return ("DIM" + getDimension() + "DimDoorsDungeon"); return "DIM" + getDimension() + "DimDoorsDungeon";
} }
@Override @Override

View file

@ -33,7 +33,7 @@ public class WorldProviderPersonalPocket extends WorldProviderPublicPocket {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @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); return new Vec3d(1, 1, 1);
} }
@ -49,6 +49,6 @@ public class WorldProviderPersonalPocket extends WorldProviderPublicPocket {
@Override @Override
public String getSaveFolder() { public String getSaveFolder() {
return ("DIM" + getDimension() + "DimDoorsPersonal"); return "DIM" + getDimension() + "DimDoorsPersonal";
} }
} }

View file

@ -4,7 +4,6 @@ import com.zixiken.dimdoors.client.CloudRenderBlank;
import com.zixiken.dimdoors.shared.EnumPocketType; import com.zixiken.dimdoors.shared.EnumPocketType;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions; import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.DimensionType; import net.minecraft.world.DimensionType;
@ -20,7 +19,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might
protected IRenderHandler skyRenderer; protected IRenderHandler skyRenderer;
public WorldProviderPublicPocket() { public WorldProviderPublicPocket() {
this.hasSkyLight = true; hasSkyLight = true;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -32,7 +31,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public Vec3d getFogColor(float par1, float par2) { public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) {
return Vec3d.ZERO; return Vec3d.ZERO;
} }
@ -47,7 +46,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might
} }
@Override @Override
public boolean canSnowAt(BlockPos pos, boolean light) { public boolean canSnowAt(BlockPos pos, boolean checkLight) {
return false; return false;
} }
@ -57,7 +56,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might
} }
@Override @Override
public float calculateCelestialAngle(long par1, float par3) { public float calculateCelestialAngle(long worldTime, float partialTicks) {
return .5F; return .5F;
} }
@ -91,7 +90,7 @@ public class WorldProviderPublicPocket extends WorldProvider {//@todo, we might
@Override @Override
public String getSaveFolder() { public String getSaveFolder() {
return ("DIM" + getDimension() + "DimDoorsPublic"); return "DIM" + getDimension() + "DimDoorsPublic";
} }
@Override @Override

View file

@ -10,7 +10,7 @@
"credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu, Recent updates by Zixiken and Waterpicker", "credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu, Recent updates by Zixiken and Waterpicker",
"logoFile": "/dimdoors_logo.png", "logoFile": "/dimdoors_logo.png",
"mcversion": "1.12.2", "mcversion": "1.12.2",
"url": "http://www.minecraftforum.net/topic/1650007", "url": "https://github.com/DimensionalDevelopment/DimDoors",
"updateUrl": "", "updateUrl": "",
"authorList": [ "StevenRS11", "SenseiKiwi", "Zixiken", "WaterPicker", "Robijnvogel" ], "authorList": [ "StevenRS11", "SenseiKiwi", "Zixiken", "WaterPicker", "Robijnvogel" ],
"parent":"", "parent":"",