mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 11:33:43 +01:00
Custom lighting refactor and JEI tweaks
- Create ILightingSettings and CustomLightingSettings to better manage custom lighting - Allow item GuiGameElements to have custom lighting - Add defaultBlockElement methods to automatically apply default custom lighting to JEI scenes - Add blaze head bobbing to JEI scenes - Shift elements on JEI washing scene - Use an empty screen instead of creating a new one in IScreenRenderable
This commit is contained in:
parent
e61dd71df1
commit
31bd6865fc
19 changed files with 200 additions and 127 deletions
|
@ -21,11 +21,10 @@ public class FanSmokingCategory extends ProcessingViaFanCategory<SmokingRecipe>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderAttachedBlock(MatrixStack matrixStack) {
|
public void renderAttachedBlock(MatrixStack matrixStack) {
|
||||||
|
|
||||||
GuiGameElement.of(Blocks.FIRE.getDefaultState())
|
GuiGameElement.of(Blocks.FIRE.getDefaultState())
|
||||||
.scale(24)
|
.scale(24)
|
||||||
.atLocal(0, 0, 2)
|
.atLocal(0, 0, 2)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -49,7 +49,7 @@ public class FanWashingCategory extends ProcessingViaFanCategory<SplashingRecipe
|
||||||
int xOffset = (outputIndex % 3) * 19;
|
int xOffset = (outputIndex % 3) * 19;
|
||||||
int yOffset = (outputIndex / 3) * -19;
|
int yOffset = (outputIndex / 3) * -19;
|
||||||
|
|
||||||
itemStacks.init(outputIndex + 1, false, single ? 126 : 121 + xOffset, 47 + yOffset + (excessive ? 8 : 0));
|
itemStacks.init(outputIndex + 1, false, single ? 126 : 126 + xOffset, 47 + yOffset + (excessive ? 8 : 0));
|
||||||
itemStacks.set(outputIndex + 1, results.get(outputIndex)
|
itemStacks.set(outputIndex + 1, results.get(outputIndex)
|
||||||
.getStack());
|
.getStack());
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,8 @@ public class FanWashingCategory extends ProcessingViaFanCategory<SplashingRecipe
|
||||||
.size();
|
.size();
|
||||||
|
|
||||||
AllGuiTextures.JEI_SLOT.draw(matrixStack, 12, 47);
|
AllGuiTextures.JEI_SLOT.draw(matrixStack, 12, 47);
|
||||||
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 39, 29);
|
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 47 + 4, 29);
|
||||||
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 54, 39);
|
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 66 + 4, 39);
|
||||||
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 42, 51);
|
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 42, 51);
|
||||||
|
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
|
@ -75,13 +75,13 @@ public class FanWashingCategory extends ProcessingViaFanCategory<SplashingRecipe
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
int xOffset = (i % 3) * 19;
|
int xOffset = (i % 3) * 19;
|
||||||
int yOffset = (i / 3) * -19 + (size > 9 ? 8 : 0);
|
int yOffset = (i / 3) * -19 + (size > 9 ? 8 : 0);
|
||||||
getRenderedSlot(recipe, i).draw(matrixStack, 121 + xOffset, 47 + yOffset);
|
getRenderedSlot(recipe, i).draw(matrixStack, 126 + xOffset, 47 + yOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void translateFan(MatrixStack ms) {
|
protected void translateFan(MatrixStack ms) {
|
||||||
ms.translate(43, 33, 0);
|
ms.translate(56 + 4, 33, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -68,6 +68,7 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
|
||||||
if (matrixStack == null)
|
if (matrixStack == null)
|
||||||
return;
|
return;
|
||||||
renderWidgets(matrixStack, recipe, mouseX, mouseY);
|
renderWidgets(matrixStack, recipe, mouseX, mouseY);
|
||||||
|
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
translateFan(matrixStack);
|
translateFan(matrixStack);
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-12.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-12.5f));
|
||||||
|
@ -77,12 +78,14 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
|
||||||
GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER)
|
GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER)
|
||||||
.rotateBlock(180, 0, AnimatedKinetics.getCurrentAngle() * 16)
|
.rotateBlock(180, 0, AnimatedKinetics.getCurrentAngle() * 16)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
|
.lighting(AnimatedKinetics.DEFAULT_LIGHTING)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.ENCASED_FAN.getDefaultState())
|
GuiGameElement.of(AllBlocks.ENCASED_FAN.getDefaultState())
|
||||||
.rotateBlock(0, 180, 0)
|
.rotateBlock(0, 180, 0)
|
||||||
.atLocal(0, 0, 0)
|
.atLocal(0, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
|
.lighting(AnimatedKinetics.DEFAULT_LIGHTING)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
renderAttachedBlock(matrixStack);
|
renderAttachedBlock(matrixStack);
|
||||||
|
|
|
@ -5,12 +5,12 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
public class AnimatedBlazeBurner implements IDrawable {
|
public class AnimatedBlazeBurner extends AnimatedKinetics {
|
||||||
|
|
||||||
private HeatLevel heatLevel;
|
private HeatLevel heatLevel;
|
||||||
|
|
||||||
|
@ -26,14 +26,15 @@ public class AnimatedBlazeBurner implements IDrawable {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
||||||
int scale = 23;
|
int scale = 23;
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.BLAZE_BURNER.getDefaultState())
|
defaultBlockElement(AllBlocks.BLAZE_BURNER.getDefaultState())
|
||||||
.atLocal(0, 1.65, 0)
|
.atLocal(0, 1.65, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
|
float offset = (MathHelper.sin(AnimationTickHolder.getRenderTime() / 16f) + 0.5f) / 16f;
|
||||||
PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel);
|
PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel);
|
||||||
GuiGameElement.of(blaze)
|
defaultBlockElement(blaze)
|
||||||
.atLocal(1, 1.65, 1)
|
.atLocal(1, 1.65 + offset, 1)
|
||||||
.rotate(0, 180, 0)
|
.rotate(0, 180, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
@ -41,13 +42,4 @@ public class AnimatedBlazeBurner implements IDrawable {
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWidth() {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHeight() {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.compat.jei.category.animations;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
|
|
||||||
public class AnimatedCrafter extends AnimatedKinetics {
|
public class AnimatedCrafter extends AnimatedKinetics {
|
||||||
|
@ -20,12 +19,12 @@ public class AnimatedCrafter extends AnimatedKinetics {
|
||||||
.rotateY(-22.5f);
|
.rotateY(-22.5f);
|
||||||
int scale = 22;
|
int scale = 22;
|
||||||
|
|
||||||
GuiGameElement.of(cogwheel())
|
defaultBlockElement(cogwheel())
|
||||||
.rotateBlock(90, 0, getCurrentAngle())
|
.rotateBlock(90, 0, getCurrentAngle())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.MECHANICAL_CRAFTER.getDefaultState())
|
defaultBlockElement(AllBlocks.MECHANICAL_CRAFTER.getDefaultState())
|
||||||
.rotateBlock(0, 180, 0)
|
.rotateBlock(0, 180, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.compat.jei.category.animations;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
@ -11,6 +10,9 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
public class AnimatedCrushingWheels extends AnimatedKinetics {
|
public class AnimatedCrushingWheels extends AnimatedKinetics {
|
||||||
|
|
||||||
|
private final BlockState wheel = AllBlocks.CRUSHING_WHEEL.getDefaultState()
|
||||||
|
.with(BlockStateProperties.AXIS, Axis.X);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
|
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
|
@ -18,16 +20,12 @@ public class AnimatedCrushingWheels extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-22.5f));
|
||||||
int scale = 22;
|
int scale = 22;
|
||||||
|
|
||||||
BlockState wheel = AllBlocks.CRUSHING_WHEEL.get()
|
defaultBlockElement(wheel)
|
||||||
.getDefaultState()
|
|
||||||
.with(BlockStateProperties.AXIS, Axis.X);
|
|
||||||
|
|
||||||
GuiGameElement.of(wheel)
|
|
||||||
.rotateBlock(0, 90, -getCurrentAngle())
|
.rotateBlock(0, 90, -getCurrentAngle())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(wheel)
|
defaultBlockElement(wheel)
|
||||||
.rotateBlock(0, 90, getCurrentAngle())
|
.rotateBlock(0, 90, getCurrentAngle())
|
||||||
.atLocal(2, 0, 0)
|
.atLocal(2, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
|
|
|
@ -4,12 +4,10 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.components.deployer.DeployerBlock;
|
import com.simibubi.create.content.contraptions.components.deployer.DeployerBlock;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
public class AnimatedDeployer extends AnimatedKinetics {
|
public class AnimatedDeployer extends AnimatedKinetics {
|
||||||
|
@ -22,12 +20,12 @@ public class AnimatedDeployer extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
||||||
int scale = 20;
|
int scale = 20;
|
||||||
|
|
||||||
GuiGameElement.of(shaft(Axis.Z))
|
defaultBlockElement(shaft(Axis.Z))
|
||||||
.rotateBlock(0, 0, getCurrentAngle())
|
.rotateBlock(0, 0, getCurrentAngle())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.DEPLOYER.getDefaultState()
|
defaultBlockElement(AllBlocks.DEPLOYER.getDefaultState()
|
||||||
.with(DeployerBlock.FACING, Direction.DOWN)
|
.with(DeployerBlock.FACING, Direction.DOWN)
|
||||||
.with(DeployerBlock.AXIS_ALONG_FIRST_COORDINATE, false))
|
.with(DeployerBlock.AXIS_ALONG_FIRST_COORDINATE, false))
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
|
@ -39,18 +37,18 @@ public class AnimatedDeployer extends AnimatedKinetics {
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
|
|
||||||
matrixStack.translate(0, offset * 17, 0);
|
matrixStack.translate(0, offset * 17, 0);
|
||||||
GuiGameElement.of(AllBlockPartials.DEPLOYER_POLE)
|
defaultBlockElement(AllBlockPartials.DEPLOYER_POLE)
|
||||||
.rotateBlock(90, 0, 0)
|
.rotateBlock(90, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
GuiGameElement.of(AllBlockPartials.DEPLOYER_HAND_HOLDING)
|
defaultBlockElement(AllBlockPartials.DEPLOYER_HAND_HOLDING)
|
||||||
.rotateBlock(90, 0, 0)
|
.rotateBlock(90, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.DEPOT.getDefaultState())
|
defaultBlockElement(AllBlocks.DEPOT.getDefaultState())
|
||||||
.atLocal(0, 2, 0)
|
.atLocal(0, 2, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.compat.jei.category.animations;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
|
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
|
||||||
|
@ -28,7 +27,7 @@ public class AnimatedItemDrain extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
||||||
int scale = 20;
|
int scale = 20;
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.ITEM_DRAIN.getDefaultState())
|
defaultBlockElement(AllBlocks.ITEM_DRAIN.getDefaultState())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ public class AnimatedItemDrain extends AnimatedKinetics {
|
||||||
ms.scale(scale, -scale, scale);
|
ms.scale(scale, -scale, scale);
|
||||||
float from = 2/16f;
|
float from = 2/16f;
|
||||||
float to = 1f - from;
|
float to = 1f - from;
|
||||||
FluidRenderer.renderTiledFluidBB(fluid, from, from, from, to, 3/4f, to, buffer, ms, 0xf000f0, false);
|
FluidRenderer.renderTiledFluidBB(fluid, from, from, from, to, 3/4f, to, buffer, ms, 0xF000F0, false);
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
|
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
|
|
|
@ -3,6 +3,9 @@ package com.simibubi.create.compat.jei.category.animations;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.foundation.gui.CustomLightingSettings;
|
||||||
|
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||||
|
import com.simibubi.create.foundation.gui.ILightingSettings;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
|
@ -12,8 +15,13 @@ import net.minecraft.util.Direction.Axis;
|
||||||
|
|
||||||
public abstract class AnimatedKinetics implements IDrawable {
|
public abstract class AnimatedKinetics implements IDrawable {
|
||||||
|
|
||||||
|
public static final ILightingSettings DEFAULT_LIGHTING = CustomLightingSettings.builder()
|
||||||
|
.firstLightRotation(12.5f, 45.0f)
|
||||||
|
.secondLightRotation(-20.0f, 50.0f)
|
||||||
|
.build();
|
||||||
|
|
||||||
public static float getCurrentAngle() {
|
public static float getCurrentAngle() {
|
||||||
return ((AnimationTickHolder.getRenderTime()) * 4f) % 360;
|
return (AnimationTickHolder.getRenderTime() * 4f) % 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BlockState shaft(Axis axis) {
|
protected BlockState shaft(Axis axis) {
|
||||||
|
@ -24,6 +32,16 @@ public abstract class AnimatedKinetics implements IDrawable {
|
||||||
return AllBlockPartials.SHAFTLESS_COGWHEEL;
|
return AllBlockPartials.SHAFTLESS_COGWHEEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected GuiGameElement.GuiRenderBuilder defaultBlockElement(BlockState state) {
|
||||||
|
return GuiGameElement.of(state)
|
||||||
|
.lighting(DEFAULT_LIGHTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected GuiGameElement.GuiRenderBuilder defaultBlockElement(PartialModel partial) {
|
||||||
|
return GuiGameElement.of(partial)
|
||||||
|
.lighting(DEFAULT_LIGHTING);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return 50;
|
return 50;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
|
|
||||||
public class AnimatedMillstone extends AnimatedKinetics {
|
public class AnimatedMillstone extends AnimatedKinetics {
|
||||||
|
|
||||||
|
@ -16,12 +15,12 @@ public class AnimatedMillstone extends AnimatedKinetics {
|
||||||
matrixStack.translate(-2, 18, 0);
|
matrixStack.translate(-2, 18, 0);
|
||||||
int scale = 22;
|
int scale = 22;
|
||||||
|
|
||||||
GuiGameElement.of(AllBlockPartials.MILLSTONE_COG)
|
defaultBlockElement(AllBlockPartials.MILLSTONE_COG)
|
||||||
.rotateBlock(22.5, getCurrentAngle() * 2, 0)
|
.rotateBlock(22.5, getCurrentAngle() * 2, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.MILLSTONE.getDefaultState())
|
defaultBlockElement(AllBlocks.MILLSTONE.getDefaultState())
|
||||||
.rotateBlock(22.5, 22.5, 0)
|
.rotateBlock(22.5, 22.5, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.compat.jei.category.animations;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -19,31 +18,31 @@ public class AnimatedMixer extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
||||||
int scale = 23;
|
int scale = 23;
|
||||||
|
|
||||||
GuiGameElement.of(cogwheel())
|
defaultBlockElement(cogwheel())
|
||||||
.rotateBlock(0, getCurrentAngle() * 2, 0)
|
.rotateBlock(0, getCurrentAngle() * 2, 0)
|
||||||
.atLocal(0, 0, 0)
|
.atLocal(0, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.MECHANICAL_MIXER.getDefaultState())
|
defaultBlockElement(AllBlocks.MECHANICAL_MIXER.getDefaultState())
|
||||||
.atLocal(0, 0, 0)
|
.atLocal(0, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
float animation = ((MathHelper.sin(AnimationTickHolder.getRenderTime() / 32f) + 1) / 5) + .5f;
|
float animation = ((MathHelper.sin(AnimationTickHolder.getRenderTime() / 32f) + 1) / 5) + .5f;
|
||||||
|
|
||||||
GuiGameElement.of(AllBlockPartials.MECHANICAL_MIXER_POLE)
|
defaultBlockElement(AllBlockPartials.MECHANICAL_MIXER_POLE)
|
||||||
.atLocal(0, animation, 0)
|
.atLocal(0, animation, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlockPartials.MECHANICAL_MIXER_HEAD)
|
defaultBlockElement(AllBlockPartials.MECHANICAL_MIXER_HEAD)
|
||||||
.rotateBlock(0, getCurrentAngle() * 4, 0)
|
.rotateBlock(0, getCurrentAngle() * 4, 0)
|
||||||
.atLocal(0, animation, 0)
|
.atLocal(0, animation, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.BASIN.getDefaultState())
|
defaultBlockElement(AllBlocks.BASIN.getDefaultState())
|
||||||
.atLocal(0, 1.65, 0)
|
.atLocal(0, 1.65, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.compat.jei.category.animations;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -25,22 +24,22 @@ public class AnimatedPress extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
||||||
int scale = basin ? 20 : 24;
|
int scale = basin ? 20 : 24;
|
||||||
|
|
||||||
GuiGameElement.of(shaft(Axis.Z))
|
defaultBlockElement(shaft(Axis.Z))
|
||||||
.rotateBlock(0, 0, getCurrentAngle())
|
.rotateBlock(0, 0, getCurrentAngle())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.MECHANICAL_PRESS.getDefaultState())
|
defaultBlockElement(AllBlocks.MECHANICAL_PRESS.getDefaultState())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlockPartials.MECHANICAL_PRESS_HEAD)
|
defaultBlockElement(AllBlockPartials.MECHANICAL_PRESS_HEAD)
|
||||||
.atLocal(0, -getAnimatedHeadOffset(), 0)
|
.atLocal(0, -getAnimatedHeadOffset(), 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
if (basin)
|
if (basin)
|
||||||
GuiGameElement.of(AllBlocks.BASIN.getDefaultState())
|
defaultBlockElement(AllBlocks.BASIN.getDefaultState())
|
||||||
.atLocal(0, 1.65, 0)
|
.atLocal(0, 1.65, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.components.saw.SawBlock;
|
import com.simibubi.create.content.contraptions.components.saw.SawBlock;
|
||||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -25,18 +24,18 @@ public class AnimatedSaw extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90 - 225f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90 - 225f));
|
||||||
int scale = 25;
|
int scale = 25;
|
||||||
|
|
||||||
GuiGameElement.of(shaft(Axis.X))
|
defaultBlockElement(shaft(Axis.X))
|
||||||
.rotateBlock(-getCurrentAngle(), 0, 0)
|
.rotateBlock(-getCurrentAngle(), 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.MECHANICAL_SAW.getDefaultState()
|
defaultBlockElement(AllBlocks.MECHANICAL_SAW.getDefaultState()
|
||||||
.with(SawBlock.FACING, Direction.UP))
|
.with(SawBlock.FACING, Direction.UP))
|
||||||
.rotateBlock(0, 0, 0)
|
.rotateBlock(0, 0, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
GuiGameElement.of(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE)
|
defaultBlockElement(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE)
|
||||||
.rotateBlock(0, -90, -90)
|
.rotateBlock(0, -90, -90)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
||||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
@ -33,7 +32,7 @@ public class AnimatedSpout extends AnimatedKinetics {
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
|
||||||
int scale = 20;
|
int scale = 20;
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.SPOUT.getDefaultState())
|
defaultBlockElement(AllBlocks.SPOUT.getDefaultState())
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
|
||||||
|
@ -43,22 +42,22 @@ public class AnimatedSpout extends AnimatedKinetics {
|
||||||
|
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
|
|
||||||
GuiGameElement.of(AllBlockPartials.SPOUT_TOP)
|
defaultBlockElement(AllBlockPartials.SPOUT_TOP)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
matrixStack.translate(0, -3 * squeeze / 32f, 0);
|
matrixStack.translate(0, -3 * squeeze / 32f, 0);
|
||||||
GuiGameElement.of(AllBlockPartials.SPOUT_MIDDLE)
|
defaultBlockElement(AllBlockPartials.SPOUT_MIDDLE)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
matrixStack.translate(0, -3 * squeeze / 32f, 0);
|
matrixStack.translate(0, -3 * squeeze / 32f, 0);
|
||||||
GuiGameElement.of(AllBlockPartials.SPOUT_BOTTOM)
|
defaultBlockElement(AllBlockPartials.SPOUT_BOTTOM)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
matrixStack.translate(0, -3 * squeeze / 32f, 0);
|
matrixStack.translate(0, -3 * squeeze / 32f, 0);
|
||||||
|
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
|
|
||||||
GuiGameElement.of(AllBlocks.DEPOT.getDefaultState())
|
defaultBlockElement(AllBlocks.DEPOT.getDefaultState())
|
||||||
.atLocal(0, 2, 0)
|
.atLocal(0, 2, 0)
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
.render(matrixStack);
|
.render(matrixStack);
|
||||||
|
@ -69,14 +68,14 @@ public class AnimatedSpout extends AnimatedKinetics {
|
||||||
matrixStack.scale(16, -16, 16);
|
matrixStack.scale(16, -16, 16);
|
||||||
float from = 2/16f;
|
float from = 2/16f;
|
||||||
float to = 1f - from;
|
float to = 1f - from;
|
||||||
FluidRenderer.renderTiledFluidBB(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, 0xf000f0, false);
|
FluidRenderer.renderTiledFluidBB(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, 0xF000F0, false);
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
|
|
||||||
float width = 1 / 128f * squeeze;
|
float width = 1 / 128f * squeeze;
|
||||||
matrixStack.translate(scale / 2f, scale * 1.5f, scale / 2f);
|
matrixStack.translate(scale / 2f, scale * 1.5f, scale / 2f);
|
||||||
matrixStack.scale(16, -16, 16);
|
matrixStack.scale(16, -16, 16);
|
||||||
matrixStack.translate(-width / 2, 0, -width / 2);
|
matrixStack.translate(-width / 2, 0, -width / 2);
|
||||||
FluidRenderer.renderTiledFluidBB(fluids.get(0), 0, -0.001f, 0, width, 2.001f, width, buffer, matrixStack, 0xf000f0,
|
FluidRenderer.renderTiledFluidBB(fluids.get(0), 0, -0.001f, 0, width, 2.001f, width, buffer, matrixStack, 0xF000F0,
|
||||||
false);
|
false);
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.simibubi.create.foundation.gui;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
|
public class CustomLightingSettings implements ILightingSettings {
|
||||||
|
|
||||||
|
private Vector3f light1;
|
||||||
|
private Vector3f light2;
|
||||||
|
private Matrix4f lightMatrix;
|
||||||
|
|
||||||
|
protected CustomLightingSettings(float yRot, float xRot) {
|
||||||
|
init(yRot, xRot, 0, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CustomLightingSettings(float yRot1, float xRot1, float yRot2, float xRot2) {
|
||||||
|
init(yRot1, xRot1, yRot2, xRot2, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init(float yRot1, float xRot1, float yRot2, float xRot2, boolean doubleLight) {
|
||||||
|
light1 = Vector3f.POSITIVE_Z.copy();
|
||||||
|
light1.func_214905_a(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot1));
|
||||||
|
light1.func_214905_a(Vector3f.POSITIVE_X.getDegreesQuaternion(xRot1));
|
||||||
|
|
||||||
|
if (doubleLight) {
|
||||||
|
light2 = Vector3f.POSITIVE_Z.copy();
|
||||||
|
light2.func_214905_a(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot2));
|
||||||
|
light2.func_214905_a(Vector3f.POSITIVE_X.getDegreesQuaternion(xRot2));
|
||||||
|
} else {
|
||||||
|
light2 = VecHelper.ZERO_3F;
|
||||||
|
}
|
||||||
|
|
||||||
|
lightMatrix = new Matrix4f();
|
||||||
|
lightMatrix.loadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyLighting() {
|
||||||
|
RenderSystem.setupLevelDiffuseLighting(light1, light2, lightMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private float yRot1, xRot1;
|
||||||
|
private float yRot2, xRot2;
|
||||||
|
private boolean doubleLight;
|
||||||
|
|
||||||
|
public Builder firstLightRotation(float yRot, float xRot) {
|
||||||
|
yRot1 = yRot;
|
||||||
|
xRot1 = xRot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder secondLightRotation(float yRot, float xRot) {
|
||||||
|
yRot2 = yRot;
|
||||||
|
xRot2 = xRot;
|
||||||
|
doubleLight = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder doubleLight() {
|
||||||
|
doubleLight = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomLightingSettings build() {
|
||||||
|
if (doubleLight) {
|
||||||
|
return new CustomLightingSettings(yRot1, xRot1, yRot2, xRot2);
|
||||||
|
} else {
|
||||||
|
return new CustomLightingSettings(yRot1, xRot1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -35,15 +35,12 @@ import net.minecraft.inventory.container.PlayerContainer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.IItemProvider;
|
import net.minecraft.util.IItemProvider;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector2f;
|
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
public class GuiGameElement {
|
public class GuiGameElement {
|
||||||
|
|
||||||
public static Vector2f defaultBlockLighting = new Vector2f(30.0f, 7.5f);
|
|
||||||
|
|
||||||
public static GuiRenderBuilder of(ItemStack stack) {
|
public static GuiRenderBuilder of(ItemStack stack) {
|
||||||
return new GuiItemRenderBuilder(stack);
|
return new GuiItemRenderBuilder(stack);
|
||||||
}
|
}
|
||||||
|
@ -72,8 +69,7 @@ public class GuiGameElement {
|
||||||
protected double scale = 1;
|
protected double scale = 1;
|
||||||
protected int color = 0xFFFFFF;
|
protected int color = 0xFFFFFF;
|
||||||
protected Vector3d rotationOffset = Vector3d.ZERO;
|
protected Vector3d rotationOffset = Vector3d.ZERO;
|
||||||
protected boolean hasCustomLighting = false;
|
protected ILightingSettings customLighting = null;
|
||||||
protected float lightingXRot, lightingYRot;
|
|
||||||
|
|
||||||
public GuiRenderBuilder atLocal(double x, double y, double z) {
|
public GuiRenderBuilder atLocal(double x, double y, double z) {
|
||||||
this.xLocal = x;
|
this.xLocal = x;
|
||||||
|
@ -109,15 +105,11 @@ public class GuiGameElement {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiRenderBuilder lighting(float xRot, float yRot) {
|
public GuiRenderBuilder lighting(ILightingSettings lighting) {
|
||||||
hasCustomLighting = true;
|
customLighting = lighting;
|
||||||
lightingXRot = xRot;
|
|
||||||
lightingYRot = yRot;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void render(MatrixStack matrixStack);
|
|
||||||
|
|
||||||
protected void prepareMatrix(MatrixStack matrixStack) {
|
protected void prepareMatrix(MatrixStack matrixStack) {
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
@ -150,10 +142,17 @@ public class GuiGameElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void prepareLighting(MatrixStack matrixStack) {
|
protected void prepareLighting(MatrixStack matrixStack) {
|
||||||
RenderHelper.enableGuiDepthLighting();
|
if (customLighting != null) {
|
||||||
|
customLighting.applyLighting();
|
||||||
|
} else {
|
||||||
|
RenderHelper.enableGuiDepthLighting();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanUpLighting(MatrixStack matrixStack) {
|
protected void cleanUpLighting(MatrixStack matrixStack) {
|
||||||
|
if (customLighting != null) {
|
||||||
|
RenderHelper.enableGuiDepthLighting();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,19 +199,6 @@ public class GuiGameElement {
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void prepareLighting(MatrixStack matrixStack) {
|
|
||||||
if (hasCustomLighting) {
|
|
||||||
UIRenderHelper.setupSimpleCustomLighting(lightingXRot, lightingYRot);
|
|
||||||
} else {
|
|
||||||
UIRenderHelper.setupSimpleCustomLighting(defaultBlockLighting.x, defaultBlockLighting.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void cleanUpLighting(MatrixStack matrixStack) {
|
|
||||||
RenderHelper.enableGuiDepthLighting();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GuiBlockStateRenderBuilder extends GuiBlockModelRenderBuilder {
|
public static class GuiBlockStateRenderBuilder extends GuiBlockModelRenderBuilder {
|
||||||
|
@ -244,7 +230,7 @@ public class GuiGameElement {
|
||||||
ms.push();
|
ms.push();
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState()
|
FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState()
|
||||||
.getFluid(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, 0xf000f0, true);
|
.getFluid(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, 0xF000F0, true);
|
||||||
buffer.draw(RenderType.getTranslucent());
|
buffer.draw(RenderType.getTranslucent());
|
||||||
RenderHelper.enable();
|
RenderHelper.enable();
|
||||||
ms.pop();
|
ms.pop();
|
||||||
|
@ -275,43 +261,42 @@ public class GuiGameElement {
|
||||||
public void render(MatrixStack matrixStack) {
|
public void render(MatrixStack matrixStack) {
|
||||||
prepareMatrix(matrixStack);
|
prepareMatrix(matrixStack);
|
||||||
transformMatrix(matrixStack);
|
transformMatrix(matrixStack);
|
||||||
renderItemIntoGUI(matrixStack, stack);
|
renderItemIntoGUI(matrixStack, stack, customLighting == null);
|
||||||
cleanUpMatrix(matrixStack);
|
cleanUpMatrix(matrixStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderItemIntoGUI(MatrixStack matrixStack, ItemStack stack) {
|
public static void renderItemIntoGUI(MatrixStack matrixStack, ItemStack stack, boolean useDefaultLighting) {
|
||||||
ItemRenderer renderer = Minecraft.getInstance()
|
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
||||||
.getItemRenderer();
|
|
||||||
IBakedModel bakedModel = renderer.getItemModelWithOverrides(stack, null, null);
|
IBakedModel bakedModel = renderer.getItemModelWithOverrides(stack, null, null);
|
||||||
|
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
renderer.textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
renderer.textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||||
renderer.textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
|
renderer.textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).setBlurMipmapDirect(false, false);
|
||||||
.setBlurMipmapDirect(false, false);
|
|
||||||
RenderSystem.enableRescaleNormal();
|
RenderSystem.enableRescaleNormal();
|
||||||
RenderSystem.enableAlphaTest();
|
RenderSystem.enableAlphaTest();
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
RenderSystem.defaultAlphaFunc();
|
RenderSystem.defaultAlphaFunc();
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
matrixStack.translate((float) 0, (float) 0, 100.0F + renderer.zLevel);
|
matrixStack.translate(0, 0, 100.0F + renderer.zLevel);
|
||||||
matrixStack.translate(8.0F, -8.0F, 0.0F);
|
matrixStack.translate(8.0F, -8.0F, 0.0F);
|
||||||
matrixStack.scale(16.0F, 16.0F, 16.0F);
|
matrixStack.scale(16.0F, 16.0F, 16.0F);
|
||||||
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance()
|
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
||||||
.getBufferBuilders()
|
|
||||||
.getEntityVertexConsumers();
|
|
||||||
boolean flatLighting = !bakedModel.isSideLit();
|
boolean flatLighting = !bakedModel.isSideLit();
|
||||||
if (flatLighting) {
|
if (useDefaultLighting) {
|
||||||
RenderHelper.disableGuiDepthLighting();
|
if (flatLighting) {
|
||||||
|
RenderHelper.disableGuiDepthLighting();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.renderItem(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack,
|
renderer.renderItem(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, bakedModel);
|
||||||
buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, bakedModel);
|
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
if (flatLighting) {
|
if (useDefaultLighting) {
|
||||||
RenderHelper.enableGuiDepthLighting();
|
if (flatLighting) {
|
||||||
|
RenderHelper.enableGuiDepthLighting();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.disableAlphaTest();
|
RenderSystem.disableAlphaTest();
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.simibubi.create.foundation.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
|
||||||
|
public interface ILightingSettings {
|
||||||
|
|
||||||
|
void applyLighting();
|
||||||
|
|
||||||
|
static final ILightingSettings DEFAULT_3D = () -> RenderHelper.enableGuiDepthLighting();
|
||||||
|
static final ILightingSettings DEFAULT_FLAT = () -> RenderHelper.disableGuiDepthLighting();
|
||||||
|
|
||||||
|
}
|
|
@ -10,12 +10,14 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
public interface IScreenRenderable {
|
public interface IScreenRenderable {
|
||||||
|
|
||||||
|
Screen EMPTY_SCREEN = new Screen(new StringTextComponent("")) {};
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
void draw(MatrixStack ms, AbstractGui screen, int x, int y);
|
void draw(MatrixStack ms, AbstractGui screen, int x, int y);
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
default void draw(MatrixStack ms, int x, int y) {
|
default void draw(MatrixStack ms, int x, int y) {
|
||||||
draw(ms, new Screen(new StringTextComponent("")) {
|
draw(ms, EMPTY_SCREEN, x, y);
|
||||||
}, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.simibubi.create.foundation.gui;
|
package com.simibubi.create.foundation.gui;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
import com.simibubi.create.foundation.utility.Couple;
|
import com.simibubi.create.foundation.utility.Couple;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
|
||||||
|
|
||||||
import net.minecraft.client.MainWindow;
|
import net.minecraft.client.MainWindow;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -269,13 +268,4 @@ public class UIRenderHelper {
|
||||||
WorldVertexBufferUploader.draw(bufferbuilder);
|
WorldVertexBufferUploader.draw(bufferbuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setupSimpleCustomLighting(float xRot, float yRot) {
|
|
||||||
Matrix4f lightingMatrix = new Matrix4f();
|
|
||||||
lightingMatrix.loadIdentity();
|
|
||||||
lightingMatrix.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot));
|
|
||||||
lightingMatrix.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(xRot));
|
|
||||||
lightingMatrix.multiply(Matrix4f.translate(0, 0, 1));
|
|
||||||
RenderSystem.setupLevelDiffuseLighting(VecHelper.ZERO_3F, VecHelper.ZERO_3F, lightingMatrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue