Port most remaining instances of manual lightmap modification

This commit is contained in:
tterrag 2020-03-29 14:21:22 -04:00
parent 3c07aa51de
commit 9f2dcc5635
15 changed files with 120 additions and 137 deletions

View File

@ -19,6 +19,7 @@ import com.simibubi.create.modules.curiosities.zapper.terrainzapper.TerrainZappe
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -70,7 +71,7 @@ public class ClientEvents {
public static void onRenderWorld(RenderWorldLastEvent event) { public static void onRenderWorld(RenderWorldLastEvent event) {
MatrixStack ms = event.getMatrixStack(); MatrixStack ms = event.getMatrixStack();
IRenderTypeBuffer buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers(); IRenderTypeBuffer buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers();
CreateClient.schematicHandler.render(ms, buffer); CreateClient.schematicHandler.render(ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV);
CreateClient.schematicAndQuillHandler.render(ms, buffer); CreateClient.schematicAndQuillHandler.render(ms, buffer);
CreateClient.schematicHologram.render(ms, buffer); CreateClient.schematicHologram.render(ms, buffer);
KineticDebugger.renderSourceOutline(ms, buffer); KineticDebugger.renderSourceOutline(ms, buffer);
@ -83,11 +84,12 @@ public class ClientEvents {
if (event.getType() != ElementType.HOTBAR) if (event.getType() != ElementType.HOTBAR)
return; return;
onRenderHotbar(); onRenderHotbar(new MatrixStack(), Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers(),
0xF000F0, OverlayTexture.DEFAULT_UV);
} }
public static void onRenderHotbar() { public static void onRenderHotbar(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
CreateClient.schematicHandler.renderOverlay(); CreateClient.schematicHandler.renderOverlay(ms, buffer, light, overlay);
} }
@SubscribeEvent @SubscribeEvent

View File

@ -1,6 +1,7 @@
package com.simibubi.create.modules.contraptions.redstone; package com.simibubi.create.modules.contraptions.redstone;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -29,7 +30,7 @@ public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<Analog
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos()); int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
float state = te.clientState.get(partialTicks); float state = te.clientState.get(partialTicks);
IVertexBuffer vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
// Handle // Handle
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState); SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);

View File

@ -19,6 +19,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
public class ContactBlock extends ProperDirectionalBlock implements IPortableBlock { public class ContactBlock extends ProperDirectionalBlock implements IPortableBlock {
@ -72,7 +73,7 @@ public class ContactBlock extends ProperDirectionalBlock implements IPortableBlo
} }
@Override @Override
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
boolean hasValidContact = hasValidContact(worldIn, pos, state.get(FACING)); boolean hasValidContact = hasValidContact(worldIn, pos, state.get(FACING));
if (state.get(POWERED) != hasValidContact) if (state.get(POWERED) != hasValidContact)
worldIn.setBlockState(pos, state.with(POWERED, hasValidContact)); worldIn.setBlockState(pos, state.with(POWERED, hasValidContact));

View File

@ -1,15 +1,15 @@
package com.simibubi.create.modules.curiosities.deforester; package com.simibubi.create.modules.curiosities.deforester;
import org.lwjgl.opengl.GL13;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -21,28 +21,23 @@ public class DeforesterItemRenderer extends ItemStackTileEntityRenderer {
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
DeforesterModel mainModel = (DeforesterModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, Minecraft.getInstance().player); DeforesterModel mainModel = (DeforesterModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, Minecraft.getInstance().player);
float worldTime = AnimationTickHolder.getRenderTick(); float worldTime = AnimationTickHolder.getRenderTick();
float lastCoordx = GLX.lastBrightnessX;
float lastCoordy = GLX.lastBrightnessY;
RenderSystem.pushMatrix(); ms.push();
RenderSystem.translatef(0.5F, 0.5F, 0.5F); ms.translate(0.5F, 0.5F, 0.5F);
itemRenderer.renderItem(stack, mainModel.getBakedModel()); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel());
RenderSystem.disableLighting(); int brightLight = LightTexture.pack(15, 7);
GLX.glMultiTexCoord2f(GL13.GL_TEXTURE1, 240, 120); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, brightLight, overlay, mainModel.getPartial("light"));
itemRenderer.renderItem(stack, mainModel.getPartial("light")); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, brightLight, overlay, mainModel.getPartial("blade"));
itemRenderer.renderItem(stack, mainModel.getPartial("blade"));
GLX.glMultiTexCoord2f(GL13.GL_TEXTURE1, lastCoordx, lastCoordy);
RenderSystem.enableLighting();
float angle = worldTime * -.5f % 360; float angle = worldTime * -.5f % 360;
float xOffset = 0; float xOffset = 0;
float zOffset = 0; float zOffset = 0;
RenderSystem.translatef(-xOffset, 0, -zOffset); ms.translate(-xOffset, 0, -zOffset);
RenderSystem.rotatef(angle, 0, 1, 0); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle));
RenderSystem.translatef(xOffset, 0, zOffset); ms.translate(xOffset, 0, zOffset);
itemRenderer.renderItem(stack, mainModel.getPartial("gear")); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, brightLight, overlay, mainModel.getPartial("gear"));
RenderSystem.popMatrix(); RenderSystem.popMatrix();

