The great screen refactor

- Use vanilla's widget lists instead of custom ones
- Use press callback instead of overriding mouseClicked
- Switch old container classes to extend ContainerBase or
GhostItemContainer
- Organize foundation.gui package
- Remove deprecated methods in Color
- Various other changes
This commit is contained in:
PepperBell 2021-11-14 16:11:14 -08:00
parent 1e90f84875
commit ad350507c9
148 changed files with 1454 additions and 1853 deletions

View file

@ -25,7 +25,6 @@ import com.simibubi.create.foundation.utility.outliner.Outliner;
import net.minecraft.ChatFormatting;
import net.minecraft.client.GraphicsStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.ComponentUtils;
@ -40,7 +39,6 @@ public class CreateClient {
public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache();
public static final Outliner OUTLINER = new Outliner();
public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks();
public static final Screen EMPTY_SCREEN = new Screen(new TextComponent("")) {};
public static final ModelSwapper MODEL_SWAPPER = new ModelSwapper();
public static final CasingConnectivity CASING_CONNECTIVITY = new CasingConnectivity();

View file

@ -40,18 +40,13 @@ import com.simibubi.create.content.contraptions.components.press.MechanicalPress
import com.simibubi.create.content.contraptions.components.saw.SawTileEntity;
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.processing.BasinRecipe;
import com.simibubi.create.content.curiosities.toolbox.ToolboxScreen;
import com.simibubi.create.content.curiosities.tools.BlueprintScreen;
import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateScreen;
import com.simibubi.create.content.logistics.item.LinkedControllerScreen;
import com.simibubi.create.content.logistics.item.filter.AbstractFilterScreen;
import com.simibubi.create.content.logistics.item.filter.AttributeFilterScreen;
import com.simibubi.create.content.logistics.item.filter.FilterScreen;
import com.simibubi.create.content.schematics.block.SchematicTableScreen;
import com.simibubi.create.content.schematics.block.SchematicannonScreen;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.CRecipes;
import com.simibubi.create.foundation.config.ConfigBase.ConfigBool;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo;
import mezz.jei.api.IModPlugin;
@ -247,18 +242,11 @@ public class CreateJEI implements IModPlugin {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
SlotMover slotMover = new SlotMover();
registration.addGuiContainerHandler(SchematicTableScreen.class, slotMover);
registration.addGuiContainerHandler(SchematicannonScreen.class, slotMover);
registration.addGuiContainerHandler(AdjustableCrateScreen.class, slotMover);
registration.addGuiContainerHandler(FilterScreen.class, slotMover);
registration.addGuiContainerHandler(AttributeFilterScreen.class, slotMover);
registration.addGuiContainerHandler(BlueprintScreen.class, slotMover);
registration.addGuiContainerHandler(LinkedControllerScreen.class, slotMover);
registration.addGuiContainerHandler(ToolboxScreen.class, slotMover);
registration.addGenericGuiContainerHandler(AbstractSimiContainerScreen.class, new SlotMover());
registration.addGhostIngredientHandler(AbstractFilterScreen.class, new GhostIngredientHandler());
registration.addGhostIngredientHandler(BlueprintScreen.class, new GhostIngredientHandler());
registration.addGhostIngredientHandler(LinkedControllerScreen.class, new GhostIngredientHandler());
}
private class CategoryBuilder<T extends Recipe<?>> {

View file

@ -4,7 +4,7 @@ import java.util.function.Supplier;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import mezz.jei.api.gui.drawable.IDrawable;
import net.minecraft.world.item.ItemStack;

View file

@ -6,9 +6,9 @@ import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import com.simibubi.create.content.logistics.item.filter.AttributeFilterScreen;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.GhostItemContainer;
import com.simibubi.create.foundation.gui.GhostItemSubmitPacket;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.container.GhostItemContainer;
import com.simibubi.create.foundation.gui.container.GhostItemSubmitPacket;
import com.simibubi.create.foundation.networking.AllPackets;
import mezz.jei.api.gui.handlers.IGhostIngredientHandler;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.compat.jei;
import java.util.List;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import net.minecraft.client.renderer.Rect2i;
@ -18,4 +18,5 @@ public class SlotMover implements IGuiContainerHandler<AbstractSimiContainerScre
public List<Rect2i> getGuiExtraAreas(AbstractSimiContainerScreen<?> containerScreen) {
return containerScreen.getExtraAreas();
}
}

View file

@ -158,25 +158,25 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
int yOffset = 0;
for (int i = 0; i < size; i++)
AllGuiTextures.JEI_SLOT.draw(matrixStack, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
AllGuiTextures.JEI_SLOT.render(matrixStack, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
boolean noHeat = requiredHeat == HeatCondition.NONE;
int vRows = (1 + outSize) / 2;
for (int i = 0; i < outSize; i++)
AllGuiTextures.JEI_SLOT.draw(matrixStack,
AllGuiTextures.JEI_SLOT.render(matrixStack,
141 - (outSize % 2 != 0 && i == outSize - 1 ? 0 : i % 2 == 0 ? 10 : -9), -19 * (i / 2) + 50 + yOffset);
if (vRows <= 2)
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 136, -19 * (vRows - 1) + 32 + yOffset);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 136, -19 * (vRows - 1) + 32 + yOffset);
AllGuiTextures shadow = noHeat ? AllGuiTextures.JEI_SHADOW : AllGuiTextures.JEI_LIGHT;
shadow.draw(matrixStack, 81, 58 + (noHeat ? 10 : 30));
shadow.render(matrixStack, 81, 58 + (noHeat ? 10 : 30));
if (!needsHeating)
return;
AllGuiTextures heatBar = noHeat ? AllGuiTextures.JEI_NO_HEAT_BAR : AllGuiTextures.JEI_HEAT_BAR;
heatBar.draw(matrixStack, 4, 80);
heatBar.render(matrixStack, 4, 80);
Minecraft.getInstance().font.draw(matrixStack, Lang.translate(requiredHeat.getTranslationKey()), 9,
86, requiredHeat.getColor());
}

View file

@ -59,15 +59,15 @@ public class BlockCuttingCategory extends CreateRecipeCategory<CondensedBlockCut
@Override
public void draw(CondensedBlockCuttingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 4, 4);
AllGuiTextures.JEI_SLOT.render(matrixStack, 4, 4);
int size = Math.min(recipe.getOutputs().size(), 15);
for (int i = 0; i < size; i++) {
int xOffset = (i % 5) * 19;
int yOffset = (i / 5) * -19;
AllGuiTextures.JEI_SLOT.draw(matrixStack, 77 + xOffset, 47 + yOffset);
AllGuiTextures.JEI_SLOT.render(matrixStack, 77 + xOffset, 47 + yOffset);
}
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 31, 6);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 33 - 17, 37 + 13);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 31, 6);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 33 - 17, 37 + 13);
saw.draw(matrixStack, 33, 37);
}

View file

@ -58,13 +58,13 @@ public class CrushingCategory extends CreateRecipeCategory<AbstractCrushingRecip
@Override
public void draw(AbstractCrushingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
List<ProcessingOutput> results = recipe.getRollableResults();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 50, 2);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 72, 7);
AllGuiTextures.JEI_SLOT.render(matrixStack, 50, 2);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 72, 7);
int size = results.size();
int offset = -size * 19 / 2;
for (int outputIndex = 0; outputIndex < results.size(); outputIndex++)
getRenderedSlot(recipe, outputIndex).draw(matrixStack, getBackground().getWidth() / 2 + offset + 19 * outputIndex, 78);
getRenderedSlot(recipe, outputIndex).render(matrixStack, getBackground().getWidth() / 2 + offset + 19 * outputIndex, 78);
crushingWheels.draw(matrixStack, 62, 59);
}

View file

@ -72,11 +72,11 @@ public class DeployingCategory extends CreateRecipeCategory<DeployerApplicationR
@Override
public void draw(DeployerApplicationRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 50, 4);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 50);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 50);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 62, 57);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 126, 29);
AllGuiTextures.JEI_SLOT.render(matrixStack, 50, 4);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 50);
getRenderedSlot(recipe, 0).render(matrixStack, 131, 50);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 62, 57);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 126, 29);
deployer.draw(matrixStack, getBackground().getWidth() / 2 - 13, 22);
}

View file

@ -3,7 +3,7 @@ package com.simibubi.create.compat.jei.category;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.compat.jei.category;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.SmokingRecipe;

View file

@ -9,7 +9,7 @@ import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics;
import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingOutput;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
@ -63,20 +63,20 @@ public class FanWashingCategory extends ProcessingViaFanCategory<SplashingRecipe
int size = recipe.getRollableResultsAsItemStacks()
.size();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 12, 47);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 47 + 4, 29);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 66 + 4, 39);
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 42, 51);
AllGuiTextures.JEI_SLOT.render(matrixStack, 12, 47);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 47 + 4, 29);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 66 + 4, 39);
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 42, 51);
if (size == 1) {
getRenderedSlot(recipe, 0).draw(matrixStack, 126, 47);
getRenderedSlot(recipe, 0).render(matrixStack, 126, 47);
return;
}
for (int i = 0; i < size; i++) {
int xOffset = (i % 3) * 19;
int yOffset = (i / 3) * -19 + (size > 9 ? 8 : 0);
getRenderedSlot(recipe, i).draw(matrixStack, 126 + xOffset, 47 + yOffset);
getRenderedSlot(recipe, i).render(matrixStack, 126 + xOffset, 47 + yOffset);
}
}

View file

@ -128,11 +128,11 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
@Override
public void draw(EmptyingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 131, 7);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 7);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 26);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 62, 37);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 73, 4);
AllGuiTextures.JEI_SLOT.render(matrixStack, 131, 7);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 7);
getRenderedSlot(recipe, 0).render(matrixStack, 131, 26);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 62, 37);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 73, 4);
drain.withFluid(recipe.getResultingFluid())
.draw(matrixStack, getBackground().getWidth() / 2 - 13, 40);
}

View file

@ -107,14 +107,14 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
matrixStack.pushPose();
matrixStack.translate(col * 19 * scale, row * 19 * scale, 0);
matrixStack.scale(scale, scale, scale);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 0, 0);
AllGuiTextures.JEI_SLOT.render(matrixStack, 0, 0);
matrixStack.popPose();
}
matrixStack.popPose();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 133, 80);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 128, 59);
AllGuiTextures.JEI_SLOT.render(matrixStack, 133, 80);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 128, 59);
crafter.draw(matrixStack, 129, 25);
matrixStack.pushPose();

View file

@ -62,20 +62,20 @@ public class MillingCategory extends CreateRecipeCategory<AbstractCrushingRecipe
int size = recipe.getRollableResultsAsItemStacks()
.size();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 14, 8);
AllGuiTextures.JEI_ARROW.draw(matrixStack, 85, 32);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 43, 4);
AllGuiTextures.JEI_SLOT.render(matrixStack, 14, 8);
AllGuiTextures.JEI_ARROW.render(matrixStack, 85, 32);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 43, 4);
millstone.draw(matrixStack, 48, 27);
if (size == 1) {
getRenderedSlot(recipe, 0).draw(matrixStack, 139, 27);
getRenderedSlot(recipe, 0).render(matrixStack, 139, 27);
return;
}
for (int i = 0; i < size; i++) {
int xOffset = i % 2 == 0 ? 0 : 19;
int yOffset = (i / 2) * -19;
getRenderedSlot(recipe, i).draw(matrixStack, 133 + xOffset, 27 + yOffset);
getRenderedSlot(recipe, i).render(matrixStack, 133 + xOffset, 27 + yOffset);
}
}

View file

@ -54,10 +54,10 @@ public class MysteriousItemConversionCategory extends CreateRecipeCategory<Conve
@Override
public void draw(ConversionRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 16);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 131, 16);
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 52, 20);
AllGuiTextures.JEI_QUESTION_MARK.draw(matrixStack, 77, 5);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 16);
AllGuiTextures.JEI_SLOT.render(matrixStack, 131, 16);
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52, 20);
AllGuiTextures.JEI_QUESTION_MARK.render(matrixStack, 77, 5);
}
}

View file

@ -76,11 +76,11 @@ public class PackingCategory extends BasinCategory {
int size = ingredients2.size();
int rows = size == 4 ? 2 : 3;
for (int i = 0; i < size; i++)
AllGuiTextures.JEI_SLOT.draw(matrixStack, (rows == 2 ? 26 : 17) + (i % rows) * 19,
AllGuiTextures.JEI_SLOT.render(matrixStack, (rows == 2 ? 26 : 17) + (i % rows) * 19,
50 - (i / rows) * 19);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 141, 50);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 136, 32);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 81, 68);
AllGuiTextures.JEI_SLOT.render(matrixStack, 141, 50);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 136, 32);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 81, 68);
}
HeatCondition requiredHeat = recipe.getRequiredHeat();

View file

@ -8,7 +8,7 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.content.contraptions.processing.ProcessingOutput;
import com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
@ -57,10 +57,10 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
@Override
public void draw(SandPaperPolishingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 28);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 28);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 61, 21);
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 52, 32);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 28);
getRenderedSlot(recipe, 0).render(matrixStack, 131, 28);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 61, 21);
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52, 32);
NonNullList<Ingredient> ingredients = recipe.getIngredients();
ItemStack[] matchingStacks = ingredients.get(0)

View file

@ -55,13 +55,13 @@ public class PressingCategory extends CreateRecipeCategory<PressingRecipe> {
@Override
public void draw(PressingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 50);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 50);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 50);
getRenderedSlot(recipe, 0).render(matrixStack, 131, 50);
if (recipe.getRollableResults()
.size() > 1)
getRenderedSlot(recipe, 1).draw(matrixStack, 131 + 19, 50);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 61, 41);
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 52, 54);
getRenderedSlot(recipe, 1).render(matrixStack, 131 + 19, 50);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 61, 41);
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52, 54);
press.draw(matrixStack, getBackground().getWidth() / 2 - 17, 22);
}

View file

@ -55,11 +55,11 @@ public abstract class ProcessingViaFanCategory<T extends Recipe<?>> extends Crea
}
protected void renderWidgets(PoseStack matrixStack, T recipe, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 20, 47);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 139, 47);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 47, 29);
AllGuiTextures.JEI_LIGHT.draw(matrixStack, 66, 39);
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 53, 51);
AllGuiTextures.JEI_SLOT.render(matrixStack, 20, 47);
AllGuiTextures.JEI_SLOT.render(matrixStack, 139, 47);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 47, 29);
AllGuiTextures.JEI_LIGHT.render(matrixStack, 66, 39);
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 53, 51);
}
@Override

View file

@ -58,16 +58,16 @@ public class SawingCategory extends CreateRecipeCategory<CuttingRecipe> {
@Override
public void draw(CuttingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 43, 4);
AllGuiTextures.JEI_SLOT.render(matrixStack, 43, 4);
int size = recipe.getRollableResults()
.size();
for (int i = 0; i < size; i++) {
int xOffset = i % 2 == 0 ? 0 : 19;
int yOffset = (i / 2) * -19;
getRenderedSlot(recipe, i).draw(matrixStack, 117 + xOffset, 47 + yOffset);
getRenderedSlot(recipe, i).render(matrixStack, 117 + xOffset, 47 + yOffset);
}
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 70, 6);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 72 - 17, 42 + 13);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 70, 6);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 72 - 17, 42 + 13);
saw.draw(matrixStack, 72, 42);
}

View file

@ -131,11 +131,11 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
matrixStack.translate(0, 15, 0);
boolean singleOutput = recipe.getOutputChance() == 1;
int xOffset = singleOutput ? 0 : -7;
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26 + xOffset, 75);
(singleOutput ? AllGuiTextures.JEI_SLOT : AllGuiTextures.JEI_CHANCE_SLOT).draw(matrixStack, 131 + xOffset, 75);
AllGuiTextures.JEI_LONG_ARROW.draw(matrixStack, 52 + xOffset, 79);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26 + xOffset, 75);
(singleOutput ? AllGuiTextures.JEI_SLOT : AllGuiTextures.JEI_CHANCE_SLOT).render(matrixStack, 131 + xOffset, 75);
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52 + xOffset, 79);
if (!singleOutput) {
AllGuiTextures.JEI_CHANCE_SLOT.draw(matrixStack, 150 + xOffset, 75);
AllGuiTextures.JEI_CHANCE_SLOT.render(matrixStack, 150 + xOffset, 75);
Component component = new TextComponent("?").withStyle(ChatFormatting.BOLD);
font.drawShadow(matrixStack, component, font.width(component) / -2 + 8 + 150 + xOffset, 2 + 78,
0xefefef);
@ -144,7 +144,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
if (recipe.getLoops() > 1) {
matrixStack.pushPose();
matrixStack.translate(15, 9, 0);
AllIcons.I_SEQ_REPEAT.draw(matrixStack, 50 + xOffset, 75);
AllIcons.I_SEQ_REPEAT.render(matrixStack, 50 + xOffset, 75);
Component repeat = new TextComponent("x" + recipe.getLoops());
font.draw(matrixStack, repeat, 66 + xOffset, 80, 0x888888);
matrixStack.popPose();

View file

@ -144,11 +144,11 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
@Override
public void draw(FillingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 31);
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 50);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 50);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 62, 57);
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 126, 29);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 31);
AllGuiTextures.JEI_SLOT.render(matrixStack, 26, 50);
getRenderedSlot(recipe, 0).render(matrixStack, 131, 50);
AllGuiTextures.JEI_SHADOW.render(matrixStack, 62, 57);
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 126, 29);
spout.withFluids(recipe.getRequiredFluid()
.getMatchingFluidStacks())
.draw(matrixStack, getBackground().getWidth() / 2 - 13, 22);

View file

