Skip to content

Commit

Permalink
Unmark container on item takeout
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Oct 25, 2022
1 parent e3ac641 commit 2a49248
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.concurrent.LinkedBlockingDeque;

import static org.samo_lego.clientstorage.fabric_client.ClientStorageFabric.config;
import static org.samo_lego.clientstorage.fabric_client.util.ESPRender.BLOCK_ESPS;

/**
* The heart of the mod.
Expand Down Expand Up @@ -152,6 +153,8 @@ public static InteractionResult onUseBlock(Player player, Level world, Interacti

RemoteInventory.getInstance().sort();
}
} else {
BLOCK_ESPS.remove(craftingPos);
}
}
return InteractionResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ public class ESPRender {

public static final Set<BlockPos> BLOCK_ESPS = new HashSet<>();
private static final ModelPart.Cube CUBE = new ModelPart.Cube(0, 0, 0, 0, 0, 16, 16, 16, 0, 0, 0, false, 0, 0);
private static final RenderType RENDER_TYPE = RenderType.outline(new ResourceLocation("minecraft", "textures/particles/white.png"));
private static boolean isAlreadyRenderingOutline = false;
private static final RenderType RENDER_TYPE = RenderType.outline(new ResourceLocation("textures/misc/white.png"));

public static void render(PoseStack matrices, Camera camera, OutlineBufferSource vertexConsumers) {
Vec3 pos = camera.getPosition();
matrices.pushPose();
matrices.translate(-pos.x, -pos.y, -pos.z);
renderBlockOutline(matrices, pos, vertexConsumers);
renderBlockOutlines(matrices, pos, vertexConsumers);
matrices.popPose();
}

public static void renderBlockOutline(PoseStack matrices, Vec3 playerPos, OutlineBufferSource vertexConsumers) {
public static void renderBlockOutlines(PoseStack matrices, Vec3 playerPos, OutlineBufferSource vertexConsumers) {
vertexConsumers.setColor(255, 255, 255, 255);

for (BlockPos pos : BLOCK_ESPS) {
Expand All @@ -60,13 +59,10 @@ public static void onRender(WorldRenderContext context) {
var worldRenderer = (ALevelRenderer) context.worldRenderer();

if (!BLOCK_ESPS.isEmpty()) {
if (!isAlreadyRenderingOutline) {
worldRenderer.getEntityEffect().process(context.tickDelta());
Minecraft.getInstance().getMainRenderTarget().bindWrite(false);
}
worldRenderer.getEntityEffect().process(context.tickDelta());
Minecraft.getInstance().getMainRenderTarget().bindWrite(false);
render(context.matrixStack(), context.camera(), worldRenderer.getRenderBuffers().outlineBufferSource());
}
isAlreadyRenderingOutline = false;
}

public static void markPos(BlockPos blockPos) {
Expand Down

0 comments on commit 2a49248

Please sign in to comment.