View File

@ -1,13 +1,13 @@
package com.simibubi.create.modules.curiosities.symmetry.client; package com.simibubi.create.modules.curiosities.symmetry.client;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -18,34 +18,25 @@ public class SymmetryWandItemRenderer extends ItemStackTileEntityRenderer {
public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
SymmetryWandModel mainModel = (SymmetryWandModel) itemRenderer.getModelWithOverrides(stack); SymmetryWandModel mainModel = (SymmetryWandModel) itemRenderer.getItemModelWithOverrides(stack, null, null);
float worldTime = AnimationTickHolder.getRenderTick() / 20; float worldTime = AnimationTickHolder.getRenderTick() / 20;
RenderSystem.pushMatrix(); ms.push();
RenderSystem.translatef(0.5F, 0.5F, 0.5F); ms.translate(0.5F, 0.5F, 0.5F);
itemRenderer.renderItem(stack, mainModel.getBakedModel()); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel());
float lastCoordx = 0; float lastCoordx = 0;
float lastCoordy = 0; float lastCoordy = 0;
RenderSystem.disableLighting(); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, 0xF000F0, overlay, mainModel.getPartial("core"));
lastCoordx = GLX.lastBrightnessX;
lastCoordy = GLX.lastBrightnessY;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, 240, 240);
itemRenderer.renderItem(stack, mainModel.getPartial("core"));
float floating = MathHelper.sin(worldTime) * .05f; float floating = MathHelper.sin(worldTime) * .05f;
RenderSystem.translated(0, floating, 0); ms.translate(0, floating, 0);
float angle = worldTime * -10 % 360; float angle = worldTime * -10 % 360;
RenderSystem.rotatef(angle, 0, 1, 0); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle));
itemRenderer.renderItem(stack, mainModel.getPartial("bits")); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, 0xF000F0, overlay, mainModel.getPartial("bits"));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy);
RenderSystem.enableLighting();
RenderSystem.popMatrix();
ms.pop();
} }
} }

View File

@ -1,32 +1,35 @@
package com.simibubi.create.modules.curiosities.zapper; package com.simibubi.create.modules.curiosities.zapper;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FourWayBlock; import net.minecraft.block.FourWayBlock;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
public abstract class ZapperItemRenderer extends ItemStackTileEntityRenderer { public abstract class ZapperItemRenderer extends ItemStackTileEntityRenderer {
protected void renderBlockUsed(ItemStack stack, ItemRenderer itemRenderer) { protected void renderBlockUsed(ItemStack stack, ItemRenderer itemRenderer, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) {
BlockState state = NBTUtil.readBlockState(stack.getTag().getCompound("BlockUsed")); BlockState state = NBTUtil.readBlockState(stack.getTag().getCompound("BlockUsed"));
RenderSystem.pushMatrix(); ms.push();
RenderSystem.translatef(-0.3F, -0.45F, -0.0F); ms.translate(-0.3F, -0.45F, -0.0F);
RenderSystem.scalef(0.25F, 0.25F, 0.25F); ms.scale(0.25F, 0.25F, 0.25F);
IBakedModel modelForState = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state); IBakedModel modelForState = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state);
if (state.getBlock() instanceof FourWayBlock) if (state.getBlock() instanceof FourWayBlock)
modelForState = Minecraft.getInstance().getItemRenderer() modelForState = Minecraft.getInstance().getItemRenderer()
.getItemModelWithOverrides(new ItemStack(state.getBlock()), Minecraft.getInstance().world, null); .getItemModelWithOverrides(new ItemStack(state.getBlock()), Minecraft.getInstance().world, null);
itemRenderer.renderItem(new ItemStack(state.getBlock()), modelForState); itemRenderer.renderItem(new ItemStack(state.getBlock()), TransformType.NONE, false, ms, buffer, light, overlay, modelForState);
RenderSystem.popMatrix(); ms.pop();
} }
} }