@ -11,7 +11,7 @@ public class AnimatedCrafter extends AnimatedKinetics {
public void draw(PoseStack matrixStack, int xOffset, int yOffset) {
matrixStack.pushPose();
matrixStack.translate(xOffset, yOffset, 0);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, -16, 13);
AllGuiTextures.JEI_SHADOW.render(matrixStack, -16, 13);
matrixStack.translate(3, 16, 0);
MatrixTransformStack.of(matrixStack)

View file

@ -4,8 +4,8 @@ import com.jozufozu.flywheel.core.PartialModel;
import com.simibubi.create.AllBlockPartials;
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.gui.element.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import mezz.jei.api.gui.drawable.IDrawable;

View file

@ -11,7 +11,7 @@ public class AnimatedMillstone extends AnimatedKinetics {
public void draw(PoseStack matrixStack, int xOffset, int yOffset) {
matrixStack.pushPose();
matrixStack.translate(xOffset, yOffset, 0);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, -16, 13);
AllGuiTextures.JEI_SHADOW.render(matrixStack, -16, 13);
matrixStack.translate(-2, 18, 0);
int scale = 22;

View file

@ -89,7 +89,7 @@ public abstract class SequencedAssemblySubCategory {
@Override
public void draw(SequencedRecipe<?> recipe, PoseStack ms, double mouseX, double mouseY, int index) {
spout.offset = index;
AllGuiTextures.JEI_SLOT.draw(ms, 3, 14);
AllGuiTextures.JEI_SLOT.render(ms, 3, 14);
ms.pushPose();
ms.translate(-7, 50, 0);
ms.scale(.75f, .75f, .75f);
@ -143,7 +143,7 @@ public abstract class SequencedAssemblySubCategory {
ms.scale(.75f, .75f, .75f);
deployer.draw(ms, getWidth() / 2, 0);
ms.popPose();
AllGuiTextures.JEI_SLOT.draw(ms, 3, 14);
AllGuiTextures.JEI_SLOT.render(ms, 3, 14);
}
}

View file

@ -6,11 +6,11 @@ import static com.simibubi.create.foundation.utility.AngleHelper.rad;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.gui.widgets.InterpolatedValue;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import com.simibubi.create.foundation.utility.animation.InterpolatedValue;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;

View file

@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack;
public class MechanicalCraftingInventory extends CraftingContainer {
private static AbstractContainerMenu dummyContainer = new AbstractContainerMenu(null, -1) {
private static final AbstractContainerMenu dummyContainer = new AbstractContainerMenu(null, -1) {
public boolean stillValid(Player playerIn) {
return false;
}

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.components.flywheel;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;

View file

@ -5,9 +5,9 @@ import com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTil
import com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTileEntity.CreativeSmartFluidTank;
import com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity;
import com.simibubi.create.foundation.fluid.SmartFluidTank;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;

View file

@ -11,7 +11,6 @@ import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.fluids.FluidStack;
public class FluidStackParticle extends TextureSheetParticle {
@ -98,10 +97,10 @@ public class FluidStackParticle extends TextureSheetParticle {
if (!onGround && level.random.nextFloat() < 1 / 8f)
return;
Vec3 rgb = Color.vectorFromRGB(fluid.getFluid()
Color color = new Color(fluid.getFluid()
.getAttributes()
.getColor(fluid));
level.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, rgb.x, rgb.y, rgb.z);
level.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, color.getRedAsFloat(), color.getGreenAsFloat(), color.getBlueAsFloat());
}
protected boolean canEvaporate() {

View file

@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.fluids.tank;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;

View file

@ -11,9 +11,9 @@ import com.simibubi.create.content.contraptions.fluids.tank.FluidTankBlock.Shape
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.SmartFluidTank;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View file

@ -7,7 +7,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting;

View file

@ -15,8 +15,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pis
import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.CClient;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;

View file

@ -310,7 +310,7 @@ public class InWorldProcessing {
world.addParticle(ParticleTypes.POOF, vec.x, vec.y + .25f, vec.z, 0, 1 / 16f, 0);
break;
case SPLASHING:
Vector3f color = new Vector3f(Color.vectorFromRGB(0x0055FF));
Vector3f color = new Color(0x0055FF).asVectorF();
world.addParticle(new DustParticleOptions(color, 1), vec.x + (world.random.nextFloat() - .5f) * .5f,
vec.y + .5f, vec.z + (world.random.nextFloat() - .5f) * .5f, 0, 1 / 8f, 0);
world.addParticle(ParticleTypes.SPIT, vec.x + (world.random.nextFloat() - .5f) * .5f, vec.y + .5f,

View file

@ -7,10 +7,10 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
@ -44,7 +44,6 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
setWindowSize(background.width, background.height);
setWindowOffset(-20, 0);
super.init();
widgets.clear();
int x = guiLeft;
int y = guiTop;
@ -58,7 +57,10 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
confirmButton =
new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
widgets.add(confirmButton);
confirmButton.withCallback(() -> {
onClose();
});
addRenderableWidget(confirmButton);
}
public void initInputsOfRow(int row, int backgroundX, int backgroundY) {
@ -67,7 +69,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
int rowHeight = 22;
Vector<ScrollInput> rowInputs = inputs.get(row);
rowInputs.forEach(widgets::remove);
removeWidgets(rowInputs);
rowInputs.clear();
int index = row;
Instruction instruction = instructions.get(row);
@ -88,7 +90,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
rowInputs.add(value);
rowInputs.add(direction);
widgets.addAll(rowInputs);
addRenderableWidgets(rowInputs);
updateParamsOfRow(row);
}
@ -130,19 +132,19 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
int x = guiLeft;
int y = guiTop;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
for (int row = 0; row < instructions.capacity(); row++) {
AllGuiTextures toDraw = AllGuiTextures.SEQUENCER_EMPTY;
int yOffset = toDraw.height * row;
if (row >= instructions.size()) {
toDraw.draw(ms, x, y + 14 + yOffset);
toDraw.render(ms, x, y + 14 + yOffset, this);
continue;
}
Instruction instruction = instructions.get(row);
SequencerInstructions def = instruction.instruction;
def.background.draw(ms, x, y + 14 + yOffset);
def.background.render(ms, x, y + 14 + yOffset, this);
label(ms, 36, yOffset - 3, Lang.translate(def.translationKey));
if (def.hasValueParameter) {
@ -187,7 +189,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
for (int i = instructions.size() - 1; i > index; i--) {
instructions.remove(i);
Vector<ScrollInput> rowInputs = inputs.get(i);
rowInputs.forEach(widgets::remove);
removeWidgets(rowInputs);
rowInputs.clear();
}
} else {
@ -198,14 +200,4 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
}
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
return super.mouseClicked(x, y, button);
}
}

View file

@ -132,7 +132,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock implements ITE<Gauge
if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face))
continue;
Vector3f rgb = new Vector3f(Color.vectorFromRGB(color));
Vector3f rgb = new Color(color).asVectorF();
Vec3 faceVec = Vec3.atLowerCornerOf(face.getNormal());
Direction positiveFacing = Direction.get(AxisDirection.POSITIVE, face.getAxis());
Vec3 positiveFaceVec = Vec3.atLowerCornerOf(positiveFacing.getNormal());

View file

@ -6,7 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;

View file

@ -10,11 +10,11 @@ import com.simibubi.create.content.curiosities.symmetry.mirror.TriplePlaneMirror
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
@ -57,7 +57,6 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
setWindowSize(background.width, background.height);
setWindowOffset(-20, 0);
super.init();
widgets.clear();
int x = guiLeft;
int y = guiTop;
@ -93,17 +92,20 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
initAlign(currentElement, x, y);
widgets.add(labelAlign);
widgets.add(areaType);
widgets.add(labelType);
addRenderableWidget(labelAlign);
addRenderableWidget(areaType);
addRenderableWidget(labelType);
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
widgets.add(confirmButton);
confirmButton.withCallback(() -> {
onClose();
});
addRenderableWidget(confirmButton);
}
private void initAlign(SymmetryMirror element, int x, int y) {
if (areaAlign != null)
widgets.remove(areaAlign);
removeWidget(areaAlign);
areaAlign = new SelectionScrollInput(x + 45, y + 43, 109, 18).forOptions(element.getAlignToolTips())
.titled(orientation.plainCopy())
@ -111,7 +113,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
.setState(element.getOrientationIndex())
.calling(element::setOrientation);
widgets.add(areaAlign);
addRenderableWidget(areaAlign);
}
@Override
@ -119,7 +121,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
int x = guiLeft;
int y = guiTop;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
font.draw(ms, wand.getHoverName(), x + 11, y + 4, 0x6B3802);
renderBlock(ms, x, y);
@ -149,14 +151,4 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
AllPackets.channel.sendToServer(new ConfigureSymmetryWandPacket(hand, currentElement));
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (confirmButton.isHovered()) {
onClose();
return true;
}
return super.mouseClicked(x, y, button);
}
}

View file

@ -12,7 +12,7 @@ import com.simibubi.create.AllKeys;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -86,19 +86,19 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
hoveredSlot = UNEQUIP;
ms.pushPose();
AllGuiTextures.TOOLBELT_INACTIVE_SLOT.draw(ms, this, -12, -12);
AllGuiTextures.TOOLBELT_INACTIVE_SLOT.render(ms, -12, -12, this);
GuiGameElement.of(AllBlocks.TOOLBOXES.get(DyeColor.BROWN)
.asStack())
.at(-9, -9)
.render(ms);
ms.translate(0, -40 + (10 * (1 - fade) * (1 - fade)), 0);
AllGuiTextures.TOOLBELT_SLOT.draw(ms, this, -12, -12);
AllGuiTextures.TOOLBELT_SLOT.render(ms, -12, -12, this);
ms.translate(-0.5, 0.5, 0);
AllIcons.I_DISABLE.draw(ms, this, -9, -9);
AllIcons.I_DISABLE.render(ms, -9, -9, this);
ms.translate(0.5, -0.5, 0);
if (!scrollMode && hoveredSlot == UNEQUIP) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -13, -13);
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -13, -13, this);
tip = Lang.translate("toolbox.detach")
.withStyle(ChatFormatting.GOLD);
}
@ -111,12 +111,12 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
ms.pushPose();
ms.translate(80 + (-5 * (1 - fade) * (1 - fade)), 0, 0);
AllGuiTextures.TOOLBELT_SLOT.draw(ms, this, -12, -12);
AllGuiTextures.TOOLBELT_SLOT.render(ms, -12, -12, this);
ms.translate(-0.5, 0.5, 0);
AllIcons.I_TOOLBOX.draw(ms, this, -9, -9);
AllIcons.I_TOOLBOX.render(ms, -9, -9, this);
ms.translate(0.5, -0.5, 0);
if (!scrollMode && hoveredSlot == DEPOSIT) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -13, -13);
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -13, -13, this);
tip = Lang.translate(state == State.SELECT_BOX ? "toolbox.depositAll" : "toolbox.depositBox")
.withStyle(ChatFormatting.GOLD);
}
@ -138,23 +138,23 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
boolean empty = inv.getStackInSlot(slot * ToolboxInventory.STACKS_PER_COMPARTMENT)
.isEmpty();
(empty ? AllGuiTextures.TOOLBELT_INACTIVE_SLOT : AllGuiTextures.TOOLBELT_SLOT).draw(ms, this, 0,
0);
(empty ? AllGuiTextures.TOOLBELT_INACTIVE_SLOT : AllGuiTextures.TOOLBELT_SLOT)
.render(ms, 0, 0, this);
GuiGameElement.of(stackInSlot)
.at(3, 3)
.render(ms);
if (slot == (scrollMode ? scrollSlot : hoveredSlot) && !empty) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -1, -1);
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -1, -1, this);
tip = stackInSlot.getHoverName();
}
} else
AllGuiTextures.TOOLBELT_EMPTY_SLOT.draw(ms, this, 0, 0);
AllGuiTextures.TOOLBELT_EMPTY_SLOT.render(ms, 0, 0, this);
} else if (state == State.SELECT_BOX) {
if (slot < toolboxes.size()) {
AllGuiTextures.TOOLBELT_SLOT.draw(ms, this, 0, 0);
AllGuiTextures.TOOLBELT_SLOT.render(ms, 0, 0, this);
ToolboxTileEntity toolboxTileEntity = toolboxes.get(slot);
GuiGameElement.of(AllBlocks.TOOLBOXES.get(toolboxTileEntity.getColor())
.asStack())
@ -162,11 +162,11 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
.render(ms);
if (slot == (scrollMode ? scrollSlot : hoveredSlot)) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -1, -1);
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -1, -1, this);
tip = toolboxTileEntity.getDisplayName();
}
} else
AllGuiTextures.TOOLBELT_EMPTY_SLOT.draw(ms, this, 0, 0);
AllGuiTextures.TOOLBELT_EMPTY_SLOT.render(ms, 0, 0, this);
}
@ -175,10 +175,10 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
if (renderCenterSlot) {
ms.pushPose();
AllGuiTextures.TOOLBELT_SLOT.draw(ms, this, -12, -12);
(scrollMode ? AllIcons.I_REFRESH : AllIcons.I_FLIP).draw(ms, this, -9, -9);
AllGuiTextures.TOOLBELT_SLOT.render(ms, -12, -12, this);
(scrollMode ? AllIcons.I_REFRESH : AllIcons.I_FLIP).render(ms, -9, -9, this);
if (!scrollMode && UNEQUIP == hoveredSlot) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -13, -13);
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -13, -13, this);
tip = Lang.translate("toolbox.unequip", minecraft.player.getMainHandItem()
.getHoverName())
.withStyle(ChatFormatting.GOLD);

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.curiosities.toolbox;
import static com.simibubi.create.content.curiosities.toolbox.ToolboxInventory.STACKS_PER_COMPARTMENT;
import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.foundation.gui.ContainerBase;
import com.simibubi.create.foundation.gui.container.ContainerBase;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
@ -21,10 +21,6 @@ import net.minecraftforge.items.SlotItemHandler;
public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
public static ToolboxContainer create(int id, Inventory inv, ToolboxTileEntity te) {
return new ToolboxContainer(AllContainerTypes.TOOLBOX.get(), id, inv, te);
}
public ToolboxContainer(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
super(type, id, inv, extraData);
}
@ -34,6 +30,10 @@ public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
te.startOpen(player);
}
public static ToolboxContainer create(int id, Inventory inv, ToolboxTileEntity te) {
return new ToolboxContainer(AllContainerTypes.TOOLBOX.get(), id, inv, te);
}
@Override
protected ToolboxTileEntity createOnClient(FriendlyByteBuf extraData) {
BlockPos readBlockPos = extraData.readBlockPos();
@ -121,7 +121,7 @@ public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
protected void addSlots() {
ToolboxInventory inventory = contentHolder.inventory;
int x = 59;
int x = 79;
int y = 37;
int[] xOffsets = { x, x + 33, x + 66, x + 66 + 6, x + 66, x + 33, x, x - 6 };
@ -138,7 +138,7 @@ public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
addSlot(new SlotItemHandler(inventory, baseIndex + i, -100, -100));
}
addPlayerSlots(-12, 166);
addPlayerSlots(8, 165);
}
@Override

View file

@ -177,7 +177,7 @@ public class ToolboxHandlerClient {
AllGuiTextures texture = ToolboxHandler.distance(player.position(), pos) < max * max
? selected ? TOOLBELT_SELECTED_ON : TOOLBELT_HOTBAR_ON
: selected ? TOOLBELT_SELECTED_OFF : TOOLBELT_HOTBAR_OFF;
texture.draw(ms, x + 20 * slot - offset, y + offset);
texture.render(ms, x + 20 * slot - offset, y + offset);
}
ms.popPose();
}

View file

@ -9,11 +9,11 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
@ -27,8 +27,9 @@ import net.minecraft.world.item.ItemStack;
public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer> {
AllGuiTextures BG = AllGuiTextures.TOOLBOX;
AllGuiTextures PLAYER = AllGuiTextures.PLAYER_INVENTORY;
protected static final AllGuiTextures BG = AllGuiTextures.TOOLBOX;
protected static final AllGuiTextures PLAYER = AllGuiTextures.PLAYER_INVENTORY;
protected Slot hoveredToolboxSlot;
private IconButton confirmButton;
private IconButton disposeButton;
@ -43,18 +44,28 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer>
@Override
protected void init() {
setWindowSize(30 + BG.width, BG.height + PLAYER.height - 24);
setWindowOffset(-11, 0);
super.init();
widgets.clear();
setWindowSize(BG.width, 256);
confirmButton = new IconButton(getGuiLeft() + BG.width - 23, getGuiTop() + BG.height - 24, AllIcons.I_CONFIRM);
disposeButton = new IconButton(getGuiLeft() + 91, getGuiTop() + 69, AllIcons.I_TOOLBOX);
disposeButton.setToolTip(Lang.translate("toolbox.depositBox"));
widgets.add(confirmButton);
widgets.add(disposeButton);
color = menu.contentHolder.getColor();
extraAreas = ImmutableList.of(new Rect2i(getGuiLeft() + -28, getGuiTop() + 141, 80, 100),
new Rect2i(getGuiLeft() + 162, getGuiTop() + 111, 100, 70));
confirmButton = new IconButton(leftPos + 30 + BG.width - 33, topPos + BG.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
addRenderableWidget(confirmButton);
disposeButton = new IconButton(leftPos + 30 + 81, topPos + 69, AllIcons.I_TOOLBOX);
disposeButton.withCallback(() -> {
AllPackets.channel.sendToServer(new ToolboxDisposeAllPacket(menu.contentHolder.getBlockPos()));
});
disposeButton.setToolTip(Lang.translate("toolbox.depositBox"));
addRenderableWidget(disposeButton);
extraAreas = ImmutableList.of(
new Rect2i(leftPos + 30 + BG.width, topPos + BG.height - 15 - 34 - 6, 72, 68)
);
}
@Override
@ -65,18 +76,18 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer>
}
@Override
public void setBlitOffset(int p_230926_1_) {
super.setBlitOffset(p_230926_1_);
}
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int x = leftPos + imageWidth - BG.width;
int y = topPos;
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
BG.draw(ms, this, leftPos + 10, topPos);
PLAYER.draw(ms, this, leftPos + (BG.width - PLAYER.width) / 2 - 26, topPos + imageHeight - PLAYER.height);
font.draw(ms, title, leftPos + 24, topPos + 4, 0x442000);
font.draw(ms, playerInventoryTitle, leftPos - 13, topPos + 154, 0x404040);
BG.render(ms, x, y, this);
font.draw(ms, title, x + 15, y + 4, 0x442000);
renderToolbox(ms, mouseX, mouseY, partialTicks);
int invX = leftPos;
int invY = topPos + imageHeight - PLAYER.height;
renderPlayerInventory(ms, invX, invY);
renderToolbox(ms, x + BG.width + 50, y + BG.height + 12, partialTicks);
hoveredToolboxSlot = null;
for (int compartment = 0; compartment < 8; compartment++) {
@ -91,7 +102,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer>
if (!itemstack.isEmpty()) {
int count = menu.totalCountInCompartment(compartment);
String s = count + "";
String s = String.valueOf(count);
setBlitOffset(100);
itemRenderer.blitOffset = 100.0F;
RenderSystem.enableDepthTest();
@ -113,9 +124,9 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer>
}
}
private void renderToolbox(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
private void renderToolbox(PoseStack ms, int x, int y, float partialTicks) {
ms.pushPose();
ms.translate(leftPos + 247, topPos + 180, 100);
ms.translate(x, y, 100);
MatrixTransformStack.of(ms)
.scale(50)
.rotateX(-22)
@ -146,28 +157,10 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer>
}
@Override
protected void renderWindowForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
protected void renderForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
if (hoveredToolboxSlot != null)
hoveredSlot = hoveredToolboxSlot;
super.renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks);
}
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean mouseClicked = super.mouseClicked(x, y, button);
if (button == 0) {
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
if (disposeButton.isHovered()) {
AllPackets.channel.sendToServer(new ToolboxDisposeAllPacket(menu.contentHolder.getBlockPos()));
return true;
}
}
return mouseClicked;
super.renderForeground(matrixStack, mouseX, mouseY, partialTicks);
}
@Override

View file

@ -4,7 +4,7 @@ import java.util.Optional;
import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection;
import com.simibubi.create.foundation.gui.GhostItemContainer;
import com.simibubi.create.foundation.gui.container.GhostItemContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf;

View file

