Skip to content

Commit

Permalink
Name static fields LIKE_THIS
Browse files Browse the repository at this point in the history
Update Forge
  • Loading branch information
darkevilmac committed Nov 14, 2016
1 parent 2323f08 commit 0dae5a7
Show file tree
Hide file tree
Showing 21 changed files with 178 additions and 236 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

minecraft {
version = "1.10.2-12.18.1.2074"
version = "1.10.2-12.18.2.2125"
runDir = "run"

def replacementVersion = 'MOD_VERSION = \"' + project.version + '\"'

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

mappings = "snapshot_20160731"
mappings = "snapshot_20161111"
}

mixin {
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/io/github/elytra/movingworld/MovingWorldMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@ public class MovingWorldMod {
public static final String MOD_GUIFACTORY = "io.github.elytra.movingworld.client.gui.MovingWorldGUIFactory";

@Mod.Instance(MOD_ID)
public static MovingWorldMod instance;

public static MovingWorldMod INSTANCE;
@SidedProxy(clientSide = "io.github.elytra.movingworld.client.ClientProxy", serverSide = "io.github.elytra.movingworld.common.CommonProxy")
public static CommonProxy proxy;

public static Logger logger;
public static CommonProxy PROXY;
public static Logger LOG;

public MetaRotations metaRotations;
private MainConfig localConfig;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
logger = e.getModLog();
LOG = e.getModLog();
File configFolder = new File(e.getModConfigurationDirectory(), "MovingWorld");
File mConfigFile = new File(configFolder, "Main.cfg");
localConfig = new MainConfig(new Configuration(mConfigFile));
Expand All @@ -47,7 +44,7 @@ public void preInit(FMLPreInitializationEvent e) {
public void init(FMLInitializationEvent e) {
localConfig.postLoad();
MovingWorldNetworking.setupNetwork();
proxy.registerRenderers();
PROXY.registerRenderers();
localConfig.getShared().assemblePriorityConfig.loadAndSaveInit();
}

Expand All @@ -58,8 +55,8 @@ public void postInit(FMLPostInitializationEvent e) {

public MainConfig getNetworkConfig() {
if (FMLCommonHandler.instance().getSide().isClient()) {
if (((ClientProxy) proxy).syncedConfig != null)
return ((ClientProxy) proxy).syncedConfig;
if (((ClientProxy) PROXY).syncedConfig != null)
return ((ClientProxy) PROXY).syncedConfig;
}
return localConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public class MovingWorldConfigGUI extends GuiConfig {

public MovingWorldConfigGUI(GuiScreen parentScreen) {
super(parentScreen, generateConfigList(), "MovingWorld",
false, false, GuiConfig.getAbridgedConfigPath(MovingWorldMod.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 : MovingWorldMod.instance.getNetworkConfig().getConfig().getCategoryNames())
elements.add(new ConfigElement(MovingWorldMod.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
Expand Up @@ -167,12 +167,6 @@ public static boolean onEntityMove(Entity entity, MobileChunk mobileChunk, doubl
double maxY = entityBox.maxY + (mobileChunk.getEntityMovingWorld().posY - (mobileChunk.maxY() / 2));
double maxZ = entityBox.maxZ + (mobileChunk.getEntityMovingWorld().posZ - (mobileChunk.maxZ() / 2));

System.out.println(minX);
System.out.println(minY);
System.out.println(minZ);
System.out.println(maxX);
System.out.println(maxY);
System.out.println(maxZ);
entity.setEntityBoundingBox(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));

mixinEntity.resetPosToBB();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static int writeAll(DataOutput out, MobileChunk chunk) throws IOException
}
}
}
MovingWorldMod.logger.debug("Writing mobile chunk data: " + count + " blocks");
MovingWorldMod.LOG.debug("Writing mobile chunk data: " + count + " blocks");

out.writeShort(count);
for (int i = chunk.minX(); i < chunk.maxX(); i++) {
Expand Down Expand Up @@ -70,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();

MovingWorldMod.logger.debug("Reading mobile chunk data: " + count + " blocks");
MovingWorldMod.LOG.debug("Reading mobile chunk data: " + count + " blocks");

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

return buffer.array();
Expand Down Expand Up @@ -121,10 +121,10 @@ private static void postCompress(ByteBuf data, DataOutputStream out, int count)

int byteswritten = data.writerIndex();
float f = (float) byteswritten / (count * 9);
MovingWorldMod.logger.debug(String.format(Locale.ENGLISH, "%d blocks written. Efficiency: %d/%d = %.2f", count, byteswritten, count * 9, f));
MovingWorldMod.LOG.debug(String.format(Locale.ENGLISH, "%d blocks written. Efficiency: %d/%d = %.2f", count, byteswritten, count * 9, f));

if (byteswritten > 32000) {
MovingWorldMod.logger.warn("Ship probably contains too many blocks");
MovingWorldMod.LOG.warn("MobileChunk probably contains too many blocks");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public MovingWorldAssemblyInteractor fromNBT(NBTTagCompound tag, World world) {
}

public boolean doDiagonalAssembly() {
return MovingWorldMod.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 MovingWorldMod.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() && MovingWorldMod.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 @@ -88,7 +88,7 @@ public EntityMovingWorld getEntity(World world, EntityMovingWorld entity) {
if (!isOK()) return null;

if (entity == null) {
MovingWorldMod.logger.error("A null movingWorld was attempted!");
MovingWorldMod.LOG.error("A null movingWorld was attempted!");
return null;
}

Expand All @@ -111,8 +111,8 @@ public EntityMovingWorld getEntity(World world, EntityMovingWorld entity) {
}
} catch (Exception e) {
resultType = ResultType.RESULT_ERROR_OCCURED;
MovingWorldMod.logger.error("Result code: RESULT ERROR OCCURRED was reached when attempting to getEntity from assembly result. Printing stacktrace...");
MovingWorldMod.logger.error(e);
MovingWorldMod.LOG.error("Result code: RESULT ERROR OCCURRED was reached when attempting to getEntity from assembly result. Printing stacktrace...");
MovingWorldMod.LOG.error(e);
e.printStackTrace();
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public AssembleResult doAssemble(MovingWorldAssemblyInteractor interactor) {
result.offset = start;
result.assemblyInteractor = interactor;
try {
if (MovingWorldMod.instance.getNetworkConfig().getShared().iterativeAlgorithm) {
if (MovingWorldMod.INSTANCE.getNetworkConfig().getShared().iterativeAlgorithm) {
assembleIterative(result, result.assemblyInteractor, start);
} else {
assembleRecursive(result, new HashSet<>(), result.assemblyInteractor, start);
Expand All @@ -46,7 +46,7 @@ public AssembleResult doAssemble(MovingWorldAssemblyInteractor interactor) {
result.resultType = AssembleResult.ResultType.RESULT_BLOCK_OVERFLOW;
} catch (Error e) {
result.resultType = AssembleResult.ResultType.RESULT_ERROR_OCCURED;
MovingWorldMod.logger.error(e.toString());
MovingWorldMod.LOG.error(e.toString());
}
result.assemblyInteractor.chunkAssembled(result);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public AssembleResult doDisassemble(MovingWorldAssemblyInteractor assemblyIntera
if (pList != null && !pList.isEmpty())
for (LocatedBlock locatedBlockInstance : pList) {
pos = locatedBlockInstance.blockPos;
MovingWorldMod.logger.debug("Post-rejoining block: " + locatedBlockInstance.toString());
MovingWorldMod.LOG.debug("Post-rejoining block: " + locatedBlockInstance.toString());
world.setBlockState(pos, locatedBlockInstance.blockState, 2);
assemblyInteractor.blockDisassembled(locatedBlockInstance);
DisassembleBlockEvent event = new DisassembleBlockEvent(locatedBlockInstance);
Expand Down Expand Up @@ -212,16 +212,14 @@ LocatedBlockList processLocatedBlockList(World world, LocatedBlockList locatedBl
}
}
if (tileentity != null) {
tileentity.setPos(pos);
if (tileentity instanceof IMovingTile) {
((IMovingTile) tileentity).setParentMovingWorld(null, new BlockPos(i, j, k));
}
NBTTagCompound tileTag = new NBTTagCompound();
tileentity.writeToNBT(tileTag);

world.setTileEntity(pos, tileentity);
world.getTileEntity(pos).readFromNBT(tileTag);
tileentity.validate();
tileentity.invalidate();
tileentity = world.getTileEntity(pos);

if (tileMarker != null && tileMarker.getPos().equals(tileentity.getPos())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ public boolean addBlockWithState(BlockPos pos, IBlockState state) {
Block currentBlock = currentState.getBlock();
int currentID = Block.getIdFromBlock(currentBlock);
int currentMeta = currentBlock.getMetaFromState(currentState);
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));
MovingWorldMod.LOG.debug(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));
if (currentID == id && currentMeta == meta) {
return false;
}
Expand Down Expand Up @@ -506,7 +505,7 @@ private void setChunkBlockTileEntity(BlockPos pos, TileEntity tileentity) {
if (!movingWorldTileEntities.contains(tileentity))
movingWorldTileEntities.add((IMovingTile) tileentity);
((IMovingTile) tileentity).setParentMovingWorld(entityMovingWorld, chunkPosition);
} else if (tileentity instanceof ITickable && MovingWorldMod.instance.getNetworkConfig().isTileUpdatable(tileentity.getClass())) {
} else if (tileentity instanceof ITickable && MovingWorldMod.INSTANCE.getNetworkConfig().isTileUpdatable(tileentity.getClass())) {
updatableTiles.add(tileentity);
}
}
Expand All @@ -532,7 +531,7 @@ public void removeChunkBlockTileEntity(BlockPos pos) {
movingWorldTileEntities.add((IMovingTile) tileentity);
((IMovingTile) tileentity).setParentMovingWorld(null, pos);
}
if (tileentity instanceof ITickable && MovingWorldMod.instance.getNetworkConfig().isTileUpdatable(tileentity.getClass())) {
if (tileentity instanceof ITickable && MovingWorldMod.INSTANCE.getNetworkConfig().isTileUpdatable(tileentity.getClass())) {
updatableTiles.remove(tileentity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ public void postLoad() {
s = s.replace("\"", "");
String[] pair = splitpattern.split(s);
if (pair.length != 2) {
MovingWorldMod.logger.warn("Invalid key-value pair at block_densities[" + i + "]");
MovingWorldMod.LOG.warn("Invalid key-value pair at block_densities[" + i + "]");
continue;
}
String key = pair[0];
float density;
try {
density = Float.parseFloat(pair[1]);
} catch (NumberFormatException e) {
MovingWorldMod.logger.warn("Cannot parse value " + pair[1] + " to floating point at block_densities[" + i + "]");
MovingWorldMod.LOG.warn("Cannot parse value " + pair[1] + " to floating point at block_densities[" + i + "]");
continue;
}
Block block = Block.getBlockFromName(key);
if (block == null) {
MovingWorldMod.logger.warn("No block found for " + key + " at block_densities[" + i + "]");
MovingWorldMod.LOG.warn("No block found for " + key + " at block_densities[" + i + "]");
continue;
}

Expand All @@ -146,20 +146,20 @@ public void postLoad() {
s = s.replace("\"", "");
String[] pair = splitpattern.split(s);
if (pair.length != 2) {
MovingWorldMod.logger.warn("Invalid key-value pair at material_densities[" + i + "]");
MovingWorldMod.LOG.warn("Invalid key-value pair at material_densities[" + i + "]");
continue;
}
String key = pair[0];
float density;
try {
density = Float.parseFloat(pair[1]);
} catch (NumberFormatException e) {
MovingWorldMod.logger.warn("Cannot parse value " + pair[1] + " to floating point at material_densities[" + i + "]");
MovingWorldMod.LOG.warn("Cannot parse value " + pair[1] + " to floating point at material_densities[" + i + "]");
continue;
}
Block block = Block.getBlockFromName(key);
if (block == null) {
MovingWorldMod.logger.warn("No block found for " + key + " at material_densities[" + i + "]");
MovingWorldMod.LOG.warn("No block found for " + key + " at material_densities[" + i + "]");
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void discoverPoweredBlocks() {
if (prop.getName().equals("powered")) {
String poweredBlockName = Block.REGISTRY.getNameForObject(checkBlock).toString();
poweredBlockNames.add(poweredBlockName);
MovingWorldMod.logger.info("Found powered block with name: " + poweredBlockName);
MovingWorldMod.LOG.info("Found powered block with name: " + poweredBlockName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void setInfo(MovingWorldInfo movingWorldInfo) {

@Override
public boolean processInitialInteract(EntityPlayer entityplayer, ItemStack stack, EnumHand hand) {
return getHandler().interact(entityplayer, stack, hand);
return getHandler().processInitialInteract(entityplayer, stack, hand);
}

@Override
Expand Down Expand Up @@ -521,32 +521,6 @@ public void updatePassengerPosition(Entity passenger, BlockPos riderDestination,

@Override
protected void applyYawToEntity(Entity entityToUpdate) {
int frontDirIndex = frontDirection.getHorizontalIndex();

float modifiedRotationYaw = -this.rotationYaw;
EnumFacing frontDirEnumFacing = EnumFacing.getHorizontal(frontDirIndex);
switch (frontDirEnumFacing) {
case NORTH: {
modifiedRotationYaw -= 180;
}
case SOUTH: {
modifiedRotationYaw -= 90;
}
case WEST: {
modifiedRotationYaw -= 180;
}
case EAST: {
modifiedRotationYaw -= 90;
}
}


entityToUpdate.setRenderYawOffset(modifiedRotationYaw);
float f = MathHelper.wrapDegrees(entityToUpdate.rotationYaw - modifiedRotationYaw);
float f1 = MathHelper.clamp_float(f, -105.0F, 105.0F);
entityToUpdate.prevRotationYaw += f1 - f;
entityToUpdate.rotationYaw += f1 - f;
entityToUpdate.setRotationYawHead(entityToUpdate.rotationYaw);
}

@Nullable
Expand Down Expand Up @@ -928,7 +902,7 @@ public void writeSpawnData(ByteBuf data) {
e.printStackTrace();
} catch (MovingWorldSizeOverflowException ssoe) {
disassemble(false);
MovingWorldMod.logger.warn("Ship is too large to be sent");
MovingWorldMod.LOG.warn("Ship is too large to be sent");
}
writeMovingWorldSpawnData(data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public MovingWorldHandlerClient(EntityMovingWorld movingWorld) {
}

@Override
public boolean interact(EntityPlayer player, ItemStack stack, EnumHand hand) {
public boolean processInitialInteract(EntityPlayer player, ItemStack stack, EnumHand hand) {
if (player.getDistanceSqToEntity(getMovingWorld()) >= 36D) {
PendingPacket packet = MovingWorldNetworking.NETWORK.send().packet("FarInteractMessage")
.with("dimID", getMovingWorld().worldObj.provider.getDimension())
Expand All @@ -27,6 +27,6 @@ public boolean interact(EntityPlayer player, ItemStack stack, EnumHand hand) {
packet.toServer();
}

return super.interact(player, stack, hand);
return super.processInitialInteract(player, stack, hand);
}
}
Loading

0 comments on commit 0dae5a7

Please sign in to comment.