Skip to content

Commit

Permalink
Initial 1.12 port, waiting for better mappings before more work is done.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkevilmac committed Jun 13, 2017
1 parent 7d5c8c8 commit eed1068
Show file tree
Hide file tree
Showing 55 changed files with 407 additions and 572 deletions.
57 changes: 35 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
Expand All @@ -23,23 +23,34 @@ apply plugin: 'org.spongepowered.mixin'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'idea'

version = '1.11-0000'
group = "com.elytradev.movingworld"
archivesBaseName = "movingworld"
def branch
if (System.env.BRANCH_NAME) {
// Jenkins support
branch = System.env.BRANCH_NAME
branch = branch.substring(branch.lastIndexOf('/') + 1)
} else {
branch = 'git rev-parse --abbrev-ref HEAD'.execute().in.text.trim()
}
def commits = 'git rev-list --count HEAD'.execute().in.text.trim()
def dirty = !'git diff-index HEAD'.execute().in.text.trim().isEmpty()

version = branch + '-' + modVersion + '.' + commits + (dirty ? '-dirty' : '')
group = modGroup
archivesBaseName = modBaseName

sourceCompatibility = 1.8
targetCompatibility = 1.8

minecraft {
version = "1.11.2-13.20.0.2255"
version = project.forgeVersion
runDir = "run"

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

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

mappings = "snapshot_20170308"
mappings = project.mcpVersion
}

mixin {
Expand All @@ -57,13 +68,13 @@ repositories {
}

dependencies {
compile('org.spongepowered:mixin:0.6.8-SNAPSHOT') {
compile('org.spongepowered:mixin:0.6.9-SNAPSHOT') {
exclude module: 'launchwrapper'
exclude module: 'guava'
}

compile 'com.elytradev:concrete:0.1.0'
shadow 'com.elytradev:concrete:0.1.0'
compile 'com.elytradev:concrete:0.2.2:all'
shadow 'com.elytradev:concrete:0.2.2:all'

compile 'cglib:cglib:3.2.5'
compile 'org.objenesis:objenesis:2.5.1'
Expand Down Expand Up @@ -103,22 +114,24 @@ jar {
}
}

processResources
{
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"

expand 'version': project.version, 'mcversion': project.minecraft.version
}

from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// replace version and mcversion
expand "version": project.version, "mcversion": project.minecraft.version
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}

idea {
workspace {
Expand Down
9 changes: 9 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
modGroup=com.elytradev
modVersion=1
modBaseName=movingworld
forgeVersion=1.12-14.21.0.2322
mcpVersion=snapshot_20170611

# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@

import java.util.Set;


public class MovingWorldGUIFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) {
}

@Override
public boolean hasConfigGui() {
return true;
}

@Override
public GuiScreen createConfigGui(GuiScreen parentScreen) {
return new MovingWorldConfigGUI(parentScreen);
}

@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return MovingWorldConfigGUI.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
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.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 @@ -21,111 +17,109 @@
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class MobileChunkRenderer {
/**
* Boolean for whether this renderer needs to be updated or not
*/
public boolean needsUpdate;
public boolean isRemoved;

private MobileChunk chunk;

public MobileChunkRenderer(MobileChunk mobilechunk) {
chunk = mobilechunk;
needsUpdate = true;
}

public void render(float partialTicks) {
if (needsUpdate) {
try{
updateSimpleRender(partialTicks);
}
catch(Exception e) {
MovingWorldMod.LOG.error("Exception when rendering a MobileChunk! ", e);
}
}
}

private void updateSimpleRender(float partialTicks) {
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexBuffer = tessellator.getBuffer();

RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.enableCull();

if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(7425);
} else {
GlStateManager.shadeModel(7424);
}

vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
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);
IBlockState blockState = chunk.getBlockState(pos);
Block block = blockState.getBlock();

for (BlockRenderLayer blockRenderLayer : BlockRenderLayer.values()) {
if (!block.canRenderInLayer(blockState, blockRenderLayer)) continue;
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(blockRenderLayer);

if (!block.getRenderType(blockState).equals(EnumBlockRenderType.INVISIBLE)) {
dispatchBlockRender(blockState, pos, vertexBuffer);
}
}
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}
}
}
vertexBuffer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
GlStateManager.disableBlend();
GlStateManager.disableCull();
RenderHelper.enableStandardItemLighting();