@ -16,9 +16,9 @@ import com.simibubi.create.content.logistics.item.filter.FilterItem;
import com.simibubi.create.content.schematics.ISpecialEntityItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.gui.IInteractionChecker;
import com.simibubi.create.foundation.networking.ISyncPersistentData;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.IInteractionChecker;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
@ -456,7 +456,7 @@ public class BlueprintEntity extends HangingEntity
static class BlueprintCraftingInventory extends CraftingContainer {
private static AbstractContainerMenu dummyContainer = new AbstractContainerMenu(null, -1) {
private static final AbstractContainerMenu dummyContainer = new AbstractContainerMenu(null, -1) {
public boolean stillValid(Player playerIn) {
return false;
}

View file

@ -16,7 +16,7 @@ import com.simibubi.create.content.logistics.item.filter.AttributeFilterContaine
import com.simibubi.create.content.logistics.item.filter.FilterItem;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Pair;
@ -219,7 +219,7 @@ public class BlueprintOverlayRenderer {
for (Pair<ItemStack, Boolean> pair : ingredients) {
RenderSystem.enableBlend();
(pair.getSecond() ? AllGuiTextures.HOTSLOT_ACTIVE : AllGuiTextures.HOTSLOT).draw(ms, x, y);
(pair.getSecond() ? AllGuiTextures.HOTSLOT_ACTIVE : AllGuiTextures.HOTSLOT).render(ms, x, y);
ItemStack itemStack = pair.getFirst();
String count = pair.getSecond() ? null : ChatFormatting.GOLD.toString() + itemStack.getCount();
drawItemStack(ms, mc, x, y, itemStack, count);
@ -228,16 +228,16 @@ public class BlueprintOverlayRenderer {
x += 5;
RenderSystem.enableBlend();
AllGuiTextures.HOTSLOT_ARROW.draw(ms, x, y + 4);
AllGuiTextures.HOTSLOT_ARROW.render(ms, x, y + 4);
x += 25;
if (result.isEmpty()) {
AllGuiTextures.HOTSLOT.draw(ms, x, y);
AllGuiTextures.HOTSLOT.render(ms, x, y);
GuiGameElement.of(Items.BARRIER)
.at(x + 3, y + 3)
.render(ms);
} else {
(resultCraftable ? AllGuiTextures.HOTSLOT_SUPER_ACTIVE : AllGuiTextures.HOTSLOT).draw(ms,
(resultCraftable ? AllGuiTextures.HOTSLOT_SUPER_ACTIVE : AllGuiTextures.HOTSLOT).render(ms,
resultCraftable ? x - 1 : x, resultCraftable ? y - 1 : y);
drawItemStack(ms, mc, x, y, result, null);
}

View file

@ -11,11 +11,11 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket;
import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
@ -41,18 +41,25 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
@Override
protected void init() {
setWindowSize(background.width, background.height + 4 + PLAYER_INVENTORY.height);
setWindowOffset(2 + (width % 2 == 0 ? 0 : -1), 0);
setWindowOffset(1, 0);
super.init();
widgets.clear();
int x = leftPos;
int y = topPos;
resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH);
resetButton.withCallback(() -> {
menu.clearContents();
contentsCleared();
menu.sendClearPacket();
});
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
widgets.add(resetButton);
widgets.add(confirmButton);
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width, y + background.height - 36, 56, 44)
@ -60,7 +67,7 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int invX = getLeftOfCentered(PLAYER_INVENTORY.width);
int invY = topPos + background.height + 4;
renderPlayerInventory(ms, invX, invY);
@ -68,7 +75,7 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
int x = leftPos;
int y = topPos;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
font.draw(ms, title, x + 15, y + 4, 0xFFFFFF);
GuiGameElement.of(AllBlockPartials.CRAFTING_BLUEPRINT_1x1)
@ -131,10 +138,12 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
@Override
protected void containerTick() {
// handleTooltips();
if (!menu.contentHolder.isEntityAlive())
minecraft.player.closeContainer();
menu.player.closeContainer();
super.containerTick();
// handleTooltips();
}
// protected void handleTooltips() {
@ -157,26 +166,6 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
// }
// }
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean mouseClicked = super.mouseClicked(x, y, button);
if (button == 0) {
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
if (resetButton.isHovered()) {
menu.clearContents();
contentsCleared();
menu.sendClearPacket();
return true;
}
}
return mouseClicked;
}
protected void contentsCleared() {}
protected void sendOptionUpdate(Option option) {

View file

@ -7,8 +7,8 @@ import com.mojang.math.Vector3f;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper;
@ -57,7 +57,6 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
setWindowSize(background.width, background.height);
setWindowOffset(-10, 0);
super.init();
widgets.clear();
animationProgress = 0;
@ -66,23 +65,30 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
confirmButton =
new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
widgets.add(confirmButton);
confirmButton.withCallback(() -> {
onClose();
});
addRenderableWidget(confirmButton);
patternButtons.clear();
for (int row = 0; row <= 1; row++) {
for (int col = 0; col <= 2; col++) {
int id = patternButtons.size();
PlacementPatterns pattern = PlacementPatterns.values()[id];
patternButtons
.add(new IconButton(x + background.width - 76 + col * 18, y + 21 + row * 18, pattern.icon));
patternButtons.get(id)
.setToolTip(Lang.translate("gui.terrainzapper.pattern." + pattern.translationKey));
IconButton patternButton = new IconButton(x + background.width - 76 + col * 18, y + 21 + row * 18, pattern.icon);
patternButton.withCallback(() -> {
patternButtons.forEach(b -> b.active = true);
patternButton.active = false;
currentPattern = pattern;
});
patternButton.setToolTip(Lang.translate("gui.terrainzapper.pattern." + pattern.translationKey));
patternButtons.add(patternButton);
}
}
patternButtons.get(currentPattern.ordinal()).active = false;
widgets.addAll(patternButtons);
addRenderableWidgets(patternButtons);
}
@Override
@ -90,7 +96,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
int x = guiLeft;
int y = guiTop;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
drawOnBackground(ms, x, y);
renderBlock(ms, x, y);
@ -114,25 +120,6 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
AllPackets.channel.sendToServer(packet);
}
@Override
public boolean mouseClicked(double x, double y, int button) {
for (IconButton patternButton : patternButtons) {
if (patternButton.isHovered()) {
patternButtons.forEach(b -> b.active = true);
patternButton.active = false;
patternButton.playDownSound(minecraft.getSoundManager());
currentPattern = PlacementPatterns.values()[patternButtons.indexOf(patternButton)];
}
}
if (confirmButton.isHovered()) {
onClose();
return true;
}
return super.mouseClicked(x, y, button);
}
protected void renderZapper(PoseStack ms, int x, int y) {
GuiGameElement.of(zapper)
.scale(4)

View file

@ -8,12 +8,12 @@ import com.simibubi.create.content.curiosities.zapper.ConfigureZapperPacket;
import com.simibubi.create.content.curiosities.zapper.ZapperScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widgets.Indicator.State;
import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.gui.widget.Indicator.State;
import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper;
@ -93,8 +93,8 @@ public class WorldshaperScreen extends ZapperScreen {
brushInput.setState(currentBrush.ordinal());
widgets.add(brushLabel);
widgets.add(brushInput);
addRenderableWidget(brushLabel);
addRenderableWidget(brushInput);
initBrushParams(x, y);
}
@ -104,8 +104,8 @@ public class WorldshaperScreen extends ZapperScreen {
// Brush Params
widgets.removeAll(brushParamLabels);
widgets.removeAll(brushParams);
removeWidgets(brushParamLabels);
removeWidgets(brushParams);
brushParamLabels.clear();
brushParams.clear();
@ -136,16 +136,16 @@ public class WorldshaperScreen extends ZapperScreen {
brushParams.add(input);
}
widgets.addAll(brushParamLabels);
widgets.addAll(brushParams);
addRenderableWidgets(brushParamLabels);
addRenderableWidgets(brushParams);
// Connectivity Options
if (followDiagonals != null) {
widgets.remove(followDiagonals);
widgets.remove(followDiagonalsIndicator);
widgets.remove(acrossMaterials);
widgets.remove(acrossMaterialsIndicator);
removeWidget(followDiagonals);
removeWidget(followDiagonalsIndicator);
removeWidget(acrossMaterials);
removeWidget(acrossMaterialsIndicator);
followDiagonals = null;
followDiagonalsIndicator = null;
acrossMaterials = null;
@ -161,12 +161,20 @@ public class WorldshaperScreen extends ZapperScreen {
acrossMaterialsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY);
acrossMaterials = new IconButton(x1, y1, AllIcons.I_FOLLOW_MATERIAL);
followDiagonals.withCallback(() -> {
followDiagonalsIndicator.state = followDiagonalsIndicator.state == State.OFF ? State.ON : State.OFF;
currentFollowDiagonals = !currentFollowDiagonals;
});
followDiagonals.setToolTip(Lang.translate("gui.terrainzapper.searchDiagonal"));
acrossMaterials.withCallback(() -> {
acrossMaterialsIndicator.state = acrossMaterialsIndicator.state == State.OFF ? State.ON : State.OFF;
currentAcrossMaterials = !currentAcrossMaterials;
});
acrossMaterials.setToolTip(Lang.translate("gui.terrainzapper.searchFuzzy"));
widgets.add(followDiagonals);
widgets.add(followDiagonalsIndicator);
widgets.add(acrossMaterials);
widgets.add(acrossMaterialsIndicator);
addRenderableWidget(followDiagonals);
addRenderableWidget(followDiagonalsIndicator);
addRenderableWidget(acrossMaterials);
addRenderableWidget(acrossMaterialsIndicator);
if (currentFollowDiagonals)
followDiagonalsIndicator.state = State.ON;
if (currentAcrossMaterials)
@ -176,15 +184,20 @@ public class WorldshaperScreen extends ZapperScreen {
// Tools
if (toolButtons != null)
widgets.removeAll(toolButtons);
removeWidgets(toolButtons);
TerrainTools[] toolValues = currentBrush.getSupportedTools();
toolButtons = new Vector<>(toolValues.length);
for (int id = 0; id < toolValues.length; id++) {
TerrainTools tool = toolValues[id];
toolButtons.add(new IconButton(x + 7 + id * 18, y + 79, tool.icon));
toolButtons.get(id)
.setToolTip(Lang.translate("gui.terrainzapper.tool." + tool.translationKey));
IconButton toolButton = new IconButton(x + 7 + id * 18, y + 79, tool.icon);
toolButton.withCallback(() -> {
toolButtons.forEach(b -> b.active = true);
toolButton.active = false;
currentTool = tool;
});
toolButton.setToolTip(Lang.translate("gui.terrainzapper.tool." + tool.translationKey));
toolButtons.add(toolButton);
}
int toolIndex = -1;
@ -197,72 +210,41 @@ public class WorldshaperScreen extends ZapperScreen {
}
toolButtons.get(toolIndex).active = false;
widgets.addAll(toolButtons);
addRenderableWidgets(toolButtons);
// Placement Options
if (placementButtons != null)
widgets.removeAll(placementButtons);
removeWidgets(placementButtons);
if (currentBrush.hasPlacementOptions()) {
PlacementOptions[] placementValues = PlacementOptions.values();
placementButtons = new Vector<>(placementValues.length);
for (int id = 0; id < placementValues.length; id++) {
PlacementOptions option = placementValues[id];
placementButtons.add(new IconButton(x + 136 + id * 18, y + 79, option.icon));
placementButtons.get(id)
.setToolTip(Lang.translate("gui.terrainzapper.placement." + option.translationKey));
IconButton placementButton = new IconButton(x + 136 + id * 18, y + 79, option.icon);
placementButton.withCallback(() -> {
placementButtons.forEach(b -> b.active = true);
placementButton.active = false;
currentPlacement = option;
});
placementButton.setToolTip(Lang.translate("gui.terrainzapper.placement." + option.translationKey));
placementButtons.add(placementButton);
}
placementButtons.get(currentPlacement.ordinal()).active = false;
widgets.addAll(placementButtons);
addRenderableWidgets(placementButtons);
}
}
@Override
public boolean mouseClicked(double x, double y, int button) {
TerrainTools[] supportedTools = currentBrush.get()
.getSupportedTools();
for (IconButton toolButton : toolButtons) {
if (toolButton.isHovered()) {
toolButtons.forEach(b -> b.active = true);
toolButton.active = false;
toolButton.playDownSound(minecraft.getSoundManager());
currentTool = supportedTools[toolButtons.indexOf(toolButton)];
}
}
if (placementButtons != null) {
for (IconButton placementButton : placementButtons) {
if (placementButton.isHovered()) {
placementButtons.forEach(b -> b.active = true);
placementButton.active = false;
placementButton.playDownSound(minecraft.getSoundManager());
currentPlacement = PlacementOptions.values()[placementButtons.indexOf(placementButton)];
}
}
}
if (followDiagonals != null && followDiagonals.isHovered()) {
followDiagonalsIndicator.state = followDiagonalsIndicator.state == State.OFF ? State.ON : State.OFF;
currentFollowDiagonals = !currentFollowDiagonals;
}
if (acrossMaterials != null && acrossMaterials.isHovered()) {
acrossMaterialsIndicator.state = acrossMaterialsIndicator.state == State.OFF ? State.ON : State.OFF;
currentAcrossMaterials = !currentAcrossMaterials;
}
return super.mouseClicked(x, y, button);
}
@Override
protected void drawOnBackground(PoseStack matrixStack, int x, int y) {
super.drawOnBackground(matrixStack, x, y);
Brush currentBrush = this.currentBrush.get();
for (int index = 2; index >= currentBrush.amtParams; index--)
AllGuiTextures.TERRAINZAPPER_INACTIVE_PARAM.draw(matrixStack, x + 56 + 20 * index, y + 40);
AllGuiTextures.TERRAINZAPPER_INACTIVE_PARAM.render(matrixStack, x + 56 + 20 * index, y + 40, this);
font.draw(matrixStack, toolSection, x + 7, y + 69, fontColor);
if (currentBrush.hasPlacementOptions())

View file

@ -12,9 +12,9 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.FlapData;
import com.simibubi.create.foundation.gui.widgets.InterpolatedValue;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.animation.InterpolatedValue;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LightLayer;

View file

@ -15,11 +15,11 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape;
import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock;
import com.simibubi.create.content.logistics.packet.TunnelFlapPacket;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View file

@ -17,7 +17,6 @@ import com.simibubi.create.content.contraptions.particle.AirParticleData;
import com.simibubi.create.content.logistics.block.funnel.FunnelBlock;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.widgets.InterpolatedValue;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
@ -29,6 +28,7 @@ import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedValue;
import net.minecraft.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -208,7 +208,7 @@ public class EjectorTargetHandler {
double tickOffset = totalFlyingTicks / segments;
boolean valid = xDiff == validX && zDiff == validZ;
int intColor = valid ? 0x9ede73 : 0xff7171;
Vector3f color = new Vector3f(Color.vectorFromRGB(intColor));
Vector3f color = new Color(intColor).asVectorF();
DustParticleOptions data = new DustParticleOptions(color, 1);
ClientLevel world = mc.level;

View file

@ -14,7 +14,6 @@ import com.simibubi.create.content.contraptions.relays.belt.transport.Transporte
import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock.Shape;
import com.simibubi.create.content.logistics.packet.FunnelFlapPacket;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
@ -23,6 +22,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View file

@ -1,72 +1,72 @@
package com.simibubi.create.content.logistics.block.inventories;
import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.foundation.gui.container.ContainerBase;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.items.SlotItemHandler;
public class AdjustableCrateContainer extends AbstractContainerMenu {
public class AdjustableCrateContainer extends ContainerBase<AdjustableCrateTileEntity> {
public AdjustableCrateTileEntity te;
public Inventory playerInventory;
public boolean doubleCrate;
protected boolean doubleCrate;
public AdjustableCrateContainer(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
super(type, id);
ClientLevel world = Minecraft.getInstance().level;
BlockEntity tileEntity = world.getBlockEntity(extraData.readBlockPos());
this.playerInventory = inv;
if (tileEntity instanceof AdjustableCrateTileEntity) {
this.te = (AdjustableCrateTileEntity) tileEntity;
this.te.handleUpdateTag(extraData.readNbt());
init();
}
super(type, id, inv, extraData);
}
public AdjustableCrateContainer(MenuType<?> type, int id, Inventory inv, AdjustableCrateTileEntity te) {
super(type, id);
this.te = te;
this.playerInventory = inv;
init();
super(type, id, inv, te);
}
public static AdjustableCrateContainer create(int id, Inventory inv, AdjustableCrateTileEntity te) {
return new AdjustableCrateContainer(AllContainerTypes.FLEXCRATE.get(), id, inv, te);
}
private void init() {
doubleCrate = te.isDoubleCrate();
@Override
protected AdjustableCrateTileEntity createOnClient(FriendlyByteBuf extraData) {
BlockPos readBlockPos = extraData.readBlockPos();
CompoundTag readNbt = extraData.readNbt();
ClientLevel world = Minecraft.getInstance().level;
BlockEntity tileEntity = world.getBlockEntity(readBlockPos);
if (tileEntity instanceof AdjustableCrateTileEntity crate) {
crate.handleUpdateTag(readNbt);
return crate;
}
return null;
}
@Override
protected void initAndReadInventory(AdjustableCrateTileEntity contentHolder) {
doubleCrate = contentHolder.isDoubleCrate();
}
@Override
protected void addSlots() {
int x = doubleCrate ? 23 : 53;
int maxCol = doubleCrate ? 8 : 4;
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < maxCol; ++col) {
this.addSlot(new SlotItemHandler(te.inventory, col + row * maxCol, x + col * 18, 20 + row * 18));
this.addSlot(new SlotItemHandler(contentHolder.inventory, col + row * maxCol, x + col * 18, 20 + row * 18));
}
}
// player Slots
int xOffset = doubleCrate ? 20 : 8;
int yOffset = 149;
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 9; ++col) {
this.addSlot(new Slot(playerInventory, col + row * 9 + 9, xOffset + col * 18, yOffset + row * 18));
}
addPlayerSlots(doubleCrate ? 20 : 8, 149);
}
for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot) {
this.addSlot(new Slot(playerInventory, hotbarSlot, xOffset + hotbarSlot * 18, yOffset + 58));
}
broadcastChanges();
@Override
protected void saveData(AdjustableCrateTileEntity contentHolder) {
}
@Override
@ -79,16 +79,11 @@ public class AdjustableCrateContainer extends AbstractContainerMenu {
int crateSize = doubleCrate ? 32 : 16;
if (index < crateSize) {
moveItemStackTo(stack, crateSize, slots.size(), false);
te.inventory.onContentsChanged(index);
contentHolder.inventory.onContentsChanged(index);
} else
moveItemStackTo(stack, 0, crateSize - 1, false);
return ItemStack.EMPTY;
}
@Override
public boolean stillValid(Player player) {
return te != null && te.canPlayerUse(player);
}
}

View file

@ -11,11 +11,11 @@ import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.logistics.packet.ConfigureFlexcratePacket;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
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.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
@ -44,7 +44,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
public AdjustableCrateScreen(AdjustableCrateContainer container, Inventory inv, Component title) {
super(container, inv, title);
te = container.te;
te = container.contentHolder;
lastModification = -1;
background = container.doubleCrate ? ADJUSTABLE_DOUBLE_CRATE : ADJUSTABLE_CRATE;
}
@ -54,7 +54,6 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
setWindowSize(Math.max(background.width, PLAYER_INVENTORY.width), background.height + 4 + PLAYER_INVENTORY.height);
setWindowOffset(menu.doubleCrate ? -2 : 0, 0);
super.init();
widgets.clear();
itemLabelOffset = menu.doubleCrate ? 137 : 65;
textureXShift = menu.doubleCrate ? 0 : (imageWidth - (background.width - 8)) / 2;
@ -72,8 +71,8 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
.setState(te.allowedAmount)
.calling(s -> lastModification = 0);
allowedItems.onChanged();
widgets.add(allowedItemsLabel);
widgets.add(allowedItems);
addRenderableWidget(allowedItemsLabel);
addRenderableWidget(allowedItems);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width, y + background.height - 56 + itemYShift, 80, 80)
@ -81,7 +80,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int invX = getLeftOfCentered(PLAYER_INVENTORY.width);
int invY = topPos + background.height + 4;
renderPlayerInventory(ms, invX, invY);
@ -89,7 +88,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
int x = leftPos + textureXShift;
int y = topPos;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF);
String itemCount = String.valueOf(te.itemCount);
@ -101,7 +100,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
int slotsPerRow = (menu.doubleCrate ? 8 : 4);
int slotX = x + 22 + (slot % slotsPerRow) * 18;
int slotY = y + 19 + (slot / slotsPerRow) * 18;
AllGuiTextures.ADJUSTABLE_CRATE_LOCKED_SLOT.draw(ms, this, slotX, slotY);
AllGuiTextures.ADJUSTABLE_CRATE_LOCKED_SLOT.render(ms, slotX, slotY, this);
}
GuiGameElement.of(renderedItem)
@ -120,6 +119,8 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
if (!AllBlocks.ADJUSTABLE_CRATE.has(minecraft.level.getBlockState(te.getBlockPos())))
minecraft.setScreen(null);
super.containerTick();
if (lastModification >= 0)
lastModification++;

View file

@ -14,7 +14,6 @@ import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionP
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.widgets.InterpolatedAngle;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
@ -24,6 +23,7 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedAngle;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View file

@ -4,10 +4,10 @@ import java.util.List;
import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;

View file

@ -6,9 +6,9 @@ import com.simibubi.create.content.logistics.packet.ConfigureStockswitchPacket;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -47,7 +47,6 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
setWindowSize(background.width, background.height);
setWindowOffset(-20, 0);
super.init();
widgets.clear();
int x = guiLeft;
int y = guiTop;
@ -84,16 +83,22 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
onAbove.onChanged();
offBelow.onChanged();
widgets.add(onAbove);
widgets.add(offBelow);
addRenderableWidget(onAbove);
addRenderableWidget(offBelow);
confirmButton =
new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
widgets.add(confirmButton);
confirmButton.withCallback(() -> {
onClose();
});
addRenderableWidget(confirmButton);
flipSignals = new IconButton(x + 14, y + 40, AllIcons.I_FLIP);
flipSignals.withCallback(() -> {
send(!te.isInverted());
});
flipSignals.setToolTip(invertSignal);
widgets.add(flipSignals);
addRenderableWidget(flipSignals);
}
@Override
@ -101,10 +106,10 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
int x = guiLeft;
int y = guiTop;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
AllGuiTextures.STOCKSWITCH_POWERED_LANE.draw(ms, this, x + 36, y + (te.isInverted() ? 18 : 40));
AllGuiTextures.STOCKSWITCH_UNPOWERED_LANE.draw(ms, this, x + 36, y + (te.isInverted() ? 40 : 18));
AllGuiTextures.STOCKSWITCH_POWERED_LANE.render(ms, x + 36, y + (te.isInverted() ? 18 : 40), this);
AllGuiTextures.STOCKSWITCH_UNPOWERED_LANE.render(ms, x + 36, y + (te.isInverted() ? 40 : 18), this);
drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF);
AllGuiTextures sprite = AllGuiTextures.STOCKSWITCH_INTERVAL;
@ -116,15 +121,15 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
(int) (sprite.width - upperBound), sprite.height);
blit(ms, x + 37, y + 40, sprite.startX, sprite.startY, (int) (lowerBound), sprite.height);
AllGuiTextures.STOCKSWITCH_ARROW_UP.draw(ms, this, (int) (x + lowerBound + 36) - 2, y + 35);
AllGuiTextures.STOCKSWITCH_ARROW_DOWN.draw(ms, this, (int) (x + upperBound + 36) - 3, y + 17);
AllGuiTextures.STOCKSWITCH_ARROW_UP.render(ms, (int) (x + lowerBound + 36) - 2, y + 35, this);
AllGuiTextures.STOCKSWITCH_ARROW_DOWN.render(ms, (int) (x + upperBound + 36) - 3, y + 17, this);
if (te.currentLevel != -1) {
AllGuiTextures cursor = AllGuiTextures.STOCKSWITCH_CURSOR;
ms.pushPose();
ms.translate(Math.min(99, this.cursor.getValue(partialTicks) * sprite.width),
cursorLane.getValue(partialTicks) * 22, 0);
cursor.draw(ms, this, x + 34, y + 19);
cursor.render(ms, x + 34, y + 19, this);
ms.popPose();
}
@ -162,15 +167,4 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
onAbove.getState() / 100f, invert));
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (flipSignals.isHovered())
send(!te.isInverted());
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
return super.mouseClicked(x, y, button);
}
}

