Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.recipe.modifier.RecipeModifier;
import com.gregtechceu.gtceu.client.model.machine.MachineRenderState;

import com.lowdragmc.lowdraglib.utils.ShapeUtils;
import com.gregtechceu.gtceu.utils.GTUtil;

import net.minecraft.core.Direction;
import net.minecraft.core.IdMapper;
Expand Down Expand Up @@ -173,7 +172,7 @@ public ItemStack asStack(int count) {

public VoxelShape getShape(Direction direction) {
if (shape.isEmpty() || shape == Shapes.block() || direction == Direction.NORTH) return shape;
return this.cache.computeIfAbsent(direction, dir -> ShapeUtils.rotate(shape, dir));
return this.cache.computeIfAbsent(direction, dir -> GTUtil.rotateVoxelShape(shape, dir));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,43 @@
import com.gregtechceu.gtceu.api.data.RotationState;

import com.lowdragmc.lowdraglib.utils.BlockInfo;
import com.lowdragmc.lowdraglib.utils.Builder;

import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

import lombok.Getter;

import java.util.*;
import java.util.function.Supplier;

public class MultiblockShapeInfo {

@Getter
private final BlockInfo[][][] blocks; // [z][y][x]

public MultiblockShapeInfo(BlockInfo[][][] blocks) {
this.blocks = blocks;
}

public BlockInfo[][][] getBlocks() {
return blocks;
}

public static ShapeInfoBuilder builder() {
return new ShapeInfoBuilder();
}

public static class ShapeInfoBuilder extends Builder<BlockInfo, ShapeInfoBuilder> {
public static class ShapeInfoBuilder {

protected List<String[]> shape = new ArrayList<>();
protected Map<Character, BlockInfo> symbolMap = new LinkedHashMap<>();

public ShapeInfoBuilder aisle(String... data) {
this.shape.add(data);
return this;
}

public ShapeInfoBuilder where(char symbol, BlockInfo value) {
this.symbolMap.put(symbol, value);
return this;
}

public ShapeInfoBuilder where(char symbol, BlockState blockState) {
return where(symbol, BlockInfo.fromBlockState(blockState));
Expand All @@ -53,11 +65,29 @@ public ShapeInfoBuilder where(char symbol, MetaMachineBlock machine, Direction f
}

private BlockInfo[][][] bake() {
return this.bakeArray(BlockInfo.class, BlockInfo.EMPTY);
BlockInfo[][][] Ts = new BlockInfo[shape.get(0)[0].length()][shape.get(0).length][shape.size()];
for (int z = 0; z < shape.size(); z++) { // z
String[] aisleEntry = shape.get(z);
for (int y = 0; y < shape.get(0).length; y++) {
String columnEntry = aisleEntry[y];
for (int x = 0; x < columnEntry.length(); x++) {
BlockInfo info = symbolMap.getOrDefault(columnEntry.charAt(x), BlockInfo.EMPTY);
Ts[x][y][z] = info;
}
}
}
return Ts;
}

public MultiblockShapeInfo build() {
return new MultiblockShapeInfo(bake());
}

public ShapeInfoBuilder shallowCopy() {
ShapeInfoBuilder builder = new ShapeInfoBuilder();
builder.shape = new ArrayList<>(this.shape);
builder.symbolMap = new HashMap<>(this.symbolMap);
return builder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.gregtechceu.gtceu.utils.ItemStackHashStrategy;

import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -487,15 +486,6 @@ protected boolean createManualIOModeRow() {
return true;
}

@NotNull
protected String getUITitle() {
return "cover.conveyor.title";
}

protected void buildAdditionalUI(WidgetGroup group) {
// Do nothing in the base implementation. This is intended to be overridden by subclasses.
}

protected void configureFilter() {
// Do nothing in the base implementation. This is intended to be overridden by subclasses.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.gregtechceu.gtceu.api.cover.CoverDefinition;
import com.gregtechceu.gtceu.api.cover.filter.ItemFilter;
import com.gregtechceu.gtceu.api.cover.filter.SimpleItemFilter;
import com.gregtechceu.gtceu.api.gui.widget.EnumSelectorWidget;
import com.gregtechceu.gtceu.api.gui.widget.IntInputWidget;
import com.gregtechceu.gtceu.api.mui.base.drawable.IKey;
import com.gregtechceu.gtceu.api.mui.factory.SidedPosGuiData;
Expand All @@ -21,8 +20,6 @@
import com.gregtechceu.gtceu.common.mui.GTGuiTextures;
import com.gregtechceu.gtceu.common.pipelike.item.ItemNetHandler;

import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -33,7 +30,6 @@

import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;

import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -167,13 +163,6 @@ public void clearBuffer() {

//////////////////////////////////////
// *********** GUI ***********//
//////////////////////////////////////

@Override
@NotNull
protected String getUITitle() {
return "cover.robotic_arm.title";
}

@Override
public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManager syncManager,
Expand All @@ -196,18 +185,6 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage
.setEnabledIf($ -> shouldShowStackSize()));
}

@Override
protected void buildAdditionalUI(WidgetGroup group) {
group.addWidget(
new EnumSelectorWidget<>(146, 45, 20, 20, TransferMode.values(), transferMode, this::setTransferMode));

this.stackSizeInput = new IntInputWidget(64, 45, 80, 20,
() -> globalTransferLimit, val -> globalTransferLimit = val);
configureStackSizeInput();

group.addWidget(this.stackSizeInput);
}

public void setTransferMode(TransferMode transferMode) {
this.transferMode = transferMode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.gregtechceu.gtceu.api.cover.CoverDefinition;
import com.gregtechceu.gtceu.api.cover.filter.ItemFilter;
import com.gregtechceu.gtceu.api.cover.filter.SimpleItemFilter;
import com.gregtechceu.gtceu.api.gui.widget.EnumSelectorWidget;
import com.gregtechceu.gtceu.api.gui.widget.IntInputWidget;
import com.gregtechceu.gtceu.api.mui.base.drawable.IKey;
import com.gregtechceu.gtceu.api.mui.factory.SidedPosGuiData;
Expand All @@ -20,8 +19,6 @@
import com.gregtechceu.gtceu.common.mui.GTGuiTextures;
import com.gregtechceu.gtceu.utils.GTUtil;

import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -32,7 +29,6 @@

import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

Expand Down Expand Up @@ -147,23 +143,6 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage
.setEnabledIf($ -> shouldShowStackSize()));
}

@Override
protected @NotNull String getUITitle() {
return "cover.item.voiding.advanced.title";
}

@Override
protected void buildAdditionalUI(WidgetGroup group) {
group.addWidget(
new EnumSelectorWidget<>(146, 20, 20, 20, VoidingMode.values(), voidingMode, this::setVoidingMode));

this.stackSizeInput = new IntInputWidget(64, 20, 80, 20,
() -> globalVoidingLimit, val -> globalVoidingLimit = val);
configureStackSizeInput();

group.addWidget(this.stackSizeInput);
}

@Override
protected void configureFilter() {
if (filterHandler.getFilter() instanceof SimpleItemFilter filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.items.IItemHandler;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Set;
Expand Down Expand Up @@ -94,11 +93,6 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage
settings));
}

@NotNull
protected String getUITitle() {
return "cover.item.voiding.title";
}

@Override
public InteractionResult onSoftMalletClick(Player playerIn, InteractionHand hand, BlockHitResult hitResult) {
if (!isRemote()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import com.gregtechceu.gtceu.common.data.GTItems;
import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets;

import com.lowdragmc.lowdraglib.gui.factory.HeldItemUIFactory;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -62,23 +59,6 @@ public static boolean isIntegratedCircuit(ItemStack itemStack) {
return isCircuit;
}

// deprecated, not needed (for now)
@Deprecated
public static void adjustConfiguration(HeldItemUIFactory.HeldItemHolder holder, int amount) {
adjustConfiguration(holder.getHeld(), amount);
holder.markAsDirty();
}

// deprecated, not needed (for now)
@Deprecated
public static void adjustConfiguration(ItemStack stack, int amount) {
if (!isIntegratedCircuit(stack)) return;
int configuration = getCircuitConfiguration(stack);
configuration += amount;
configuration = Mth.clamp(configuration, 0, CIRCUIT_MAX);
setCircuitConfiguration(stack, configuration);
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltipComponents,
TooltipFlag isAdvanced) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.gregtechceu.gtceu.utils.GTUtil;

import com.lowdragmc.lowdraglib.gui.widget.*;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;

// TODO figure out how this should work with mui
public class PrimitiveFancyUIWorkableMachine extends PrimitiveWorkableMachine implements IFancyUIMachine {

public PrimitiveFancyUIWorkableMachine(BlockEntityCreationInfo info) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField;
import com.gregtechceu.gtceu.utils.GTUtil;

import com.lowdragmc.lowdraglib.gui.widget.*;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.recipe.ShapedEnergyTransferRecipe;

import com.lowdragmc.lowdraglib.utils.Builder;
import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter;

import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -22,17 +21,21 @@
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.function.Consumer;

public class ShapedEnergyTransferRecipeBuilder extends Builder<Ingredient, ShapedEnergyTransferRecipeBuilder> {
public class ShapedEnergyTransferRecipeBuilder {

protected ItemStack output = ItemStack.EMPTY;
protected Ingredient chargeIngredient = Ingredient.EMPTY;
protected ResourceLocation id;
protected String group;
protected @Nullable ResourceLocation id;
protected @Nullable String group;
protected boolean transferMaxCharge;
protected boolean overrideCharge;

protected List<String[]> shape = new ArrayList<>();
protected Map<Character, Ingredient> ingredientMap = new LinkedHashMap<>();

public ShapedEnergyTransferRecipeBuilder(@Nullable ResourceLocation id) {
this.id = id;
}
Expand All @@ -41,6 +44,16 @@ public ShapedEnergyTransferRecipeBuilder() {
this(null);
}

public ShapedEnergyTransferRecipeBuilder aisle(String... data) {
this.shape.add(data);
return this;
}

public ShapedEnergyTransferRecipeBuilder where(char symbol, Ingredient value) {
this.ingredientMap.put(symbol, value);
return this;
}

public ShapedEnergyTransferRecipeBuilder pattern(String slice) {
return aisle(slice);
}
Expand Down Expand Up @@ -109,9 +122,10 @@ public ShapedEnergyTransferRecipeBuilder group(String group) {
return this;
}

@Override
public ShapedEnergyTransferRecipeBuilder shallowCopy() {
var builder = super.shallowCopy();
var builder = new ShapedEnergyTransferRecipeBuilder();
builder.shape = new ArrayList<>(this.shape);
builder.ingredientMap = new HashMap<>(this.ingredientMap);
builder.output = output.copy();
return builder;
}
Expand All @@ -131,9 +145,9 @@ public void toJson(JsonObject json) {
json.add("pattern", pattern);
}

if (!symbolMap.isEmpty()) {
if (!ingredientMap.isEmpty()) {
JsonObject key = new JsonObject();
symbolMap.forEach((k, v) -> key.add(k.toString(), v.toJson()));
ingredientMap.forEach((k, v) -> key.add(k.toString(), v.toJson()));
json.add("key", key);
}

Expand Down
Loading