Skip to content

Commit

Permalink
A lot of weird experimental code that explodes a lot, still trying to…
Browse files Browse the repository at this point in the history
… figure out one annoying bug with client sync then i can get back to features.
  • Loading branch information
darkevilmac committed Aug 3, 2016
1 parent e65e696 commit b4e22b4
Show file tree
Hide file tree
Showing 30 changed files with 319 additions and 211 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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 + '\"'

replace("MOD_VERSION = \"@MOVINGWORLDVER@\"",
replacementVersion)

mappings = "snapshot_20160715"
mappings = "snapshot_20160731"
}

mixin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
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;
import net.minecraftforge.fml.common.SidedProxy;
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package darkevilmac.movingworld.common.tile;
package darkevilmac.movingworld.api;

import net.minecraft.util.math.BlockPos;

Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package darkevilmac.movingworld.common.util.rotation;
package darkevilmac.movingworld.api.rotation;

import darkevilmac.movingworld.common.chunk.LocatedBlock;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package darkevilmac.movingworld.common.util.rotation;
package darkevilmac.movingworld.api.rotation;

import net.minecraft.block.state.IBlockState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IConfigElement> generateConfigList() {

ArrayList<IConfigElement> elements = new ArrayList<IConfigElement>();

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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
/**
Expand Down Expand Up @@ -81,6 +74,7 @@ private void updateSimpleRender(float partialTicks) {
dispatchBlockRender(blockState, pos, vertexBuffer);
}
}
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}
}
}
Expand All @@ -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();
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
31 changes: 13 additions & 18 deletions src/main/java/darkevilmac/movingworld/common/chunk/ChunkIO.java
Original file line number Diff line number Diff line change
@@ -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<BlockPos> blocks) throws IOException {
out.writeShort(blocks.size());
Expand All @@ -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++) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand All @@ -96,7 +91,7 @@ public static byte[] writeCompressed(MobileChunk chunk, Collection<BlockPos> blo
try {
ChunkIO.writeCompressed(buffer, chunk, blocks);
} catch (IOException e) {
MovingWorld.logger.error(e);
MovingWorldMod.logger.error(e);
}

return buffer.array();
Expand Down Expand Up @@ -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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
Loading

0 comments on commit b4e22b4

Please sign in to comment.