GlStateManager.pushMatrix();
World tesrDispatchWorld = TileEntityRendererDispatcher.instance.world;
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.setWorld(chunk.getFakeWorld());
TileEntitySpecialRenderer renderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(tile);

if (renderer != null && tile.shouldRenderInPass(MinecraftForgeClient.getRenderPass())) {
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), partialTicks);
}
tile.setWorld(chunk.world);
}
}
}
}
TileEntityRendererDispatcher.instance.setWorld(tesrDispatchWorld);
GlStateManager.popMatrix();
}

public void dispatchBlockRender(IBlockState blockState, BlockPos blockPos, VertexBuffer vertexBuffer) {
vertexBuffer.color(1.0F, 1.0F, 1.0F, 1.0F);
BlockRendererDispatcher blockRendererDispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
blockRendererDispatcher.renderBlock(blockState, blockPos, chunk.getFakeWorld(), vertexBuffer);
}

public void markDirty() {
needsUpdate = true;
}

public void markRemoved() {
isRemoved = true;
}
/**
* Boolean for whether this renderer needs to be updated or not
*/
public boolean needsUpdate;
public boolean isRemoved;

private MobileChunk chunk;

public MobileChunkRenderer(MobileChunk mobilechunk) {
chunk = mobilechunk;
needsUpdate = true;
}

public void render(float partialTicks) {
if (needsUpdate) {
try {
updateSimpleRender(partialTicks);
} catch (Exception e) {
MovingWorldMod.LOG.error("Exception when rendering a MobileChunk! ", e);
}
}
}

private void updateSimpleRender(float partialTicks) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();

RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.enableCull();

if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(7425);
} else {
GlStateManager.shadeModel(7424);
}

buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
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);
IBlockState blockState = chunk.getBlockState(pos);
Block block = blockState.getBlock();

for (BlockRenderLayer blockRenderLayer : BlockRenderLayer.values()) {
if (!block.canRenderInLayer(blockState, blockRenderLayer)) continue;
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(blockRenderLayer);

if (!block.getRenderType(blockState).equals(EnumBlockRenderType.INVISIBLE)) {
dispatchBlockRender(blockState, pos, buffer);
}
}
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}
}
}
buffer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
GlStateManager.disableBlend();
GlStateManager.disableCull();
RenderHelper.enableStandardItemLighting();

GlStateManager.pushMatrix();
World tesrDispatchWorld = TileEntityRendererDispatcher.instance.world;
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.setWorld(chunk.getFakeWorld());
TileEntitySpecialRenderer renderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(tile);

if (renderer != null && tile.shouldRenderInPass(MinecraftForgeClient.getRenderPass())) {
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), partialTicks);
}
tile.setWorld(chunk.world);
}
}
}
}
TileEntityRendererDispatcher.instance.setWorld(tesrDispatchWorld);
GlStateManager.popMatrix();
}

public void dispatchBlockRender(IBlockState blockState, BlockPos blockPos, BufferBuilder buffer) {
buffer.color(1.0F, 1.0F, 1.0F, 1.0F);
BlockRendererDispatcher blockRendererDispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
blockRendererDispatcher.renderBlock(blockState, blockPos, chunk.getFakeWorld(), buffer);
}

public void markDirty() {
needsUpdate = true;
}

public void markRemoved() {
isRemoved = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MovingWorldCoreMod implements IFMLLoadingPlugin {
public MovingWorldCoreMod() {
MixinBootstrap.init();
Mixins.addConfiguration("mixins.movingworld.json");
Mixins.addConfiguration("mixins.movingworld.experiments.json");
Mixins.addConfiguration("src/test/resources/mixins.movingworld.experiments.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.elytradev.movingworld.common.network;

import com.elytradev.concrete.NetworkContext;
import com.elytradev.concrete.network.NetworkContext;
import com.elytradev.movingworld.MovingWorldMod;
import com.elytradev.movingworld.common.network.message.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.elytradev.movingworld.common.network.marshallers;

import com.elytradev.concrete.Marshaller;
import com.elytradev.concrete.network.Marshaller;
import io.netty.buffer.ByteBuf;
import net.minecraftforge.fml.common.network.ByteBufUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.elytradev.movingworld.common.network.marshallers;

import com.elytradev.concrete.Marshaller;
import com.elytradev.concrete.network.Marshaller;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
Expand Down
Loading

0 comments on commit eed1068

Please sign in to comment.