mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 00:03:41 +01:00
Better game element rendering in GUIs
- Fixed uv issues with connected textures - Fixed chromatic scope not showing on blockzappers - Refactored game element rendering in user interfaces, such as JEI screens
This commit is contained in:
parent
e69af69b0a
commit
20ab49e46e
29 changed files with 543 additions and 602 deletions
|
@ -2,11 +2,9 @@ package com.simibubi.create.compat.jei.category;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FlowingFluidBlock;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.AbstractCookingRecipe;
|
||||
|
||||
|
@ -23,28 +21,12 @@ public class BlastingViaFanCategory extends ProcessingViaFanCategory<AbstractCoo
|
|||
|
||||
@Override
|
||||
public void renderAttachedBlock() {
|
||||
BlockState state = Blocks.LAVA.getDefaultState().with(FlowingFluidBlock.LEVEL, 8);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 0, 200);
|
||||
RenderSystem.enableRescaleNormal();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 200, 0);
|
||||
RenderSystem.rotatef(90, 1, 0, 0);
|
||||
ScreenElementRenderer.renderBlock(() -> state);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 200, 0);
|
||||
RenderSystem.rotatef(90, 1, 0, 0);
|
||||
RenderSystem.rotatef(270, 0, 0, 1);
|
||||
ScreenElementRenderer.renderBlock(() -> state);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(-103, -100, 0);
|
||||
ScreenElementRenderer.renderBlock(() -> state);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(Fluids.LAVA)
|
||||
.scale(24)
|
||||
.atLocal(0, 0, 2)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
|
|
@ -66,8 +66,7 @@ public class BlockCuttingCategory extends CreateRecipeCategory<CondensedBlockCut
|
|||
ScreenResources.JEI_SLOT.draw(77 + xOffset, 47 + yOffset);
|
||||
}
|
||||
ScreenResources.JEI_DOWN_ARROW.draw(31, 6);
|
||||
ScreenResources.JEI_SHADOW.draw(19, 55);
|
||||
saw.draw(33, 35);
|
||||
saw.draw(33, 37);
|
||||
}
|
||||
|
||||
public static class CondensedBlockCuttingRecipe extends StonecuttingRecipe {
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.stream.Collectors;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.compat.jei.ScreenResourceWrapper;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperUpgradeRecipe;
|
||||
|
||||
|
@ -80,18 +80,17 @@ public class BlockzapperUpgradeCategory extends CreateRecipeCategory<Blockzapper
|
|||
public void draw(BlockzapperUpgradeRecipe recipe, double mouseX, double mouseY) {
|
||||
FontRenderer font = Minecraft.getInstance().fontRenderer;
|
||||
String componentName =
|
||||
Lang.translate("blockzapper.component." + Lang.asId(recipe.getUpgradedComponent().name()));
|
||||
Lang.translate("blockzapper.component." + Lang.asId(recipe.getUpgradedComponent().name()));
|
||||
String text = "+ " + recipe.getTier().color + componentName;
|
||||
font.drawStringWithShadow(text, (BLOCKZAPPER_UPGRADE_RECIPE.width - font.getStringWidth(text)) / 2, 57,
|
||||
0x8B8B8B);
|
||||
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(126, 0, 0);
|
||||
RenderSystem.scaled(3.5, 3.5, 3.5);
|
||||
RenderSystem.translated(-10, 0, 0);
|
||||
RenderSystem.color3f(1, 1, 1);
|
||||
RenderSystem.enableDepthTest();
|
||||
ScreenElementRenderer.render3DItem(() -> recipe.getRecipeOutput());
|
||||
GuiGameElement.of(recipe.getRecipeOutput()).render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
|
@ -63,7 +63,7 @@ public class CrushingCategory extends CreateRecipeCategory<AbstractCrushingRecip
|
|||
for (int outputIndex = 0; outputIndex < results.size(); outputIndex++)
|
||||
getRenderedSlot(recipe, outputIndex).draw(getBackground().getWidth() / 2 + offset + 19 * outputIndex, 78);
|
||||
|
||||
crushingWheels.draw(92, 49);
|
||||
crushingWheels.draw(62, 59);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -168,11 +168,10 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<ShapedRecip
|
|||
|
||||
ScreenResources.JEI_SLOT.draw(133, 80);
|
||||
ScreenResources.JEI_DOWN_ARROW.draw(128, 59);
|
||||
ScreenResources.JEI_SHADOW.draw(116, 36);
|
||||
crafter.draw(219, 8);
|
||||
crafter.draw(129, 25);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 0, 200);
|
||||
RenderSystem.translated(0, 0, 300);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
int amount = 0;
|
||||
|
|
|
@ -58,11 +58,9 @@ public class MillingCategory extends CreateRecipeCategory<AbstractCrushingRecipe
|
|||
int size = recipe.getPossibleOutputs().size();
|
||||
|
||||
ScreenResources.JEI_SLOT.draw(14, 8);
|
||||
ScreenResources.JEI_SHADOW.draw(30, 40);
|
||||
ScreenResources.JEI_ARROW.draw(85, 32);
|
||||
ScreenResources.JEI_DOWN_ARROW.draw(43, 4);
|
||||
|
||||
millstone.draw(57, 27);
|
||||
millstone.draw(48, 27);
|
||||
|
||||
if (size == 1) {
|
||||
getRenderedSlot(recipe, 0).draw(139, 27);
|
||||
|
|
|
@ -103,7 +103,7 @@ public class MixingCategory extends CreateRecipeCategory<MixingRecipe> {
|
|||
ScreenResources.JEI_SLOT.draw(141, 50);
|
||||
ScreenResources.JEI_DOWN_ARROW.draw(136, 32);
|
||||
ScreenResources.JEI_SHADOW.draw(81, 57);
|
||||
mixer.draw(getBackground().getWidth() / 2 + 20, 8);
|
||||
mixer.draw(getBackground().getWidth() / 2 + 3, 25);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class PackingCategory extends CreateRecipeCategory<IRecipe<?>> {
|
|||
ScreenResources.JEI_SLOT.draw(141, 50);
|
||||
ScreenResources.JEI_DOWN_ARROW.draw(136, 32);
|
||||
ScreenResources.JEI_SHADOW.draw(81, 57);
|
||||
press.draw(getBackground().getWidth() / 2 + 20, 8);
|
||||
press.draw(getBackground().getWidth() / 2 + 6, 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PressingCategory extends CreateRecipeCategory<PressingRecipe> {
|
|||
getRenderedSlot(recipe, 1).draw(131 + 19, 50);
|
||||
ScreenResources.JEI_SHADOW.draw(61, 41);
|
||||
ScreenResources.JEI_LONG_ARROW.draw(52, 54);
|
||||
press.draw(getBackground().getWidth() / 2, 8);
|
||||
press.draw(getBackground().getWidth() / 2 - 17, 22);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,18 +7,14 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends CreateRecipeCategory<T> {
|
||||
|
||||
|
@ -53,47 +49,29 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
|
|||
@Override
|
||||
public void draw(T recipe, double mouseX, double mouseY) {
|
||||
renderWidgets(recipe, mouseX, mouseY);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.color3f(1, 1, 1);
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
RenderSystem.translatef(56, 33, 0);
|
||||
RenderSystem.rotatef(-12.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(22.5f, 0, 1, 0);
|
||||
int scale = 24;
|
||||
|
||||
RenderSystem.translated(28, 18, 0);
|
||||
RenderSystem.rotatef(10.5f, -1f, 0, 0);
|
||||
RenderSystem.rotatef(15.5f, 0, 1, 0);
|
||||
RenderSystem.scaled(.6f, .6f, .6f);
|
||||
ScreenElementRenderer.renderBlock(this::renderFanCasing);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
float angle = AnimatedKinetics.getCurrentAngle() * 12;
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, t);
|
||||
RenderSystem.rotatef(angle, 0, 0, 1);
|
||||
RenderSystem.translatef(-t, t, -t);
|
||||
|
||||
RenderSystem.translatef(t, 0, 175);
|
||||
RenderSystem.rotatef(90, 0, 1, 0);
|
||||
RenderSystem.translatef(-t, 0, -175);
|
||||
|
||||
ScreenElementRenderer.renderModel(this::renderFanInner);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER)
|
||||
.rotateBlock(180, 0, AnimatedKinetics.getCurrentAngle() * 16)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.translated(-10, 0, 95);
|
||||
RenderSystem.rotatef(7, 0, 1, 0);
|
||||
GuiGameElement.of(AllBlocks.ENCASED_FAN.getDefault())
|
||||
.rotateBlock(0, 180, 0)
|
||||
.atLocal(0, 0, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
renderAttachedBlock();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
}
|
||||
|
||||
protected BlockState renderFanCasing() {
|
||||
return AllBlocks.ENCASED_FAN.get().getDefaultState().with(BlockStateProperties.FACING, Direction.WEST);
|
||||
}
|
||||
|
||||
protected IBakedModel renderFanInner() {
|
||||
return AllBlockPartials.ENCASED_FAN_INNER.get();
|
||||
}
|
||||
|
||||
public abstract void renderAttachedBlock();
|
||||
|
||||
}
|
||||
|
|
|
@ -62,8 +62,7 @@ public class SawingCategory extends CreateRecipeCategory<CuttingRecipe> {
|
|||
getRenderedSlot(recipe, i).draw(117 + xOffset, 47 + yOffset);
|
||||
}
|
||||
ScreenResources.JEI_DOWN_ARROW.draw(70, 6);
|
||||
ScreenResources.JEI_SHADOW.draw(58, 55);
|
||||
saw.draw(72, 35);
|
||||
saw.draw(72, 42);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.compat.jei.category;
|
||||
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Items;
|
||||
|
@ -20,6 +20,11 @@ public class SmokingViaFanCategory extends ProcessingViaFanCategory<SmokingRecip
|
|||
|
||||
@Override
|
||||
public void renderAttachedBlock() {
|
||||
ScreenElementRenderer.renderBlock(() -> Blocks.FIRE.getDefaultState());
|
||||
|
||||
GuiGameElement.of(Blocks.FIRE.getDefaultState())
|
||||
.scale(24)
|
||||
.atLocal(0, 0, 2)
|
||||
.render();
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.modules.contraptions.components.fan.SplashingRecipe;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingOutput;
|
||||
|
||||
|
@ -14,9 +14,7 @@ import mezz.jei.api.constants.VanillaTypes;
|
|||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FlowingFluidBlock;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Items;
|
||||
|
||||
public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe> {
|
||||
|
@ -40,7 +38,9 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
|
|||
public void setRecipe(IRecipeLayout recipeLayout, SplashingRecipe recipe, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, true, 20, 47);
|
||||
itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks()));
|
||||
itemStacks.set(0, Arrays.asList(recipe.getIngredients()
|
||||
.get(0)
|
||||
.getMatchingStacks()));
|
||||
|
||||
List<ProcessingOutput> results = recipe.getRollableResults();
|
||||
boolean single = results.size() == 1;
|
||||
|
@ -49,7 +49,8 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
|
|||
int yOffset = (outputIndex / 2) * -19;
|
||||
|
||||
itemStacks.init(outputIndex + 1, false, single ? 139 : 133 + xOffset, 47 + yOffset);
|
||||
itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack());
|
||||
itemStacks.set(outputIndex + 1, results.get(outputIndex)
|
||||
.getStack());
|
||||
}
|
||||
|
||||
addStochasticTooltip(itemStacks, results);
|
||||
|
@ -57,7 +58,8 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
|
|||
|
||||
@Override
|
||||
protected void renderWidgets(SplashingRecipe recipe, double mouseX, double mouseY) {
|
||||
int size = recipe.getPossibleOutputs().size();
|
||||
int size = recipe.getPossibleOutputs()
|
||||
.size();
|
||||
|
||||
ScreenResources.JEI_SLOT.draw(20, 47);
|
||||
ScreenResources.JEI_SHADOW.draw(47, 29);
|
||||
|
@ -78,27 +80,12 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
|
|||
|
||||
@Override
|
||||
public void renderAttachedBlock() {
|
||||
BlockState state = Blocks.WATER.getDefaultState().with(FlowingFluidBlock.LEVEL, 8);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 0, 200);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 200, 0);
|
||||
RenderSystem.rotatef(90, 1, 0, 0);
|
||||
ScreenElementRenderer.renderBlock(() -> state);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(0, 200, 0);
|
||||
RenderSystem.rotatef(90, 1, 0, 0);
|
||||
RenderSystem.rotatef(270, 0, 0, 1);
|
||||
ScreenElementRenderer.renderBlock(() -> state);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(-103, -100, 0);
|
||||
ScreenElementRenderer.renderBlock(() -> state);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(Fluids.WATER)
|
||||
.scale(24)
|
||||
.atLocal(0, 0, 2)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
|
|
@ -1,57 +1,34 @@
|
|||
package com.simibubi.create.compat.jei.category.animations;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.modules.contraptions.components.crafter.MechanicalCrafterBlock;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
public class AnimatedCrafter extends AnimatedKinetics {
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int xOffset, int yOffset) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.rotatef(-15.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(-22.5f, 0, 1, 0);
|
||||
RenderSystem.translatef(xOffset, yOffset, 0);
|
||||
RenderSystem.translatef(-45, -5, 0);
|
||||
RenderSystem.scaled(.45f, .45f, .45f);
|
||||
ScreenResources.JEI_SHADOW.draw(-16, 13);
|
||||
|
||||
RenderSystem.translatef(3, 16, 0);
|
||||
RenderSystem.rotatef(-12.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(-22.5f, 0, 1, 0);
|
||||
int scale = 22;
|
||||
|
||||
ScreenElementRenderer.renderModel(() -> cogwheel(true));
|
||||
ScreenElementRenderer.renderBlock(this::body);
|
||||
GuiGameElement.of(cogwheel())
|
||||
.rotateBlock(90, 0, getCurrentAngle())
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
GuiGameElement.of(AllBlocks.MECHANICAL_CRAFTER.getDefault())
|
||||
.rotateBlock(0, 180, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
private IBakedModel cogwheel(boolean forward) {
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, -t);
|
||||
RenderSystem.rotatef(getCurrentAngle() * 2 * (forward ? 1 : -1), 0, 0, 1);
|
||||
RenderSystem.rotatef(90, 1, 0, 0);
|
||||
RenderSystem.translatef(-t, t, t);
|
||||
return AllBlockPartials.SHAFTLESS_COGWHEEL.get();
|
||||
}
|
||||
|
||||
private BlockState body() {
|
||||
return AllBlocks.MECHANICAL_CRAFTER
|
||||
.get()
|
||||
.getDefaultState()
|
||||
.with(MechanicalCrafterBlock.HORIZONTAL_FACING, Direction.WEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.compat.jei.category.animations;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
|
@ -10,49 +10,27 @@ import net.minecraft.util.Direction.Axis;
|
|||
|
||||
public class AnimatedCrushingWheels extends AnimatedKinetics {
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int xOffset, int yOffset) {
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.translatef(xOffset, yOffset, 0);
|
||||
RenderSystem.translatef(-45, 10, 0);
|
||||
RenderSystem.rotatef(22.5f, 0, 1, 0);
|
||||
RenderSystem.scaled(.45f, .45f, .45f);
|
||||
ScreenElementRenderer.renderBlock(this::leftWheel);
|
||||
ScreenElementRenderer.renderBlock(this::rightWheel);
|
||||
}
|
||||
RenderSystem.translatef(xOffset, yOffset, 300);
|
||||
RenderSystem.rotatef(-22.5f, 0, 1, 0);
|
||||
int scale = 22;
|
||||
|
||||
BlockState wheel = AllBlocks.CRUSHING_WHEEL.get()
|
||||
.getDefaultState()
|
||||
.with(BlockStateProperties.AXIS, Axis.X);
|
||||
|
||||
private BlockState leftWheel() {
|
||||
float angle = getCurrentAngle();
|
||||
RenderSystem.translatef(-50, 0, 0);
|
||||
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, t);
|
||||
RenderSystem.rotatef(angle, 0, 0, 1);
|
||||
RenderSystem.translatef(-t, t, -t);
|
||||
|
||||
return AllBlocks.CRUSHING_WHEEL.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X);
|
||||
}
|
||||
GuiGameElement.of(wheel)
|
||||
.rotateBlock(0, 90, -getCurrentAngle())
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
private BlockState rightWheel() {
|
||||
float angle = -getCurrentAngle();
|
||||
RenderSystem.translatef(50, 0, 0);
|
||||
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, t);
|
||||
RenderSystem.rotatef(angle, 0, 0, 1);
|
||||
RenderSystem.translatef(-t, t, -t);
|
||||
|
||||
return AllBlocks.CRUSHING_WHEEL.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X);
|
||||
GuiGameElement.of(wheel)
|
||||
.rotateBlock(0, 90, getCurrentAngle())
|
||||
.atLocal(2, 0, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.compat.jei.category.animations;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocksNew;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
|
@ -18,5 +19,19 @@ public abstract class AnimatedKinetics implements IDrawable {
|
|||
protected BlockState shaft(Axis axis) {
|
||||
return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, axis);
|
||||
}
|
||||
|
||||
protected AllBlockPartials cogwheel() {
|
||||
return AllBlockPartials.SHAFTLESS_COGWHEEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,53 +3,30 @@ package com.simibubi.create.compat.jei.category.animations;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
public class AnimatedMillstone extends AnimatedKinetics {
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int xOffset, int yOffset) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.translatef(xOffset, yOffset, 0);
|
||||
RenderSystem.rotatef(-15.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(22.5f, 0, 1, 0);
|
||||
RenderSystem.translatef(-45, -5, 0);
|
||||
RenderSystem.scaled(.45f, .45f, .45f);
|
||||
ScreenResources.JEI_SHADOW.draw(-16, 13);
|
||||
RenderSystem.translatef(-2, 18, 0);
|
||||
int scale = 22;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderModel(this::cogwheel);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::body);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlockPartials.MILLSTONE_COG)
|
||||
.rotateBlock(22.5, getCurrentAngle() * 2, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
GuiGameElement.of(AllBlocks.MILLSTONE.getDefault())
|
||||
.rotateBlock(22.5, 22.5, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
private IBakedModel cogwheel() {
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, -t);
|
||||
RenderSystem.rotatef(getCurrentAngle() * 2, 0, 1, 0);
|
||||
RenderSystem.translatef(-t, t, t);
|
||||
return AllBlockPartials.MILLSTONE_COG.get();
|
||||
}
|
||||
|
||||
private BlockState body() {
|
||||
return AllBlocks.MILLSTONE.get().getDefaultState();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,84 +3,46 @@ package com.simibubi.create.compat.jei.category.animations;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
public class AnimatedMixer extends AnimatedKinetics {
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int xOffset, int yOffset) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.translatef(xOffset, yOffset, 0);
|
||||
RenderSystem.translatef(xOffset, yOffset, 200);
|
||||
RenderSystem.rotatef(-15.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(22.5f, 0, 1, 0);
|
||||
RenderSystem.translatef(-45, -5, 0);
|
||||
RenderSystem.scaled(.45f, .45f, .45f);
|
||||
int scale = 23;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderModel(this::cogwheel);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(cogwheel())
|
||||
.rotateBlock(0, getCurrentAngle() * 2, 0)
|
||||
.atLocal(0, 0, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::body);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlocks.MECHANICAL_MIXER.getDefault())
|
||||
.atLocal(0, 0, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderModel(this::pole);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlockPartials.MECHANICAL_MIXER_POLE)
|
||||
.atLocal(0, 1, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderModel(this::head);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlockPartials.MECHANICAL_MIXER_HEAD)
|
||||
.rotateBlock(0, getCurrentAngle() * 4, 0)
|
||||
.atLocal(0, 1, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::basin);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlocks.BASIN.getDefault())
|
||||
.atLocal(0, 1.65, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
private IBakedModel cogwheel() {
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, -t);
|
||||
RenderSystem.rotatef(getCurrentAngle() * 2, 0, 1, 0);
|
||||
RenderSystem.translatef(-t, t, t);
|
||||
return AllBlockPartials.SHAFTLESS_COGWHEEL.get();
|
||||
}
|
||||
|
||||
private BlockState body() {
|
||||
return AllBlocks.MECHANICAL_MIXER.get().getDefaultState();
|
||||
}
|
||||
|
||||
private IBakedModel pole() {
|
||||
RenderSystem.translatef(0, 51, 0);
|
||||
return AllBlockPartials.MECHANICAL_MIXER_POLE.get();
|
||||
}
|
||||
|
||||
private IBakedModel head() {
|
||||
float t = 25;
|
||||
RenderSystem.translatef(0, 51, 0);
|
||||
RenderSystem.translatef(t, -t, -t);
|
||||
RenderSystem.rotatef(getCurrentAngle() * 4, 0, 1, 0);
|
||||
RenderSystem.translatef(-t, t, t);
|
||||
return AllBlockPartials.MECHANICAL_MIXER_HEAD.get();
|
||||
}
|
||||
|
||||
private BlockState basin() {
|
||||
RenderSystem.translatef(0, 85, 0);
|
||||
return AllBlocks.BASIN.get().getDefaultState();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,9 @@ import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllBlocksNew;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
||||
public class AnimatedPress extends AnimatedKinetics {
|
||||
|
@ -23,80 +18,49 @@ public class AnimatedPress extends AnimatedKinetics {
|
|||
this.basin = basin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int xOffset, int yOffset) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.translatef(xOffset, yOffset, 0);
|
||||
RenderSystem.translatef(xOffset, yOffset, 100);
|
||||
RenderSystem.rotatef(-15.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(22.5f, 0, 1, 0);
|
||||
RenderSystem.translatef(-45, -5, 0);
|
||||
RenderSystem.scaled(.45f, .45f, .45f);
|
||||
int scale = basin ? 20 : 24;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::shaft);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(shaft(Axis.Z))
|
||||
.rotateBlock(0, 0, getCurrentAngle())
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::body);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlocks.MECHANICAL_PRESS.getDefault())
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderModel(this::head);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlockPartials.MECHANICAL_PRESS_HEAD)
|
||||
.atLocal(0, -getAnimatedHeadOffset(), 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
if (basin) {
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::basin);
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
if (basin)
|
||||
GuiGameElement.of(AllBlocks.BASIN.getDefault())
|
||||
.atLocal(0, 1.65, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
private BlockState shaft() {
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, -t);
|
||||
RenderSystem.rotatef(getCurrentAngle() * 2, 1, 0, 0);
|
||||
RenderSystem.translatef(-t, t, t);
|
||||
return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, Axis.Z);
|
||||
}
|
||||
|
||||
private BlockState body() {
|
||||
return AllBlocks.MECHANICAL_PRESS.get().getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING,
|
||||
Direction.SOUTH);
|
||||
}
|
||||
|
||||
private IBakedModel head() {
|
||||
float cycle = (ticks + Minecraft.getInstance().getRenderPartialTicks()) % 30;
|
||||
float verticalOffset = 0;
|
||||
private float getAnimatedHeadOffset() {
|
||||
float cycle = (ticks + Minecraft.getInstance()
|
||||
.getRenderPartialTicks()) % 30;
|
||||
if (cycle < 10) {
|
||||
float progress = cycle / 10;
|
||||
verticalOffset = -(progress * progress * progress);
|
||||
} else if (cycle < 15) {
|
||||
verticalOffset = -1;
|
||||
} else if (cycle < 20) {
|
||||
verticalOffset = -1 + (1 - ((20 - cycle) / 5));
|
||||
} else {
|
||||
verticalOffset = 0;
|
||||
return -(progress * progress * progress);
|
||||
}
|
||||
RenderSystem.translated(0, -verticalOffset * 50, 0);
|
||||
return AllBlockPartials.MECHANICAL_PRESS_HEAD.get();
|
||||
}
|
||||
|
||||
private BlockState basin() {
|
||||
RenderSystem.translatef(0, 85, 0);
|
||||
return AllBlocks.BASIN.get().getDefaultState();
|
||||
if (cycle < 15)
|
||||
return -1;
|
||||
if (cycle < 20)
|
||||
return -1 + (1 - ((20 - cycle) / 5));
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,58 +2,40 @@ package com.simibubi.create.compat.jei.category.animations;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.modules.contraptions.components.saw.SawBlock;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
||||
public class AnimatedSaw extends AnimatedKinetics {
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int xOffset, int yOffset) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.translatef(xOffset, yOffset, 0);
|
||||
RenderSystem.rotatef(-15.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(22.5f, 0, 1, 0);
|
||||
RenderSystem.translatef(-45, -5, 0);
|
||||
RenderSystem.scaled(.6f, .6f, .6f);
|
||||
ScreenResources.JEI_SHADOW.draw(-16, 13);
|
||||
|
||||
RenderSystem.translatef(0, 0, 200);
|
||||
RenderSystem.translatef(-6, 19, 0);
|
||||
RenderSystem.rotatef(-22.5f, 1, 0, 0);
|
||||
RenderSystem.rotatef(90 - 22.5f, 0, 1, 0);
|
||||
int scale = 25;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::shaft);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(shaft(Axis.X))
|
||||
.rotateBlock(-getCurrentAngle(), 0, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
ScreenElementRenderer.renderBlock(this::block);
|
||||
RenderSystem.popMatrix();
|
||||
GuiGameElement.of(AllBlocks.SAW.getDefault()
|
||||
.with(SawBlock.FACING, Direction.UP)
|
||||
.with(SawBlock.RUNNING, true))
|
||||
.rotateBlock(0, 0, 0)
|
||||
.scale(scale)
|
||||
.render();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
private BlockState shaft() {
|
||||
float t = 25;
|
||||
RenderSystem.translatef(t, -t, t);
|
||||
RenderSystem.rotatef(-getCurrentAngle() * 2, 0, 0, 1);
|
||||
RenderSystem.translatef(-t, t, -t);
|
||||
return shaft(Axis.X);
|
||||
}
|
||||
|
||||
private BlockState block() {
|
||||
return AllBlocks.SAW.get().getDefaultState().with(BlockStateProperties.FACING, Direction.UP)
|
||||
.with(SawBlock.RUNNING, true).with(SawBlock.AXIS_ALONG_FIRST_COORDINATE, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class CTModel extends BakedModelWrapper<IBakedModel> {
|
|||
int[] vertexData = newQuad.getVertexData();
|
||||
|
||||
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
||||
int uvOffset = 20 / 4; // TODO 1.15 is this the right offset?
|
||||
int uvOffset = 16 / 4;
|
||||
int uIndex = vertex + uvOffset;
|
||||
int vIndex = vertex + uvOffset + 1;
|
||||
float u = Float.intBitsToFloat(vertexData[uIndex]);
|
||||
|
|
|
@ -0,0 +1,251 @@
|
|||
package com.simibubi.create.foundation.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FireBlock;
|
||||
import net.minecraft.block.FlowingFluidBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
public class GuiGameElement {
|
||||
|
||||
public static GuiRenderBuilder of(ItemStack stack) {
|
||||
return new GuiItemRenderBuilder(stack);
|
||||
}
|
||||
|
||||
public static GuiRenderBuilder of(IItemProvider itemProvider) {
|
||||
return new GuiItemRenderBuilder(itemProvider);
|
||||
}
|
||||
|
||||
public static GuiRenderBuilder of(BlockState state) {
|
||||
return new GuiBlockStateRenderBuilder(state);
|
||||
}
|
||||
|
||||
public static GuiRenderBuilder of(AllBlockPartials partial) {
|
||||
return new GuiBlockPartialRenderBuilder(partial);
|
||||
}
|
||||
|
||||
public static GuiRenderBuilder of(Fluid fluid) {
|
||||
return new GuiBlockStateRenderBuilder(fluid.getDefaultState()
|
||||
.getBlockState()
|
||||
.with(FlowingFluidBlock.LEVEL, 5));
|
||||
}
|
||||
|
||||
public static abstract class GuiRenderBuilder {
|
||||
double xBeforeScale, yBeforeScale;
|
||||
double x, y, z;
|
||||
double xRot, yRot, zRot;
|
||||
double scale = 1;
|
||||
int color = 0xFFFFFF;
|
||||
Vec3d rotationOffset = Vec3d.ZERO;
|
||||
|
||||
public GuiRenderBuilder atLocal(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiRenderBuilder at(double x, double y) {
|
||||
this.xBeforeScale = x;
|
||||
this.yBeforeScale = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiRenderBuilder rotate(double xRot, double yRot, double zRot) {
|
||||
this.xRot = xRot;
|
||||
this.yRot = yRot;
|
||||
this.zRot = zRot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiRenderBuilder rotateBlock(double xRot, double yRot, double zRot) {
|
||||
return this.rotate(xRot, yRot, zRot)
|
||||
.withRotationOffset(VecHelper.getCenterOf(BlockPos.ZERO));
|
||||
}
|
||||
|
||||
public GuiRenderBuilder scale(double scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiRenderBuilder color(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiRenderBuilder withRotationOffset(Vec3d offset) {
|
||||
this.rotationOffset = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract void render();
|
||||
|
||||
protected void prepare() {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderHelper.enableGuiDepthLighting();
|
||||
RenderSystem.alphaFunc(516, 0.1F);
|
||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
protected void transform() {
|
||||
int verticalFlip = (this instanceof GuiItemRenderBuilder) ? 1 : -1;
|
||||
|
||||
RenderSystem.translated(xBeforeScale, yBeforeScale, 0);
|
||||
RenderSystem.scaled(scale, scale, scale);
|
||||
RenderSystem.translated(x, y, z);
|
||||
RenderSystem.scaled(1, verticalFlip, 1);
|
||||
RenderSystem.translated(rotationOffset.x, rotationOffset.y, rotationOffset.z);
|
||||
RenderSystem.rotatef((float) zRot, 0, 0, 1);
|
||||
RenderSystem.rotatef((float) xRot, 1, 0, 0);
|
||||
RenderSystem.rotatef((float) yRot, 0, 1, 0);
|
||||
RenderSystem.translated(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z);
|
||||
}
|
||||
|
||||
protected void cleanUp() {
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.disableRescaleNormal();
|
||||
}
|
||||
}
|
||||
|
||||
private static class GuiBlockModelRenderBuilder extends GuiRenderBuilder {
|
||||
|
||||
protected IBakedModel blockmodel;
|
||||
protected BlockState blockState;
|
||||
|
||||
public GuiBlockModelRenderBuilder(IBakedModel blockmodel, @Nullable BlockState blockState) {
|
||||
this.blockState = blockState == null ? Blocks.AIR.getDefaultState() : blockState;
|
||||
this.blockmodel = blockmodel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
prepare();
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
BlockRendererDispatcher blockRenderer = mc.getBlockRendererDispatcher();
|
||||
IRenderTypeBuffer.Impl buffer = mc.getBufferBuilders()
|
||||
.getEntityVertexConsumers();
|
||||
RenderType renderType = RenderTypeLookup.getEntityBlockLayer(blockState);
|
||||
IVertexBuilder vb = buffer.getBuffer(renderType);
|
||||
MatrixStack ms = new MatrixStack();
|
||||
|
||||
transform();
|
||||
|
||||
mc.getTextureManager()
|
||||
.bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE);
|
||||
renderModel(blockRenderer, buffer, renderType, vb, ms);
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer,
|
||||
RenderType renderType, IVertexBuilder vb, MatrixStack ms) {
|
||||
Vec3d rgb = ColorHelper.getRGB(color);
|
||||
blockRenderer.getBlockModelRenderer()
|
||||
.renderModel(ms.peek(), vb, blockState, blockmodel, (float) rgb.x, (float) rgb.y, (float) rgb.z,
|
||||
0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
|
||||
buffer.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuiBlockStateRenderBuilder extends GuiBlockModelRenderBuilder {
|
||||
|
||||
public GuiBlockStateRenderBuilder(BlockState blockstate) {
|
||||
super(Minecraft.getInstance()
|
||||
.getBlockRendererDispatcher()
|
||||
.getModelForState(blockstate), blockstate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer,
|
||||
RenderType renderType, IVertexBuilder vb, MatrixStack ms) {
|
||||
if (blockState.getBlock() instanceof FireBlock) {
|
||||
RenderHelper.disableGuiDepthLighting();
|
||||
blockRenderer.renderBlock(blockState, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV,
|
||||
EmptyModelData.INSTANCE);
|
||||
RenderHelper.enable();
|
||||
buffer.draw();
|
||||
return;
|
||||
}
|
||||
|
||||
super.renderModel(blockRenderer, buffer, renderType, vb, ms);
|
||||
|
||||
if (blockState.getFluidState().isEmpty())
|
||||
return;
|
||||
|
||||
// TODO fluids are not visible for some reason. See fan washing recipes in JEI for an example use case
|
||||
for (RenderType type : RenderType.getBlockLayers()) {
|
||||
if (!RenderTypeLookup.canRenderInLayer(blockState.getFluidState(), type))
|
||||
continue;
|
||||
|
||||
vb = buffer.getBuffer(type);
|
||||
blockRenderer.renderFluid(new BlockPos(0, 0, 0), Minecraft.getInstance().world, vb,
|
||||
blockState.getFluidState());
|
||||
buffer.draw(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuiBlockPartialRenderBuilder extends GuiBlockModelRenderBuilder {
|
||||
|
||||
public GuiBlockPartialRenderBuilder(AllBlockPartials partial) {
|
||||
super(partial.get(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class GuiItemRenderBuilder extends GuiRenderBuilder {
|
||||
|
||||
private ItemStack stack;
|
||||
|
||||
public GuiItemRenderBuilder(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public GuiItemRenderBuilder(IItemProvider provider) {
|
||||
this(new ItemStack(provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
prepare();
|
||||
transform();
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderItemIntoGUI(stack, 0, 0);
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
package com.simibubi.create.foundation.gui;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FireBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
public class ScreenElementRenderer {
|
||||
|
||||
public static void render3DItem(Supplier<ItemStack> transformsAndStack) {
|
||||
RenderSystem.pushMatrix();
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderHelper.enableGuiDepthLighting(); // TODO 1.15 buffered render
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
ItemStack stack = transformsAndStack.get();
|
||||
|
||||
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(stack, 0, 0);
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
public static void renderBlock(Supplier<BlockState> transformsAndState) {
|
||||
renderBlock(transformsAndState, -1);
|
||||
}
|
||||
|
||||
public static void renderBlock(Supplier<BlockState> transformsAndState, int color) {
|
||||
render(transformsAndState, null, -1);
|
||||
}
|
||||
|
||||
public static void renderModel(Supplier<IBakedModel> transformsAndModel) {
|
||||
render(null, transformsAndModel, -1);
|
||||
}
|
||||
|
||||
private static void render(Supplier<BlockState> transformsAndState, Supplier<IBakedModel> transformsAndModel,
|
||||
int color) {
|
||||
RenderSystem.pushMatrix();
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderHelper.enableGuiDepthLighting();
|
||||
RenderSystem.alphaFunc(516, 0.1F);
|
||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.translated(0, 0, 200);
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
BlockRendererDispatcher blockRenderer = mc.getBlockRendererDispatcher();
|
||||
IBakedModel modelToRender = null;
|
||||
BlockState blockToRender = Blocks.AIR.getDefaultState();
|
||||
boolean stateMode = transformsAndModel == null;
|
||||
boolean fire = false;
|
||||
|
||||
if (transformsAndModel == null) {
|
||||
blockToRender = transformsAndState.get();
|
||||
fire = (blockToRender.getBlock() instanceof FireBlock);
|
||||
modelToRender = blockRenderer.getModelForState(blockToRender);
|
||||
} else {
|
||||
modelToRender = transformsAndModel.get();
|
||||
}
|
||||
|
||||
RenderSystem.scaled(50, -50, 50);
|
||||
IRenderTypeBuffer.Impl buffer = mc.getBufferBuilders().getEntityVertexConsumers();
|
||||
RenderType renderType = RenderTypeLookup.getEntityBlockLayer(blockToRender);
|
||||
IVertexBuilder vb = buffer.getBuffer(renderType);
|
||||
MatrixStack ms = new MatrixStack();
|
||||
mc.getTextureManager().bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
if (fire) {
|
||||
blockRenderer.renderBlock(blockToRender, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV,
|
||||
EmptyModelData.INSTANCE);
|
||||
} else {
|
||||
if (modelToRender != null) {
|
||||
RenderSystem.rotatef(90, 0, 1, 0);
|
||||
if (color == -1) {
|
||||
blockRenderer.getBlockModelRenderer().renderModel(ms.peek(), vb, blockToRender, modelToRender, 1, 1,
|
||||
1, 0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
|
||||
} else {
|
||||
Vec3d rgb = ColorHelper.getRGB(color);
|
||||
blockRenderer.getBlockModelRenderer().renderModel(ms.peek(), vb, blockToRender, modelToRender,
|
||||
(float) rgb.x, (float) rgb.y, (float) rgb.z, 0xF000F0, OverlayTexture.DEFAULT_UV,
|
||||
EmptyModelData.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
buffer.draw(renderType);
|
||||
|
||||
if (blockToRender != null && !blockToRender.getFluidState().isEmpty()) {
|
||||
renderType = RenderTypeLookup.getFluidLayer(blockToRender.getFluidState());
|
||||
vb = buffer.getBuffer(renderType);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
RenderSystem.translatef(0, -300, 0);
|
||||
blockRenderer.renderFluid(new BlockPos(0, 300, 0), mc.world, vb, blockToRender.getFluidState());
|
||||
buffer.draw(renderType);
|
||||
}
|
||||
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.disableRescaleNormal();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
}
|
|
@ -3,9 +3,9 @@ package com.simibubi.create.modules.contraptions.goggle;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
|
@ -25,6 +26,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|||
@EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class GoggleOverlayRenderer {
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() != ElementType.HOTBAR)
|
||||
|
@ -71,29 +73,30 @@ public class GoggleOverlayRenderer {
|
|||
if (tooltip.isEmpty())
|
||||
return;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
Screen tooltipScreen = new Screen(null) {
|
||||
|
||||
@Override
|
||||
public void init(Minecraft mc, int width, int height) {
|
||||
this.minecraft = mc;
|
||||
this.itemRenderer = mc.getItemRenderer();
|
||||
this.font = mc.fontRenderer;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
Screen tooltipScreen = new TooltipScreen(null);
|
||||
tooltipScreen.init(mc, mc.getWindow().getScaledWidth(), mc.getWindow().getScaledHeight());
|
||||
tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2);
|
||||
|
||||
ItemStack item = AllItems.GOGGLES.asStack();
|
||||
ScreenElementRenderer.render3DItem(() -> {
|
||||
GlStateManager.translated(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16, 0);
|
||||
return item;
|
||||
});
|
||||
GlStateManager.popMatrix();
|
||||
GuiGameElement.of(item).at(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16).render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
|
||||
private static final class TooltipScreen extends Screen {
|
||||
private TooltipScreen(ITextComponent p_i51108_1_) {
|
||||
super(p_i51108_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Minecraft mc, int width, int height) {
|
||||
this.minecraft = mc;
|
||||
this.itemRenderer = mc.getItemRenderer();
|
||||
this.font = mc.fontRenderer;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
||||
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
@ -18,8 +18,8 @@ import net.minecraft.util.math.BlockPos;
|
|||
|
||||
public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
||||
|
||||
private static final ItemStack renderedItem = new ItemStack(AllBlocks.SEQUENCED_GEARSHIFT.get());
|
||||
private static final ScreenResources background = ScreenResources.SEQUENCER;
|
||||
private final ItemStack renderedItem = new ItemStack(AllBlocks.SEQUENCED_GEARSHIFT.get());
|
||||
private final ScreenResources background = ScreenResources.SEQUENCER;
|
||||
|
||||
private final String title = Lang.translate("gui.sequenced_gearshift.title");
|
||||
private ListNBT compareTag;
|
||||
|
@ -61,7 +61,8 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
|||
|
||||
ScrollInput type =
|
||||
new SelectionScrollInput(x, y + rowHeight * row, 50, 14).forOptions(SequencerInstructions.getOptions())
|
||||
.calling(state -> instructionUpdated(index, state)).setState(instruction.instruction.ordinal())
|
||||
.calling(state -> instructionUpdated(index, state))
|
||||
.setState(instruction.instruction.ordinal())
|
||||
.titled(Lang.translate("gui.sequenced_gearshift.instruction"));
|
||||
ScrollInput value =
|
||||
new ScrollInput(x + 54, y + rowHeight * row, 30, 14).calling(state -> instruction.value = state);
|
||||
|
@ -88,8 +89,11 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
|||
ScrollInput value = rowInputs.get(1);
|
||||
value.active = value.visible = hasValue;
|
||||
if (hasValue)
|
||||
value.withRange(1, def.maxValue + 1).titled(Lang.translate(def.parameterKey)).withShiftStep(def.shiftStep)
|
||||
.setState(instruction.value).onChanged();
|
||||
value.withRange(1, def.maxValue + 1)
|
||||
.titled(Lang.translate(def.parameterKey))
|
||||
.withShiftStep(def.shiftStep)
|
||||
.setState(instruction.value)
|
||||
.onChanged();
|
||||
if (def == SequencerInstructions.WAIT) {
|
||||
value.withStepFunction(context -> {
|
||||
int v = context.currentValue;
|
||||
|
@ -139,7 +143,13 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
|||
|
||||
font.drawStringWithShadow(title, guiLeft - 3 + (background.width - font.getStringWidth(title)) / 2, guiTop + 10,
|
||||
hFontColor);
|
||||
ScreenElementRenderer.render3DItem(this::getRenderedBlock);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(guiLeft + background.width + 20, guiTop + 50, 0);
|
||||
GuiGameElement.of(renderedItem)
|
||||
.scale(5)
|
||||
.render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
private void label(int x, int y, String text) {
|
||||
|
@ -158,12 +168,6 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
|||
sendPacket();
|
||||
}
|
||||
|
||||
public ItemStack getRenderedBlock() {
|
||||
RenderSystem.translated(guiLeft + background.width + 20, guiTop + 50, 0);
|
||||
RenderSystem.scaled(5, 5, 5);
|
||||
return renderedItem;
|
||||
}
|
||||
|
||||
private void instructionUpdated(int index, int state) {
|
||||
SequencerInstructions newValue = SequencerInstructions.values()[state];
|
||||
instructions.get(index).instruction = newValue;
|
||||
|
|
|
@ -27,26 +27,30 @@ import net.minecraft.util.math.MathHelper;
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlockzapperItemRenderer extends ZapperItemRenderer {
|
||||
|
||||
|
||||
@Override
|
||||
public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
BlockzapperModel mainModel = (BlockzapperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null);
|
||||
float pt = Minecraft.getInstance().getRenderPartialTicks();
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance()
|
||||
.getItemRenderer();
|
||||
BlockzapperModel mainModel =
|
||||
(BlockzapperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null);
|
||||
float pt = Minecraft.getInstance()
|
||||
.getRenderPartialTicks();
|
||||
float worldTime = AnimationTickHolder.getRenderTick() / 20;
|
||||
|
||||
ms.push();
|
||||
ms.translate(0.5F, 0.5F, 0.5F);
|
||||
|
||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel());
|
||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay,
|
||||
mainModel.getBakedModel());
|
||||
renderComponent(stack, mainModel, Body, itemRenderer, ms, buffer, light, overlay);
|
||||
renderComponent(stack, mainModel, Amplifier, itemRenderer, ms, buffer, light, overlay);
|
||||
renderComponent(stack, mainModel, Retriever, itemRenderer, ms, buffer, light, overlay);
|
||||
renderComponent(stack, mainModel, Scope, itemRenderer, ms, buffer, light, overlay);
|
||||
|
||||
// Block indicator
|
||||
if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag()
|
||||
&& stack.getTag().contains("BlockUsed"))
|
||||
if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag() && stack.getTag()
|
||||
.contains("BlockUsed"))
|
||||
renderBlockUsed(stack, itemRenderer, ms, buffer, light, overlay);
|
||||
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
|
@ -55,8 +59,8 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer {
|
|||
boolean offHand = player.getHeldItemOffhand() == stack;
|
||||
float last = mainHand ^ leftHanded ? ZapperRenderHandler.lastRightHandAnimation
|
||||
: ZapperRenderHandler.lastLeftHandAnimation;
|
||||
float current = mainHand ^ leftHanded ? ZapperRenderHandler.rightHandAnimation
|
||||
: ZapperRenderHandler.leftHandAnimation;
|
||||
float current =
|
||||
mainHand ^ leftHanded ? ZapperRenderHandler.rightHandAnimation : ZapperRenderHandler.leftHandAnimation;
|
||||
float animation = MathHelper.clamp(MathHelper.lerp(pt, last, current) * 5, 0, 1);
|
||||
|
||||
// Core glows
|
||||
|
@ -64,10 +68,12 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer {
|
|||
if (mainHand || offHand) {
|
||||
multiplier = animation;
|
||||
}
|
||||
int glowLight = LightTexture.pack((int) (15 * multiplier), 15);
|
||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, mainModel.getPartial("core"));
|
||||
int glowLight = LightTexture.pack(0, (int) (15 * multiplier));
|
||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay,
|
||||
mainModel.getPartial("core"));
|
||||
if (BlockzapperItem.getTier(Amplifier, stack) != ComponentTier.None)
|
||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, mainModel.getPartial("amplifier_core"));
|
||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay,
|
||||
mainModel.getPartial("amplifier_core"));
|
||||
|
||||
// Accelerator spins
|
||||
float angle = worldTime * -25;
|
||||
|
|
|
@ -14,7 +14,7 @@ public class BlockzapperModel extends CustomRenderedItemModel {
|
|||
public BlockzapperModel(IBakedModel template) {
|
||||
super(template, "blockzapper");
|
||||
addPartials("core", "body", "amplifier_core", "accelerator", "gold_body", "gold_scope", "gold_amplifier",
|
||||
"gold_retriever", "gold_accelerator", "chorus_body", "chorus_amplifier", "chorus_retriever",
|
||||
"gold_retriever", "gold_accelerator", "chorus_body", "chorus_scope", "chorus_amplifier", "chorus_retriever",
|
||||
"chorus_accelerator");
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.gui.widgets.Label;
|
||||
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.modules.logistics.packet.ConfigureStockswitchPacket;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class StockswitchScreen extends AbstractSimiScreen {
|
||||
|
||||
|
@ -31,6 +31,7 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
|||
private final String stopAt = Lang.translate("gui.stockswitch.stopAt");
|
||||
private final String lowerLimit = Lang.translate("gui.stockswitch.lowerLimit");
|
||||
private final String upperLimit = Lang.translate("gui.stockswitch.upperLimit");
|
||||
private final ItemStack renderedItem = new ItemStack(AllBlocks.STOCKSWITCH.get());
|
||||
|
||||
private int lastModification;
|
||||
private StockswitchTileEntity te;
|
||||
|
@ -48,8 +49,10 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
|||
widgets.clear();
|
||||
cursorPos = te.currentLevel == -1 ? 0 : te.currentLevel;
|
||||
|
||||
offBelowLabel = new Label(guiLeft + 116, guiTop + 72, "").colored(0xD3CBBE).withShadow();
|
||||
offBelow = new ScrollInput(guiLeft + 113, guiTop + 69, 33, 14).withRange(0, 96).titled(lowerLimit)
|
||||
offBelowLabel = new Label(guiLeft + 116, guiTop + 72, "").colored(0xD3CBBE)
|
||||
.withShadow();
|
||||
offBelow = new ScrollInput(guiLeft + 113, guiTop + 69, 33, 14).withRange(0, 96)
|
||||
.titled(lowerLimit)
|
||||
.calling(state -> {
|
||||
offBelowLabel.text = state + "%";
|
||||
lastModification = 0;
|
||||
|
@ -57,10 +60,13 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
|||
onAbove.setState(state + 5);
|
||||
onAbove.onChanged();
|
||||
}
|
||||
}).setState((int) (te.offWhenBelow * 100));
|
||||
})
|
||||
.setState((int) (te.offWhenBelow * 100));
|
||||
|
||||
onAboveLabel = new Label(guiLeft + 116, guiTop + 55, "").colored(0xD3CBBE).withShadow();
|
||||
onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101).titled(upperLimit)
|
||||
onAboveLabel = new Label(guiLeft + 116, guiTop + 55, "").colored(0xD3CBBE)
|
||||
.withShadow();
|
||||
onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101)
|
||||
.titled(upperLimit)
|
||||
.calling(state -> {
|
||||
onAboveLabel.text = state + "%";
|
||||
lastModification = 0;
|
||||
|
@ -68,7 +74,8 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
|||
offBelow.setState(state - 5);
|
||||
offBelow.onChanged();
|
||||
}
|
||||
}).setState((int) (te.onWhenAbove * 100));
|
||||
})
|
||||
.setState((int) (te.onWhenAbove * 100));
|
||||
|
||||
onAbove.onChanged();
|
||||
offBelow.onChanged();
|
||||
|
@ -101,14 +108,19 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
|||
ScreenResources.STOCKSWITCH_BOUND_LEFT.draw(this, (int) (guiLeft + lowerBound) - 1, guiTop + 24);
|
||||
ScreenResources.STOCKSWITCH_BOUND_RIGHT.draw(this, (int) (guiLeft + upperBound) - 5, guiTop + 24);
|
||||
|
||||
ScreenResources cursor = te.powered ? ScreenResources.STOCKSWITCH_CURSOR_ON
|
||||
: ScreenResources.STOCKSWITCH_CURSOR_OFF;
|
||||
ScreenResources cursor =
|
||||
te.powered ? ScreenResources.STOCKSWITCH_CURSOR_ON : ScreenResources.STOCKSWITCH_CURSOR_OFF;
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef((cursorPos * (sprite.width - 20) + 10), 0, 0);
|
||||
cursor.draw(this, guiLeft - 4, guiTop + 24);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
||||
RenderSystem.pushMatrix();
|
||||
GuiGameElement.of(renderedItem)
|
||||
.at(guiLeft + STOCKSWITCH.width + 15, guiTop + 20)
|
||||
.scale(5)
|
||||
.render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,10 +148,4 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
|||
new ConfigureStockswitchPacket(te.getPos(), offBelow.getState() / 100f, onAbove.getState() / 100f));
|
||||
}
|
||||
|
||||
public BlockState getRenderedBlock() {
|
||||
RenderSystem.translated(guiLeft + STOCKSWITCH.width + 50, guiTop + 100, 0);
|
||||
RenderSystem.rotatef(50, -.5f, 1, -.2f);
|
||||
return AllBlocks.STOCKSWITCH.get().getDefaultState();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.ScreenResources;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.gui.widgets.Label;
|
||||
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.modules.logistics.packet.ConfigureFlexcratePacket;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Rectangle2d;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContainer> {
|
||||
|
@ -32,6 +32,7 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
|
|||
|
||||
private List<Rectangle2d> extraAreas;
|
||||
|
||||
private final ItemStack renderedItem = new ItemStack(AllBlocks.FLEXCRATE.get());
|
||||
private final String title = Lang.translate("gui.flexcrate.title");
|
||||
private final String storageSpace = Lang.translate("gui.flexcrate.storageSpace");
|
||||
|
||||
|
@ -47,10 +48,14 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
|
|||
super.init();
|
||||
widgets.clear();
|
||||
|
||||
allowedItemsLabel = new Label(guiLeft + 100 + 70, guiTop + 107, "").colored(0xD3CBBE).withShadow();
|
||||
allowedItemsLabel = new Label(guiLeft + 100 + 70, guiTop + 107, "").colored(0xD3CBBE)
|
||||
.withShadow();
|
||||
allowedItems = new ScrollInput(guiLeft + 100 + 65, guiTop + 104, 41, 14).titled(storageSpace)
|
||||
.withRange(1, (container.doubleCrate ? 2049 : 1025)).writingTo(allowedItemsLabel).withShiftStep(64)
|
||||
.setState(te.allowedAmount).calling(s -> lastModification = 0);
|
||||
.withRange(1, (container.doubleCrate ? 2049 : 1025))
|
||||
.writingTo(allowedItemsLabel)
|
||||
.withShiftStep(64)
|
||||
.setState(te.allowedAmount)
|
||||
.calling(s -> lastModification = 0);
|
||||
allowedItems.onChanged();
|
||||
widgets.add(allowedItemsLabel);
|
||||
widgets.add(allowedItems);
|
||||
|
@ -80,7 +85,8 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
|
|||
font.drawString(itemCount, guiLeft + 100 + 53 - font.getStringWidth(itemCount), crateTop + 107, fontColor);
|
||||
|
||||
PLAYER_INVENTORY.draw(this, invLeft, invTop);
|
||||
font.drawString(playerInventory.getDisplayName().getFormattedText(), invLeft + 7, invTop + 6, 0x666666);
|
||||
font.drawString(playerInventory.getDisplayName()
|
||||
.getFormattedText(), invLeft + 7, invTop + 6, 0x666666);
|
||||
|
||||
for (int slot = 0; slot < (container.doubleCrate ? 32 : 16); slot++) {
|
||||
if (allowedItems.getState() > slot * 64)
|
||||
|
@ -91,12 +97,12 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
|
|||
ScreenResources.FLEXCRATE_LOCKED_SLOT.draw(this, x, y);
|
||||
}
|
||||
|
||||
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
||||
|
||||
// to see or debug the bounds of the extra area uncomment the following lines
|
||||
// Rectangle2d r = extraAreas.get(0);
|
||||
// fill(r.getX() + r.getWidth(), r.getY() + r.getHeight(), r.getX(), r.getY(),
|
||||
// 0xd3d3d3d3);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(guiLeft + FLEXCRATE.width + 110, guiTop + 40, 0);
|
||||
GuiGameElement.of(renderedItem)
|
||||
.scale(5)
|
||||
.render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,12 +129,6 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
|
|||
container.playerInventory.player.closeScreen();
|
||||
}
|
||||
|
||||
public BlockState getRenderedBlock() {
|
||||
RenderSystem.translated(guiLeft + FLEXCRATE.width + 145, guiTop + 115, 0);
|
||||
RenderSystem.rotatef(50, -.5f, 1, -.2f);
|
||||
return AllBlocks.FLEXCRATE.get().getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Rectangle2d> getExtraAreas() {
|
||||
return extraAreas;
|
||||
|
|
Loading…
Reference in a new issue