Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts committed Dec 27, 2024
1 parent 44fd806 commit 94ce8e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
6 changes: 1 addition & 5 deletions src/main/java/blockrenderer6343/client/utils/BRUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public class BRUtil {
public static final AutoPlaceEnvironment AUTO_PLACE_ENVIRONMENT = AutoPlaceEnvironment
.fromLegacy(CreativeItemSource.instance, FAKE_PLAYER, a -> {});

public static AutoPlaceEnvironment getBuildEnvironment() {
return AUTO_PLACE_ENVIRONMENT;
}

public static void projectMultiblock(ItemStack buildStack, ItemStack multiStack, int blocksBelowController) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
World baseWorld = Minecraft.getMinecraft().theWorld;
Expand Down Expand Up @@ -157,7 +153,7 @@ public static List<List<ItemStack>> scanCandidates(Object multi, IStructureEleme
block.y,
block.z,
buildStack,
getBuildEnvironment());
AUTO_PLACE_ENVIRONMENT);
if (blocksToPlace == null) return Collections.emptyList();

Set<ItemStack> rawCandidates = CreativeItemSource.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public List<String> getHoveredTooltip(@NotNull ItemStack stack) {
protected void onPostBlocksRendered(WorldSceneRenderer renderer) {
if (!highlightHatch || hatchGroupPositions.isEmpty()) return;
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_DEPTH_BUFFER_BIT);

GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
Expand Down Expand Up @@ -226,6 +226,7 @@ private void findHints() {
String hint = getFallbackHint(structureElementMap.get(pos));
if (hint.isEmpty()) continue;
hintForDot.put(dot, hint);
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package blockrenderer6343.integration.nei;

import static blockrenderer6343.client.utils.BRUtil.AUTO_PLACE_ENVIRONMENT;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
Expand All @@ -15,12 +17,10 @@
import org.jetbrains.annotations.Nullable;

import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.structure.IStructureElementChain;
import com.gtnewhorizon.structurelib.structure.StructureUtility;

import blockrenderer6343.client.utils.BRUtil;
import blockrenderer6343.client.utils.ConstructableData;
import blockrenderer6343.client.world.DummyWorld;
import cpw.mods.fml.relauncher.ReflectionHelper;
Expand All @@ -42,8 +42,7 @@ public class StructureHacks {
StructureUtility.error());

static {
// This is so dumb but all elements are anonymous classes so this is the best way to only check the necessary
// ones
// This is so dumb but all elements are anonymous classes so we have to get the classes through "creative" means
addTieredElement(
StructureUtility.ofBlocksTiered((a, b) -> 0, null, Collections.emptyList(), (c, d) -> {}, e -> -1)
.getClass().getName());
Expand Down Expand Up @@ -94,11 +93,10 @@ public static void addTieredElement(String className) {
return chainStacks;
}

AutoPlaceEnvironment env = BRUtil.getBuildEnvironment();
IStructureElement.BlocksToPlace blocks = element
.getBlocksToPlace(multi, DummyWorld.INSTANCE, 0, 0, 0, HOLO_STACK, env);
.getBlocksToPlace(multi, DummyWorld.INSTANCE, 0, 0, 0, HOLO_STACK, AUTO_PLACE_ENVIRONMENT);
if (TIERED_ELEMENTS.contains(name)) {
return extractTieredBlocks(multi, element, data, env, getChannel(name, element));
return extractTieredBlocks(multi, element, data, getChannel(name, element));
}

if (blocks == null) return Collections.emptyList();
Expand All @@ -107,15 +105,15 @@ public static void addTieredElement(String className) {
}

private static <T> ObjectSet<ItemStack> extractTieredBlocks(T multi, IStructureElement<T> element,
ConstructableData data, AutoPlaceEnvironment env, String channel) {
ConstructableData data, String channel) {
ObjectSet<ItemStack> result = new ObjectOpenHashSet<>();
ItemStack holo = HOLO_STACK.copy();
int tier = 0;

do {
holo.stackSize = tier++ + 1;
IStructureElement.BlocksToPlace toPlace = element
.getBlocksToPlace(multi, DummyWorld.INSTANCE, 0, 0, 0, holo, env);
.getBlocksToPlace(multi, DummyWorld.INSTANCE, 0, 0, 0, holo, AUTO_PLACE_ENVIRONMENT);
if (toPlace == null || toPlace.getStacks() == null) break;
Iterator<ItemStack> iterator = toPlace.getStacks().iterator();
if (!iterator.hasNext()) break;
Expand Down

0 comments on commit 94ce8e2

Please sign in to comment.