View File

@ -7,8 +7,6 @@ import static com.simibubi.create.modules.curiosities.zapper.blockzapper.Blockza
import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Scope; import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Scope;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.modules.curiosities.zapper.ZapperItemRenderer; import com.simibubi.create.modules.curiosities.zapper.ZapperItemRenderer;
import com.simibubi.create.modules.curiosities.zapper.ZapperRenderHandler; import com.simibubi.create.modules.curiosities.zapper.ZapperRenderHandler;
@ -19,6 +17,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -35,22 +35,19 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer {
float pt = Minecraft.getInstance().getRenderPartialTicks(); float pt = Minecraft.getInstance().getRenderPartialTicks();
float worldTime = AnimationTickHolder.getRenderTick() / 20; float worldTime = AnimationTickHolder.getRenderTick() / 20;
RenderSystem.pushMatrix(); ms.push();
RenderSystem.translatef(0.5F, 0.5F, 0.5F); ms.translate(0.5F, 0.5F, 0.5F);
float lastCoordx = GLX.lastBrightnessX;
float lastCoordy = GLX.lastBrightnessY;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, Math.min(lastCoordx + 60, 240), Math.min(lastCoordy + 120, 240));
itemRenderer.renderItem(stack, mainModel.getBakedModel()); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel);
renderComponent(stack, mainModel, Body, itemRenderer); renderComponent(stack, mainModel, Body, itemRenderer, ms, buffer, light, overlay);
renderComponent(stack, mainModel, Amplifier, itemRenderer); renderComponent(stack, mainModel, Amplifier, itemRenderer, ms, buffer, light, overlay);
renderComponent(stack, mainModel, Retriever, itemRenderer); renderComponent(stack, mainModel, Retriever, itemRenderer, ms, buffer, light, overlay);
renderComponent(stack, mainModel, Scope, itemRenderer); renderComponent(stack, mainModel, Scope, itemRenderer, ms, buffer, light, overlay);
// Block indicator // Block indicator
if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag() if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag()
&& stack.getTag().contains("BlockUsed")) && stack.getTag().contains("BlockUsed"))
renderBlockUsed(stack, itemRenderer); renderBlockUsed(stack, itemRenderer, ms, buffer, light, overlay);
ClientPlayerEntity player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
boolean leftHanded = player.getPrimaryHand() == HandSide.LEFT; boolean leftHanded = player.getPrimaryHand() == HandSide.LEFT;
@ -63,17 +60,14 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer {
float animation = MathHelper.clamp(MathHelper.lerp(pt, last, current) * 5, 0, 1); float animation = MathHelper.clamp(MathHelper.lerp(pt, last, current) * 5, 0, 1);
// Core glows // Core glows
RenderSystem.disableLighting();
float multiplier = MathHelper.sin(worldTime * 5); float multiplier = MathHelper.sin(worldTime * 5);
if (mainHand || offHand) { if (mainHand || offHand) {
multiplier = animation; multiplier = animation;
} }
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, multiplier * 240, 120); int glowLight = LightTexture.pack((int) (15 * multiplier), 15);
itemRenderer.renderItem(stack, mainModel.getPartial("core")); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, mainModel.getPartial("core"));
if (BlockzapperItem.getTier(Amplifier, stack) != ComponentTier.None) if (BlockzapperItem.getTier(Amplifier, stack) != ComponentTier.None)
itemRenderer.renderItem(stack, mainModel.getPartial("amplifier_core")); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, mainModel.getPartial("amplifier_core"));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy);
RenderSystem.enableLighting();
// Accelerator spins // Accelerator spins
float angle = worldTime * -25; float angle = worldTime * -25;
@ -82,20 +76,20 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer {
angle %= 360; angle %= 360;
float offset = -.155f; float offset = -.155f;
RenderSystem.translatef(0, offset, 0); ms.translate(0, offset, 0);
RenderSystem.rotatef(angle, 0, 0, 1); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(angle));
RenderSystem.translatef(0, -offset, 0); ms.translate(0, -offset, 0);
renderComponent(stack, mainModel, Accelerator, itemRenderer); renderComponent(stack, mainModel, Accelerator, itemRenderer, ms, buffer, light, overlay);
RenderSystem.popMatrix(); ms.pop();
} }
public void renderComponent(ItemStack stack, BlockzapperModel model, Components component, public void renderComponent(ItemStack stack, BlockzapperModel model, Components component,
ItemRenderer itemRenderer) { ItemRenderer itemRenderer, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
ComponentTier tier = BlockzapperItem.getTier(component, stack); ComponentTier tier = BlockzapperItem.getTier(component, stack);
IBakedModel partial = model.getComponentPartial(tier, component); IBakedModel partial = model.getComponentPartial(tier, component);
if (partial != null) if (partial != null)
itemRenderer.renderItem(stack, partial); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, partial);
} }
} }

