Skip to content

Commit

Permalink
bump up ldlib (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yefancy authored Nov 21, 2023
1 parent e538e6d commit 3a37577
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Version: 1.0.16
* fix ore processing diagram
* fix GT tools not doing the tooltype-specific things like making paths
* fix small distillery recipes
* fix High Power Casing recipe
* fix High Power Casing recipe
* always enable VBO cache for multis previews + add config option to disable it
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.gregtechceu.gtceu.api.gui.compass;

import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController;
import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.lowdragmc.lowdraglib.gui.compass.component.animation.Action;
import com.lowdragmc.lowdraglib.gui.compass.component.animation.AnimationFrame;
import com.lowdragmc.lowdraglib.gui.compass.component.animation.BlockAnima;
import com.lowdragmc.lowdraglib.gui.compass.component.animation.CompassScene;
import com.lowdragmc.lowdraglib.utils.BlockInfo;
import com.lowdragmc.lowdraglib.utils.XmlUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.w3c.dom.Element;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;

public class MultiblockAction extends Action {
private final BlockAnima animation;
@Nullable
private final MultiblockMachineDefinition machineDefinition;
private final int shapeIndex;
private final boolean isFormed;
private final Direction facing;

public MultiblockAction(Element element) {
var machineName = XmlUtils.getAsString(element, "machine", "");
var blockPos = XmlUtils.getAsBlockPos(element, "pos", BlockPos.ZERO);
shapeIndex = XmlUtils.getAsInt(element, "shape-index", 0);
facing = XmlUtils.getAsEnum(element, "facing", Direction.class, Direction.NORTH);
isFormed = XmlUtils.getAsBoolean(element, "formed", true);
animation = new BlockAnima(blockPos, XmlUtils.getAsVec3(element, "offset", new Vec3(0, 0.7, 0)), XmlUtils.getAsInt(element, "duration", 15));
if (ResourceLocation.isValidResourceLocation(machineName)) {
var definition = GTRegistries.MACHINES.get(new ResourceLocation(machineName));
if (definition instanceof MultiblockMachineDefinition multiblockDefinition) {
machineDefinition = multiblockDefinition;
return;
}
}
machineDefinition = null;
}

@Override
public int getDuration() {
return machineDefinition == null ? 5 : animation.duration() + 5;
}

@Override
public void performAction(AnimationFrame frame, CompassScene scene, boolean anima) {
if (machineDefinition != null) {
var shapes = machineDefinition.getMatchingShapes();
if (!shapes.isEmpty()) {
MultiblockShapeInfo shape = shapes.get(0);
if (shapeIndex < shapes.size()) {
shape = shapes.get(shapeIndex);
}
var blocks = shape.getBlocks();
Map<BlockPos, BlockInfo> blockMap = new HashMap<>();
BlockPos offset = BlockPos.ZERO;
for (int x = 0; x < blocks.length; x++) {
BlockInfo[][] aisle = blocks[x];
for (int y = 0; y < aisle.length; y++) {
BlockInfo[] column = aisle[y];
for (int z = 0; z < column.length; z++) {
BlockState blockState = column[z].getBlockState();
BlockPos pos = animation.pos().offset(x, y, z);
if (column[z].getBlockEntity(pos) instanceof IMachineBlockEntity holder
&& holder.getMetaMachine() instanceof IMultiController) {
offset = pos;
}
blockMap.put(pos, BlockInfo.fromBlockState(blockState));
}
}
}
BlockPos finalOffset = offset;
blockMap.forEach((pos, blockInfo) -> scene.addBlock(pos.subtract(finalOffset).offset(animation.pos()), blockInfo, anima ? animation : null));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo;
import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate;
import com.gregtechceu.gtceu.api.pattern.predicates.SimplePredicate;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.lowdragmc.lowdraglib.LDLib;
import com.lowdragmc.lowdraglib.gui.editor.ColorPattern;
import com.lowdragmc.lowdraglib.gui.texture.*;
Expand Down Expand Up @@ -73,7 +74,7 @@ protected PatternPreviewWidget(MultiblockMachineDefinition controllerDefinition)
.setRenderFacing(false)
.setRenderFacing(false));

if (!GTCEu.isIrisLoaded() && !LDLib.isEmiLoaded()) {
if (ConfigHolder.INSTANCE.client.useVBO) {
if (!RenderSystem.isOnRenderThread()) {
RenderSystem.recordRenderCall(sceneWidget::useCacheBuffer);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.gui.compass.GTCompassUIConfig;
import com.gregtechceu.gtceu.api.gui.compass.GTRecipeViewCreator;
import com.gregtechceu.gtceu.api.gui.compass.MultiblockAction;
import com.lowdragmc.lowdraglib.gui.compass.CompassManager;
import com.lowdragmc.lowdraglib.gui.compass.component.RecipeComponent;
import net.fabricmc.api.EnvType;
Expand All @@ -18,5 +19,6 @@ public class ClientProxy {
public static void init() {
RecipeComponent.registerRecipeViewCreator(new GTRecipeViewCreator());
CompassManager.INSTANCE.registerUIConfig(GTCEu.MOD_ID, new GTCompassUIConfig());
CompassManager.INSTANCE.registerAction("multiblock", MultiblockAction::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ public static class ClientConfigs {
@Configurable.StringPattern(value = "#[0-9a-fA-F]{1,6}")
@Configurable.Gui.ColorValue
public String defaultPaintingColor = "#FFFFFF";
@Configurable
@Configurable.Comment({"Use VBO cache for multiblock preview.", "Disable it if you have issues with rendering multiblocks.", "Default: true"})
@Configurable.Gui.ColorValue
public boolean useVBO = true;
}

public static class DeveloperConfigs {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencyResolutionManagement {
def vineFlowerVersion = "1.+"
def macheteVersion = "1.+"
def configurationVersion = "2.2.0"
def ldLibVersion = "1.0.21.c"
def ldLibVersion = "1.0.21.d"
def mixinextrasVersion = "0.2.0"

fabric {
Expand Down

0 comments on commit 3a37577

Please sign in to comment.