From b4e22b4bc8a1964a89b79bb1857bb84bad3dc3fd Mon Sep 17 00:00:00 2001 From: darkevilmac Date: Tue, 2 Aug 2016 23:05:33 -0700 Subject: [PATCH] A lot of weird experimental code that explodes a lot, still trying to figure out one annoying bug with client sync then i can get back to features. --- build.gradle | 4 +- .../{MovingWorld.java => MovingWorldMod.java} | 20 ++-- .../tile => api}/IMovingWorldTileEntity.java | 6 +- .../util => api}/rotation/IRotationBlock.java | 2 +- .../rotation/IRotationProperty.java | 2 +- .../client/gui/MovingWorldConfigGUI.java | 8 +- .../client/render/MobileChunkRenderer.java | 31 +++---- .../asm/mixin/core/block/MixinBlockSkull.java | 2 +- .../block/property/MixinPropertyEnum.java | 2 +- .../block/property/MixinPropertyInteger.java | 2 +- .../movingworld/common/chunk/ChunkIO.java | 31 +++---- .../chunk/MovingWorldAssemblyInteractor.java | 8 +- .../common/chunk/assembly/AssembleResult.java | 8 +- .../common/chunk/assembly/ChunkAssembler.java | 6 +- .../chunk/assembly/ChunkDisassembler.java | 6 +- .../common/chunk/mobilechunk/MobileChunk.java | 92 ++++++++++++++----- .../chunk/mobilechunk/MobileChunkClient.java | 10 +- .../chunk/mobilechunk/MobileChunkServer.java | 30 ++++-- .../chunk/mobilechunk/world/FakeWorld.java | 20 +++- .../movingworld/common/config/MainConfig.java | 35 ++++--- .../priority/AssemblePriorityConfig.java | 4 +- .../common/entity/EntityMovingWorld.java | 56 +++++------ .../entity/MovingWorldHandlerCommon.java | 4 +- .../entity/MovingWorldHandlerServer.java | 64 ++++++++++--- .../common/mrot/MetaRotations.java | 24 ++--- .../common/network/MovingWorldNetworking.java | 29 +++--- .../tile/TileMovingWorldMarkingBlock.java | 1 + .../common/util/LocatedBlockList.java | 18 ++-- .../common/util/RotationHelper.java | 4 +- src/main/resources/MovingWorld_at.cfg | 1 + 30 files changed, 319 insertions(+), 211 deletions(-) rename src/main/java/darkevilmac/movingworld/{MovingWorld.java => MovingWorldMod.java} (89%) rename src/main/java/darkevilmac/movingworld/{common/tile => api}/IMovingWorldTileEntity.java (77%) rename src/main/java/darkevilmac/movingworld/{common/util => api}/rotation/IRotationBlock.java (93%) rename src/main/java/darkevilmac/movingworld/{common/util => api}/rotation/IRotationProperty.java (91%) diff --git a/build.gradle b/build.gradle index 1a93c328..be600a13 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ group = "darkevilmac.movingworld" archivesBaseName = "movingworld" minecraft { - version = "1.10.2-12.18.1.2014" + version = "1.10.2-12.18.1.2044" runDir = "run" def replacementVersion = 'MOD_VERSION = \"' + project.version + '\"' @@ -36,7 +36,7 @@ minecraft { replace("MOD_VERSION = \"@MOVINGWORLDVER@\"", replacementVersion) - mappings = "snapshot_20160715" + mappings = "snapshot_20160731" } mixin { diff --git a/src/main/java/darkevilmac/movingworld/MovingWorld.java b/src/main/java/darkevilmac/movingworld/MovingWorldMod.java similarity index 89% rename from src/main/java/darkevilmac/movingworld/MovingWorld.java rename to src/main/java/darkevilmac/movingworld/MovingWorldMod.java index e039da64..a6841811 100644 --- a/src/main/java/darkevilmac/movingworld/MovingWorld.java +++ b/src/main/java/darkevilmac/movingworld/MovingWorldMod.java @@ -1,5 +1,10 @@ package darkevilmac.movingworld; +import darkevilmac.movingworld.client.ClientProxy; +import darkevilmac.movingworld.common.CommonProxy; +import darkevilmac.movingworld.common.config.MainConfig; +import darkevilmac.movingworld.common.mrot.MetaRotations; +import darkevilmac.movingworld.common.network.MovingWorldNetworking; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; @@ -7,26 +12,19 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - import org.apache.logging.log4j.Logger; import java.io.File; -import darkevilmac.movingworld.client.ClientProxy; -import darkevilmac.movingworld.common.CommonProxy; -import darkevilmac.movingworld.common.config.MainConfig; -import darkevilmac.movingworld.common.mrot.MetaRotations; -import darkevilmac.movingworld.common.network.MovingWorldNetworking; - -@Mod(modid = MovingWorld.MOD_ID, name = MovingWorld.MOD_NAME, version = MovingWorld.MOD_VERSION, guiFactory = MovingWorld.MOD_GUIFACTORY) -public class MovingWorld { - public static final String MOD_ID = "MovingWorld"; +@Mod(modid = MovingWorldMod.MOD_ID, name = MovingWorldMod.MOD_NAME, version = MovingWorldMod.MOD_VERSION, guiFactory = MovingWorldMod.MOD_GUIFACTORY) +public class MovingWorldMod { + public static final String MOD_ID = "movingworld"; public static final String MOD_VERSION = "@MOVINGWORLDVER@"; public static final String MOD_NAME = "Moving World"; public static final String MOD_GUIFACTORY = "darkevilmac.movingworld.client.gui.MovingWorldGUIFactory"; @Mod.Instance(MOD_ID) - public static MovingWorld instance; + public static MovingWorldMod instance; @SidedProxy(clientSide = "darkevilmac.movingworld.client.ClientProxy", serverSide = "darkevilmac.movingworld.common.CommonProxy") public static CommonProxy proxy; diff --git a/src/main/java/darkevilmac/movingworld/common/tile/IMovingWorldTileEntity.java b/src/main/java/darkevilmac/movingworld/api/IMovingWorldTileEntity.java similarity index 77% rename from src/main/java/darkevilmac/movingworld/common/tile/IMovingWorldTileEntity.java rename to src/main/java/darkevilmac/movingworld/api/IMovingWorldTileEntity.java index aeb45ff5..c0ecadeb 100644 --- a/src/main/java/darkevilmac/movingworld/common/tile/IMovingWorldTileEntity.java +++ b/src/main/java/darkevilmac/movingworld/api/IMovingWorldTileEntity.java @@ -1,4 +1,4 @@ -package darkevilmac.movingworld.common.tile; +package darkevilmac.movingworld.api; import net.minecraft.util.math.BlockPos; @@ -7,12 +7,14 @@ public interface IMovingWorldTileEntity { - void setParentMovingWorld(BlockPos pos, EntityMovingWorld entityMovingWorld); + void setParentMovingWorld(BlockPos chunkPos, EntityMovingWorld entityMovingWorld); EntityMovingWorld getParentMovingWorld(); void setParentMovingWorld(EntityMovingWorld entityMovingWorld); + BlockPos getChunkPos(); + /** * Called each tick from the mobilechunk, I advise strongly against any major modifications to * the chunk. diff --git a/src/main/java/darkevilmac/movingworld/common/util/rotation/IRotationBlock.java b/src/main/java/darkevilmac/movingworld/api/rotation/IRotationBlock.java similarity index 93% rename from src/main/java/darkevilmac/movingworld/common/util/rotation/IRotationBlock.java rename to src/main/java/darkevilmac/movingworld/api/rotation/IRotationBlock.java index c9ac4c41..e95bf6bf 100644 --- a/src/main/java/darkevilmac/movingworld/common/util/rotation/IRotationBlock.java +++ b/src/main/java/darkevilmac/movingworld/api/rotation/IRotationBlock.java @@ -1,4 +1,4 @@ -package darkevilmac.movingworld.common.util.rotation; +package darkevilmac.movingworld.api.rotation; import darkevilmac.movingworld.common.chunk.LocatedBlock; diff --git a/src/main/java/darkevilmac/movingworld/common/util/rotation/IRotationProperty.java b/src/main/java/darkevilmac/movingworld/api/rotation/IRotationProperty.java similarity index 91% rename from src/main/java/darkevilmac/movingworld/common/util/rotation/IRotationProperty.java rename to src/main/java/darkevilmac/movingworld/api/rotation/IRotationProperty.java index a4358afe..cbb08b85 100644 --- a/src/main/java/darkevilmac/movingworld/common/util/rotation/IRotationProperty.java +++ b/src/main/java/darkevilmac/movingworld/api/rotation/IRotationProperty.java @@ -1,4 +1,4 @@ -package darkevilmac.movingworld.common.util.rotation; +package darkevilmac.movingworld.api.rotation; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/darkevilmac/movingworld/client/gui/MovingWorldConfigGUI.java b/src/main/java/darkevilmac/movingworld/client/gui/MovingWorldConfigGUI.java index 43d17297..fd71d5cf 100644 --- a/src/main/java/darkevilmac/movingworld/client/gui/MovingWorldConfigGUI.java +++ b/src/main/java/darkevilmac/movingworld/client/gui/MovingWorldConfigGUI.java @@ -9,21 +9,21 @@ import java.util.ArrayList; import java.util.List; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; public class MovingWorldConfigGUI extends GuiConfig { public MovingWorldConfigGUI(GuiScreen parentScreen) { super(parentScreen, generateConfigList(), "MovingWorld", - false, false, GuiConfig.getAbridgedConfigPath(MovingWorld.instance.getNetworkConfig().getConfig().toString())); + false, false, GuiConfig.getAbridgedConfigPath(MovingWorldMod.instance.getNetworkConfig().getConfig().toString())); } public static List generateConfigList() { ArrayList elements = new ArrayList(); - for (String name : MovingWorld.instance.getNetworkConfig().getConfig().getCategoryNames()) - elements.add(new ConfigElement(MovingWorld.instance.getNetworkConfig().getConfig().getCategory(name))); + for (String name : MovingWorldMod.instance.getNetworkConfig().getConfig().getCategoryNames()) + elements.add(new ConfigElement(MovingWorldMod.instance.getNetworkConfig().getConfig().getCategory(name))); return elements; } diff --git a/src/main/java/darkevilmac/movingworld/client/render/MobileChunkRenderer.java b/src/main/java/darkevilmac/movingworld/client/render/MobileChunkRenderer.java index a48c885c..590774b0 100644 --- a/src/main/java/darkevilmac/movingworld/client/render/MobileChunkRenderer.java +++ b/src/main/java/darkevilmac/movingworld/client/render/MobileChunkRenderer.java @@ -1,14 +1,11 @@ package darkevilmac.movingworld.client.render; +import darkevilmac.movingworld.MovingWorldMod; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -20,12 +17,8 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.lwjgl.opengl.GL11; -import darkevilmac.movingworld.MovingWorld; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; - @SideOnly(Side.CLIENT) public class MobileChunkRenderer { /** @@ -81,6 +74,7 @@ private void updateSimpleRender(float partialTicks) { dispatchBlockRender(blockState, pos, vertexBuffer); } } + net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); } } } @@ -89,29 +83,26 @@ private void updateSimpleRender(float partialTicks) { GlStateManager.pushMatrix(); World tesrDispatchWorld = TileEntityRendererDispatcher.instance.worldObj; - + TileEntityRendererDispatcher.instance.setWorld(chunk.getFakeWorld()); for (int y = chunk.minY(); y < chunk.maxY(); ++y) { for (int z = chunk.minZ(); z < chunk.maxZ(); ++z) { for (int x = chunk.minX(); x < chunk.maxX(); ++x) { BlockPos pos = new BlockPos(x, y, z); TileEntity tile = chunk.getTileEntity(pos); if (tile != null) { + tile.setWorldObj(chunk.getFakeWorld()); TileEntitySpecialRenderer renderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(tile); if (renderer != null && tile.shouldRenderInPass(MinecraftForgeClient.getRenderPass())) { - TileEntity tileClone = tile; - tileClone.setWorldObj(chunk.getFakeWorld()); - TileEntityRendererDispatcher.instance.setWorld(chunk.getFakeWorld()); - TileEntityRendererDispatcher.instance.renderTileEntityAt(tileClone, tileClone.getPos().getX(), tileClone.getPos().getY(), tileClone.getPos().getZ(), partialTicks); - TileEntityRendererDispatcher.instance.setWorld(tile.getWorld()); + TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), partialTicks); } + tile.setWorldObj(chunk.worldObj); } } } } - RenderHelper.enableStandardItemLighting(); - TileEntityRendererDispatcher.instance.setWorld(tesrDispatchWorld); + RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); GlStateManager.popMatrix(); @@ -132,12 +123,12 @@ public void markRemoved() { try { if (glRenderList != 0) { - MovingWorld.logger.debug("Deleting mobile chunk display list " + glRenderList); + MovingWorldMod.logger.debug("Deleting mobile chunk display list " + glRenderList); GLAllocation.deleteDisplayLists(glRenderList); glRenderList = 0; } } catch (Exception e) { - MovingWorld.logger.error("Failed to destroy mobile chunk display list", e); + MovingWorldMod.logger.error("Failed to destroy mobile chunk display list", e); } } } diff --git a/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/MixinBlockSkull.java b/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/MixinBlockSkull.java index 48a02e84..80ee2840 100644 --- a/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/MixinBlockSkull.java +++ b/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/MixinBlockSkull.java @@ -7,7 +7,7 @@ import darkevilmac.movingworld.common.chunk.LocatedBlock; import darkevilmac.movingworld.common.util.RotationHelper; -import darkevilmac.movingworld.common.util.rotation.IRotationBlock; +import darkevilmac.movingworld.api.rotation.IRotationBlock; @Mixin(BlockSkull.class) public class MixinBlockSkull implements IRotationBlock { diff --git a/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyEnum.java b/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyEnum.java index 5674f19b..d9c39c03 100644 --- a/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyEnum.java +++ b/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyEnum.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.Mixin; -import darkevilmac.movingworld.common.util.rotation.IRotationProperty; +import darkevilmac.movingworld.api.rotation.IRotationProperty; @Mixin(PropertyEnum.class) public class MixinPropertyEnum implements IRotationProperty { diff --git a/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyInteger.java b/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyInteger.java index 6b7b249d..1f78a0b7 100644 --- a/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyInteger.java +++ b/src/main/java/darkevilmac/movingworld/common/asm/mixin/core/block/property/MixinPropertyInteger.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Mixin; import darkevilmac.movingworld.common.util.RotationHelper; -import darkevilmac.movingworld.common.util.rotation.IRotationProperty; +import darkevilmac.movingworld.api.rotation.IRotationProperty; @Mixin(PropertyInteger.class) public class MixinPropertyInteger implements IRotationProperty { diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/ChunkIO.java b/src/main/java/darkevilmac/movingworld/common/chunk/ChunkIO.java index ef1ae8e4..8bd07ac9 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/ChunkIO.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/ChunkIO.java @@ -1,27 +1,22 @@ package darkevilmac.movingworld.common.chunk; +import darkevilmac.movingworld.MovingWorldMod; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; +import io.netty.buffer.ByteBufOutputStream; +import io.netty.buffer.Unpooled; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.IOException; +import java.io.*; import java.util.Collection; import java.util.Locale; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import darkevilmac.movingworld.MovingWorld; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufInputStream; -import io.netty.buffer.ByteBufOutputStream; -import io.netty.buffer.Unpooled; - public abstract class ChunkIO { public static void write(DataOutput out, MobileChunk chunk, Collection blocks) throws IOException { out.writeShort(blocks.size()); @@ -42,7 +37,7 @@ public static int writeAll(DataOutput out, MobileChunk chunk) throws IOException } } } - MovingWorld.logger.debug("Writing mobile chunk data: " + count + " blocks"); + MovingWorldMod.logger.debug("Writing mobile chunk data: " + count + " blocks"); out.writeShort(count); for (int i = chunk.minX(); i < chunk.maxX(); i++) { @@ -75,7 +70,7 @@ public static void writeBlock(DataOutput out, IBlockState state, BlockPos pos) t public static void read(DataInput in, MobileChunk chunk) throws IOException { int count = in.readShort(); - MovingWorld.logger.debug("Reading mobile chunk data: " + count + " blocks"); + MovingWorldMod.logger.debug("Reading mobile chunk data: " + count + " blocks"); int x, y, z; int id; @@ -86,7 +81,7 @@ public static void read(DataInput in, MobileChunk chunk) throws IOException { z = in.readByte(); id = in.readShort(); state = Block.getBlockById(id).getStateFromMeta(in.readInt()); - chunk.addBlockWithState(new BlockPos(x, y, z), state); + chunk.setBlockState(new BlockPos(x, y, z), state); } } @@ -96,7 +91,7 @@ public static byte[] writeCompressed(MobileChunk chunk, Collection blo try { ChunkIO.writeCompressed(buffer, chunk, blocks); } catch (IOException e) { - MovingWorld.logger.error(e); + MovingWorldMod.logger.error(e); } return buffer.array(); @@ -126,10 +121,10 @@ private static void postCompress(ByteBuf data, DataOutputStream out, int count) int byteswritten = data.writerIndex(); float f = (float) byteswritten / (count * 9); - MovingWorld.logger.debug(String.format(Locale.ENGLISH, "%d blocks written. Efficiency: %d/%d = %.2f", count, byteswritten, count * 9, f)); + MovingWorldMod.logger.debug(String.format(Locale.ENGLISH, "%d blocks written. Efficiency: %d/%d = %.2f", count, byteswritten, count * 9, f)); if (byteswritten > 32000) { - MovingWorld.logger.warn("Ship probably contains too many blocks"); + MovingWorldMod.logger.warn("Ship probably contains too many blocks"); } } diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/MovingWorldAssemblyInteractor.java b/src/main/java/darkevilmac/movingworld/common/chunk/MovingWorldAssemblyInteractor.java index 90240c4e..9d4178be 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/MovingWorldAssemblyInteractor.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/MovingWorldAssemblyInteractor.java @@ -8,7 +8,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; import darkevilmac.movingworld.common.block.BlockMovingWorldMarker; import darkevilmac.movingworld.common.chunk.assembly.AssembleResult; import darkevilmac.movingworld.common.chunk.assembly.CanAssemble; @@ -30,7 +30,7 @@ public MovingWorldAssemblyInteractor fromNBT(NBTTagCompound tag, World world) { } public boolean doDiagonalAssembly() { - return MovingWorld.instance.getNetworkConfig().getShared().diagonalAssembly; + return MovingWorldMod.instance.getNetworkConfig().getShared().diagonalAssembly; } public void toByteBuf(ByteBuf byteBuf) { @@ -54,7 +54,7 @@ public void blockDisassembled(LocatedBlock locatedBlock) { * @return returns if it is an over writable block in the config. */ public boolean canOverwriteState(IBlockState state) { - return MovingWorld.instance.getNetworkConfig().canOverwriteState(state); + return MovingWorldMod.instance.getNetworkConfig().canOverwriteState(state); } /** @@ -86,7 +86,7 @@ public CanAssemble isBlockAllowed(World world, LocatedBlock lb) { CanAssemble canAssemble = new CanAssemble(false, false); IBlockState state = lb.blockState; - canAssemble.justCancel = !(!state.getMaterial().equals(Material.AIR) && !state.getMaterial().isLiquid() && MovingWorld.instance.getNetworkConfig().isStateAllowed(state)); + canAssemble.justCancel = !(!state.getMaterial().equals(Material.AIR) && !state.getMaterial().isLiquid() && MovingWorldMod.instance.getNetworkConfig().isStateAllowed(state)); return canAssemble; } diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/assembly/AssembleResult.java b/src/main/java/darkevilmac/movingworld/common/chunk/assembly/AssembleResult.java index 3e3c3064..98abaad9 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/assembly/AssembleResult.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/assembly/AssembleResult.java @@ -13,7 +13,7 @@ import java.util.ArrayList; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; import darkevilmac.movingworld.common.chunk.LocatedBlock; import darkevilmac.movingworld.common.chunk.MovingWorldAssemblyInteractor; import darkevilmac.movingworld.common.entity.EntityMovingWorld; @@ -89,7 +89,7 @@ public EntityMovingWorld getEntity(World world, EntityMovingWorld entity) { if (!isOK()) return null; if (entity == null) { - MovingWorld.logger.error("A null movingWorld was attempted!"); + MovingWorldMod.logger.error("A null movingWorld was attempted!"); return null; } @@ -112,8 +112,8 @@ public EntityMovingWorld getEntity(World world, EntityMovingWorld entity) { } } catch (Exception e) { resultType = ResultType.RESULT_ERROR_OCCURED; - MovingWorld.logger.error("Result code: RESULT ERROR OCCURED was reached when attempting to getEntity from assembly result. Printing stacktrace..."); - MovingWorld.logger.error(e); + MovingWorldMod.logger.error("Result code: RESULT ERROR OCCURED was reached when attempting to getEntity from assembly result. Printing stacktrace..."); + MovingWorldMod.logger.error(e); e.printStackTrace(); return null; } diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkAssembler.java b/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkAssembler.java index 7b7971af..0c52a31f 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkAssembler.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkAssembler.java @@ -10,7 +10,7 @@ import java.util.HashSet; import java.util.List; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; import darkevilmac.movingworld.common.chunk.LocatedBlock; import darkevilmac.movingworld.common.chunk.MovingWorldAssemblyInteractor; import darkevilmac.movingworld.common.chunk.MovingWorldSizeOverflowException; @@ -33,7 +33,7 @@ public AssembleResult doAssemble(MovingWorldAssemblyInteractor interactor) { result.offset = start; result.assemblyInteractor = interactor; try { - if (MovingWorld.instance.getNetworkConfig().getShared().iterativeAlgorithm) { + if (MovingWorldMod.instance.getNetworkConfig().getShared().iterativeAlgorithm) { assembleIterative(result, result.assemblyInteractor, start); } else { assembleRecursive(result, new HashSet(), result.assemblyInteractor, start); @@ -47,7 +47,7 @@ public AssembleResult doAssemble(MovingWorldAssemblyInteractor interactor) { result.resultType = AssembleResult.ResultType.RESULT_BLOCK_OVERFLOW; } catch (Error e) { result.resultType = AssembleResult.ResultType.RESULT_ERROR_OCCURED; - MovingWorld.logger.error(e.toString()); + MovingWorldMod.logger.error(e.toString()); } result.assemblyInteractor.chunkAssembled(result); return result; diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkDisassembler.java b/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkDisassembler.java index 666d1180..ff15f031 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkDisassembler.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/assembly/ChunkDisassembler.java @@ -11,13 +11,13 @@ import java.util.ArrayList; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; import darkevilmac.movingworld.common.chunk.LocatedBlock; import darkevilmac.movingworld.common.chunk.MovingWorldAssemblyInteractor; import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; import darkevilmac.movingworld.common.entity.EntityMovingWorld; import darkevilmac.movingworld.common.event.DisassembleBlockEvent; -import darkevilmac.movingworld.common.tile.IMovingWorldTileEntity; +import darkevilmac.movingworld.api.IMovingWorldTileEntity; import darkevilmac.movingworld.common.tile.TileMovingWorldMarkingBlock; import darkevilmac.movingworld.common.util.FloodFiller; import darkevilmac.movingworld.common.util.LocatedBlockList; @@ -150,7 +150,7 @@ public AssembleResult doDisassemble(MovingWorldAssemblyInteractor assemblyIntera if (pList != null && !pList.isEmpty()) for (LocatedBlock locatedBlockInstance : pList) { pos = locatedBlockInstance.blockPos; - MovingWorld.logger.debug("Post-rejoining block: " + locatedBlockInstance.toString()); + MovingWorldMod.logger.debug("Post-rejoining block: " + locatedBlockInstance.toString()); world.setBlockState(pos, locatedBlockInstance.blockState, 2); assemblyInteractor.blockDisassembled(locatedBlockInstance); DisassembleBlockEvent event = new DisassembleBlockEvent(locatedBlockInstance); diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunk.java b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunk.java index 797b458d..71b0536e 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunk.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunk.java @@ -1,13 +1,20 @@ package darkevilmac.movingworld.common.chunk.mobilechunk; import com.google.common.collect.HashBiMap; - +import darkevilmac.movingworld.MovingWorldMod; +import darkevilmac.movingworld.api.IMovingWorldTileEntity; +import darkevilmac.movingworld.common.chunk.LocatedBlock; +import darkevilmac.movingworld.common.chunk.mobilechunk.world.FakeWorld; +import darkevilmac.movingworld.common.entity.EntityMovingWorld; +import darkevilmac.movingworld.common.util.AABBRotator; +import darkevilmac.movingworld.common.util.Vec3dMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -25,20 +32,14 @@ import java.util.List; import java.util.Map; -import darkevilmac.movingworld.common.chunk.LocatedBlock; -import darkevilmac.movingworld.common.chunk.mobilechunk.world.FakeWorld; -import darkevilmac.movingworld.common.entity.EntityMovingWorld; -import darkevilmac.movingworld.common.tile.IMovingWorldTileEntity; -import darkevilmac.movingworld.common.util.AABBRotator; -import darkevilmac.movingworld.common.util.Vec3dMod; - -public class MobileChunk implements IBlockAccess { +public abstract class MobileChunk implements IBlockAccess { public static final int CHUNK_SIZE = 16; public static final int CHUNK_MEMORY_USING = CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE * (4 + 2); //(16*16*16 shorts and ints) public final World worldObj; protected final EntityMovingWorld entityMovingWorld; public Map chunkTileEntityMap; + public List updatableTiles; public boolean isChunkLoaded; public boolean isModified; public LocatedBlock marker; @@ -51,12 +52,14 @@ public class MobileChunk implements IBlockAccess { private Biome creationSpotBiome; private HashBiMap boundingBoxes; private HashBiMap chunkBoundingBoxes; + private FakeWorld fakeWorld; public MobileChunk(World world, EntityMovingWorld entitymovingWorld) { worldObj = world; entityMovingWorld = entitymovingWorld; blockStorageMap = new HashMap(1); chunkTileEntityMap = new HashMap(2); + updatableTiles = new ArrayList<>(); boundingBoxes = HashBiMap.create(); chunkBoundingBoxes = HashBiMap.create(); movingWorldTileEntities = new ArrayList(); @@ -75,7 +78,9 @@ public MobileChunk(World world, EntityMovingWorld entitymovingWorld) { } public FakeWorld getFakeWorld() { - return FakeWorld.getFakeWorld(this); + if (fakeWorld != null) return fakeWorld; + fakeWorld = FakeWorld.getFakeWorld(this); + return fakeWorld; } public EntityMovingWorld getEntityMovingWorld() { @@ -130,11 +135,12 @@ public AxisAlignedBB offsetWorldBBToChunkBB(AxisAlignedBB axisAlignedBB) { } public ExtendedBlockStorage getBlockStorage(BlockPos pos) { - ExtendedBlockStorage storage = blockStorageMap.get(pos); + ExtendedBlockStorage storage = blockStorageMap.get(new BlockPos(pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4)); return storage; } public ExtendedBlockStorage getBlockStorageOrCreate(BlockPos pos) { + pos = new BlockPos(pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4); ExtendedBlockStorage storage = blockStorageMap.get(pos); if (storage != null) return storage; storage = new ExtendedBlockStorage(pos.getY(), false); @@ -190,6 +196,7 @@ public boolean addBlockWithState(BlockPos pos, IBlockState state) { if (state == null) return false; Block block = state.getBlock(); + int id = Block.getIdFromBlock(block); int meta = block.getMetaFromState(state); if (block == null) return false; @@ -201,8 +208,11 @@ public boolean addBlockWithState(BlockPos pos, IBlockState state) { IBlockState currentState = storage.get(i, j, k); Block currentBlock = currentState.getBlock(); + int currentID = Block.getIdFromBlock(currentBlock); int currentMeta = currentBlock.getMetaFromState(currentState); - if (currentBlock == block && currentMeta == meta) { + MovingWorldMod.logger.info(String.format("Adding block with state: %s, at position %s in a mobile chunk. \n The block id is: %s, and the metadata is: %s", state, pos, id, meta)); + MovingWorldMod.logger.info(String.format("The current state of the block is %s, the id is %s and the meta is %s", currentState, currentID, currentMeta)); + if (currentID == id && currentMeta == meta) { return false; } @@ -230,6 +240,7 @@ public boolean addBlockWithState(BlockPos pos, IBlockState state) { minBounds = new BlockPos(minX, minY, minZ); maxBounds = new BlockPos(maxX, maxY, maxZ); } + blockCount++; setChunkModified(); @@ -239,9 +250,7 @@ public boolean addBlockWithState(BlockPos pos, IBlockState state) { if (tileentity == null) { setTileEntity(pos, tileentity); - } - - if (tileentity != null) { + } else { tileentity.updateContainingBlockInfo(); tileentity.blockType = block; tileentity.blockMetadata = meta; @@ -379,14 +388,16 @@ public void updateBlockBounds(float rotationYaw) { public boolean setBlockState(BlockPos pos, IBlockState state) { ExtendedBlockStorage storage = getBlockStorage(pos); - if (storage == null) return false; + if (storage == null) return addBlockWithState(pos, state); IBlockState checkState = getBlockState(new BlockPos(pos.getX(), pos.getY() & 15, pos.getZ())); if (checkState.getBlock().equals(state.getBlock()) && checkState.getBlock().getMetaFromState(checkState) == state.getBlock().getMetaFromState(state)) { return false; } + if(storage.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15) == null){ + blockCount++; + } - setChunkModified(); storage.set(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15, state); state = storage.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15); Block block = state.getBlock(); @@ -400,6 +411,30 @@ public boolean setBlockState(BlockPos pos, IBlockState state) { } } + if (boundsInit) { + int minX = Math.min(minBounds.getX(), pos.getX()); + int minY = Math.min(minBounds.getY(), pos.getY()); + int minZ = Math.min(minBounds.getZ(), pos.getZ()); + int maxX = Math.max(maxBounds.getX(), pos.getX() + 1); + int maxY = Math.max(maxBounds.getY(), pos.getY() + 1); + int maxZ = Math.max(maxBounds.getZ(), pos.getZ() + 1); + + minBounds = new BlockPos(minX, minY, minZ); + maxBounds = new BlockPos(maxX, maxY, maxZ); + } else { + boundsInit = true; + int minX = pos.getX(); + int minY = pos.getY(); + int minZ = pos.getZ(); + int maxX = pos.getX() + 1; + int maxY = pos.getY() + 1; + int maxZ = pos.getZ() + 1; + + minBounds = new BlockPos(minX, minY, minZ); + maxBounds = new BlockPos(maxX, maxY, maxZ); + } + + setChunkModified(); return true; } @@ -414,15 +449,11 @@ public boolean setBlockAsFilledAir(BlockPos pos) { } if (block == null || state.getMaterial().equals(Material.AIR)) { storage.set(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15, Blocks.AIR.getDefaultState()); - onSetBlockAsFilledAir(pos); return true; } return false; } - protected void onSetBlockAsFilledAir(BlockPos pos) { - } - /** * Gets the TileEntity for a given block in this chunk */ @@ -449,6 +480,7 @@ public TileEntity getTileEntity(BlockPos pos) { public void setTileEntity(BlockPos pos, TileEntity tileentity) { if (tileentity == null) { + removeChunkBlockTileEntity(pos); return; } @@ -460,9 +492,8 @@ public void setTileEntity(BlockPos pos, TileEntity tileentity) { */ private void setChunkBlockTileEntity(BlockPos pos, TileEntity tileentity) { BlockPos chunkPosition = new BlockPos(pos.getX(), pos.getY(), pos.getZ()); - tileentity.setWorldObj(worldObj); - BlockPos oPos = tileentity.getPos(); tileentity.setPos(pos); + tileentity.setWorldObj(getFakeWorld()); IBlockState blockState = getBlockState(pos); Block block = blockState.getBlock(); @@ -474,7 +505,9 @@ private void setChunkBlockTileEntity(BlockPos pos, TileEntity tileentity) { if (tileentity instanceof IMovingWorldTileEntity) { if (!movingWorldTileEntities.contains(tileentity)) movingWorldTileEntities.add((IMovingWorldTileEntity) tileentity); - ((IMovingWorldTileEntity) tileentity).setParentMovingWorld(oPos, entityMovingWorld); + ((IMovingWorldTileEntity) tileentity).setParentMovingWorld(chunkPosition, entityMovingWorld); + } else if (tileentity instanceof ITickable && MovingWorldMod.instance.getNetworkConfig().isTileUpdatable(tileentity.getClass())) { + updatableTiles.add(tileentity); } } } @@ -499,6 +532,10 @@ public void removeChunkBlockTileEntity(BlockPos pos) { movingWorldTileEntities.add((IMovingWorldTileEntity) tileentity); ((IMovingWorldTileEntity) tileentity).setParentMovingWorld(pos, null); } + if (tileentity instanceof ITickable && MovingWorldMod.instance.getNetworkConfig().isTileUpdatable(tileentity.getClass())) { + updatableTiles.remove(tileentity); + } + tileentity.invalidate(); } } @@ -510,6 +547,7 @@ public void removeChunkBlockTileEntity(BlockPos pos) { public void onChunkLoad() { isChunkLoaded = true; worldObj.addTileEntities(chunkTileEntityMap.values()); + } /** @@ -619,4 +657,10 @@ private boolean bbContainsBB(AxisAlignedBB container, AxisAlignedBB axisAlignedB } return false; } + + public abstract Side side(); + + public void markTileDirty(BlockPos pos) { + setChunkModified(); + } } diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkClient.java b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkClient.java index a71416a0..221996ad 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkClient.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkClient.java @@ -1,5 +1,7 @@ package darkevilmac.movingworld.common.chunk.mobilechunk; +import darkevilmac.movingworld.client.render.MobileChunkRenderer; +import darkevilmac.movingworld.common.entity.EntityMovingWorld; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -8,9 +10,6 @@ import java.util.ArrayList; import java.util.List; -import darkevilmac.movingworld.client.render.MobileChunkRenderer; -import darkevilmac.movingworld.common.entity.EntityMovingWorld; - @SideOnly(Side.CLIENT) public class MobileChunkClient extends MobileChunk { private MobileChunkRenderer renderer; @@ -39,4 +38,9 @@ public void setChunkModified() { super.setChunkModified(); renderer.markDirty(); } + + @Override + public Side side() { + return Side.CLIENT; + } } \ No newline at end of file diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkServer.java b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkServer.java index 6aad4e0a..8c52f987 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkServer.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/MobileChunkServer.java @@ -1,31 +1,37 @@ package darkevilmac.movingworld.common.chunk.mobilechunk; +import darkevilmac.movingworld.common.entity.EntityMovingWorld; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import darkevilmac.movingworld.common.entity.EntityMovingWorld; - public class MobileChunkServer extends MobileChunk { - private Set sendQueue; + private Set blockQueue; + private Set tileQueue; public MobileChunkServer(World world, EntityMovingWorld entityMovingWorld) { super(world, entityMovingWorld); - sendQueue = new HashSet(); + blockQueue = new HashSet<>(); + tileQueue = new HashSet<>(); } - public Collection getSendQueue() { - return sendQueue; + public Collection getBlockQueue() { + return blockQueue; + } + + public Collection getTileQueue() { + return tileQueue; } @Override public boolean addBlockWithState(BlockPos pos, IBlockState blockState) { if (super.addBlockWithState(pos, blockState)) { - sendQueue.add(pos); + blockQueue.add(pos); return true; } return false; @@ -34,13 +40,19 @@ public boolean addBlockWithState(BlockPos pos, IBlockState blockState) { @Override public boolean setBlockState(BlockPos pos, IBlockState state) { if (super.setBlockState(pos, state)) { - sendQueue.add(pos); + blockQueue.add(pos); return true; } return false; } + public void markTileDirty(BlockPos pos) { + tileQueue.add(pos); + super.markTileDirty(pos); + } + @Override - protected void onSetBlockAsFilledAir(BlockPos pos) { + public Side side() { + return Side.SERVER; } } diff --git a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/world/FakeWorld.java b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/world/FakeWorld.java index a5d1ed3f..f63d7854 100644 --- a/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/world/FakeWorld.java +++ b/src/main/java/darkevilmac/movingworld/common/chunk/mobilechunk/world/FakeWorld.java @@ -1,5 +1,6 @@ package darkevilmac.movingworld.common.chunk.mobilechunk.world; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -9,7 +10,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; +import javax.annotation.Nullable; /** * A wrapper for MobileChunks, used to give blocks accurate information about it's neighbors. @@ -46,14 +47,29 @@ public IBlockState getBlockState(BlockPos pos) { @Override public boolean setBlockState(BlockPos pos, IBlockState state) { + mobileChunk.setBlockState(pos, state); return false; } @Override - public boolean setBlockState(BlockPos pos, IBlockState newState, int flags) { + public boolean setBlockState(BlockPos pos, IBlockState state, int flags) { + mobileChunk.setBlockState(pos,state); return false; } + @Override + public void setTileEntity(BlockPos pos, @Nullable TileEntity tileEntityIn) { + mobileChunk.setTileEntity(pos, tileEntityIn); + } + + @Override + public void markChunkDirty(BlockPos pos, TileEntity unusedTileEntity) { + mobileChunk.setChunkModified(); + if(mobileChunk.side().isServer()){ + mobileChunk.markTileDirty(pos); + } + } + private boolean isValidPosition(BlockPos pos) { return pos.getX() >= mobileChunk.minX() && pos.getZ() >= mobileChunk.minZ() && pos.getX() < mobileChunk.maxX() && pos.getZ() < mobileChunk.maxZ() && pos.getY() >= 0 && pos.getY() < mobileChunk.maxY(); } diff --git a/src/main/java/darkevilmac/movingworld/common/config/MainConfig.java b/src/main/java/darkevilmac/movingworld/common/config/MainConfig.java index 38e3fc46..c5a189f2 100644 --- a/src/main/java/darkevilmac/movingworld/common/config/MainConfig.java +++ b/src/main/java/darkevilmac/movingworld/common/config/MainConfig.java @@ -1,8 +1,12 @@ package darkevilmac.movingworld.common.config; +import darkevilmac.movingworld.MovingWorldMod; +import darkevilmac.movingworld.common.config.priority.AssemblePriorityConfig; +import darkevilmac.movingworld.common.util.MaterialDensity; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -16,10 +20,6 @@ import java.util.Set; import java.util.regex.Pattern; -import darkevilmac.movingworld.MovingWorld; -import darkevilmac.movingworld.common.config.priority.AssemblePriorityConfig; -import darkevilmac.movingworld.common.util.MaterialDensity; - public class MainConfig { private Configuration config; @@ -35,6 +35,7 @@ public MainConfig(Configuration config) { shared.blockBlacklist = new HashSet(); shared.blockWhitelist = new HashSet(); shared.overwritableBlocks = new HashSet(); + shared.updatableTiles = new HashSet<>(); MinecraftForge.EVENT_BUS.register(this); // For in game config reloads. } @@ -68,6 +69,7 @@ private Block[] getDefaultBlockBlackList() { public void loadAndSave() { String[] defaultMaterialDensities = {"\"minecraft:air=0.0\"", "\"minecraft:wool=0.1\""}; String[] defaultBlockDensities = {"\"ArchimedesShipsPlus:floater=0.04\"", "\"ArchimedesShipsPlus:balloon=0.02\""}; + String[] defaultUpdatableTiles = {"Furnace", "Hopper", "Banner", "EnchantTable", "DLDetector"}; Block[] defaultOverWritableBlocks = {Blocks.TALLGRASS, Blocks.WATERLILY, Blocks.SNOW_LAYER}; @@ -85,9 +87,10 @@ public void loadAndSave() { for (int i = 0; i < defaultOverWritableBlocks.length; i++) { overWritableBlockNames[i] = Block.REGISTRY.getNameForObject(defaultOverWritableBlocks[i]).toString(); } + config.load(); - shared.iterativeAlgorithm = config.get(Configuration.CATEGORY_GENERAL, "Use Iterative Algorithm", false).getBoolean(); + shared.iterativeAlgorithm = config.get(Configuration.CATEGORY_GENERAL, "Use Iterative Algorithm", true).getBoolean(); shared.diagonalAssembly = config.get(Configuration.CATEGORY_GENERAL, "Assemble Diagonal Blocks NOTE: Can be overridden by mods!", false).getBoolean(); shared.useWhitelist = config.get("mobile_chunk", "use_whitelist", false, "Switch this property to select the block restriction list to use. 'true' for the 'allowed_blocks' whitelist, 'false' for the 'forbidden_blocks' blacklist.").getBoolean(false); shared.loadedBlockDensities = config.get("mobile_chunk", "block_densities", defaultBlockDensities, "A list of pairs of a block with a density value. This list overrides the 'material_densities' list.").getStringList(); @@ -98,10 +101,13 @@ public void loadAndSave() { String[] forbiddenBlocks = config.get("mobile_chunk", "forbidden_blocks", blockBlackListNames, "A list of blocks that will not be added to a Moving World.").getStringList(); String[] allowedBlocks = config.get("mobile_chunk", "allowed_blocks", blockWhiteListNames, "A list of blocks that are allowed on a Moving World.").getStringList(); String[] overwritableBlocks = config.get("mobile_chunk", "overwritable_blocks", overWritableBlockNames, "A list of blocks that may be overwritten when decompiling a Moving World.").getStringList(); + String[] updatableTiles = config.get("mobile_chunk", "updatable_tiles", defaultUpdatableTiles, + "A list of tiles that are allowed to tick while they're part of a MobileChunk, might cause explosions loss of data, type 2 diabetes, and cancer. Use with caution.").getStringList(); Collections.addAll(this.shared.blockBlacklist, forbiddenBlocks); Collections.addAll(this.shared.blockWhitelist, allowedBlocks); Collections.addAll(this.shared.overwritableBlocks, overwritableBlocks); + Collections.addAll(this.shared.updatableTiles, updatableTiles); config.save(); @@ -115,7 +121,7 @@ public void postLoad() { s = s.replace("\"", ""); String[] pair = splitpattern.split(s); if (pair.length != 2) { - MovingWorld.logger.warn("Invalid key-value pair at block_densities[" + i + "]"); + MovingWorldMod.logger.warn("Invalid key-value pair at block_densities[" + i + "]"); continue; } String key = pair[0]; @@ -123,12 +129,12 @@ public void postLoad() { try { density = Float.parseFloat(pair[1]); } catch (NumberFormatException e) { - MovingWorld.logger.warn("Cannot parse value " + pair[1] + " to floating point at block_densities[" + i + "]"); + MovingWorldMod.logger.warn("Cannot parse value " + pair[1] + " to floating point at block_densities[" + i + "]"); continue; } Block block = Block.getBlockFromName(key); if (block == null) { - MovingWorld.logger.warn("No block found for " + key + " at block_densities[" + i + "]"); + MovingWorldMod.logger.warn("No block found for " + key + " at block_densities[" + i + "]"); continue; } @@ -140,7 +146,7 @@ public void postLoad() { s = s.replace("\"", ""); String[] pair = splitpattern.split(s); if (pair.length != 2) { - MovingWorld.logger.warn("Invalid key-value pair at material_densities[" + i + "]"); + MovingWorldMod.logger.warn("Invalid key-value pair at material_densities[" + i + "]"); continue; } String key = pair[0]; @@ -148,12 +154,12 @@ public void postLoad() { try { density = Float.parseFloat(pair[1]); } catch (NumberFormatException e) { - MovingWorld.logger.warn("Cannot parse value " + pair[1] + " to floating point at material_densities[" + i + "]"); + MovingWorldMod.logger.warn("Cannot parse value " + pair[1] + " to floating point at material_densities[" + i + "]"); continue; } Block block = Block.getBlockFromName(key); if (block == null) { - MovingWorld.logger.warn("No block found for " + key + " at material_densities[" + i + "]"); + MovingWorldMod.logger.warn("No block found for " + key + " at material_densities[" + i + "]"); continue; } @@ -235,9 +241,13 @@ public boolean canOverwriteState(IBlockState state) { return shared.overwritableBlocks.contains(Block.REGISTRY.getNameForObject(state.getBlock())); } + public boolean isTileUpdatable(Class tileClass) { + return shared.updatableTiles.contains(TileEntity.classToNameMap.get(tileClass)); + } + @SubscribeEvent public void onConfigChange(ConfigChangedEvent.OnConfigChangedEvent event) { - if (event.getModID().equals(MovingWorld.MOD_ID)) { + if (event.getModID().equals(MovingWorldMod.MOD_ID)) { if (config.hasChanged()) config.save(); loadAndSave(); @@ -251,6 +261,7 @@ public class SharedConfig { public Set blockBlacklist; public Set blockWhitelist; public Set overwritableBlocks; + public Set updatableTiles; public AssemblePriorityConfig assemblePriorityConfig; private String[] loadedBlockDensities; diff --git a/src/main/java/darkevilmac/movingworld/common/config/priority/AssemblePriorityConfig.java b/src/main/java/darkevilmac/movingworld/common/config/priority/AssemblePriorityConfig.java index dbc82728..a9eefc0f 100644 --- a/src/main/java/darkevilmac/movingworld/common/config/priority/AssemblePriorityConfig.java +++ b/src/main/java/darkevilmac/movingworld/common/config/priority/AssemblePriorityConfig.java @@ -16,7 +16,7 @@ import java.util.HashSet; import java.util.Set; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; public class AssemblePriorityConfig { @@ -156,7 +156,7 @@ void discoverPoweredBlocks() { if (prop.getName().equals("powered")) { String poweredBlockName = Block.REGISTRY.getNameForObject(checkBlock).toString(); poweredBlockNames.add(poweredBlockName); - MovingWorld.logger.info("Found powered block with name: " + poweredBlockName); + MovingWorldMod.logger.info("Found powered block with name: " + poweredBlockName); } } } diff --git a/src/main/java/darkevilmac/movingworld/common/entity/EntityMovingWorld.java b/src/main/java/darkevilmac/movingworld/common/entity/EntityMovingWorld.java index 663a5d8b..c9b74606 100644 --- a/src/main/java/darkevilmac/movingworld/common/entity/EntityMovingWorld.java +++ b/src/main/java/darkevilmac/movingworld/common/entity/EntityMovingWorld.java @@ -1,7 +1,22 @@ package darkevilmac.movingworld.common.entity; import com.google.common.base.Objects; - +import com.google.common.collect.Lists; +import darkevilmac.movingworld.MovingWorldMod; +import darkevilmac.movingworld.api.IMovingWorldTileEntity; +import darkevilmac.movingworld.common.chunk.ChunkIO; +import darkevilmac.movingworld.common.chunk.LocatedBlock; +import darkevilmac.movingworld.common.chunk.MovingWorldAssemblyInteractor; +import darkevilmac.movingworld.common.chunk.MovingWorldSizeOverflowException; +import darkevilmac.movingworld.common.chunk.assembly.AssembleResult; +import darkevilmac.movingworld.common.chunk.assembly.ChunkDisassembler; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkClient; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkServer; +import darkevilmac.movingworld.common.util.AABBRotator; +import darkevilmac.movingworld.common.util.MathHelperMod; +import darkevilmac.movingworld.common.util.Vec3dMod; +import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -20,6 +35,7 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -29,31 +45,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import java.io.*; import java.util.List; import java.util.Set; import java.util.UUID; -import darkevilmac.movingworld.MovingWorld; -import darkevilmac.movingworld.common.chunk.ChunkIO; -import darkevilmac.movingworld.common.chunk.LocatedBlock; -import darkevilmac.movingworld.common.chunk.MovingWorldAssemblyInteractor; -import darkevilmac.movingworld.common.chunk.MovingWorldSizeOverflowException; -import darkevilmac.movingworld.common.chunk.assembly.AssembleResult; -import darkevilmac.movingworld.common.chunk.assembly.ChunkDisassembler; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkClient; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkServer; -import darkevilmac.movingworld.common.tile.IMovingWorldTileEntity; -import darkevilmac.movingworld.common.util.AABBRotator; -import darkevilmac.movingworld.common.util.MathHelperMod; -import darkevilmac.movingworld.common.util.Vec3dMod; -import io.netty.buffer.ByteBuf; - /** * All moving sections of blocks extend from this class. */ @@ -381,9 +377,17 @@ protected void handleClientUpdate() { } protected void handleServerUpdate(double horvel) { - if (getMobileChunk() != null && !getMobileChunk().movingWorldTileEntities.isEmpty()) { - for (IMovingWorldTileEntity movingWorldTileEntity : getMobileChunk().movingWorldTileEntities) { - movingWorldTileEntity.tick(getMobileChunk()); + if (getMobileChunk() != null) { + if (!getMobileChunk().movingWorldTileEntities.isEmpty()) + for (IMovingWorldTileEntity movingWorldTileEntity : getMobileChunk().movingWorldTileEntities) { + movingWorldTileEntity.tick(getMobileChunk()); + } + if (!getMobileChunk().updatableTiles.isEmpty()) { + for (TileEntity tickable : Lists.newArrayList(getMobileChunk().updatableTiles)) { + tickable.setWorldObj(mobileChunk.getFakeWorld()); + ((ITickable)tickable).update(); + tickable.setWorldObj(mobileChunk.worldObj); + } } } @@ -875,7 +879,7 @@ public void writeSpawnData(ByteBuf data) { e.printStackTrace(); } catch (MovingWorldSizeOverflowException ssoe) { disassemble(false); - MovingWorld.logger.warn("Ship is too large to be sent"); + MovingWorldMod.logger.warn("Ship is too large to be sent"); } writeMovingWorldSpawnData(data); } diff --git a/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerCommon.java b/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerCommon.java index f6a259f6..02b6324f 100644 --- a/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerCommon.java +++ b/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerCommon.java @@ -10,7 +10,7 @@ import java.util.HashSet; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunk; public abstract class MovingWorldHandlerCommon { @@ -48,7 +48,7 @@ public void onChunkUpdate() { try { getMovingWorld().fillAirBlocks(new HashSet(), new BlockPos(-1, -1, -1)); } catch (StackOverflowError e) { - MovingWorld.logger.error("Failure during moving world post-initialization", e); + MovingWorldMod.logger.error("Failure during moving world post-initialization", e); } getMovingWorld().setLayeredBlockVolumeCount(new int[chunk.maxY() - chunk.minY()]); diff --git a/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerServer.java b/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerServer.java index 4d5fa29c..eeaa2c6e 100644 --- a/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerServer.java +++ b/src/main/java/darkevilmac/movingworld/common/entity/MovingWorldHandlerServer.java @@ -1,16 +1,17 @@ package darkevilmac.movingworld.common.entity; +import darkevilmac.movingworld.common.chunk.ChunkIO; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkServer; +import darkevilmac.movingworld.common.network.MovingWorldNetworking; +import darkevilmac.movingworld.common.tile.TileMovingWorldMarkingBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import java.util.Collection; - -import darkevilmac.movingworld.common.chunk.ChunkIO; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkServer; -import darkevilmac.movingworld.common.network.MovingWorldNetworking; - public abstract class MovingWorldHandlerServer extends MovingWorldHandlerCommon { protected boolean firstChunkUpdate; @@ -31,18 +32,53 @@ public boolean interact(EntityPlayer player, ItemStack stack, EnumHand hand) { return false; } + private MobileChunkServer getMobileChunkServer() { + if (this.getMovingWorld() != null && this.getMovingWorld().getMobileChunk() != null && this.getMovingWorld().getMobileChunk().side().isServer()) + return (MobileChunkServer) this.getMovingWorld().getMobileChunk(); + else + return null; + } + @Override public void onChunkUpdate() { super.onChunkUpdate(); - Collection list = ((MobileChunkServer) getMovingWorld().getMobileChunk()).getSendQueue(); - if (!firstChunkUpdate) { - MovingWorldNetworking.NETWORK.send().packet("ChunkBlockUpdateMessage") - .with("dimID", getMovingWorld().worldObj.provider.getDimension()) - .with("entityID", getMovingWorld().getEntityId()) - .with("chunk", ChunkIO.writeCompressed(getMovingWorld().getMobileChunk(), list)) - .toAllAround(getMovingWorld().worldObj, getMovingWorld(), 64D); + if (getMobileChunkServer() != null) { + if (!firstChunkUpdate) { + if (!getMobileChunkServer().getBlockQueue().isEmpty()) + MovingWorldNetworking.NETWORK.send().packet("ChunkBlockUpdateMessage") + .with("dimID", getMovingWorld().worldObj.provider.getDimension()) + .with("entityID", getMovingWorld().getEntityId()) + .with("chunk", ChunkIO.writeCompressed(getMovingWorld().getMobileChunk(), getMobileChunkServer().getBlockQueue())) + .toAllAround(getMovingWorld().worldObj, getMovingWorld(), 64D); + + if(!getMobileChunkServer().getTileQueue().isEmpty()){ + NBTTagCompound tagCompound = new NBTTagCompound(); + NBTTagList list = new NBTTagList(); + for (BlockPos tilePosition : getMobileChunkServer().getTileQueue()) { + NBTTagCompound nbt = new NBTTagCompound(); + if(getMobileChunkServer().getTileEntity(tilePosition) == null) + continue; + + TileEntity te = getMobileChunkServer().getTileEntity(tilePosition); + if (te instanceof TileMovingWorldMarkingBlock) { + ((TileMovingWorldMarkingBlock) te).writeNBTForSending(nbt); + } else { + te.writeToNBT(nbt); + } + list.appendTag(nbt); + } + tagCompound.setTag("list", list); + + MovingWorldNetworking.NETWORK.send().packet("TileEntitiesMessage") + .with("dimID", getMovingWorld().dimension) + .with("entityID", getMovingWorld().getEntityId()) + .with("tagCompound", tagCompound) + .toAllAround(getMovingWorld().worldObj, getMovingWorld(), 64D); + } + } + getMobileChunkServer().getTileQueue().clear(); + getMobileChunkServer().getBlockQueue().clear(); } - list.clear(); firstChunkUpdate = false; } } diff --git a/src/main/java/darkevilmac/movingworld/common/mrot/MetaRotations.java b/src/main/java/darkevilmac/movingworld/common/mrot/MetaRotations.java index 1759847e..ae336022 100644 --- a/src/main/java/darkevilmac/movingworld/common/mrot/MetaRotations.java +++ b/src/main/java/darkevilmac/movingworld/common/mrot/MetaRotations.java @@ -18,7 +18,7 @@ import java.util.List; import java.util.Map; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; public class MetaRotations { public Map metaRotationMap; @@ -41,10 +41,10 @@ public int getRotatedMeta(Block block, int meta, int rotate) { public void addMetaRotation(Block block, int bitmask, int... metarotation) { if (block == null) { - MovingWorld.logger.error("Adding null block meta rotations"); + MovingWorldMod.logger.error("Adding null block meta rotations"); return; } - MovingWorld.logger.trace("Adding meta rotations (block=" + Block.REGISTRY.getNameForObject(block) + ", id=" + Block.getIdFromBlock(block) + ", mask=" + bitmask + ", rot=" + Arrays.toString(metarotation) + ")"); + MovingWorldMod.logger.trace("Adding meta rotations (block=" + Block.REGISTRY.getNameForObject(block) + ", id=" + Block.getIdFromBlock(block) + ", mask=" + bitmask + ", rot=" + Arrays.toString(metarotation) + ")"); metaRotationMap.put(Block.getIdFromBlock(block), new BlockMetaRotation(block, metarotation, bitmask)); } @@ -64,9 +64,9 @@ public void registerMetaRotationFile(String fileName, InputStream iStream) throw IOUtils.copy(iStream, oStream); iStream.close(); oStream.close(); - MovingWorld.logger.debug("Created " + fileName + " meta rotation"); + MovingWorldMod.logger.debug("Created " + fileName + " meta rotation"); } - MovingWorld.logger.debug(fileName + " ready to load"); + MovingWorldMod.logger.debug(fileName + " ready to load"); } public boolean parseMetaRotations(BufferedReader reader) throws IOException, OutdatedMrotException { @@ -131,7 +131,7 @@ public boolean parseMetaRotations(BufferedReader reader) throws IOException, Out } public void mrotError(String msg, int lineno) { - MovingWorld.logger.warn("Error in metarotation file at line " + lineno + " (" + msg + ")"); + MovingWorldMod.logger.warn("Error in metarotation file at line " + lineno + " (" + msg + ")"); } public void readMetaRotationFiles() { @@ -143,18 +143,18 @@ public void readMetaRotationFiles() { try { readMetaRotationFile(new File(metaRotationsDirectory, "vanilla.mrot")); } catch (OutdatedMrotException ome) { - MovingWorld.logger.info("Outdated vanilla.mrot detected: " + ome.getLocalizedMessage()); + MovingWorldMod.logger.info("Outdated vanilla.mrot detected: " + ome.getLocalizedMessage()); createDefaultMrot(); readMetaRotationFile(new File(metaRotationsDirectory, "vanilla.mrot")); } catch (FileNotFoundException fnfe) { - MovingWorld.logger.info("vanilla.mrot file not found: " + fnfe.getLocalizedMessage()); + MovingWorldMod.logger.info("vanilla.mrot file not found: " + fnfe.getLocalizedMessage()); createDefaultMrot(); readMetaRotationFile(new File(metaRotationsDirectory, "vanilla.mrot")); } catch (Exception e0) { throw e0; } } catch (Exception e1) { - MovingWorld.logger.error("Could not load default meta rotations", e1); + MovingWorldMod.logger.error("Could not load default meta rotations", e1); } //Discover other defaults. @@ -195,7 +195,7 @@ public boolean accept(File f, String name) { } public void readMetaRotationFile(File file) throws IOException, OutdatedMrotException { - MovingWorld.logger.info("Reading metarotation file: " + file.getName()); + MovingWorldMod.logger.info("Reading metarotation file: " + file.getName()); BufferedReader reader = new BufferedReader(new FileReader(file)); boolean flag = parseMetaRotations(reader); @@ -206,11 +206,11 @@ public void readMetaRotationFile(File file) throws IOException, OutdatedMrotExce } public void createDefaultMrot() { - MovingWorld.logger.info("Creating vanilla.mrot"); + MovingWorldMod.logger.info("Creating vanilla.mrot"); try { registerMetaRotationFile("vanilla.mrot", getClass().getResourceAsStream("/mrot/vanilla.mrot")); } catch (IOException e) { - MovingWorld.logger.error("UNABLE TO LOAD VANILLA.MROT"); + MovingWorldMod.logger.error("UNABLE TO LOAD VANILLA.MROT"); } } } diff --git a/src/main/java/darkevilmac/movingworld/common/network/MovingWorldNetworking.java b/src/main/java/darkevilmac/movingworld/common/network/MovingWorldNetworking.java index 6002197e..cf668e4f 100644 --- a/src/main/java/darkevilmac/movingworld/common/network/MovingWorldNetworking.java +++ b/src/main/java/darkevilmac/movingworld/common/network/MovingWorldNetworking.java @@ -1,11 +1,13 @@ package darkevilmac.movingworld.common.network; -import com.unascribed.lambdanetwork.BiConsumer; -import com.unascribed.lambdanetwork.DataType; -import com.unascribed.lambdanetwork.LambdaNetwork; -import com.unascribed.lambdanetwork.LambdaNetworkBuilder; -import com.unascribed.lambdanetwork.Token; - +import com.unascribed.lambdanetwork.*; +import darkevilmac.movingworld.MovingWorldMod; +import darkevilmac.movingworld.common.chunk.ChunkIO; +import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkClient; +import darkevilmac.movingworld.common.entity.EntityMovingWorld; +import darkevilmac.movingworld.common.tile.TileMovingWorldMarkingBlock; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -20,14 +22,6 @@ import java.io.IOException; -import darkevilmac.movingworld.MovingWorld; -import darkevilmac.movingworld.common.chunk.ChunkIO; -import darkevilmac.movingworld.common.chunk.mobilechunk.MobileChunkClient; -import darkevilmac.movingworld.common.entity.EntityMovingWorld; -import darkevilmac.movingworld.common.tile.TileMovingWorldMarkingBlock; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - public class MovingWorldNetworking { public static LambdaNetwork NETWORK; @@ -35,9 +29,9 @@ public class MovingWorldNetworking { public static void setupNetwork() { //Init net code with builder. - MovingWorld.logger.info("Setting up network..."); + MovingWorldMod.logger.info("Setting up network..."); MovingWorldNetworking.NETWORK = registerPackets(LambdaNetwork.builder().channel("MovingWorld")).build(); - MovingWorld.logger.info("Setup network! " + MovingWorldNetworking.NETWORK.toString()); + MovingWorldMod.logger.info("Setup network! " + MovingWorldNetworking.NETWORK.toString()); } private static LambdaNetworkBuilder registerPackets(LambdaNetworkBuilder builder) { @@ -71,7 +65,6 @@ public void accept(EntityPlayer entityPlayer, Token token) { @Override public void accept(EntityPlayer entityPlayer, Token token) { ByteBuf buf = Unpooled.wrappedBuffer(token.getData("chunk")); - World world = DimensionManager.getWorld(token.getInt("dimID")); if (world != null) { Entity unCast = world.getEntityByID(token.getInt("entityID")); @@ -81,7 +74,7 @@ public void accept(EntityPlayer entityPlayer, Token token) { try { ChunkIO.readCompressed(buf, movingWorld.getMobileChunk()); } catch (IOException e) { - MovingWorld.logger.error(e); + MovingWorldMod.logger.error(e); } } } diff --git a/src/main/java/darkevilmac/movingworld/common/tile/TileMovingWorldMarkingBlock.java b/src/main/java/darkevilmac/movingworld/common/tile/TileMovingWorldMarkingBlock.java index 48454379..5ce73961 100644 --- a/src/main/java/darkevilmac/movingworld/common/tile/TileMovingWorldMarkingBlock.java +++ b/src/main/java/darkevilmac/movingworld/common/tile/TileMovingWorldMarkingBlock.java @@ -12,6 +12,7 @@ import java.util.UUID; +import darkevilmac.movingworld.api.IMovingWorldTileEntity; import darkevilmac.movingworld.common.chunk.LocatedBlock; import darkevilmac.movingworld.common.chunk.MovingWorldAssemblyInteractor; import darkevilmac.movingworld.common.chunk.assembly.AssembleResult; diff --git a/src/main/java/darkevilmac/movingworld/common/util/LocatedBlockList.java b/src/main/java/darkevilmac/movingworld/common/util/LocatedBlockList.java index bac9afb8..3daf3175 100644 --- a/src/main/java/darkevilmac/movingworld/common/util/LocatedBlockList.java +++ b/src/main/java/darkevilmac/movingworld/common/util/LocatedBlockList.java @@ -6,7 +6,7 @@ import java.util.ArrayList; -import darkevilmac.movingworld.MovingWorld; +import darkevilmac.movingworld.MovingWorldMod; import darkevilmac.movingworld.common.chunk.LocatedBlock; public class LocatedBlockList extends ArrayList { @@ -63,7 +63,7 @@ public LocatedBlockList getHighPriorityAssemblyBlocks() { if (!thisList.isEmpty()) { for (LocatedBlock lb : thisList) { - if (MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityAssembly().contains(lb.getBlockName())) { + if (MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityAssembly().contains(lb.getBlockName())) { lbList.add(lb); } } @@ -79,7 +79,7 @@ public LocatedBlockList getHighPriorityDisassemblyBlocks() { if (!thisList.isEmpty()) { for (LocatedBlock lb : thisList) { - if (MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityDisassembly().contains(lb.getBlockName())) { + if (MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityDisassembly().contains(lb.getBlockName())) { lbList.add(lb); } } @@ -95,7 +95,7 @@ public LocatedBlockList getLowPriorityAssemblyBlocks() { if (!thisList.isEmpty()) { for (LocatedBlock lb : thisList) { - if (MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityAssembly().contains(lb.getBlockName())) { + if (MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityAssembly().contains(lb.getBlockName())) { lbList.add(lb); } } @@ -111,7 +111,7 @@ public LocatedBlockList getLowPriorityDisassemblyBlocks() { if (!thisList.isEmpty()) { for (LocatedBlock lb : thisList) { - if (MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityDisassembly().contains(lb.getBlockName())) { + if (MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityDisassembly().contains(lb.getBlockName())) { lbList.add(lb); } } @@ -127,8 +127,8 @@ public LocatedBlockList getStandardPriorityAssemblyBlocks() { if (!thisList.isEmpty()) { for (LocatedBlock lb : thisList) { - if (!MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityAssembly().contains(lb.getBlockName()) - && !MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityAssembly().contains(lb.getBlockName())) { + if (!MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityAssembly().contains(lb.getBlockName()) + && !MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityAssembly().contains(lb.getBlockName())) { lbList.add(lb); } } @@ -144,8 +144,8 @@ public LocatedBlockList getStandardPriorityDisassemblyBlocks() { if (!thisList.isEmpty()) { for (LocatedBlock lb : thisList) { - if (!MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityDisassembly().contains(lb.getBlockName()) - && !MovingWorld.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityDisassembly().contains(lb.getBlockName())) { + if (!MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getHighPriorityDisassembly().contains(lb.getBlockName()) + && !MovingWorldMod.instance.getNetworkConfig().getShared().assemblePriorityConfig.getLowPriorityDisassembly().contains(lb.getBlockName())) { lbList.add(lb); } } diff --git a/src/main/java/darkevilmac/movingworld/common/util/RotationHelper.java b/src/main/java/darkevilmac/movingworld/common/util/RotationHelper.java index 2fd9f3a7..d426754c 100644 --- a/src/main/java/darkevilmac/movingworld/common/util/RotationHelper.java +++ b/src/main/java/darkevilmac/movingworld/common/util/RotationHelper.java @@ -6,8 +6,8 @@ import net.minecraft.util.math.Vec3i; import darkevilmac.movingworld.common.chunk.LocatedBlock; -import darkevilmac.movingworld.common.util.rotation.IRotationBlock; -import darkevilmac.movingworld.common.util.rotation.IRotationProperty; +import darkevilmac.movingworld.api.rotation.IRotationBlock; +import darkevilmac.movingworld.api.rotation.IRotationProperty; public class RotationHelper { diff --git a/src/main/resources/MovingWorld_at.cfg b/src/main/resources/MovingWorld_at.cfg index 3d38dee3..15062f68 100644 --- a/src/main/resources/MovingWorld_at.cfg +++ b/src/main/resources/MovingWorld_at.cfg @@ -1,5 +1,6 @@ public net.minecraft.tileentity.TileEntity field_145847_g # blockMetadata public net.minecraft.tileentity.TileEntity field_145854_h # blockType +public net.minecraft.tileentity.TileEntity field_145853_j # classToNameMap public net.minecraft.client.renderer.entity.RenderManager field_78725_b # renderPosX public net.minecraft.client.renderer.entity.RenderManager field_78726_c # renderPosY public net.minecraft.client.renderer.entity.RenderManager field_78723_d # renderPosZ \ No newline at end of file