View File

@ -1,7 +1,6 @@
package com.simibubi.create.modules.curiosities.zapper.terrainzapper; package com.simibubi.create.modules.curiosities.zapper.terrainzapper;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.modules.curiosities.zapper.ZapperItemRenderer; import com.simibubi.create.modules.curiosities.zapper.ZapperItemRenderer;
@ -11,6 +10,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.HandSide; import net.minecraft.util.HandSide;
@ -26,17 +27,18 @@ public class TerrainzapperItemRenderer extends ZapperItemRenderer {
float pt = Minecraft.getInstance().getRenderPartialTicks(); float pt = Minecraft.getInstance().getRenderPartialTicks();
float worldTime = AnimationTickHolder.getRenderTick() / 20; float worldTime = AnimationTickHolder.getRenderTick() / 20;
RenderSystem.pushMatrix(); ms.push();
RenderSystem.translatef(0.5F, 0.5F, 0.5F); ms.translate(0.5F, 0.5F, 0.5F);
float lastCoordx = GLX.lastBrightnessX; int lastBl = LightTexture.getBlockLightCoordinates(light);
float lastCoordy = GLX.lastBrightnessY; int lastSl = LightTexture.getSkyLightCoordinates(light);
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, Math.min(lastCoordx + 60, 240), Math.min(lastCoordy + 120, 240)); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer,
itemRenderer.renderItem(stack, mainModel.getBakedModel()); LightTexture.pack(Math.min(lastBl + 4, 15), Math.min(lastSl + 7, 15)), overlay,
mainModel.getBakedModel());
// Block indicator // Block indicator
if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag() if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag()
&& stack.getTag().contains("BlockUsed")) && stack.getTag().contains("BlockUsed"))
renderBlockUsed(stack, itemRenderer); renderBlockUsed(stack, itemRenderer, ms, buffer, light, overlay);
ClientPlayerEntity player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
boolean leftHanded = player.getPrimaryHand() == HandSide.LEFT; boolean leftHanded = player.getPrimaryHand() == HandSide.LEFT;
@ -49,16 +51,13 @@ public class TerrainzapperItemRenderer extends ZapperItemRenderer {
float animation = MathHelper.clamp(MathHelper.lerp(pt, last, current) * 5, 0, 1); float animation = MathHelper.clamp(MathHelper.lerp(pt, last, current) * 5, 0, 1);
// Core glows // Core glows
RenderSystem.disableLighting();
float multiplier = MathHelper.sin(worldTime * 5); float multiplier = MathHelper.sin(worldTime * 5);
if (mainHand || offHand) { if (mainHand || offHand) {
multiplier = animation; multiplier = animation;
} }
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, multiplier * 240, 120); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer,
itemRenderer.renderItem(stack, mainModel.getPartial("terrain_core")); LightTexture.pack((int) (15 * multiplier), 7), overlay, mainModel.getPartial("terrain_core"));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy);
RenderSystem.enableLighting();
// Accelerator spins // Accelerator spins
float angle = worldTime * -25; float angle = worldTime * -25;
@ -67,10 +66,11 @@ public class TerrainzapperItemRenderer extends ZapperItemRenderer {
angle %= 360; angle %= 360;
float offset = -.155f; float offset = -.155f;
RenderSystem.translatef(0, offset, 0); ms.translate(0, offset, 0);
RenderSystem.rotatef(angle, 0, 0, 1); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(angle));
RenderSystem.translatef(0, -offset, 0); ms.translate(0, -offset, 0);
itemRenderer.renderItem(stack, mainModel.getPartial("terrain_accelerator")); itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay,
mainModel.getPartial("terrain_accelerator"));
RenderSystem.popMatrix(); RenderSystem.popMatrix();
} }