View file

@ -1,69 +1,52 @@
package com.simibubi.create.content.logistics.item;
import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.foundation.gui.IClearableContainer;
import com.simibubi.create.foundation.gui.container.GhostItemContainer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.SlotItemHandler;
public class LinkedControllerContainer extends AbstractContainerMenu implements IClearableContainer {
public Player player;
protected Inventory playerInventory;
public ItemStack mainItem;
public ItemStackHandler filterInventory;
public class LinkedControllerContainer extends GhostItemContainer<ItemStack> {
public LinkedControllerContainer(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
this(type, id, inv, extraData.readItem());
super(type, id, inv, extraData);
}
public LinkedControllerContainer(MenuType<?> type, int id, Inventory inv, ItemStack filterItem) {
super(type, id);
player = inv.player;
playerInventory = inv;
this.mainItem = filterItem;
init();
super(type, id, inv, filterItem);
}
public static LinkedControllerContainer create(int id, Inventory inv, ItemStack filterItem) {
return new LinkedControllerContainer(AllContainerTypes.LINKED_CONTROLLER.get(), id, inv, filterItem);
}
protected void init() {
this.filterInventory = createFilterInventory();
// readData(mainItem);
addPlayerSlots();
addLinkSlots();
broadcastChanges();
@Override
protected ItemStack createOnClient(FriendlyByteBuf extraData) {
return extraData.readItem();
}
protected void addPlayerSlots() {
int x = 8;
int y = 131;
for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot)
this.addSlot(new Slot(playerInventory, hotbarSlot, x + hotbarSlot * 18, y + 58));
for (int row = 0; row < 3; ++row)
for (int col = 0; col < 9; ++col)
this.addSlot(new Slot(playerInventory, col + row * 9 + 9, x + col * 18, y + row * 18));
@Override
protected ItemStackHandler createGhostInventory() {
return LinkedControllerItem.getFrequencyItems(contentHolder);
}
protected void addLinkSlots() {
@Override
protected void addSlots() {
addPlayerSlots(8, 131);
int x = 12;
int y = 34;
int slot = 0;
for (int column = 0; column < 6; column++) {
for (int row = 0; row < 2; ++row)
addSlot(new SlotItemHandler(filterInventory, slot++, x, y + row * 18));
addSlot(new SlotItemHandler(ghostInventory, slot++, x, y + row * 18));
x += 24;
if (column == 3)
x += 11;
@ -71,89 +54,26 @@ public class LinkedControllerContainer extends AbstractContainerMenu implements
}
@Override
public void clearContents() {
for (int i = 0; i < filterInventory.getSlots(); i++)
filterInventory.setStackInSlot(i, ItemStack.EMPTY);
protected void saveData(ItemStack contentHolder) {
contentHolder.getOrCreateTag()
.put("Items", ghostInventory.serializeNBT());
}
@Override
public boolean canTakeItemForPickAll(ItemStack stack, Slot slotIn) {
return canDragTo(slotIn);
}
@Override
public boolean canDragTo(Slot slotIn) {
return slotIn.container == playerInventory;
}
@Override
public boolean stillValid(Player playerIn) {
return playerInventory.getSelected() == mainItem;
protected boolean allowRepeats() {
return true;
}
@Override
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
if (slotId == playerInventory.selected && clickTypeIn != ClickType.THROW)
return;
ItemStack held = getCarried();
if (slotId < 36) {
super.clicked(slotId, dragType, clickTypeIn, player);
return;
}
if (clickTypeIn == ClickType.THROW)
return;
int slot = slotId - 36;
if (clickTypeIn == ClickType.CLONE) {
if (player.isCreative() && held.isEmpty()) {
ItemStack stackInSlot = filterInventory.getStackInSlot(slot)
.copy();
stackInSlot.setCount(64);
setCarried(stackInSlot);
return;
}
return;
}
if (held.isEmpty()) {
filterInventory.setStackInSlot(slot, ItemStack.EMPTY);
return;
}
ItemStack insert = held.copy();
insert.setCount(1);
filterInventory.setStackInSlot(slot, insert);
}
protected ItemStackHandler createFilterInventory() {
return LinkedControllerItem.getFrequencyItems(mainItem);
}
@Override
public ItemStack quickMoveStack(Player playerIn, int index) {
if (index < 36) {
ItemStack stackToInsert = playerInventory.getItem(index);
for (int i = 0; i < filterInventory.getSlots(); i++) {
ItemStack stack = filterInventory.getStackInSlot(i);
if (stack.isEmpty()) {
ItemStack copy = stackToInsert.copy();
copy.setCount(1);
filterInventory.insertItem(i, copy, false);
break;
}
}
} else
filterInventory.extractItem(index - 36, 1, false);
return ItemStack.EMPTY;
}
@Override
public void removed(Player playerIn) {
super.removed(playerIn);
mainItem.getOrCreateTag()
.put("Items", filterInventory.serializeNBT());
// saveData(filterItem);
public boolean stillValid(Player playerIn) {
return playerInventory.getSelected() == contentHolder;
}
}

View file

@ -8,11 +8,11 @@ import java.util.List;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting;
@ -37,18 +37,24 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
@Override
protected void init() {
setWindowSize(background.width, background.height + 4 + PLAYER_INVENTORY.height);
setWindowOffset(2 + (width % 2 == 0 ? 0 : -1), 0);
setWindowOffset(1, 0);
super.init();
widgets.clear();
int x = leftPos;
int y = topPos;
resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH);
resetButton.withCallback(() -> {
menu.clearContents();
menu.sendClearPacket();
});
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
widgets.add(resetButton);
widgets.add(confirmButton);
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width + 4, y + background.height - 44, 64, 56)
@ -56,7 +62,7 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int invX = getLeftOfCentered(PLAYER_INVENTORY.width);
int invY = topPos + background.height + 4;
renderPlayerInventory(ms, invX, invY);
@ -64,10 +70,10 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
int x = leftPos;
int y = topPos;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
font.draw(ms, title, x + 15, y + 4, 0x442000);
GuiGameElement.of(menu.mainItem)
GuiGameElement.of(menu.contentHolder)
.<GuiGameElement.GuiRenderBuilder>at(x + background.width - 4, y + background.height - 56, -200)
.scale(5)
.render(ms);
@ -76,27 +82,10 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
@Override
protected void containerTick() {
if (!menu.player.getMainHandItem()
.equals(menu.mainItem, false))
minecraft.player.closeContainer();
}
.equals(menu.contentHolder, false))
menu.player.closeContainer();
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean mouseClicked = super.mouseClicked(x, y, button);
if (button == 0) {
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
if (resetButton.isHovered()) {
menu.clearContents();
menu.sendClearPacket();
return true;
}
}
return mouseClicked;
super.containerTick();
}
@Override

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.logistics.item.filter;
import com.simibubi.create.foundation.gui.GhostItemContainer;
import com.simibubi.create.foundation.gui.container.GhostItemContainer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;

View file

@ -9,18 +9,17 @@ import java.util.List;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widgets.Indicator.State;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.gui.widget.Indicator.State;
import com.simibubi.create.foundation.item.ItemDescription.Palette;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.networking.AllPackets;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@ -43,16 +42,23 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
protected void init() {
setWindowSize(Math.max(background.width, PLAYER_INVENTORY.width), background.height + 4 + PLAYER_INVENTORY.height);
super.init();
widgets.clear();
int x = leftPos;
int y = topPos;
resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH);
resetButton.withCallback(() -> {
menu.clearContents();
contentsCleared();
menu.sendClearPacket();
});
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
widgets.add(resetButton);
widgets.add(confirmButton);
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width, y + background.height - 40, 80, 48)
@ -60,7 +66,7 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int invX = getLeftOfCentered(PLAYER_INVENTORY.width);
int invY = topPos + background.height + 4;
renderPlayerInventory(ms, invX, invY);
@ -68,7 +74,7 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
int x = leftPos;
int y = topPos;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF);
GuiGameElement.of(menu.contentHolder)
@ -79,27 +85,16 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
@Override
protected void containerTick() {
handleTooltips();
handleIndicators();
if (!menu.player.getMainHandItem()
.equals(menu.contentHolder, false))
minecraft.player.closeContainer();
menu.player.closeContainer();
super.containerTick();
handleTooltips();
handleIndicators();
}
public void handleIndicators() {
List<IconButton> tooltipButtons = getTooltipButtons();
for (IconButton button : tooltipButtons)
button.active = isButtonEnabled(button);
for (AbstractWidget w : widgets)
if (w instanceof Indicator)
((Indicator) w).state = isIndicatorOn((Indicator) w) ? State.ON : State.OFF;
}
protected abstract boolean isButtonEnabled(IconButton button);
protected abstract boolean isIndicatorOn(Indicator indicator);
protected void handleTooltips() {
List<IconButton> tooltipButtons = getTooltipButtons();
@ -120,6 +115,17 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
}
}
public void handleIndicators() {
for (IconButton button : getTooltipButtons())
button.active = isButtonEnabled(button);
for (Indicator indicator : getIndicators())
indicator.state = isIndicatorOn(indicator) ? State.ON : State.OFF;
}
protected abstract boolean isButtonEnabled(IconButton button);
protected abstract boolean isIndicatorOn(Indicator indicator);
protected List<IconButton> getTooltipButtons() {
return Collections.emptyList();
}
@ -128,6 +134,10 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
return Collections.emptyList();
}
protected List<Indicator> getIndicators() {
return Collections.emptyList();
}
private void fillToolTip(IconButton button, Component tooltip) {
if (!button.isHovered())
return;
@ -135,26 +145,6 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
tip.addAll(TooltipHelper.cutTextComponent(tooltip, GRAY, GRAY));
}
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean mouseClicked = super.mouseClicked(x, y, button);
if (button == 0) {
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
if (resetButton.isHovered()) {
menu.clearContents();
contentsCleared();
menu.sendClearPacket();
return true;
}
}
return mouseClicked;
}
protected void contentsCleared() {}
protected void sendOptionUpdate(Option option) {

View file

@ -10,10 +10,10 @@ import com.simibubi.create.content.logistics.item.filter.AttributeFilterContaine
import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.Pair;
@ -30,11 +30,6 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
private static final String PREFIX = "gui.attribute_filter.";
private IconButton whitelistDis, whitelistCon, blacklist;
private Indicator whitelistDisIndicator, whitelistConIndicator, blacklistIndicator;
private IconButton add;
private IconButton addInverted;
private Component addDESC = Lang.translate(PREFIX + "add_attribute");
private Component addInvertedDESC = Lang.translate(PREFIX + "add_inverted_attribute");
@ -49,6 +44,11 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
private Component noSelectedT = Lang.translate(PREFIX + "no_selected_attributes");
private Component selectedT = Lang.translate(PREFIX + "selected_attributes");
private IconButton whitelistDis, whitelistCon, blacklist;
private Indicator whitelistDisIndicator, whitelistConIndicator, blacklistIndicator;
private IconButton add;
private IconButton addInverted;
private ItemStack lastItemScanned = ItemStack.EMPTY;
private List<ItemAttribute> attributesOfItem = new ArrayList<>();
private List<Component> selectedAttributes = new ArrayList<>();
@ -61,29 +61,47 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
@Override
protected void init() {
setWindowOffset(-11 + (width % 2 == 0 ? 1 : 0), 7);
setWindowOffset(-11, 7);
super.init();
int x = leftPos;
int y = topPos;
whitelistDis = new IconButton(x + 47, y + 59, AllIcons.I_WHITELIST_OR);
whitelistDis.withCallback(() -> {
menu.whitelistMode = WhitelistMode.WHITELIST_DISJ;
sendOptionUpdate(Option.WHITELIST);
});
whitelistDis.setToolTip(allowDisN);
whitelistCon = new IconButton(x + 65, y + 59, AllIcons.I_WHITELIST_AND);
whitelistCon.withCallback(() -> {
menu.whitelistMode = WhitelistMode.WHITELIST_CONJ;
sendOptionUpdate(Option.WHITELIST2);
});
whitelistCon.setToolTip(allowConN);
blacklist = new IconButton(x + 83, y + 59, AllIcons.I_WHITELIST_NOT);
blacklist.withCallback(() -> {
menu.whitelistMode = WhitelistMode.BLACKLIST;
sendOptionUpdate(Option.BLACKLIST);
});
blacklist.setToolTip(denyN);
whitelistDisIndicator = new Indicator(x + 47, y + 53, TextComponent.EMPTY);
whitelistConIndicator = new Indicator(x + 65, y + 53, TextComponent.EMPTY);
blacklistIndicator = new Indicator(x + 83, y + 53, TextComponent.EMPTY);
widgets.addAll(Arrays.asList(blacklist, whitelistCon, whitelistDis, blacklistIndicator, whitelistConIndicator,
whitelistDisIndicator));
addRenderableWidgets(blacklist, whitelistCon, whitelistDis, blacklistIndicator, whitelistConIndicator,
whitelistDisIndicator);
widgets.add(add = new IconButton(x + 182, y + 21, AllIcons.I_ADD));
widgets.add(addInverted = new IconButton(x + 200, y + 21, AllIcons.I_ADD_INVERTED_ATTRIBUTE));
addRenderableWidget(add = new IconButton(x + 182, y + 21, AllIcons.I_ADD));
addRenderableWidget(addInverted = new IconButton(x + 200, y + 21, AllIcons.I_ADD_INVERTED_ATTRIBUTE));
add.withCallback(() -> {
handleAddedAttibute(false);
});
add.setToolTip(addDESC);
addInverted.withCallback(() -> {
handleAddedAttibute(true);
});
addInverted.setToolTip(addInvertedDESC);
handleIndicators();
@ -95,8 +113,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
attributeSelector.removeCallback();
referenceItemChanged(menu.ghostInventory.getStackInSlot(0));
widgets.add(attributeSelector);
widgets.add(attributeSelectorLabel);
addRenderableWidget(attributeSelector);
addRenderableWidget(attributeSelectorLabel);
selectedAttributes.clear();
selectedAttributes.add((menu.selectedAttributes.isEmpty() ? noSelectedT : selectedT).plainCopy()
@ -160,7 +178,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
}
@Override
public void renderWindowForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
public void renderForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
ItemStack stack = menu.ghostInventory.getStackInSlot(1);
matrixStack.pushPose();
matrixStack.translate(0.0F, 0.0F, 32.0F);
@ -172,11 +190,12 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
this.itemRenderer.blitOffset = 0.0F;
matrixStack.popPose();
super.renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks);
super.renderForeground(matrixStack, mouseX, mouseY, partialTicks);
}
@Override
protected void containerTick() {
super.containerTick();
ItemStack stackInSlot = menu.ghostInventory.getStackInSlot(0);
if (!stackInSlot.equals(lastItemScanned, false))
referenceItemChanged(stackInSlot);
@ -205,36 +224,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
}
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean mouseClicked = super.mouseClicked(x, y, button);
if (button != 0)
return mouseClicked;
if (blacklist.isHovered()) {
menu.whitelistMode = WhitelistMode.BLACKLIST;
sendOptionUpdate(Option.BLACKLIST);
return true;
}
if (whitelistCon.isHovered()) {
menu.whitelistMode = WhitelistMode.WHITELIST_CONJ;
sendOptionUpdate(Option.WHITELIST2);
return true;
}
if (whitelistDis.isHovered()) {
menu.whitelistMode = WhitelistMode.WHITELIST_DISJ;
sendOptionUpdate(Option.WHITELIST);
return true;
}
if (add.isHovered() && add.active)
return handleAddedAttibute(false);
if (addInverted.isHovered() && addInverted.active)
return handleAddedAttibute(true);
return mouseClicked;
protected List<Indicator> getIndicators() {
return Arrays.asList(blacklistIndicator, whitelistConIndicator, whitelistDisIndicator);
}
protected boolean handleAddedAttibute(boolean inverted) {

View file

@ -6,8 +6,8 @@ import java.util.List;
import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.Component;
@ -47,58 +47,40 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
int y = topPos;
blacklist = new IconButton(x + 18, y + 73, AllIcons.I_BLACKLIST);
blacklist.withCallback(() -> {
menu.blacklist = true;
sendOptionUpdate(Option.BLACKLIST);
});
blacklist.setToolTip(denyN);
whitelist = new IconButton(x + 36, y + 73, AllIcons.I_WHITELIST);
whitelist.withCallback(() -> {
menu.blacklist = false;
sendOptionUpdate(Option.WHITELIST);
});
whitelist.setToolTip(allowN);
blacklistIndicator = new Indicator(x + 18, y + 67, TextComponent.EMPTY);
whitelistIndicator = new Indicator(x + 36, y + 67, TextComponent.EMPTY);
widgets.addAll(Arrays.asList(blacklist, whitelist, blacklistIndicator, whitelistIndicator));
addRenderableWidgets(blacklist, whitelist, blacklistIndicator, whitelistIndicator);
respectNBT = new IconButton(x + 60, y + 73, AllIcons.I_RESPECT_NBT);
respectNBT.withCallback(() -> {
menu.respectNBT = true;
sendOptionUpdate(Option.RESPECT_DATA);
});
respectNBT.setToolTip(respectDataN);
ignoreNBT = new IconButton(x + 78, y + 73, AllIcons.I_IGNORE_NBT);
ignoreNBT.withCallback(() -> {
menu.respectNBT = false;
sendOptionUpdate(Option.IGNORE_DATA);
});
ignoreNBT.setToolTip(ignoreDataN);
respectNBTIndicator = new Indicator(x + 60, y + 67, TextComponent.EMPTY);
ignoreNBTIndicator = new Indicator(x + 78, y + 67, TextComponent.EMPTY);
widgets.addAll(Arrays.asList(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator));
addRenderableWidgets(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator);
handleIndicators();
}
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean mouseClicked = super.mouseClicked(x, y, button);
if (button != 0)
return mouseClicked;
if (blacklist.isHovered()) {
menu.blacklist = true;
sendOptionUpdate(Option.BLACKLIST);
return true;
}
if (whitelist.isHovered()) {
menu.blacklist = false;
sendOptionUpdate(Option.WHITELIST);
return true;
}
if (respectNBT.isHovered()) {
menu.respectNBT = true;
sendOptionUpdate(Option.RESPECT_DATA);
return true;
}
if (ignoreNBT.isHovered()) {
menu.respectNBT = false;
sendOptionUpdate(Option.IGNORE_DATA);
return true;
}
return mouseClicked;
}
@Override
protected List<IconButton> getTooltipButtons() {
return Arrays.asList(blacklist, whitelist, respectNBT, ignoreNBT);
@ -109,6 +91,11 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
return Arrays.asList(denyDESC.plainCopy(), allowDESC.plainCopy(), respectDataDESC.plainCopy(), ignoreDataDESC.plainCopy());
}
@Override
protected List<Indicator> getIndicators() {
return Arrays.asList(blacklistIndicator, whitelistIndicator, respectNBTIndicator, ignoreNBTIndicator);
}
@Override
protected boolean isButtonEnabled(IconButton button) {
if (button == blacklist)

View file

@ -2,51 +2,73 @@ package com.simibubi.create.content.schematics.block;
import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.gui.container.ContainerBase;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.items.SlotItemHandler;
public class SchematicTableContainer extends AbstractContainerMenu {
public class SchematicTableContainer extends ContainerBase<SchematicTableTileEntity> {
private SchematicTableTileEntity te;
private Slot inputSlot;
private Slot outputSlot;
private Player player;
public SchematicTableContainer(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
super(type, id);
player = inv.player;
ClientLevel world = Minecraft.getInstance().level;
BlockEntity tileEntity = world.getBlockEntity(extraData.readBlockPos());
if (tileEntity instanceof SchematicTableTileEntity) {
this.te = (SchematicTableTileEntity) tileEntity;
this.te.handleUpdateTag(extraData.readNbt());
init();
}
super(type, id, inv, extraData);
}
public SchematicTableContainer(MenuType<?> type, int id, Inventory inv, SchematicTableTileEntity te) {
super(type, id);
this.player = inv.player;
this.te = te;
init();
super(type, id, inv, te);
}
public static SchematicTableContainer create(int id, Inventory inv, SchematicTableTileEntity te) {
return new SchematicTableContainer(AllContainerTypes.SCHEMATIC_TABLE.get(), id, inv, te);
}
protected void init() {
inputSlot = new SlotItemHandler(te.inventory, 0, 21, 57) {
public boolean canWrite() {
return inputSlot.hasItem() && !outputSlot.hasItem();
}
@Override
public ItemStack quickMoveStack(Player playerIn, int index) {
Slot clickedSlot = getSlot(index);
if (!clickedSlot.hasItem())
return ItemStack.EMPTY;
ItemStack stack = clickedSlot.getItem();
if (index < 2)
moveItemStackTo(stack, 2, slots.size(), false);
else
moveItemStackTo(stack, 0, 1, false);
return ItemStack.EMPTY;
}
@Override
protected SchematicTableTileEntity createOnClient(FriendlyByteBuf extraData) {
ClientLevel world = Minecraft.getInstance().level;
BlockEntity tileEntity = world.getBlockEntity(extraData.readBlockPos());
if (tileEntity instanceof SchematicTableTileEntity schematicTable) {
schematicTable.handleUpdateTag(extraData.readNbt());
return schematicTable;
}
return null;
}
@Override
protected void initAndReadInventory(SchematicTableTileEntity contentHolder) {
}
@Override
protected void addSlots() {
inputSlot = new SlotItemHandler(contentHolder.inventory, 0, 21, 57) {
@Override
public boolean mayPlace(ItemStack stack) {
return AllItems.EMPTY_SCHEMATIC.isIn(stack) || AllItems.SCHEMATIC_AND_QUILL.isIn(stack)
@ -54,7 +76,7 @@ public class SchematicTableContainer extends AbstractContainerMenu {
}
};
outputSlot = new SlotItemHandler(te.inventory, 1, 166, 57) {
outputSlot = new SlotItemHandler(contentHolder.inventory, 1, 166, 57) {
@Override
public boolean mayPlace(ItemStack stack) {
return false;
@ -74,36 +96,10 @@ public class SchematicTableContainer extends AbstractContainerMenu {
for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot) {
this.addSlot(new Slot(player.getInventory(), hotbarSlot, 38 + hotbarSlot * 18, 163));
}
broadcastChanges();
}
public boolean canWrite() {
return inputSlot.hasItem() && !outputSlot.hasItem();
}
@Override
public boolean stillValid(Player player) {
return te != null && te.canPlayerUse(player);
}
@Override
public ItemStack quickMoveStack(Player playerIn, int index) {
Slot clickedSlot = getSlot(index);
if (!clickedSlot.hasItem())
return ItemStack.EMPTY;
ItemStack stack = clickedSlot.getItem();
if (index < 2)
moveItemStackTo(stack, 2, slots.size(), false);
else
moveItemStackTo(stack, 0, 1, false);
return ItemStack.EMPTY;
}
public SchematicTableTileEntity getTileEntity() {
return te;
protected void saveData(SchematicTableTileEntity contentHolder) {
}
}

View file

@ -12,14 +12,14 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.schematics.ClientSchematicLoader;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.Util;
@ -32,8 +32,14 @@ import net.minecraft.world.item.ItemStack;
public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicTableContainer> {
private final Component uploading = Lang.translate("gui.schematicTable.uploading");
private final Component finished = Lang.translate("gui.schematicTable.finished");
private final Component refresh = Lang.translate("gui.schematicTable.refresh");
private final Component folder = Lang.translate("gui.schematicTable.open_folder");
private final Component noSchematics = Lang.translate("gui.schematicTable.noSchematics");
private final Component availableSchematicsTitle = Lang.translate("gui.schematicTable.availableSchematics");
protected AllGuiTextures background;
private List<Rect2i> extraAreas = Collections.emptyList();
private ScrollInput schematicsArea;
private IconButton confirmButton;
@ -41,18 +47,14 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
private IconButton refreshButton;
private Label schematicsLabel;
private final Component uploading = Lang.translate("gui.schematicTable.uploading");
private final Component finished = Lang.translate("gui.schematicTable.finished");
private final Component refresh = Lang.translate("gui.schematicTable.refresh");
private final Component folder = Lang.translate("gui.schematicTable.open_folder");
private final Component noSchematics = Lang.translate("gui.schematicTable.noSchematics");
private final Component availableSchematicsTitle = Lang.translate("gui.schematicTable.availableSchematics");
private final ItemStack renderedItem = AllBlocks.SCHEMATIC_TABLE.asStack();
private float progress;
private float chasingProgress;
private float lastChasingProgress;
private final ItemStack renderedItem = AllBlocks.SCHEMATIC_TABLE.asStack();
private List<Rect2i> extraAreas = Collections.emptyList();
public SchematicTableScreen(SchematicTableContainer container, Inventory playerInventory,
Component title) {
super(container, playerInventory, title);
@ -64,7 +66,6 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
setWindowSize(background.width, background.height + 4 + AllGuiTextures.PLAYER_INVENTORY.height);
setWindowOffset(-11, 8);
super.init();
widgets.clear();
CreateClient.SCHEMATIC_SENDER.refresh();
List<Component> availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics();
@ -79,20 +80,52 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
new SelectionScrollInput(x + 45, y + 21, 139, 18).forOptions(availableSchematics)
.titled(availableSchematicsTitle.plainCopy())
.writingTo(schematicsLabel);
widgets.add(schematicsArea);
widgets.add(schematicsLabel);
addRenderableWidget(schematicsArea);
addRenderableWidget(schematicsLabel);
}
confirmButton = new IconButton(x + 44, y + 56, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
if (menu.canWrite() && schematicsArea != null) {
ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
lastChasingProgress = chasingProgress = progress = 0;
List<Component> availableSchematics1 = schematicSender.getAvailableSchematics();
Component schematic = availableSchematics1.get(schematicsArea.getState());
schematicSender.startNewUpload(schematic.getContents());
}
});
folderButton = new IconButton(x + 21, y + 21, AllIcons.I_OPEN_FOLDER);
folderButton.withCallback(() -> {
Util.getPlatform()
.openFile(Paths.get("schematics/")
.toFile());
});
folderButton.setToolTip(folder);
refreshButton = new IconButton(x + 207, y + 21, AllIcons.I_REFRESH);
refreshButton.withCallback(() -> {
ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
schematicSender.refresh();
List<Component> availableSchematics1 = schematicSender.getAvailableSchematics();
removeWidget(schematicsArea);
if (!availableSchematics1.isEmpty()) {
schematicsArea = new SelectionScrollInput(leftPos + 45, topPos + 21, 139, 18)
.forOptions(availableSchematics1)
.titled(availableSchematicsTitle.plainCopy())
.writingTo(schematicsLabel);
schematicsArea.onChanged();
addRenderableWidget(schematicsArea);
} else {
schematicsArea = null;
schematicsLabel.text = TextComponent.EMPTY;
}
});
refreshButton.setToolTip(refresh);
widgets.add(confirmButton);
widgets.add(folderButton);
widgets.add(refreshButton);
addRenderableWidget(confirmButton);
addRenderableWidget(folderButton);
addRenderableWidget(refreshButton);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width, y + background.height - 40, 48, 48),
@ -101,7 +134,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int invX = getLeftOfCentered(PLAYER_INVENTORY.width);
int invY = topPos + background.height + 4;
renderPlayerInventory(ms, invX, invY);
@ -109,10 +142,10 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
int x = leftPos;
int y = topPos;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
Component titleText;
if (menu.getTileEntity().isUploading)
if (menu.contentHolder.isUploading)
titleText = uploading;
else if (menu.getSlot(1)
.hasItem())
@ -139,22 +172,24 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
@Override
protected void containerTick() {
super.containerTick();
boolean finished = menu.getSlot(1)
.hasItem();
if (menu.getTileEntity().isUploading || finished) {
if (menu.contentHolder.isUploading || finished) {
if (finished) {
chasingProgress = lastChasingProgress = progress = 1;
} else {
lastChasingProgress = chasingProgress;
progress = menu.getTileEntity().uploadingProgress;
progress = menu.contentHolder.uploadingProgress;
chasingProgress += (progress - chasingProgress) * .5f;
}
confirmButton.active = false;
if (schematicsLabel != null) {
schematicsLabel.colored(0xCCDDFF);
String uploadingSchematic = menu.getTileEntity().uploadingSchematic;
String uploadingSchematic = menu.contentHolder.uploadingSchematic;
schematicsLabel.text = uploadingSchematic == null ? null : new TextComponent(uploadingSchematic);
}
if (schematicsArea != null)
@ -174,46 +209,6 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
}
}
@Override
public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) {
ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
if (confirmButton.active && confirmButton.isHovered() && ((SchematicTableContainer) menu).canWrite()
&& schematicsArea != null) {
lastChasingProgress = chasingProgress = progress = 0;
List<Component> availableSchematics = schematicSender.getAvailableSchematics();
Component schematic = availableSchematics.get(schematicsArea.getState());
schematicSender.startNewUpload(schematic.getContents());
}
if (folderButton.isHovered()) {
Util.getPlatform()
.openFile(Paths.get("schematics/")
.toFile());
}
if (refreshButton.isHovered()) {
schematicSender.refresh();
List<Component> availableSchematics = schematicSender.getAvailableSchematics();
widgets.remove(schematicsArea);
if (!availableSchematics.isEmpty()) {
schematicsArea = new SelectionScrollInput(leftPos + 45, topPos + 21, 139, 18)
.forOptions(availableSchematics)
.titled(availableSchematicsTitle.plainCopy())
.writingTo(schematicsLabel);
schematicsArea.onChanged();
widgets.add(schematicsArea);
} else {
schematicsArea = null;
schematicsLabel.text = TextComponent.EMPTY;
}
}
return super.mouseClicked(p_mouseClicked_1_, p_mouseClicked_3_, p_mouseClicked_5_);
}
@Override
public List<Rect2i> getExtraAreas() {
return extraAreas;

View file

@ -2,9 +2,9 @@ package com.simibubi.create.content.schematics.block;
import java.util.List;
import com.simibubi.create.foundation.gui.IInteractionChecker;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.IInteractionChecker;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.core.BlockPos;

View file

@ -1,82 +1,64 @@
package com.simibubi.create.content.schematics.block;
import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.foundation.gui.container.ContainerBase;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.items.SlotItemHandler;
public class SchematicannonContainer extends AbstractContainerMenu {
private SchematicannonTileEntity te;
private Player player;
public class SchematicannonContainer extends ContainerBase<SchematicannonTileEntity> {
public SchematicannonContainer(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf buffer) {
super(type, id);
player = inv.player;
ClientLevel world = Minecraft.getInstance().level;
BlockEntity tileEntity = world.getBlockEntity(buffer.readBlockPos());
if (tileEntity instanceof SchematicannonTileEntity) {
this.te = (SchematicannonTileEntity) tileEntity;
this.te.handleUpdateTag(buffer.readNbt());
init();
}
super(type, id, inv, buffer);
}
public SchematicannonContainer(MenuType<?> type, int id, Inventory inv, SchematicannonTileEntity te) {
super(type, id);
player = inv.player;
this.te = te;
init();
super(type, id, inv, te);
}
public static SchematicannonContainer create(int id, Inventory inv, SchematicannonTileEntity te) {
return new SchematicannonContainer(AllContainerTypes.SCHEMATICANNON.get(), id, inv, te);
}
protected void init() {
@Override
protected SchematicannonTileEntity createOnClient(FriendlyByteBuf extraData) {
ClientLevel world = Minecraft.getInstance().level;
BlockEntity tileEntity = world.getBlockEntity(extraData.readBlockPos());
if (tileEntity instanceof SchematicannonTileEntity schematicannon) {
schematicannon.handleUpdateTag(extraData.readNbt());
return schematicannon;
}
return null;
}
@Override
protected void initAndReadInventory(SchematicannonTileEntity contentHolder) {
}
@Override
protected void addSlots() {
int x = 0;
int y = 0;
addSlot(new SlotItemHandler(te.inventory, 0, x + 15, y + 65));
addSlot(new SlotItemHandler(te.inventory, 1, x + 171, y + 65));
addSlot(new SlotItemHandler(te.inventory, 2, x + 134, y + 19));
addSlot(new SlotItemHandler(te.inventory, 3, x + 174, y + 19));
addSlot(new SlotItemHandler(te.inventory, 4, x + 15, y + 19));
addSlot(new SlotItemHandler(contentHolder.inventory, 0, x + 15, y + 65));
addSlot(new SlotItemHandler(contentHolder.inventory, 1, x + 171, y + 65));
addSlot(new SlotItemHandler(contentHolder.inventory, 2, x + 134, y + 19));
addSlot(new SlotItemHandler(contentHolder.inventory, 3, x + 174, y + 19));
addSlot(new SlotItemHandler(contentHolder.inventory, 4, x + 15, y + 19));
int invX = 37;
int invY = 161;
// player Slots
for (int row = 0; row < 3; ++row)
for (int col = 0; col < 9; ++col)
addSlot(new Slot(player.getInventory(), col + row * 9 + 9, invX + col * 18, invY + row * 18));
for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot)
addSlot(new Slot(player.getInventory(), hotbarSlot, invX + hotbarSlot * 18, invY + 58));
broadcastChanges();
addPlayerSlots(37, 161);
}
@Override
public boolean stillValid(Player player) {
return te != null && te.canPlayerUse(player);
}
@Override
public void removed(Player playerIn) {
super.removed(playerIn);
}
public SchematicannonTileEntity getTileEntity() {
return te;
protected void saveData(SchematicannonTileEntity contentHolder) {
}
@Override

View file

@ -14,13 +14,13 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.schematics.packet.ConfigureSchematicannonPacket;
import com.simibubi.create.content.schematics.packet.ConfigureSchematicannonPacket.Option;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widgets.Indicator.State;
import com.simibubi.create.foundation.gui.container.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.gui.widget.Indicator.State;
import com.simibubi.create.foundation.item.ItemDescription.Palette;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.networking.AllPackets;
@ -39,6 +39,19 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
private static final AllGuiTextures BG_BOTTOM = AllGuiTextures.SCHEMATICANNON_BOTTOM;
private static final AllGuiTextures BG_TOP = AllGuiTextures.SCHEMATICANNON_TOP;
private final Component listPrinter = Lang.translate("gui.schematicannon.listPrinter");
private final String _gunpowderLevel = "gui.schematicannon.gunpowderLevel";
private final String _shotsRemaining = "gui.schematicannon.shotsRemaining";
private final String _showSettings = "gui.schematicannon.showOptions";
private final String _shotsRemainingWithBackup = "gui.schematicannon.shotsRemainingWithBackup";
private final String _slotGunpowder = "gui.schematicannon.slot.gunpowder";
private final String _slotListPrinter = "gui.schematicannon.slot.listPrinter";
private final String _slotSchematic = "gui.schematicannon.slot.schematic";
private final Component optionEnabled = Lang.translate("gui.schematicannon.optionEnabled");
private final Component optionDisabled = Lang.translate("gui.schematicannon.optionDisabled");
protected Vector<Indicator> replaceLevelIndicators;
protected Vector<IconButton> replaceLevelButtons;
@ -54,28 +67,16 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
protected IconButton resetButton;
protected Indicator resetIndicator;
private List<Rect2i> extraAreas = Collections.emptyList();
protected List<AbstractWidget> placementSettingWidgets;
private final Component listPrinter = Lang.translate("gui.schematicannon.listPrinter");
private final String _gunpowderLevel = "gui.schematicannon.gunpowderLevel";
private final String _shotsRemaining = "gui.schematicannon.shotsRemaining";
private final String _showSettings = "gui.schematicannon.showOptions";
private final String _shotsRemainingWithBackup = "gui.schematicannon.shotsRemainingWithBackup";
private final String _slotGunpowder = "gui.schematicannon.slot.gunpowder";
private final String _slotListPrinter = "gui.schematicannon.slot.listPrinter";
private final String _slotSchematic = "gui.schematicannon.slot.schematic";
private final Component optionEnabled = Lang.translate("gui.schematicannon.optionEnabled");
private final Component optionDisabled = Lang.translate("gui.schematicannon.optionDisabled");
private final ItemStack renderedItem = AllBlocks.SCHEMATICANNON.asStack();
private IconButton confirmButton;
private IconButton showSettingsButton;
private Indicator showSettingsIndicator;
protected List<AbstractWidget> placementSettingWidgets;
private final ItemStack renderedItem = AllBlocks.SCHEMATICANNON.asStack();
private List<Rect2i> extraAreas = Collections.emptyList();
public SchematicannonScreen(SchematicannonContainer container, Inventory inventory, Component title) {
super(container, inventory, title);
placementSettingWidgets = new ArrayList<>();
@ -84,31 +85,46 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
@Override
protected void init() {
setWindowSize(BG_TOP.width, BG_TOP.height + BG_BOTTOM.height + 2 + AllGuiTextures.PLAYER_INVENTORY.height);
setWindowOffset(-10 + (width % 2 == 0 ? 0 : -1), 0);
setWindowOffset(-11, 0);
super.init();
widgets.clear();
int x = leftPos;
int y = topPos;
// Play Pause Stop
playButton = new IconButton(x + 75, y + 86, AllIcons.I_PLAY);
playButton.withCallback(() -> {
sendOptionUpdate(Option.PLAY, true);
});
playIndicator = new Indicator(x + 75, y + 79, TextComponent.EMPTY);
pauseButton = new IconButton(x + 93, y + 86, AllIcons.I_PAUSE);
pauseButton.withCallback(() -> {
sendOptionUpdate(Option.PAUSE, true);
});
pauseIndicator = new Indicator(x + 93, y + 79, TextComponent.EMPTY);
resetButton = new IconButton(x + 111, y + 86, AllIcons.I_STOP);
resetButton.withCallback(() -> {
sendOptionUpdate(Option.STOP, true);
});
resetIndicator = new Indicator(x + 111, y + 79, TextComponent.EMPTY);
resetIndicator.state = State.RED;
Collections.addAll(widgets, playButton, playIndicator, pauseButton, pauseIndicator, resetButton,
addRenderableWidgets(playButton, playIndicator, pauseButton, pauseIndicator, resetButton,
resetIndicator);
confirmButton = new IconButton(x + 180, y + 117, AllIcons.I_CONFIRM);
widgets.add(confirmButton);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
addRenderableWidget(confirmButton);
showSettingsButton = new IconButton(x + 9, y + 117, AllIcons.I_PLACEMENT_SETTINGS);
showSettingsButton.withCallback(() -> {
showSettingsIndicator.state = placementSettingsHidden() ? State.GREEN : State.OFF;
initPlacementSettings();
});
showSettingsButton.setToolTip(Lang.translate(_showSettings));
widgets.add(showSettingsButton);
addRenderableWidget(showSettingsButton);
showSettingsIndicator = new Indicator(x + 9, y + 111, TextComponent.EMPTY);
widgets.add(showSettingsIndicator);
addRenderableWidget(showSettingsIndicator);
extraAreas = ImmutableList.of(new Rect2i(x + BG_TOP.width, y + BG_TOP.height + BG_BOTTOM.height - 62, 84, 92));
@ -116,7 +132,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
private void initPlacementSettings() {
widgets.removeAll(placementSettingWidgets);
removeWidgets(placementSettingWidgets);
placementSettingWidgets.clear();
if (placementSettingsHidden())
@ -137,25 +153,36 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
for (int i = 0; i < 4; i++) {
replaceLevelIndicators.add(new Indicator(x + 33 + i * 18, y + 111, TextComponent.EMPTY));
replaceLevelButtons.add(new IconButton(x + 33 + i * 18, y + 117, icons.get(i)));
replaceLevelButtons.get(i)
.setToolTip(toolTips.get(i));
IconButton replaceLevelButton = new IconButton(x + 33 + i * 18, y + 117, icons.get(i));
int replaceMode = i;
replaceLevelButton.withCallback(() -> {
if (menu.contentHolder.replaceMode != replaceMode)
sendOptionUpdate(Option.values()[replaceMode], true);
});
replaceLevelButton.setToolTip(toolTips.get(i));
replaceLevelButtons.add(replaceLevelButton);
}
placementSettingWidgets.addAll(replaceLevelButtons);
placementSettingWidgets.addAll(replaceLevelIndicators);
// Other Settings
skipMissingButton = new IconButton(x + 111, y + 117, AllIcons.I_SKIP_MISSING);
skipMissingButton.withCallback(() -> {
sendOptionUpdate(Option.SKIP_MISSING, !menu.contentHolder.skipMissing);
});
skipMissingButton.setToolTip(Lang.translate("gui.schematicannon.option.skipMissing"));
skipMissingIndicator = new Indicator(x + 111, y + 111, TextComponent.EMPTY);
Collections.addAll(placementSettingWidgets, skipMissingButton, skipMissingIndicator);
skipTilesButton = new IconButton(x + 129, y + 117, AllIcons.I_SKIP_TILES);
skipTilesButton.withCallback(() -> {
sendOptionUpdate(Option.SKIP_TILES, !menu.contentHolder.replaceTileEntities);
});
skipTilesButton.setToolTip(Lang.translate("gui.schematicannon.option.skipTileEntities"));
skipTilesIndicator = new Indicator(x + 129, y + 111, TextComponent.EMPTY);
Collections.addAll(placementSettingWidgets, skipTilesButton, skipTilesIndicator);
widgets.addAll(placementSettingWidgets);
addRenderableWidgets(placementSettingWidgets);
}
protected boolean placementSettingsHidden() {
@ -164,11 +191,15 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
@Override
protected void containerTick() {
SchematicannonTileEntity te = menu.getTileEntity();
super.containerTick();
SchematicannonTileEntity te = menu.contentHolder;
if (!placementSettingsHidden()) {
for (int replaceMode = 0; replaceMode < replaceLevelButtons.size(); replaceMode++)
for (int replaceMode = 0; replaceMode < replaceLevelButtons.size(); replaceMode++) {
replaceLevelButtons.get(replaceMode).active = replaceMode != te.replaceMode;
replaceLevelIndicators.get(replaceMode).state = replaceMode == te.replaceMode ? State.ON : State.OFF;
}
skipMissingIndicator.state = te.skipMissing ? State.ON : State.OFF;
skipTilesIndicator.state = !te.replaceTileEntities ? State.ON : State.OFF;
}
@ -241,7 +272,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
int invX = getLeftOfCentered(AllGuiTextures.PLAYER_INVENTORY.width);
int invY = topPos + BG_TOP.height + BG_BOTTOM.height + 2;
renderPlayerInventory(ms, invX, invY);
@ -249,10 +280,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
int x = leftPos;
int y = topPos;
BG_TOP.draw(ms, this, x, y);
BG_BOTTOM.draw(ms, this, x, y + BG_TOP.height);
BG_TOP.render(ms, x, y, this);
BG_BOTTOM.render(ms, x, y + BG_TOP.height, this);
SchematicannonTileEntity te = menu.getTileEntity();
SchematicannonTileEntity te = menu.contentHolder;
renderPrintingProgress(ms, x, y, te.schematicProgress);
renderFuelBar(ms, x, y, te.fuelLevel);
renderChecklistPrinterProgress(ms, x, y, te.bookPrintingProgress);
@ -283,7 +314,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
protected void renderBlueprintHighlight(PoseStack matrixStack, int x, int y) {
AllGuiTextures.SCHEMATICANNON_HIGHLIGHT.draw(matrixStack, this, x + 10, y + 60);
AllGuiTextures.SCHEMATICANNON_HIGHLIGHT.render(matrixStack, x + 10, y + 60, this);
}
protected void renderPrintingProgress(PoseStack matrixStack, int x, int y, float progress) {
@ -302,8 +333,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
protected void renderFuelBar(PoseStack matrixStack, int x, int y, float amount) {
AllGuiTextures sprite = AllGuiTextures.SCHEMATICANNON_FUEL;
if (menu.getTileEntity().hasCreativeCrate) {
AllGuiTextures.SCHEMATICANNON_FUEL_CREATIVE.draw(matrixStack, this, x + 36, y + 19);
if (menu.contentHolder.hasCreativeCrate) {
AllGuiTextures.SCHEMATICANNON_FUEL_CREATIVE.render(matrixStack, x + 36, y + 19, this);
return;
}
sprite.bind();
@ -311,8 +342,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
@Override
protected void renderWindowForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
SchematicannonTileEntity te = menu.getTileEntity();
protected void renderForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
SchematicannonTileEntity te = menu.contentHolder;
int x = leftPos;
int y = topPos;
@ -348,7 +379,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
if (mouseX >= paperX && mouseY >= paperY && mouseX <= paperX + 16 && mouseY <= paperY + 16)
renderTooltip(matrixStack, listPrinter, mouseX, mouseY);
super.renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks);
super.renderForeground(matrixStack, mouseX, mouseY, partialTicks);
}
protected List<Component> getFuelLevelTooltip(SchematicannonTileEntity te) {
@ -380,41 +411,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
return tooltip;
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (showSettingsButton.isHovered()) {
showSettingsIndicator.state = placementSettingsHidden() ? State.GREEN : State.OFF;
initPlacementSettings();
}
if (confirmButton.isHovered()) {
minecraft.player.closeContainer();
return true;
}
if (!placementSettingsHidden()) {
for (int replaceMode = 0; replaceMode < replaceLevelButtons.size(); replaceMode++) {
if (!replaceLevelButtons.get(replaceMode)
.isHovered())
continue;
if (menu.getTileEntity().replaceMode == replaceMode)
continue;
sendOptionUpdate(Option.values()[replaceMode], true);
}
if (skipMissingButton.isHovered())
sendOptionUpdate(Option.SKIP_MISSING, !menu.getTileEntity().skipMissing);
if (skipTilesButton.isHovered())
sendOptionUpdate(Option.SKIP_TILES, !menu.getTileEntity().replaceTileEntities);
}
if (playButton.isHovered() && playButton.active)
sendOptionUpdate(Option.PLAY, true);
if (pauseButton.isHovered() && pauseButton.active)
sendOptionUpdate(Option.PAUSE, true);
if (resetButton.isHovered() && resetButton.active)
sendOptionUpdate(Option.STOP, true);
return super.mouseClicked(x, y, button);
protected void sendOptionUpdate(Option option, boolean set) {
AllPackets.channel.sendToServer(new ConfigureSchematicannonPacket(option, set));
}
@Override
@ -422,8 +420,4 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
return extraAreas;
}
protected void sendOptionUpdate(Option option, boolean set) {
AllPackets.channel.sendToServer(new ConfigureSchematicannonPacket(option, set));
}
}

View file

@ -1,6 +1,5 @@
package com.simibubi.create.content.schematics.client;
import java.util.Collections;
import java.util.List;
import com.mojang.blaze3d.vertex.PoseStack;
@ -9,11 +8,11 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.client.gui.components.EditBox;
@ -28,13 +27,6 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlac
public class SchematicEditScreen extends AbstractSimiScreen {
private AllGuiTextures background;
private EditBox xInput;
private EditBox yInput;
private EditBox zInput;
private IconButton confirmButton;
private final List<Component> rotationOptions =
Lang.translatedOptions("schematic.rotation", "none", "cw90", "cw180", "cw270");
private final List<Component> mirrorOptions =
@ -42,12 +34,18 @@ public class SchematicEditScreen extends AbstractSimiScreen {
private final Component rotationLabel = Lang.translate("schematic.rotation");
private final Component mirrorLabel = Lang.translate("schematic.mirror");
private AllGuiTextures background;
private EditBox xInput;
private EditBox yInput;
private EditBox zInput;
private IconButton confirmButton;
private ScrollInput rotationArea;
private ScrollInput mirrorArea;
private SchematicHandler handler;
public SchematicEditScreen() {
super();
background = AllGuiTextures.SCHEMATIC;
handler = CreateClient.SCHEMATIC_HANDLER;
}
@ -57,7 +55,6 @@ public class SchematicEditScreen extends AbstractSimiScreen {
setWindowSize(background.width, background.height);
setWindowOffset(-6, 0);
super.init();
widgets.clear();
int x = guiLeft;
int y = guiTop;
@ -113,12 +110,15 @@ public class SchematicEditScreen extends AbstractSimiScreen {
.ordinal())
.writingTo(labelM);
Collections.addAll(widgets, xInput, yInput, zInput);
Collections.addAll(widgets, labelR, labelM, rotationArea, mirrorArea);
addRenderableWidgets(xInput, yInput, zInput);
addRenderableWidgets(labelR, labelM, rotationArea, mirrorArea);
confirmButton =
new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
widgets.add(confirmButton);
confirmButton.withCallback(() -> {
onClose();
});
addRenderableWidget(confirmButton);
}
@Override
@ -155,7 +155,7 @@ public class SchematicEditScreen extends AbstractSimiScreen {
int x = guiLeft;
int y = guiTop;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
String title = handler.getCurrentSchematicName();
drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF);
@ -196,14 +196,4 @@ public class SchematicEditScreen extends AbstractSimiScreen {
}
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (confirmButton.isHovered()) {
onClose();
return true;
}
return super.mouseClicked(x, y, button);
}
}

View file

@ -16,7 +16,7 @@ public class SchematicHotbarSlotOverlay extends GuiComponent {
int y = mainWindow.getGuiScaledHeight() - 19;
RenderSystem.enableDepthTest();
matrixStack.pushPose();
AllGuiTextures.SCHEMATIC_SLOT.draw(matrixStack, this, x + 20 * slot, y);
AllGuiTextures.SCHEMATIC_SLOT.render(matrixStack, x + 20 * slot, y, this);
matrixStack.popPose();
}

View file

@ -8,8 +8,8 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.client.gui.components.EditBox;
@ -38,7 +38,6 @@ public class SchematicPromptScreen extends AbstractSimiScreen {
public void init() {
setWindowSize(background.width, background.height);
super.init();
widgets.clear();
int x = guiLeft;
int y = guiTop;
@ -49,23 +48,29 @@ public class SchematicPromptScreen extends AbstractSimiScreen {
nameField.setBordered(false);
nameField.setMaxLength(35);
nameField.changeFocus(true);
addRenderableWidget(nameField);
abort = new IconButton(x + 7, y + 53, AllIcons.I_TRASH);
abort.withCallback(() -> {
CreateClient.SCHEMATIC_AND_QUILL_HANDLER.discard();
onClose();
});
abort.setToolTip(abortLabel);
widgets.add(abort);
addRenderableWidget(abort);
confirm = new IconButton(x + 158, y + 53, AllIcons.I_CONFIRM);
confirm.withCallback(() -> {
confirm(false);
});
confirm.setToolTip(confirmLabel);
widgets.add(confirm);
addRenderableWidget(confirm);
convert = new IconButton(x + 180, y + 53, AllIcons.I_SCHEMATIC);
convert.withCallback(() -> {
confirm(true);
});
convert.setToolTip(convertLabel);
widgets.add(convert);
widgets.add(confirm);
widgets.add(convert);
widgets.add(abort);
widgets.add(nameField);
addRenderableWidget(convert);
}
@Override
@ -73,8 +78,9 @@ public class SchematicPromptScreen extends AbstractSimiScreen {
int x = guiLeft;
int y = guiTop;
background.draw(ms, this, x, y);
background.render(ms, x, y, this);
drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF);
GuiGameElement.of(AllItems.SCHEMATIC.asStack())
.at(x + 22, y + 23, 0)
.render(ms);
@ -98,27 +104,9 @@ public class SchematicPromptScreen extends AbstractSimiScreen {
return nameField.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_);
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (confirm.isHovered()) {
confirm(false);
return true;
}
if (abort.isHovered()) {
CreateClient.SCHEMATIC_AND_QUILL_HANDLER.discard();
minecraft.player.closeContainer();
return true;
}
if (convert.isHovered()) {
confirm(true);
return true;
}
return super.mouseClicked(x, y, button);
}
private void confirm(boolean convertImmediately) {
CreateClient.SCHEMATIC_AND_QUILL_HANDLER.saveSchematic(nameField.getValue(), convertImmediately);
minecraft.player.closeContainer();
onClose();
}
}

View file

@ -4,10 +4,10 @@ import static java.lang.Math.abs;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingAngle;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingAngle;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;

View file

@ -40,7 +40,7 @@ public class ConfigureSchematicannonPacket extends SimplePacketBase {
if (player == null || !(player.containerMenu instanceof SchematicannonContainer))
return;
SchematicannonTileEntity te = ((SchematicannonContainer) player.containerMenu).getTileEntity();
SchematicannonTileEntity te = ((SchematicannonContainer) player.containerMenu).contentHolder;
switch (option) {
case DONT_REPLACE:
case REPLACE_ANY:

View file

@ -71,7 +71,7 @@ public class SchematicUploadPacket extends SimplePacketBase {
if (player == null)
return;
if (code == BEGIN) {
BlockPos pos = ((SchematicTableContainer) player.containerMenu).getTileEntity()
BlockPos pos = ((SchematicTableContainer) player.containerMenu).contentHolder
.getBlockPos();
Create.SCHEMATIC_RECEIVER.handleNewUpload(player, schematic, size, pos);
}

View file

@ -12,16 +12,15 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.gui.TextStencilElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.element.TextStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import com.simibubi.create.foundation.item.TooltipHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.common.ForgeConfigSpec;
@ -142,12 +141,11 @@ public class BaseConfigScreen extends ConfigScreen {
@Override
protected void init() {
widgets.clear();
super.init();
returnOnClose = true;
TextStencilElement clientText = new TextStencilElement(minecraft.font, new TextComponent(clientTile)).centered(true, true);
widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText));
addRenderableWidget(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText));
if (clientSpec != null) {
clientConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ModConfig.Type.CLIENT, clientSpec)));
@ -159,7 +157,7 @@ public class BaseConfigScreen extends ConfigScreen {
}
TextStencilElement commonText = new TextStencilElement(minecraft.font, new TextComponent(commonTile)).centered(true, true);
widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText));
addRenderableWidget(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText));
if (commonSpec != null) {
commonConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ModConfig.Type.COMMON, commonSpec)));
@ -171,13 +169,13 @@ public class BaseConfigScreen extends ConfigScreen {
}
TextStencilElement serverText = new TextStencilElement(minecraft.font, new TextComponent(serverTile)).centered(true, true);
widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16).showingElement(serverText));
addRenderableWidget(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16).showingElement(serverText));
if (serverSpec == null) {
serverConfigWidget.active = false;
serverConfigWidget.updateColorsFromState();
serverText.withElementRenderer(DISABLED_RENDERER);
} else if (Minecraft.getInstance().level == null) {
} else if (minecraft.level == null) {
serverText.withElementRenderer(DISABLED_RENDERER);
serverConfigWidget.getToolTip()
.add(new TextComponent("Stored individually per World"));
@ -208,7 +206,7 @@ public class BaseConfigScreen extends ConfigScreen {
.showingElement(titleText.at(0, 7));
title.active = false;
widgets.add(title);
addRenderableWidget(title);
ConfigScreen.modID = this.modID;
@ -219,13 +217,13 @@ public class BaseConfigScreen extends ConfigScreen {
.withElementRenderer(BoxWidget.gradientFactory.apply(goBack)));
goBack.getToolTip()
.add(new TextComponent("Go Back"));
widgets.add(goBack);
addRenderableWidget(goBack);
TextStencilElement othersText = new TextStencilElement(minecraft.font, new TextComponent("Access Configs of other Mods")).centered(true, true);
others = new BoxWidget(width / 2 - 100, height / 2 - 15 + 90, 200, 16).showingElement(othersText);
othersText.withElementRenderer(BoxWidget.gradientFactory.apply(others));
others.withCallback(() -> linkTo(new ConfigModListScreen(this)));
widgets.add(others);
addRenderableWidget(others);
}

View file

@ -6,10 +6,10 @@ import java.util.Locale;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import com.simibubi.create.foundation.item.TooltipHelper;
import net.minecraft.ChatFormatting;
@ -29,22 +29,15 @@ public class ConfigModListScreen extends ConfigScreen {
super(parent);
}
@Override
public void tick() {
super.tick();
list.tick();
}
@Override
protected void init() {
widgets.clear();
super.init();
int listWidth = Math.min(width - 80, 300);
list = new ConfigScreenList(minecraft, listWidth, height - 60, 15, height - 45, 40);
list.setLeftPos(this.width / 2 - list.getWidth() / 2);
addWidget(list);
addRenderableWidget(list);
allEntries = new ArrayList<>();
ModList.get().getMods().stream().map(IModInfo::getModId).forEach(id -> allEntries.add(new ModEntry(id, this)));
@ -64,20 +57,13 @@ public class ConfigModListScreen extends ConfigScreen {
.withElementRenderer(BoxWidget.gradientFactory.apply(goBack)));
goBack.getToolTip()
.add(new TextComponent("Go Back"));
widgets.add(goBack);
addRenderableWidget(goBack);
search = new HintableTextFieldWidget(font, width / 2 - listWidth / 2, height - 35, listWidth, 20);
search.setResponder(this::updateFilter);
search.setHint("Search..");
search.moveCursorToStart();
widgets.add(search);
}
@Override
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
list.render(ms, mouseX, mouseY, partialTicks);
addRenderableWidget(search);
}

View file

@ -9,7 +9,6 @@ import javax.annotation.Nonnull;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.TriConsumer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
@ -23,10 +22,10 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.StencilElement;
import com.simibubi.create.foundation.gui.CreateMainMenuScreen;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.mainMenu.CreateMainMenuScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.element.StencilElement;
import com.simibubi.create.foundation.utility.animation.Force;
import com.simibubi.create.foundation.utility.animation.PhysicalFloat;
@ -99,7 +98,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen {
@Override
protected void prepareFrame() {
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget();
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
GlCompat functions = Backend.getInstance().compat;
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.frameBufferId);
@ -107,15 +106,13 @@ public abstract class ConfigScreen extends AbstractSimiScreen {
functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, thisBuffer.frameBufferId);
GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
}
@Override
protected void endFrame() {
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget();
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
GlCompat functions = Backend.getInstance().compat;
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.frameBufferId);

View file

@ -7,15 +7,15 @@ import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.config.ui.entries.NumberEntry;
import com.simibubi.create.foundation.gui.TextStencilElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.TickableGuiEventListener;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.element.TextStencilElement;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -30,7 +30,7 @@ import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.fmlclient.gui.GuiUtils;
public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry> {
public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry> implements TickableGuiEventListener {
public static EditBox currentText;
@ -56,7 +56,7 @@ public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry
@Override
protected void renderList(PoseStack p_238478_1_, int p_238478_2_, int p_238478_3_, int p_238478_4_, int p_238478_5_, float p_238478_6_) {
Window window = Minecraft.getInstance().getWindow();
Window window = minecraft.getWindow();
double d0 = window.getGuiScale();
RenderSystem.enableScissor((int) (this.x0 * d0), (int) (window.getHeight() - (this.y1 * d0)), (int) (this.width * d0), (int) (this.height * d0));
super.renderList(p_238478_1_, p_238478_2_, p_238478_3_, p_238478_4_, p_238478_5_, p_238478_6_);
@ -80,6 +80,7 @@ public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry
return x0 + this.width - 6;
}
@Override
public void tick() {
/*for(int i = 0; i < getItemCount(); ++i) {
int top = this.getRowTop(i);
@ -122,7 +123,7 @@ public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry
ConfigScreen.cogSpin.bump(3, force);
}
public static abstract class Entry extends ObjectSelectionList.Entry<Entry> {
public static abstract class Entry extends ObjectSelectionList.Entry<Entry> implements TickableGuiEventListener {
protected List<GuiEventListener> listeners;
protected Map<String, String> annotations;
protected String path;
@ -147,6 +148,7 @@ public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry
return getGuiListeners().stream().anyMatch(l -> l.charTyped(ch, code));
}
@Override
public void tick() {}
public List<GuiEventListener> getGuiListeners() {
@ -249,13 +251,13 @@ public class ConfigScreenList extends ObjectSelectionList<ConfigScreenList.Entry
if (tooltip.isEmpty())
return;
GL11.glDisable(GL11.GL_SCISSOR_TEST);
RenderSystem.disableScissor();
Screen screen = Minecraft.getInstance().screen;
ms.pushPose();
ms.translate(0, 0, 400);
GuiUtils.drawHoveringText(ms, tooltip, mouseX, mouseY, screen.width, screen.height, 300, font);
ms.popPose();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GlStateManager._enableScissorTest();
}
}

View file

@ -7,8 +7,8 @@ import java.util.stream.Collectors;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.CreateMainMenuScreen;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.gui.mainMenu.CreateMainMenuScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractWidget;

View file

@ -29,11 +29,11 @@ import com.simibubi.create.foundation.config.ui.entries.ValueEntry;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.ConfirmationScreen;
import com.simibubi.create.foundation.gui.ConfirmationScreen.Response;
import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Color;
@ -135,8 +135,8 @@ public class SubMenuConfigScreen extends ConfigScreen {
}
String command = change.annotations.get("Execute");
if (Minecraft.getInstance().player != null && command != null && command.startsWith("/")) {
Minecraft.getInstance().player.chat(command);
if (minecraft.player != null && command != null && command.startsWith("/")) {
minecraft.player.chat(command);
//AllPackets.channel.sendToServer(new CChatMessagePacket(command));
}
});
@ -163,15 +163,8 @@ public class SubMenuConfigScreen extends ConfigScreen {
.forEach(e -> ((ValueEntry<?>) e).onValueChange());
}
@Override
public void tick() {
super.tick();
list.tick();
}
@Override
protected void init() {
widgets.clear();
super.init();
listWidth = Math.min(width - 80, 300);
@ -242,21 +235,21 @@ public class SubMenuConfigScreen extends ConfigScreen {
goBack.showingElement(AllIcons.I_CONFIG_BACK.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(goBack)));
goBack.getToolTip().add(new TextComponent("Go Back"));
widgets.add(resetAll);
widgets.add(saveChanges);
widgets.add(discardChanges);
widgets.add(goBack);
addRenderableWidget(resetAll);
addRenderableWidget(saveChanges);
addRenderableWidget(discardChanges);
addRenderableWidget(goBack);
list = new ConfigScreenList(minecraft, listWidth, height - 80, 35, height - 45, 40);
list.setLeftPos(this.width / 2 - list.getWidth() / 2);
addWidget(list);
addRenderableWidget(list);
search = new ConfigTextField(font, width / 2 - listWidth / 2, height - 35, listWidth, 20);
search.setResponder(this::updateFilter);
search.setHint("Search..");
search.moveCursorToStart();
widgets.add(search);
addRenderableWidget(search);
configGroup.valueMap().forEach((key, obj) -> {
String humanKey = toHumanReadable(key);
@ -331,20 +324,20 @@ public class SubMenuConfigScreen extends ConfigScreen {
if (!canEdit) {
list.children().forEach(e -> e.setEditable(false));
resetAll.active = false;
stencil.withStencilRenderer((ms, w, h, alpha) -> AllIcons.I_CONFIG_LOCKED.draw(ms, 0, 0));
stencil.withStencilRenderer((ms, w, h, alpha) -> AllIcons.I_CONFIG_LOCKED.render(ms, 0, 0));
stencil.withElementRenderer((ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, 8, 0, 16, 16, red));
serverLocked.withBorderColors(red);
serverLocked.getToolTip().add(new TextComponent("Locked").withStyle(ChatFormatting.BOLD));
serverLocked.getToolTip().addAll(TooltipHelper.cutStringTextComponent("You do not have enough permissions to edit the server config. You can still look at the current values here though.", ChatFormatting.GRAY, ChatFormatting.GRAY));
} else {
stencil.withStencilRenderer((ms, w, h, alpha) -> AllIcons.I_CONFIG_UNLOCKED.draw(ms, 0, 0));
stencil.withStencilRenderer((ms, w, h, alpha) -> AllIcons.I_CONFIG_UNLOCKED.render(ms, 0, 0));
stencil.withElementRenderer((ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, 8, 0, 16, 16, green));
serverLocked.withBorderColors(green);
serverLocked.getToolTip().add(new TextComponent("Unlocked").withStyle(ChatFormatting.BOLD));
serverLocked.getToolTip().addAll(TooltipHelper.cutStringTextComponent("You have enough permissions to edit the server config. Changes you make here will be synced with the server when you save them.", ChatFormatting.GRAY, ChatFormatting.GRAY));
}
widgets.add(serverLocked);
addRenderableWidget(serverLocked);
}
@Override
@ -353,8 +346,6 @@ public class SubMenuConfigScreen extends ConfigScreen {
int x = width / 2;
drawCenteredString(ms, minecraft.font, ConfigScreen.modID + " > " + type.toString().toLowerCase(Locale.ROOT) + " > " + title, x, 15, Theme.i(Theme.Key.TEXT));
list.render(ms, mouseX, mouseY, partialTicks);
}
@Override

View file

@ -2,10 +2,10 @@ package com.simibubi.create.foundation.config.ui.entries;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.RenderElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.RenderElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import net.minecraftforge.common.ForgeConfigSpec;

View file

@ -5,12 +5,12 @@ import java.util.Locale;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.config.ui.ConfigScreen;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.BoxElement;
import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.TextStencilElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.BoxElement;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.element.TextStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.ForgeConfigSpec;

View file

@ -8,9 +8,9 @@ import javax.annotation.Nullable;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.config.ui.ConfigTextField;
import com.simibubi.create.foundation.gui.TextStencilElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.element.TextStencilElement;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;

View file

@ -5,9 +5,9 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.config.ui.ConfigScreenList;
import com.simibubi.create.foundation.config.ui.SubMenuConfigScreen;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import net.minecraftforge.common.ForgeConfigSpec;

View file

@ -15,8 +15,8 @@ import com.simibubi.create.foundation.config.ui.ConfigHelper;
import com.simibubi.create.foundation.config.ui.ConfigScreen;
import com.simibubi.create.foundation.config.ui.ConfigScreenList;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.utility.Pair;

View file

@ -34,7 +34,7 @@ public class CreateEntityBuilder<T extends Entity, P> extends EntityBuilder<T, P
public CreateEntityBuilder<T, P> instance(NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory) {
if (this.instanceFactory == null) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerInstance);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerInstance);
}
this.instanceFactory = instanceFactory;
@ -46,7 +46,9 @@ public class CreateEntityBuilder<T extends Entity, P> extends EntityBuilder<T, P
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, $ -> {
NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory = this.instanceFactory;
if (instanceFactory != null) {
InstancedRenderRegistry.getInstance().register(getEntry(), instanceFactory.get());
InstancedRenderRegistry.getInstance()
.entity(getEntry())
.factory(instanceFactory.get());
}
});

View file

@ -32,7 +32,7 @@ public class CreateTileEntityBuilder<T extends BlockEntity, P> extends TileEntit
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory) {
if (this.instanceFactory == null) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerInstance);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerInstance);
}
this.instanceFactory = instanceFactory;
@ -45,7 +45,8 @@ public class CreateTileEntityBuilder<T extends BlockEntity, P> extends TileEntit
NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory = this.instanceFactory;
if (instanceFactory != null) {
InstancedRenderRegistry.getInstance()
.register(getEntry(), instanceFactory.get());
.tile(getEntry())
.factory(instanceFactory.get());
}
});
}

View file

@ -1,208 +0,0 @@
package com.simibubi.create.foundation.gui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
@ParametersAreNonnullByDefault
public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMenu> extends AbstractContainerScreen<T> {
protected List<AbstractWidget> widgets;
protected int windowXOffset;
protected int windowYOffset;
public AbstractSimiContainerScreen(T container, Inventory inv, Component title) {
super(container, inv, title);
widgets = new ArrayList<>();
}
protected void setWindowSize(int width, int height) {
this.imageWidth = width;
this.imageHeight = height;
}
protected void setWindowOffset(int xOffset, int yOffset) {
windowXOffset = xOffset;
windowYOffset = yOffset;
}
@Override
protected void init() {
super.init();
leftPos += windowXOffset;
topPos += windowYOffset;
}
@Override
protected void renderLabels(PoseStack p_230451_1_, int p_230451_2_, int p_230451_3_) {
// no-op to prevent screen- and inventory-title from being rendered at incorrect location
// could also set this.titleX/Y and this.playerInventoryTitleX/Y to the proper values instead
}
@Override
public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
partialTicks = Minecraft.getInstance()
.getFrameTime();
renderBackground(matrixStack);
renderWindow(matrixStack, mouseX, mouseY, partialTicks);
for (AbstractWidget widget : widgets)
widget.render(matrixStack, mouseX, mouseY, partialTicks);
super.render(matrixStack, mouseX, mouseY, partialTicks);
renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks);
}
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean result = false;
for (AbstractWidget widget : widgets) {
if (widget.mouseClicked(x, y, button))
result = true;
}
return result || super.mouseClicked(x, y, button);
}
@Override
public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) {
for (AbstractWidget widget : widgets) {
if (widget.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_))
return true;
}
if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_))
return true;
InputConstants.Key mouseKey = InputConstants.getKey(code, p_keyPressed_2_);
if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) {
this.onClose();
return true;
}
return false;
}
@Override
public boolean charTyped(char character, int code) {
for (AbstractWidget widget : widgets) {
if (widget.charTyped(character, code))
return true;
}
return super.charTyped(character, code);
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
for (AbstractWidget widget : widgets) {
if (widget.mouseScrolled(mouseX, mouseY, delta))
return true;
}
return super.mouseScrolled(mouseX, mouseY, delta);
}
@Override
public boolean mouseReleased(double x, double y, int button) {
boolean result = false;
for (AbstractWidget widget : widgets) {
if (widget.mouseReleased(x, y, button))
result = true;
}
return result | super.mouseReleased(x, y, button);
}
protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks);
@Override
protected void renderBg(PoseStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) {
}
protected void renderWindowForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
renderTooltip(matrixStack, mouseX, mouseY);
for (AbstractWidget widget : widgets) {
if (!widget.isHovered())
continue;
if (widget instanceof AbstractSimiWidget) {
if (!((AbstractSimiWidget) widget).getToolTip().isEmpty())
renderComponentTooltip(matrixStack, ((AbstractSimiWidget) widget).getToolTip(), mouseX, mouseY);
} else {
widget.renderToolTip(matrixStack, mouseX, mouseY);
}
}
}
public double getItemCountTextScale() {
int guiScaleFactor = (int) minecraft.getWindow()
.getGuiScale();
double scale = 1;
switch (guiScaleFactor) {
case 1:
scale = 2060 / 2048d;
break;
case 2:
scale = .5;
break;
case 3:
scale = .675;
break;
case 4:
scale = .75;
break;
default:
scale = ((float) guiScaleFactor - 1) / guiScaleFactor;
}
return scale;
}
public int getLeftOfCentered(int textureWidth) {
return (width - textureWidth) / 2;
}
public void renderPlayerInventory(PoseStack ms, int x, int y) {
AllGuiTextures.PLAYER_INVENTORY.draw(ms, this, x, y);
font.draw(ms, playerInventoryTitle, x + 8, y + 6, 0x404040);
}
/**
* Used for moving JEI out of the way of extra things like Flexcrate renders.
*
* <p>This screen class must be bound to a SlotMover instance for this method to work.
*
* @return the space that the gui takes up besides the normal rectangle defined by {@link ContainerScreen}.
*/
public List<Rect2i> getExtraAreas() {
return Collections.emptyList();
}
@Deprecated
protected void debugWindowArea(PoseStack matrixStack) {
fill(matrixStack, leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3);
}
@Deprecated
protected void debugExtraAreas(PoseStack matrixStack) {
for (Rect2i area : getExtraAreas()) {
fill(matrixStack, area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(), 0xd3d3d3d3);
}
}
}

View file

@ -1,14 +1,14 @@
package com.simibubi.create.foundation.gui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
import com.simibubi.create.foundation.gui.widget.AbstractSimiWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
@ -21,22 +21,26 @@ public abstract class AbstractSimiScreen extends Screen {
protected int windowWidth, windowHeight;
protected int windowXOffset, windowYOffset;
protected int guiLeft, guiTop;
protected List<AbstractWidget> widgets;
protected AbstractSimiScreen(Component title) {
super(title);
widgets = new ArrayList<>();
}
protected AbstractSimiScreen() {
this(new TextComponent(""));
this(TextComponent.EMPTY);
}
/**
* This method must be called before {@code super.init()}!
*/
protected void setWindowSize(int width, int height) {
windowWidth = width;
windowHeight = height;
}
/**
* This method must be called before {@code super.init()}!
*/
protected void setWindowOffset(int xOffset, int yOffset) {
windowXOffset = xOffset;
windowYOffset = yOffset;
@ -44,7 +48,6 @@ public abstract class AbstractSimiScreen extends Screen {
@Override
protected void init() {
super.init();
guiLeft = (width - windowWidth) / 2;
guiTop = (height - windowHeight) / 2;
guiLeft += windowXOffset;
@ -53,16 +56,46 @@ public abstract class AbstractSimiScreen extends Screen {
@Override
public void tick() {
super.tick();
for (GuiEventListener listener : children()) {
if (listener instanceof TickableGuiEventListener tickable) {
tickable.tick();
}
}
}
widgets.stream().filter(w -> w instanceof AbstractSimiWidget).forEach(w -> ((AbstractSimiWidget) w).tick());
@Override
public boolean isPauseScreen() {
return false;
}
@SuppressWarnings("unchecked")
protected <W extends GuiEventListener & Widget & NarratableEntry> void addRenderableWidgets(W... widgets) {
for (W widget : widgets) {
addRenderableWidget(widget);
}
}
protected <W extends GuiEventListener & Widget & NarratableEntry> void addRenderableWidgets(Collection<W> widgets) {
for (W widget : widgets) {
addRenderableWidget(widget);
}
}
protected void removeWidgets(GuiEventListener... widgets) {
for (GuiEventListener widget : widgets) {
removeWidget(widget);
}
}
protected void removeWidgets(Collection<? extends GuiEventListener> widgets) {
for (GuiEventListener widget : widgets) {
removeWidget(widget);
}
}
@Override
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
partialTicks = partialTicks == 10 ? 0
: Minecraft.getInstance()
.getFrameTime();
partialTicks = minecraft.getFrameTime();
ms.pushPose();
@ -70,8 +103,7 @@ public abstract class AbstractSimiScreen extends Screen {
renderWindowBackground(ms, mouseX, mouseY, partialTicks);
renderWindow(ms, mouseX, mouseY, partialTicks);
for (AbstractWidget widget : widgets)
widget.render(ms, mouseX, mouseY, partialTicks);
super.render(ms, mouseX, mouseY, partialTicks);
renderWindowForeground(ms, mouseX, mouseY, partialTicks);
endFrame();
@ -82,105 +114,28 @@ public abstract class AbstractSimiScreen extends Screen {
protected void prepareFrame() {
}
protected void endFrame() {
}
protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
renderBackground(ms);
}
@Override
public boolean mouseClicked(double x, double y, int button) {
boolean result = false;
for (AbstractWidget widget : widgets)
if (widget.mouseClicked(x, y, button))
result = true;
if (!result) {
result = super.mouseClicked(x, y, button);
}
return result;
}
@Override
public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) {
for (AbstractWidget widget : widgets)
if (widget.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_))
return true;
if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_))
return true;
InputConstants.Key mouseKey = InputConstants.getKey(code, p_keyPressed_2_);
if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) {
this.onClose();
return true;
}
return false;
}
@Override
public boolean charTyped(char character, int code) {
for (AbstractWidget widget : widgets) {
if (widget.charTyped(character, code))
return true;
}
return super.charTyped(character, code);
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
for (AbstractWidget widget : widgets) {
if (widget.mouseScrolled(mouseX, mouseY, delta))
return true;
}
return super.mouseScrolled(mouseX, mouseY, delta);
}
@Override
public boolean mouseReleased(double x, double y, int button) {
boolean result = false;
for (AbstractWidget widget : widgets) {
if (widget.mouseReleased(x, y, button))
result = true;
}
return result | super.mouseReleased(x, y, button);
}
@Override
public boolean shouldCloseOnEsc() {
return true;
}
@Override
public boolean isPauseScreen() {
return false;
}
protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks);
protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
for (AbstractWidget widget : widgets) {
if (!widget.isHovered())
continue;
if (widget instanceof AbstractSimiWidget) {
if (!((AbstractSimiWidget) widget).getToolTip().isEmpty())
renderComponentTooltip(ms, ((AbstractSimiWidget) widget).getToolTip(), mouseX, mouseY);
} else {
widget.renderToolTip(ms, mouseX, mouseY);
for (Widget widget : renderables) {
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isHovered()) {
List<Component> tooltip = simiWidget.getToolTip();
if (!tooltip.isEmpty())
renderComponentTooltip(ms, tooltip, mouseX, mouseY);
}
}
}
protected void endFrame() {
}
@Deprecated
protected void debugWindowArea(PoseStack matrixStack) {
fill(matrixStack, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
}
public List<AbstractWidget> getWidgets() {
return widgets;
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.foundation.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.gui.element.ScreenElement;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.gui.GuiComponent;
@ -10,110 +11,110 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public enum AllGuiTextures implements IScreenRenderable {
public enum AllGuiTextures implements ScreenElement {
// Inventories
PLAYER_INVENTORY("player_inventory.png", 176, 108),
WAND_OF_SYMMETRY("curiosities.png", 0, 131, 188, 101),
BLOCKZAPPER("curiosities.png", 0, 99, 214, 97),
TERRAINZAPPER("curiosities.png", 234, 103),
TERRAINZAPPER_INACTIVE_PARAM("curiosities.png", 238, 0, 18, 18),
PLAYER_INVENTORY("player_inventory", 176, 108),
WAND_OF_SYMMETRY("curiosities", 0, 131, 188, 101),
BLOCKZAPPER("curiosities", 0, 99, 214, 97),
TERRAINZAPPER("curiosities", 234, 103),
TERRAINZAPPER_INACTIVE_PARAM("curiosities", 238, 0, 18, 18),
LOGO("logo.png", 256, 256),
LOGO("logo", 256, 256),
SCHEMATIC("schematics.png", 192, 121),
SCHEMATIC_SLOT("widgets.png", 54, 0, 16, 16),
SCHEMATIC_PROMPT("schematics_2.png", 213, 77),
HUD_BACKGROUND("overlay.png", 0, 0, 16, 16),
SCHEMATIC("schematics", 192, 121),
SCHEMATIC_SLOT("widgets", 54, 0, 16, 16),
SCHEMATIC_PROMPT("schematics_2", 213, 77),
HUD_BACKGROUND("overlay", 0, 0, 16, 16),
SCHEMATIC_TABLE("schematics.png", 0, 121, 214, 83),
SCHEMATIC_TABLE_PROGRESS("schematics.png", 0, 204, 84, 16),
SCHEMATIC_TABLE("schematics", 0, 121, 214, 83),
SCHEMATIC_TABLE_PROGRESS("schematics", 0, 204, 84, 16),
SCHEMATICANNON_TOP("schematics_2.png", 0, 77, 213, 42),
SCHEMATICANNON_BOTTOM("schematics_2.png", 0, 119, 213, 99),
SCHEMATICANNON_PROGRESS("schematics_2.png", 76, 239, 114, 16),
SCHEMATICANNON_CHECKLIST_PROGRESS("schematics_2.png", 191, 240, 16, 14),
SCHEMATICANNON_HIGHLIGHT("schematics_2.png", 1, 229, 26, 26),
SCHEMATICANNON_FUEL("schematics_2.png", 28, 222, 47, 16),
SCHEMATICANNON_FUEL_CREATIVE("schematics_2.png", 28, 239, 47, 16),
SCHEMATICANNON_TOP("schematics_2", 0, 77, 213, 42),
SCHEMATICANNON_BOTTOM("schematics_2", 0, 119, 213, 99),
SCHEMATICANNON_PROGRESS("schematics_2", 76, 239, 114, 16),
SCHEMATICANNON_CHECKLIST_PROGRESS("schematics_2", 191, 240, 16, 14),
SCHEMATICANNON_HIGHLIGHT("schematics_2", 1, 229, 26, 26),
SCHEMATICANNON_FUEL("schematics_2", 28, 222, 47, 16),
SCHEMATICANNON_FUEL_CREATIVE("schematics_2", 28, 239, 47, 16),
STOCKSWITCH("logistics.png", 182, 93),
STOCKSWITCH_ARROW_UP("logistics.png", 191, 0, 7, 24),
STOCKSWITCH_ARROW_DOWN("logistics.png", 198, 0, 7, 24),
STOCKSWITCH_CURSOR("logistics.png", 206, 0, 7, 16),
STOCKSWITCH_INTERVAL("logistics.png", 0, 93, 100, 18),
STOCKSWITCH_UNPOWERED_LANE("logistics.png", 36, 18, 102, 18),
STOCKSWITCH_POWERED_LANE("logistics.png", 36, 40, 102, 18),
STOCKSWITCH("logistics", 182, 93),
STOCKSWITCH_ARROW_UP("logistics", 191, 0, 7, 24),
STOCKSWITCH_ARROW_DOWN("logistics", 198, 0, 7, 24),
STOCKSWITCH_CURSOR("logistics", 206, 0, 7, 16),
STOCKSWITCH_INTERVAL("logistics", 0, 93, 100, 18),
STOCKSWITCH_UNPOWERED_LANE("logistics", 36, 18, 102, 18),
STOCKSWITCH_POWERED_LANE("logistics", 36, 40, 102, 18),
ADJUSTABLE_CRATE("logistics_2.png", 124, 127),
ADJUSTABLE_DOUBLE_CRATE("logistics_2.png", 0, 127, 196, 127),
ADJUSTABLE_CRATE_LOCKED_SLOT("logistics_2.png", 125, 109, 18, 18),
ADJUSTABLE_CRATE("logistics_2", 124, 127),
ADJUSTABLE_DOUBLE_CRATE("logistics_2", 0, 127, 196, 127),
ADJUSTABLE_CRATE_LOCKED_SLOT("logistics_2", 125, 109, 18, 18),
FILTER("filters.png", 214, 97),
ATTRIBUTE_FILTER("filters.png", 0, 97, 241, 83),
FILTER("filters", 214, 97),
ATTRIBUTE_FILTER("filters", 0, 97, 241, 83),
TOOLBOX("toolbox.png", 188, 171),
TOOLBELT_SLOT("minecraft", "widgets.png", 24, 23, 22, 22),
TOOLBELT_SLOT_HIGHLIGHT("minecraft", "widgets.png", 0, 22, 24, 24),
TOOLBELT_MAIN_SLOT("widgets.png", 0, 97, 24, 24),
TOOLBELT_EMPTY_SLOT("widgets.png", 27, 98, 22, 22),
TOOLBELT_INACTIVE_SLOT("widgets.png", 52, 98, 22, 22),
TOOLBOX("toolbox", 188, 171),
TOOLBELT_SLOT("minecraft", "widgets", 24, 23, 22, 22),
TOOLBELT_SLOT_HIGHLIGHT("minecraft", "widgets", 0, 22, 24, 24),
TOOLBELT_MAIN_SLOT("widgets", 0, 97, 24, 24),
TOOLBELT_EMPTY_SLOT("widgets", 27, 98, 22, 22),
TOOLBELT_INACTIVE_SLOT("widgets", 52, 98, 22, 22),
TOOLBELT_HOTBAR_OFF("widgets.png", 0, 130, 20, 24),
TOOLBELT_HOTBAR_ON("widgets.png", 20, 130, 20, 24),
TOOLBELT_SELECTED_OFF("widgets.png", 0, 155, 22, 22),
TOOLBELT_SELECTED_ON("widgets.png", 22, 155, 22, 22),
TOOLBELT_HOTBAR_OFF("widgets", 0, 130, 20, 24),
TOOLBELT_HOTBAR_ON("widgets", 20, 130, 20, 24),
TOOLBELT_SELECTED_OFF("widgets", 0, 155, 22, 22),
TOOLBELT_SELECTED_ON("widgets", 22, 155, 22, 22),
SEQUENCER("sequencer.png", 173, 159),
SEQUENCER_INSTRUCTION("sequencer.png", 0, 14, 162, 22),
SEQUENCER_DELAY("sequencer.png", 0, 58, 162, 22),
SEQUENCER_END("sequencer.png", 0, 80, 162, 22),
SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22),
SEQUENCER_AWAIT("sequencer.png", 0, 160, 162, 22),
SEQUENCER("sequencer", 173, 159),
SEQUENCER_INSTRUCTION("sequencer", 0, 14, 162, 22),
SEQUENCER_DELAY("sequencer", 0, 58, 162, 22),
SEQUENCER_END("sequencer", 0, 80, 162, 22),
SEQUENCER_EMPTY("sequencer", 0, 102, 162, 22),
SEQUENCER_AWAIT("sequencer", 0, 160, 162, 22),
LINKED_CONTROLLER("curiosities_2.png", 179, 109),
BLUEPRINT("curiosities_2.png", 0, 109, 179, 109),
LINKED_CONTROLLER("curiosities_2", 179, 109),
BLUEPRINT("curiosities_2", 0, 109, 179, 109),
PROJECTOR("projector.png", 235, 185),
PROJECTOR_FILTER_STRENGTH("projector.png", 0, 14, 162, 22),
PROJECTOR_FILTER("projector.png", 0, 36, 162, 22),
PROJECTOR_END("projector.png", 0, 58, 162, 22),
PROJECTOR_EMPTY("projector.png", 0, 80, 162, 22),
PROJECTOR("projector", 235, 185),
PROJECTOR_FILTER_STRENGTH("projector", 0, 14, 162, 22),
PROJECTOR_FILTER("projector", 0, 36, 162, 22),
PROJECTOR_END("projector", 0, 58, 162, 22),
PROJECTOR_EMPTY("projector", 0, 80, 162, 22),
// JEI
JEI_SLOT("jei/widgets.png", 18, 18),
JEI_CHANCE_SLOT("jei/widgets.png", 20, 156, 18, 18),
JEI_CATALYST_SLOT("jei/widgets.png", 0, 156, 18, 18),
JEI_ARROW("jei/widgets.png", 19, 10, 42, 10),
JEI_LONG_ARROW("jei/widgets.png", 19, 0, 71, 10),
JEI_DOWN_ARROW("jei/widgets.png", 0, 21, 18, 14),
JEI_LIGHT("jei/widgets.png", 0, 42, 52, 11),
JEI_QUESTION_MARK("jei/widgets.png", 0, 178, 12, 16),
JEI_SHADOW("jei/widgets.png", 0, 56, 52, 11),
BLOCKZAPPER_UPGRADE_RECIPE("jei/widgets.png", 0, 75, 144, 66),
JEI_HEAT_BAR("jei/widgets.png", 0, 201, 169, 19),
JEI_NO_HEAT_BAR("jei/widgets.png", 0, 221, 169, 19),
JEI_SLOT("jei/widgets", 18, 18),
JEI_CHANCE_SLOT("jei/widgets", 20, 156, 18, 18),
JEI_CATALYST_SLOT("jei/widgets", 0, 156, 18, 18),
JEI_ARROW("jei/widgets", 19, 10, 42, 10),
JEI_LONG_ARROW("jei/widgets", 19, 0, 71, 10),
JEI_DOWN_ARROW("jei/widgets", 0, 21, 18, 14),
JEI_LIGHT("jei/widgets", 0, 42, 52, 11),
JEI_QUESTION_MARK("jei/widgets", 0, 178, 12, 16),
JEI_SHADOW("jei/widgets", 0, 56, 52, 11),
BLOCKZAPPER_UPGRADE_RECIPE("jei/widgets", 0, 75, 144, 66),
JEI_HEAT_BAR("jei/widgets", 0, 201, 169, 19),
JEI_NO_HEAT_BAR("jei/widgets", 0, 221, 169, 19),
// Widgets
BUTTON("widgets.png", 18, 18),
BUTTON_HOVER("widgets.png", 18, 0, 18, 18),
BUTTON_DOWN("widgets.png", 36, 0, 18, 18),
INDICATOR("widgets.png", 0, 18, 18, 6),
INDICATOR_WHITE("widgets.png", 18, 18, 18, 6),
INDICATOR_GREEN("widgets.png", 36, 18, 18, 6),
INDICATOR_YELLOW("widgets.png", 54, 18, 18, 6),
INDICATOR_RED("widgets.png", 72, 18, 18, 6),
BUTTON("widgets", 18, 18),
BUTTON_HOVER("widgets", 18, 0, 18, 18),
BUTTON_DOWN("widgets", 36, 0, 18, 18),
INDICATOR("widgets", 0, 18, 18, 6),
INDICATOR_WHITE("widgets", 18, 18, 18, 6),
INDICATOR_GREEN("widgets", 36, 18, 18, 6),
INDICATOR_YELLOW("widgets", 54, 18, 18, 6),
INDICATOR_RED("widgets", 72, 18, 18, 6),
HOTSLOT_ARROW("widgets.png", 24, 51, 20, 12),
HOTSLOT("widgets.png", 0, 68, 22, 22),
HOTSLOT_ACTIVE("widgets.png", 0, 46, 22, 22),
HOTSLOT_SUPER_ACTIVE("widgets.png", 27, 67, 24, 24),
HOTSLOT_ARROW("widgets", 24, 51, 20, 12),
HOTSLOT("widgets", 0, 68, 22, 22),
HOTSLOT_ACTIVE("widgets", 0, 46, 22, 22),
HOTSLOT_SUPER_ACTIVE("widgets", 27, 67, 24, 24),
SPEECH_TOOLTIP_BACKGROUND("widgets.png", 0, 24, 8, 8),
SPEECH_TOOLTIP_COLOR("widgets.png", 8, 24, 8, 8),
SPEECH_TOOLTIP_BACKGROUND("widgets", 0, 24, 8, 8),
SPEECH_TOOLTIP_COLOR("widgets", 8, 24, 8, 8),
// PlacementIndicator
PLACEMENT_INDICATOR_SHEET("placement_indicator.png", 0, 0, 16, 256);
PLACEMENT_INDICATOR_SHEET("placement_indicator", 0, 0, 16, 256);
;
@ -128,7 +129,7 @@ public enum AllGuiTextures implements IScreenRenderable {
}
private AllGuiTextures(int startX, int startY) {
this("icons.png", startX * 16, startY * 16, 16, 16);
this("icons", startX * 16, startY * 16, 16, 16);
}
private AllGuiTextures(String location, int startX, int startY, int width, int height) {
@ -136,7 +137,7 @@ public enum AllGuiTextures implements IScreenRenderable {
}
private AllGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
this.location = new ResourceLocation(namespace, "textures/gui/" + location);
this.location = new ResourceLocation(namespace, "textures/gui/" + location + ".png");
this.width = width;
this.height = height;
this.startX = startX;
@ -148,14 +149,21 @@ public enum AllGuiTextures implements IScreenRenderable {
RenderSystem.setShaderTexture(0, location);
}
@Override
@OnlyIn(Dist.CLIENT)
public void draw(PoseStack ms, GuiComponent screen, int x, int y) {
@Override
public void render(PoseStack ms, int x, int y) {
bind();
screen.blit(ms, x, y, startX, startY, width, height);
GuiComponent.blit(ms, x, y, 0, startX, startY, width, height, 256, 256);
}
public void draw(PoseStack ms, int x, int y, Color c) {
@OnlyIn(Dist.CLIENT)
public void render(PoseStack ms, int x, int y, GuiComponent component) {
bind();
component.blit(ms, x, y, startX, startY, width, height);
}
@OnlyIn(Dist.CLIENT)
public void render(PoseStack ms, int x, int y, Color c) {
bind();
UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height);
}

View file

@ -2,12 +2,15 @@ package com.simibubi.create.foundation.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.PoseStack.Pose;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix4f;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.gui.element.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.element.ScreenElement;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
@ -15,9 +18,11 @@ import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class AllIcons implements IScreenRenderable {
public class AllIcons implements ScreenElement {
public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/icons.png");
public static final int ICON_ATLAS_SIZE = 256;
private static int x = 0, y = -1;
private int iconX;
private int iconY;
@ -166,51 +171,54 @@ public class AllIcons implements IScreenRenderable {
RenderSystem.setShaderTexture(0, ICON_ATLAS);
}
@Override
@OnlyIn(Dist.CLIENT)
public void draw(PoseStack matrixStack, GuiComponent screen, int x, int y) {
@Override
public void render(PoseStack matrixStack, int x, int y) {
bind();
screen.blit(matrixStack, x, y, iconX, iconY, 16, 16);
GuiComponent.blit(matrixStack, x, y, 0, iconX, iconY, 16, 16, 256, 256);
}
@OnlyIn(Dist.CLIENT)
public void draw(PoseStack ms, MultiBufferSource buffer, int color) {
public void render(PoseStack matrixStack, int x, int y, GuiComponent component) {
bind();
component.blit(matrixStack, x, y, iconX, iconY, 16, 16);
}
@OnlyIn(Dist.CLIENT)
public void render(PoseStack ms, MultiBufferSource buffer, int color) {
VertexConsumer builder = buffer.getBuffer(RenderType.textSeeThrough(ICON_ATLAS));
float sheetSize = 256;
int i = 15 << 20 | 15 << 4;
int j = i >> 16 & '\uffff';
int k = i & '\uffff';
Pose peek = ms.last();
Vec3 rgb = Color.vectorFromRGB(color);
Matrix4f matrix = ms.last().pose();
Color rgb = new Color(color);
int light = LightTexture.FULL_BRIGHT;
Vec3 vec4 = new Vec3(1, 1, 0);
Vec3 vec3 = new Vec3(0, 1, 0);
Vec3 vec2 = new Vec3(0, 0, 0);
Vec3 vec1 = new Vec3(1, 0, 0);
Vec3 vec1 = new Vec3(0, 0, 0);
Vec3 vec2 = new Vec3(0, 1, 0);
Vec3 vec3 = new Vec3(1, 1, 0);
Vec3 vec4 = new Vec3(1, 0, 0);
float u1 = (iconX + 16) / sheetSize;
float u2 = iconX / sheetSize;
float v1 = iconY / sheetSize;
float v2 = (iconY + 16) / sheetSize;
float u1 = iconX / ICON_ATLAS_SIZE;
float u2 = (iconX + 16) / ICON_ATLAS_SIZE;
float v1 = iconY / ICON_ATLAS_SIZE;
float v2 = (iconY + 16) / ICON_ATLAS_SIZE;
vertex(peek, builder, j, k, rgb, vec1, u1, v1);
vertex(peek, builder, j, k, rgb, vec2, u2, v1);
vertex(peek, builder, j, k, rgb, vec3, u2, v2);
vertex(peek, builder, j, k, rgb, vec4, u1, v2);
vertex(builder, matrix, vec1, rgb, u1, v1, light);
vertex(builder, matrix, vec2, rgb, u1, v2, light);
vertex(builder, matrix, vec3, rgb, u2, v2, light);
vertex(builder, matrix, vec4, rgb, u2, v1, light);
}
@OnlyIn(Dist.CLIENT)
private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) {
builder.vertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z)
.color(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255)
.uv(u, v)
.uv2(light)
.endVertex();
}
@OnlyIn(Dist.CLIENT)
public DelegatedStencilElement asStencil() {
return new DelegatedStencilElement().withStencilRenderer((ms, w, h, alpha) -> this.draw(ms, 0, 0)).withBounds(16, 16);
}
@OnlyIn(Dist.CLIENT)
private void vertex(Pose peek, VertexConsumer builder, int j, int k, Vec3 rgb, Vec3 vec, float u, float v) {
builder.vertex(peek.pose(), (float) vec.x, (float) vec.y, (float) vec.z)
.color((float) rgb.x, (float) rgb.y, (float) rgb.z, 1)
.uv(u, v)
.uv2(j, k)
.endVertex();
return new DelegatedStencilElement().withStencilRenderer((ms, w, h, alpha) -> this.render(ms, 0, 0)).withBounds(16, 16);
}
}

View file

@ -6,7 +6,6 @@ import java.util.function.Consumer;
import javax.annotation.Nonnull;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
@ -14,8 +13,11 @@ import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.GlConst;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.element.BoxElement;
import com.simibubi.create.foundation.gui.element.TextStencilElement;
import com.simibubi.create.foundation.gui.widget.BoxWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
@ -108,7 +110,7 @@ public class ConfirmationScreen extends AbstractSimiScreen {
@Override
protected void init() {
widgets.clear();
super.init();
ArrayList<FormattedText> copy = new ArrayList<>(text);
text.clear();
@ -139,7 +141,7 @@ public class ConfirmationScreen extends AbstractSimiScreen {
new TextStencilElement(minecraft.font, tristate ? "Save" : "Confirm").centered(true, true);
confirm = new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.Confirm));
confirm.showingElement(confirmText.withElementRenderer(BoxWidget.gradientFactory.apply(confirm)));
widgets.add(confirm);
addRenderableWidget(confirm);
buttonX += 12 + 70;
@ -150,7 +152,7 @@ public class ConfirmationScreen extends AbstractSimiScreen {
new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.ConfirmDontSave));
confirmDontSave.showingElement(
confirmDontSaveText.withElementRenderer(BoxWidget.gradientFactory.apply(confirmDontSave)));
widgets.add(confirmDontSave);
addRenderableWidget(confirmDontSave);
buttonX += 12 + 70;
}
@ -158,7 +160,7 @@ public class ConfirmationScreen extends AbstractSimiScreen {
cancel = new BoxWidget(buttonX, y + textHeight + 6, 70, 16)
.withCallback(() -> accept(Response.Cancel));
cancel.showingElement(cancelText.withElementRenderer(BoxWidget.gradientFactory.apply(cancel)));
widgets.add(cancel);
addRenderableWidget(cancel);
textBackground = new BoxElement()
.gradientBorder(Theme.p(Theme.Key.BUTTON_DISABLE))
@ -215,7 +217,7 @@ public class ConfirmationScreen extends AbstractSimiScreen {
@Override
protected void prepareFrame() {
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget();
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
GlCompat functions = Backend.getInstance().compat;
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.frameBufferId);
@ -223,15 +225,13 @@ public class ConfirmationScreen extends AbstractSimiScreen {
functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, thisBuffer.frameBufferId);
GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
}
@Override
protected void endFrame() {
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget();
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
GlCompat functions = Backend.getInstance().compat;
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.frameBufferId);

View file

@ -1,4 +1,4 @@
package com.simibubi.create.foundation.gui.mainMenu;
package com.simibubi.create.foundation.gui;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.platform.GlStateManager;
@ -7,11 +7,8 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.config.ui.BaseConfigScreen;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.BoxElement;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.gui.element.BoxElement;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.ponder.content.PonderTagIndexScreen;
import com.simibubi.create.foundation.utility.Color;
@ -104,7 +101,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen {
ms.translate(width / 2 - 32, 32, -10);
ms.pushPose();
ms.scale(0.25f, 0.25f, 0.25f);
AllGuiTextures.LOGO.draw(ms, 0, 0);
AllGuiTextures.LOGO.render(ms, 0, 0, this);
ms.popPose();
new BoxElement().withBackground(0x88_000000)
.flatBorder(new Color(0x01_000000))

View file

@ -1,20 +0,0 @@
package com.simibubi.create.foundation.gui;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.CreateClient;
import net.minecraft.client.gui.GuiComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IScreenRenderable {
@OnlyIn(Dist.CLIENT)
void draw(PoseStack ms, GuiComponent screen, int x, int y);
@OnlyIn(Dist.CLIENT)
default void draw(PoseStack ms, int x, int y) {
draw(ms, CreateClient.EMPTY_SCREEN, x, y);
}
}

View file

@ -15,25 +15,25 @@ import com.simibubi.create.foundation.utility.Couple;
public class Theme {
private static final List<Theme> themes = new ArrayList<>();
private static final Theme base = addTheme(new Theme());
private static final List<Theme> THEMES = new ArrayList<>();
private static final Theme BASE = addTheme(new Theme());
public static Theme addTheme(@Nonnull Theme theme) {
themes.add(theme);
themes.sort(Comparator.comparingInt(Theme::getPriority).reversed());
THEMES.add(theme);
THEMES.sort(Comparator.comparingInt(Theme::getPriority).reversed());
return theme;
}
public static void removeTheme(Theme theme) {
themes.remove(theme);
THEMES.remove(theme);
}
public static void reload() {
themes.forEach(Theme::init);
THEMES.forEach(Theme::init);
}
private static ColorHolder resolve(String key) {
return themes
return THEMES
.stream()
.map(theme -> theme.get(key))
.filter(Objects::nonNull)

View file

@ -0,0 +1,7 @@
package com.simibubi.create.foundation.gui;
import net.minecraft.client.gui.components.events.GuiEventListener;
public interface TickableGuiEventListener extends GuiEventListener {
void tick();
}

Some files were not shown because too many files have changed in this diff Show more