diff --git a/build.gradle b/build.gradle index a8164c1..1a042a4 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,6 @@ dependencies { implementation "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:deobf" implementation "dev.tilera:auracore:1.0.0-SNAPSHOT:deobf" implementation "com.github.tox1cozZ:mixin-booter-legacy:1.1.2" - implementation files("libs/LookingGlass-1.7.10-0.2.0.01-dev.jar") } processResources { diff --git a/libs/LookingGlass-1.7.10-0.2.0.01-dev.jar b/libs/LookingGlass-1.7.10-0.2.0.01-dev.jar deleted file mode 100644 index f26bb19..0000000 Binary files a/libs/LookingGlass-1.7.10-0.2.0.01-dev.jar and /dev/null differ diff --git a/src/main/java/net/anvilcraft/arcaneseals/ArcaneSeals.java b/src/main/java/net/anvilcraft/arcaneseals/ArcaneSeals.java index 9dd77f6..15fc978 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/ArcaneSeals.java +++ b/src/main/java/net/anvilcraft/arcaneseals/ArcaneSeals.java @@ -2,6 +2,7 @@ package net.anvilcraft.arcaneseals; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @Mod( @@ -25,4 +26,9 @@ public class ArcaneSeals { proxy.registerTileEntities(); } + + @Mod.EventHandler + public void init(FMLInitializationEvent ev) { + proxy.init(); + } } diff --git a/src/main/java/net/anvilcraft/arcaneseals/ClientProxy.java b/src/main/java/net/anvilcraft/arcaneseals/ClientProxy.java index 6ebfa2f..9be4958 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/ClientProxy.java +++ b/src/main/java/net/anvilcraft/arcaneseals/ClientProxy.java @@ -1,6 +1,7 @@ package net.anvilcraft.arcaneseals; import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.FMLCommonHandler; import net.anvilcraft.arcaneseals.render.TileSealRenderer; import net.anvilcraft.arcaneseals.tiles.TileSeal; @@ -9,4 +10,9 @@ public class ClientProxy extends CommonProxy { public void registerTileEntities() { ClientRegistry.registerTileEntity(TileSeal.class, "seal", new TileSealRenderer()); } + + @Override + public void init() { + FMLCommonHandler.instance().bus().register(new RenderTicker()); + } } diff --git a/src/main/java/net/anvilcraft/arcaneseals/CommonProxy.java b/src/main/java/net/anvilcraft/arcaneseals/CommonProxy.java index c889aef..7a4995f 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/CommonProxy.java +++ b/src/main/java/net/anvilcraft/arcaneseals/CommonProxy.java @@ -7,4 +7,6 @@ public class CommonProxy { public void registerTileEntities() { GameRegistry.registerTileEntity(TileSeal.class, "seal"); } + + public void init() {} } diff --git a/src/main/java/net/anvilcraft/arcaneseals/RenderTicker.java b/src/main/java/net/anvilcraft/arcaneseals/RenderTicker.java new file mode 100644 index 0000000..ab27e1a --- /dev/null +++ b/src/main/java/net/anvilcraft/arcaneseals/RenderTicker.java @@ -0,0 +1,15 @@ +package net.anvilcraft.arcaneseals; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; +import net.anvilcraft.arcaneseals.render.PortalRenderer; + +public class RenderTicker { + @SubscribeEvent + public void onRenderTickEvent(RenderTickEvent ev) { + for (PortalRenderer ren : PortalRenderer.INSTANCES) { + // TODO: optimize + ren.createPortalView(); + } + } +} diff --git a/src/main/java/net/anvilcraft/arcaneseals/SealData.java b/src/main/java/net/anvilcraft/arcaneseals/SealData.java index a4ea2d6..b8334be 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/SealData.java +++ b/src/main/java/net/anvilcraft/arcaneseals/SealData.java @@ -43,7 +43,46 @@ public class SealData { self.x = nbt.getInteger("x"); self.y = nbt.getInteger("y"); self.z = nbt.getInteger("z"); + self.orientation = nbt.getShort("orientation"); + self.rune = nbt.getByte("rune"); return self; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + dim; + result = prime * result + x; + result = prime * result + y; + result = prime * result + z; + result = prime * result + orientation; + result = prime * result + rune; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SealData other = (SealData) obj; + if (dim != other.dim) + return false; + if (x != other.x) + return false; + if (y != other.y) + return false; + if (z != other.z) + return false; + if (orientation != other.orientation) + return false; + if (rune != other.rune) + return false; + return true; + } } diff --git a/src/main/java/net/anvilcraft/arcaneseals/render/PortalRenderer.java b/src/main/java/net/anvilcraft/arcaneseals/render/PortalRenderer.java index 2208559..999e07c 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/render/PortalRenderer.java +++ b/src/main/java/net/anvilcraft/arcaneseals/render/PortalRenderer.java @@ -1,51 +1,195 @@ package net.anvilcraft.arcaneseals.render; -import com.xcompwiz.lookingglass.api.APIInstanceProvider; -import com.xcompwiz.lookingglass.api.APIUndefined; -import com.xcompwiz.lookingglass.api.APIVersionRemoved; -import com.xcompwiz.lookingglass.api.APIVersionUndefined; -import com.xcompwiz.lookingglass.api.hook.WorldViewAPI2; -import com.xcompwiz.lookingglass.api.view.IWorldView; -import cpw.mods.fml.common.event.FMLInterModComms; +import java.nio.ByteBuffer; +import java.util.HashSet; +import java.util.Set; + +import net.anvilcraft.arcaneseals.SealData; import net.anvilcraft.arcaneseals.tiles.TileSeal; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL11; public class PortalRenderer { - static WorldViewAPI2 LG_API; - public IWorldView ww; - TileSeal thisSeal; - TileSeal otherSeal; + public static Set INSTANCES = new HashSet<>(); - public PortalRenderer(TileSeal thisSeal, TileSeal otherSeal) { - this.thisSeal = thisSeal; - this.otherSeal = otherSeal; + public int portalTexture; + public int depthRenderBuffer; + public int frameBuffer; + public static int renderRecursion; + public TileSeal seal; - this.ww = LG_API.createWorldView( - otherSeal.getWorldObj().provider.dimensionId, - new ChunkCoordinates(otherSeal.xCoord, otherSeal.yCoord, otherSeal.zCoord), - 256, - 256 + public PortalRenderer(TileSeal seal) { + this.frameBuffer = EXTFramebufferObject.glGenFramebuffersEXT(); + this.portalTexture = GL11.glGenTextures(); + this.depthRenderBuffer = EXTFramebufferObject.glGenRenderbuffersEXT(); + EXTFramebufferObject.glBindFramebufferEXT(36160, this.frameBuffer); + GL11.glBindTexture(3553, this.portalTexture); + GL11.glTexParameterf(3553, 10241, 9729.0F); + GL11.glTexImage2D(3553, 0, 32856, 512, 512, 0, 6408, 5124, (ByteBuffer) null); + EXTFramebufferObject.glFramebufferTexture2DEXT( + 36160, 36064, 3553, this.portalTexture, 0 ); + EXTFramebufferObject.glBindRenderbufferEXT(36161, this.depthRenderBuffer); + EXTFramebufferObject.glRenderbufferStorageEXT(36161, 35056, 512, 512); + EXTFramebufferObject.glFramebufferRenderbufferEXT( + 36160, 33306, 36161, this.depthRenderBuffer + ); + EXTFramebufferObject.glBindFramebufferEXT(36160, 0); + this.seal = seal; + INSTANCES.add(this); } public void deinit() { - LG_API.cleanupWorldView(this.ww); + // TODO: WTF + //GL11.glDeleteFramebuffers(this.frameBuffer); + GL11.glDeleteTextures(this.portalTexture); + INSTANCES.remove(this); } - public static void initLookingGlass() { - FMLInterModComms.sendMessage( - "LookingGlass", - "API", - "net.anvilcraft.arcaneseals.render.PortalRenderer.lookingGlassInitCb" - ); - } + public void createPortalView() { + ++PortalRenderer.renderRecursion; + if (this.seal.otherSeal == null) + return; - public static void lookingGlassInitCb(APIInstanceProvider ip) { - try { - LG_API = (WorldViewAPI2) ip.getAPIInstance("view-2"); - } catch (APIUndefined | APIVersionUndefined | APIVersionRemoved e) { - System.err.println("LookingGlass alec"); - e.printStackTrace(); + SealData target = this.seal.otherSeal; + Minecraft mc = Minecraft.getMinecraft(); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + + int prevFbo = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); + EXTFramebufferObject.glBindFramebufferEXT(36160, this.frameBuffer); + + GL11.glEnable(2960); + GL11.glStencilFunc(519, 1, 1); + GL11.glStencilOp(7680, 7680, 7681); + GL11.glViewport(0, 0, 512, 512); + GL11.glLoadIdentity(); + GL11.glDisable(3553); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + GL11.glBegin(6); + GL11.glVertex2f(0.0f, 0.0f); + for (int oh = 0; oh <= 10; ++oh) { + final double aa = 6.283185307179586 * oh / 10.0; + GL11.glVertex2f((float) Math.cos(aa), (float) Math.sin(aa)); } + GL11.glEnd(); + GL11.glStencilFunc(514, 1, 1); + GL11.glStencilOp(7680, 7680, 7680); + GL11.glEnable(3553); + Entity rve = mc.renderViewEntity; + + mc.renderViewEntity = new EntityPlayer( + mc.theWorld, mc.getSession().func_148256_e() + ) { + @Override + public void addChatMessage(IChatComponent p_145747_1_) {} + + @Override + public boolean canCommandSenderUseCommand(int p_70003_1_, String p_70003_2_) { + return false; + } + + @Override + public ChunkCoordinates getPlayerCoordinates() { + return null; + } + }; + + int orientation = target.orientation; + float yaw = 0.0f; + float pitch = 0.0f; + switch (orientation) { + case 0: { + pitch = 90.0f; + break; + } + case 1: { + pitch = -90.0f; + break; + } + case 2: { + yaw = 180.0f; + break; + } + case 3: { + yaw = 0.0f; + break; + } + case 4: { + yaw = 90.0f; + break; + } + case 5: { + yaw = 270.0f; + break; + } + } + int xm = 0; + int zm = 0; + int ym = 0; + switch (orientation) { + case 0: { + ym = -1; + break; + } + case 1: { + ym = 1; + break; + } + case 2: { + zm = -1; + break; + } + case 3: { + zm = 1; + break; + } + case 4: { + xm = -1; + break; + } + case 5: { + xm = 1; + break; + } + } + mc.renderViewEntity.setPositionAndRotation( + target.x + 0.5 + xm, target.y - 0.5f + ym, target.z + 0.5 + zm, yaw, pitch + ); + final boolean di = mc.gameSettings.showDebugInfo; + mc.gameSettings.showDebugInfo = false; + final float fov = mc.gameSettings.fovSetting; + final int width = mc.displayWidth; + final int height = mc.displayHeight; + int tpv = mc.gameSettings.thirdPersonView; + mc.displayWidth = 512; + mc.displayHeight = 512; + mc.gameSettings.thirdPersonView = 0; + mc.gameSettings.fovSetting = 120.0f; + mc.renderViewEntity.rotationYaw = yaw; + mc.renderViewEntity.rotationPitch = pitch; + final boolean hg = mc.gameSettings.hideGUI; + mc.gameSettings.hideGUI = true; + mc.entityRenderer.renderWorld(1F, 0L); + mc.renderViewEntity = (EntityLivingBase) rve; + mc.displayWidth = width; + mc.displayHeight = height; + mc.gameSettings.showDebugInfo = di; + mc.gameSettings.hideGUI = hg; + mc.gameSettings.fovSetting = fov; + mc.gameSettings.thirdPersonView = tpv; + GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight); + //GL11.glDisable(2960); + EXTFramebufferObject.glBindFramebufferEXT(36160, prevFbo); + GL11.glPopMatrix(); + --PortalRenderer.renderRecursion; } } diff --git a/src/main/java/net/anvilcraft/arcaneseals/render/TileSealRenderer.java b/src/main/java/net/anvilcraft/arcaneseals/render/TileSealRenderer.java index 6bbb2d5..5dc33ad 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/render/TileSealRenderer.java +++ b/src/main/java/net/anvilcraft/arcaneseals/render/TileSealRenderer.java @@ -6,6 +6,7 @@ import net.anvilcraft.arcaneseals.utils.UtilsFX; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -75,95 +76,95 @@ public class TileSealRenderer extends TileEntitySpecialRenderer { GL11.glDepthMask(true); } - // TODO: portal rendering - //private void drawPortal(TileSeal seal, float angle, double x, double y, double z) { - // Tessellator tessellator = Tessellator.instance; - // Minecraft mc = ModLoader.getMinecraftInstance(); - // GL11.glDisable(2896); - // if (Config.portalGfx && seal.txRender != null - // && PortalRenderer.renderRecursion < 2) { - // GL11.glPushMatrix(); - // GL11.glDisable(3553); - // GL11.glColor4f( - // ThaumCraftCore.fColorR(), - // ThaumCraftCore.fColorG(), - // ThaumCraftCore.fColorB(), - // 1.0F - // ); - // tessellator.setBrightness(220); - // GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - // GL11.glScaled( - // (double) (seal.pSize / 2.0F), - // (double) (seal.pSize / 2.0F), - // (double) (seal.pSize / 2.0F) - // ); - // GL11.glBegin(6); - // GL11.glVertex2f(0.0F, 0.0F); + private void drawPortal(TileSeal seal, float angle, double x, double y, double z) { + Tessellator tessellator = Tessellator.instance; + Minecraft mc = Minecraft.getMinecraft(); + GL11.glDisable(2896); + if (seal.otherSeal != null && seal.renderer != null) { + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glColor4f( + 1.0f, + 1.0f, + 1.0f, + 1.0f + ); + tessellator.setBrightness(220); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glScaled( + (double) (seal.pSize / 2.0F), + (double) (seal.pSize / 2.0F), + (double) (seal.pSize / 2.0F) + ); + GL11.glBegin(6); + GL11.glVertex2f(0.0F, 0.0F); - // for (int oh = 0; oh <= 10; ++oh) { - // double aa = 6.283185307179586 * (double) oh / 10.0; - // GL11.glVertex2f((float) Math.cos(aa), (float) Math.sin(aa)); - // } + for (int oh = 0; oh <= 10; ++oh) { + double aa = 6.283185307179586 * (double) oh / 10.0; + GL11.glVertex2f((float) Math.cos(aa), (float) Math.sin(aa)); + } - // GL11.glEnd(); - // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - // GL11.glPopMatrix(); - // GL11.glEnable(3553); - // GL11.glPushMatrix(); - // GL11.glDisable(2896); - // GL11.glEnable(3042); - // GL11.glBlendFunc(770, 771); - // GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - // GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - // GL11.glTranslatef(-seal.pSize / 2.0F, -0.01F, -seal.pSize / 2.0F); - // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - // GL11.glBindTexture(3553, seal.txRender.portalTexture); - // tessellator.startDrawingQuads(); - // tessellator.setBrightness(220); - // tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); - // tessellator.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); - // tessellator.addVertexWithUV((double) seal.pSize, 0.0, 0.0, 1.0, 0.0); - // tessellator.addVertexWithUV( - // (double) seal.pSize, 0.0, (double) seal.pSize, 1.0, 1.0 - // ); - // tessellator.addVertexWithUV(0.0, 0.0, (double) seal.pSize, 0.0, 1.0); - // tessellator.draw(); - // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - // GL11.glDisable(3042); - // GL11.glPopMatrix(); - // } + GL11.glEnd(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + GL11.glEnable(3553); + GL11.glPushMatrix(); + GL11.glDisable(2896); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-seal.pSize / 2.0F, -0.01F, -seal.pSize / 2.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, seal.renderer.portalTexture); + tessellator.startDrawingQuads(); + tessellator.setBrightness(220); + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); + tessellator.addVertexWithUV((double) seal.pSize, 0.0, 0.0, 1.0, 0.0); + tessellator.addVertexWithUV( + (double) seal.pSize, 0.0, (double) seal.pSize, 1.0, 1.0 + ); + tessellator.addVertexWithUV(0.0, 0.0, (double) seal.pSize, 0.0, 1.0); + tessellator.draw(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } - // GL11.glPushMatrix(); - // GL11.glRotatef(90.0F, -1.0F, 0.0F, 0.0F); - // GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F); - // GL11.glTranslatef(-seal.pSize, 0.02F, -seal.pSize); - // GL11.glDepthMask(false); - // GL11.glEnable(3042); - // GL11.glBlendFunc(770, 771); - // if (Config.portalGfx && seal.txRender != null) { - // MinecraftForgeClient.bindTexture("/thaumcraft/resources/portal2.png"); - // } else { - // MinecraftForgeClient.bindTexture("/thaumcraft/resources/portal.png"); - // } + GL11.glPushMatrix(); + GL11.glRotatef(90.0F, -1.0F, 0.0F, 0.0F); + GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-seal.pSize, 0.02F, -seal.pSize); + GL11.glDepthMask(false); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + if (seal.otherSeal != null && seal.renderer != null) { + mc.renderEngine.bindTexture( + new ResourceLocation("arcaneseals", "textures/misc/portal2.png") + ); + } else { + mc.renderEngine.bindTexture( + new ResourceLocation("arcaneseals", "textures/misc/portal.png") + ); + } - // tessellator.startDrawingQuads(); - // tessellator.setBrightness(220); - // tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); - // tessellator.addVertexWithUV(0.0, 0.0, (double) (seal.pSize * 2.0F), 0.0, 1.0); - // tessellator.addVertexWithUV( - // (double) (seal.pSize * 2.0F), 0.0, (double) (seal.pSize * 2.0F), 1.0, 1.0 - // ); - // tessellator.addVertexWithUV((double) (seal.pSize * 2.0F), 0.0, 0.0, 1.0, 0.0); - // tessellator.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); - // tessellator.draw(); - // GL11.glDisable(3042); - // GL11.glDepthMask(true); - // GL11.glPopMatrix(); - // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - // GL11.glEnable(2896); - // GL11.glPopMatrix(); - // GL11.glPopMatrix(); - //} + tessellator.startDrawingQuads(); + tessellator.setBrightness(220); + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV(0.0, 0.0, (double) (seal.pSize * 2.0F), 0.0, 1.0); + tessellator.addVertexWithUV( + (double) (seal.pSize * 2.0F), 0.0, (double) (seal.pSize * 2.0F), 1.0, 1.0 + ); + tessellator.addVertexWithUV((double) (seal.pSize * 2.0F), 0.0, 0.0, 1.0, 0.0); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); + tessellator.draw(); + GL11.glDisable(3042); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(2896); + } public void renderEntityAt(TileSeal seal, double x, double y, double z, float fq) { int a = this.count % 360; @@ -217,14 +218,12 @@ public class TileSealRenderer extends TileEntitySpecialRenderer { GL11.glPopMatrix(); } - // TODO: portal rendering - //if (seal.runes[0] == 0 && seal.runes[1] == 1 && seal.pSize > 0.0F) { - // GL11.glPushMatrix(); - // GL11.glPushMatrix(); - // GL11.glTranslatef(0.5F, 0.5F, -seal.pSize / 5.0F); - // this.drawPortal(seal, (float) (-a * 4), x, y, z); - // nopush = false; - //} + if (seal.runes[0] == 0 && seal.runes[1] == 1 && seal.pSize > 0.0F) { + GL11.glPushMatrix(); + GL11.glTranslatef(0.5F, 0.5F, -seal.pSize / 5.0F); + this.drawPortal(seal, (float) (-a * 4), x, y, z); + GL11.glPopMatrix(); + } GL11.glPopMatrix(); } diff --git a/src/main/java/net/anvilcraft/arcaneseals/tiles/TileSeal.java b/src/main/java/net/anvilcraft/arcaneseals/tiles/TileSeal.java index 390d2c4..d300b08 100644 --- a/src/main/java/net/anvilcraft/arcaneseals/tiles/TileSeal.java +++ b/src/main/java/net/anvilcraft/arcaneseals/tiles/TileSeal.java @@ -1,6 +1,5 @@ package net.anvilcraft.arcaneseals.tiles; -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -11,6 +10,7 @@ import dev.tilera.auracore.aura.AuraManager; import dev.tilera.auracore.client.FXSparkle; import dev.tilera.auracore.helper.Utils; import net.anvilcraft.arcaneseals.SealData; +import net.anvilcraft.arcaneseals.render.PortalRenderer; import net.anvilcraft.arcaneseals.utils.HelperLocation; import net.anvilcraft.arcaneseals.utils.UtilsFX; import net.minecraft.block.Block; @@ -49,7 +49,8 @@ import thaumcraft.client.fx.particles.FXWisp; public class TileSeal extends TileEntity { public static Set SEALS = new HashSet<>(); - SealData otherSeal; + public SealData otherSeal; + public PortalRenderer renderer; public int delay = 0; private int soundDelay = 0; @@ -73,6 +74,11 @@ public class TileSeal extends TileEntity { @Override public void updateEntity() { + if (this.worldObj.isRemote && this.otherSeal != null) { + if (this.renderer == null) + this.renderer = new PortalRenderer(this); + } + if (this.delay <= 0) { boolean oldPower = this.isPowering; this.isPowering = false; @@ -1522,13 +1528,14 @@ public class TileSeal extends TileEntity { ); this.otherSeal = pd; + super.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); if (!this.pOpen && p) { super.worldObj.playSoundEffect( (double) super.xCoord + 0.5, (double) super.yCoord + 0.5, (double) super.zCoord + 0.5, - "thaumcraft:popen", + "arcaneseals:popen", 0.4F, 1.0F + super.worldObj.rand.nextFloat() * 0.2F ); @@ -1548,6 +1555,8 @@ public class TileSeal extends TileEntity { } } else { this.otherSeal = null; + super.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + if (this.pOpen) { list = this.getEntitiesSorted(super.worldObj, 2, this.orientation, false); @@ -1557,7 +1566,7 @@ public class TileSeal extends TileEntity { (double) super.xCoord + 0.5, (double) super.yCoord + 0.5, (double) super.zCoord + 0.5, - "thaumcraft:pclose", + "arcaneseals:pclose", 0.4F, 1.0F + super.worldObj.rand.nextFloat() * 0.2F ); @@ -2487,6 +2496,8 @@ public class TileSeal extends TileEntity { nbt.setInteger("window", this.portalWindow); if (this.otherSeal != null) nbt.setTag("other", this.otherSeal.writeToNbt(new NBTTagCompound())); + //nbt.setFloat("pSize", this.pSize); + nbt.setBoolean("pOpen", this.pOpen); return new S35PacketUpdateTileEntity( this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt @@ -2504,6 +2515,8 @@ public class TileSeal extends TileEntity { this.otherSeal = SealData.readFromNbt(nbt.getCompoundTag("other")); else this.otherSeal = null; + //this.pSize = nbt.getFloat("pSize"); + this.pOpen = nbt.getBoolean("pOpen"); } public List @@ -2567,7 +2580,15 @@ public class TileSeal extends TileEntity { public void invalidate() { super.invalidate(); if (!this.worldObj.isRemote) - SEALS.remove(this); + SEALS.remove(new SealData(this)); + else if (this.renderer != null) + this.renderer.deinit(); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + this.invalidate(); } public boolean canEntityBeSeen(Entity entity) { diff --git a/src/main/resources/assets/arcaneseals/sounds.json b/src/main/resources/assets/arcaneseals/sounds.json new file mode 100644 index 0000000..e3bc3ec --- /dev/null +++ b/src/main/resources/assets/arcaneseals/sounds.json @@ -0,0 +1,20 @@ +{ + "popen": { + "category": "master", + "sounds": [ + { + "name": "popen", + "stream": false + } + ] + }, + "pclose": { + "category": "master", + "sounds": [ + { + "name": "pclose", + "stream": false + } + ] + } +} diff --git a/src/main/resources/assets/arcaneseals/sounds/pclose.ogg b/src/main/resources/assets/arcaneseals/sounds/pclose.ogg new file mode 100644 index 0000000..92e2925 Binary files /dev/null and b/src/main/resources/assets/arcaneseals/sounds/pclose.ogg differ diff --git a/src/main/resources/assets/arcaneseals/sounds/popen.ogg b/src/main/resources/assets/arcaneseals/sounds/popen.ogg new file mode 100644 index 0000000..13a0378 Binary files /dev/null and b/src/main/resources/assets/arcaneseals/sounds/popen.ogg differ