View File

@ -6,13 +6,13 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.StateContainer.Builder;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.TickPriority; import net.minecraft.world.TickPriority;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
public class LatchBlock extends ToggleLatchBlock { public class LatchBlock extends ToggleLatchBlock {
@ -51,7 +51,7 @@ public class LatchBlock extends ToggleLatchBlock {
} }
@Override @Override
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
boolean back = state.get(POWERED); boolean back = state.get(POWERED);
boolean shouldBack = this.shouldBePowered(worldIn, pos, state); boolean shouldBack = this.shouldBePowered(worldIn, pos, state);
boolean side = state.get(POWERED_SIDE); boolean side = state.get(POWERED_SIDE);

View File

@ -110,25 +110,22 @@ public class SchematicHandler {
currentTool.getTool().updateSelection(); currentTool.getTool().updateSelection();
} }
public void render(MatrixStack ms, IRenderTypeBuffer buffer) { public void render(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
// TODO 1.15 buffered render
if (!active) if (!active)
return; return;
if (Minecraft.getInstance().player.isSneaking()) if (Minecraft.getInstance().player.isSneaking())
return; return;
TessellatorHelper.prepareForDrawing(); currentTool.getTool().renderTool(ms, buffer, light, overlay);
currentTool.getTool().renderTool();
TessellatorHelper.cleanUpAfterDrawing();
} }
public void renderOverlay() { public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
if (!active) if (!active)
return; return;
if (item != null) if (item != null)
overlay.renderOn(slot); this.overlay.renderOn(slot);
currentTool.getTool().renderOverlay(); currentTool.getTool().renderOverlay(ms, buffer, light, overlay);
selectionScreen.renderPassive(Minecraft.getInstance().getRenderPartialTicks()); selectionScreen.renderPassive(Minecraft.getInstance().getRenderPartialTicks());
} }

View File

@ -1,8 +1,11 @@
package com.simibubi.create.modules.schematics.client.tools; package com.simibubi.create.modules.schematics.client.tools;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -28,8 +31,8 @@ public class DeployTool extends PlacementToolBase {
} }
@Override @Override
public void renderTool() { public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
super.renderTool(); super.renderTool(ms, buffer, light, overlay);
if (selectedPos == null) if (selectedPos == null)
return; return;
@ -44,16 +47,10 @@ public class DeployTool extends PlacementToolBase {
max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ); max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
} }
RenderSystem.lineWidth(2); // RenderSystem.color4f(.5f, .8f, 1, 1); TODO 1.15
RenderSystem.color4f(.5f, .8f, 1, 1);
RenderSystem.disableTexture();
WorldRenderer.drawBoundingBox(min.getX() - 1 / 8d, min.getY() + 1 / 16d, min.getZ() - 1 / 8d, WorldRenderer.drawBox(ms, buffer.getBuffer(RenderType.getLines()), min.getX() - 1 / 8d, min.getY() + 1 / 16d, min.getZ() - 1 / 8d,
max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, .8f, .9f, 1, 1); max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, .8f, .9f, 1, 1);
RenderSystem.lineWidth(1);
RenderSystem.enableTexture();
} }
@Override @Override

View File

@ -1,5 +1,9 @@
package com.simibubi.create.modules.schematics.client.tools; package com.simibubi.create.modules.schematics.client.tools;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
public interface ISchematicTool { public interface ISchematicTool {
public void init(); public void init();
@ -8,8 +12,8 @@ public interface ISchematicTool {
public boolean handleRightClick(); public boolean handleRightClick();
public boolean handleMouseWheel(double delta); public boolean handleMouseWheel(double delta);
public void renderTool(); public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay);
public void renderOverlay(); public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay);
} }

View File

@ -1,5 +1,9 @@
package com.simibubi.create.modules.schematics.client.tools; package com.simibubi.create.modules.schematics.client.tools;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
public abstract class PlacementToolBase extends SchematicToolBase { public abstract class PlacementToolBase extends SchematicToolBase {
@Override @Override
@ -13,13 +17,13 @@ public abstract class PlacementToolBase extends SchematicToolBase {
} }
@Override @Override
public void renderTool() { public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
super.renderTool(); super.renderTool(ms, buffer, light, overlay);
} }
@Override @Override
public void renderOverlay() { public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
super.renderOverlay(); super.renderOverlay(ms, buffer, light, overlay);
} }
@Override @Override

View File

@ -1,6 +1,6 @@
package com.simibubi.create.modules.schematics.client.tools; package com.simibubi.create.modules.schematics.client.tools;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper;
@ -9,6 +9,8 @@ import com.simibubi.create.modules.schematics.client.SchematicHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
@ -78,19 +80,15 @@ public abstract class SchematicToolBase implements ISchematicTool {
} }
@Override @Override
public void renderTool() { public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
if (schematicHandler.deployed) { if (schematicHandler.deployed) {
RenderSystem.lineWidth(2);
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.disableTexture();
BlockPos min = schematicHandler.getTransformedAnchor(); BlockPos min = schematicHandler.getTransformedAnchor();
MutableBoundingBox bb = new MutableBoundingBox(min, min.add(schematicHandler.getTransformedSize())); MutableBoundingBox bb = new MutableBoundingBox(min, min.add(schematicHandler.getTransformedSize()));
min = new BlockPos(bb.minX, bb.minY, bb.minZ); min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ); BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
WorldRenderer.drawBoundingBox(min.getX() - 1 / 8d, min.getY() + 1 / 16d, min.getZ() - 1 / 8d, WorldRenderer.drawBox(buffer.getBuffer(RenderType.getLines()), min.getX() - 1 / 8d, min.getY() + 1 / 16d, min.getZ() - 1 / 8d,
max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, 1, 1, 1, 1); max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, 1, 1, 1, 1);
if (schematicSelected && renderSelectedFace && AllKeys.ACTIVATE_TOOL.isPressed()) { if (schematicSelected && renderSelectedFace && AllKeys.ACTIVATE_TOOL.isPressed()) {
@ -103,20 +101,16 @@ public abstract class SchematicToolBase implements ISchematicTool {
Vec3d faceMin = center.add(vec.mul(radii).add(onFaceOffset)).add(vec.scale(1/8f)); Vec3d faceMin = center.add(vec.mul(radii).add(onFaceOffset)).add(vec.scale(1/8f));
Vec3d faceMax = center.add(vec.mul(radii).subtract(onFaceOffset)).add(vec.scale(1/8f)); Vec3d faceMax = center.add(vec.mul(radii).subtract(onFaceOffset)).add(vec.scale(1/8f));
RenderSystem.lineWidth(6); // RenderSystem.lineWidth(6); TODO 1.15 custom line size render type
WorldRenderer.drawBoundingBox(faceMin.getX(), faceMin.getY() + 1 / 16d, faceMin.getZ(), faceMax.getX(), WorldRenderer.drawBox(buffer.getBuffer(RenderType.getLines()), faceMin.getX(), faceMin.getY() + 1 / 16d, faceMin.getZ(), faceMax.getX(),
faceMax.getY() + 1 / 8d, faceMax.getZ(), .6f, .7f, 1, 1); faceMax.getY() + 1 / 8d, faceMax.getZ(), .6f, .7f, 1, 1);
} }
RenderSystem.lineWidth(1);
RenderSystem.enableTexture();
} }
} }
@Override @Override
public void renderOverlay() { public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
} }

View File

@ -4,7 +4,7 @@ loaderVersion="[28,)"
[[mods]] [[mods]]
modId="create" modId="create"
version="mc1.14-0.2.2a" version="${file.jarVersion}"
displayName="Create" displayName="Create"
#updateJSONURL="" #updateJSONURL=""
authors="simibubi" authors="simibubi"
@ -14,13 +14,13 @@ Technology that empowers the player.'''
[[dependencies.create]] [[dependencies.create]]
modId="forge" modId="forge"
mandatory=true mandatory=true
versionRange="[28.1.56,)" versionRange="[31.1.0,)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.create]] [[dependencies.create]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
versionRange="[1.14.4]" versionRange="[1.15.2,1.16)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"