Added a config option to reduce the rendering range of drawers

This commit is contained in:
Buuz135 2022-06-06 16:45:25 +02:00
parent 37deecbbdc
commit 6afd5ee8ba
6 changed files with 24 additions and 1 deletions

View File

@ -12,7 +12,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
group = 'com.buuz135' group = 'com.buuz135'
version = '1.18.2-0.0.15' version = '1.18.2-0.0.16'
java { java {
archivesBaseName = 'functionalstorage' archivesBaseName = 'functionalstorage'

View File

@ -18,6 +18,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.HitResult;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
@ -127,4 +128,5 @@ public class DrawerTile extends ControllableDrawerTile<DrawerTile> {
public BigInventoryHandler getHandler() { public BigInventoryHandler getHandler() {
return handler; return handler;
} }
} }

View File

@ -32,6 +32,9 @@ public class CompactingDrawerRenderer implements BlockEntityRenderer<CompactingD
@Override @Override
public void render(CompactingDrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { public void render(CompactingDrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
if (Minecraft.getInstance().player != null && !tile.getBlockPos().closerThan(Minecraft.getInstance().player.getOnPos(), FunctionalStorageClientConfig.DRAWER_RENDER_RANGE)){
return;
}
matrixStack.pushPose(); matrixStack.pushPose();
Direction facing = tile.getFacingDirection(); Direction facing = tile.getFacingDirection();

View File

@ -47,6 +47,9 @@ public class DrawerRenderer implements BlockEntityRenderer<DrawerTile> {
@Override @Override
public void render(DrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { public void render(DrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
if (Minecraft.getInstance().player != null && !tile.getBlockPos().closerThan(Minecraft.getInstance().player.getOnPos(), FunctionalStorageClientConfig.DRAWER_RENDER_RANGE)){
return;
}
matrixStack.pushPose(); matrixStack.pushPose();
Direction facing = tile.getFacingDirection(); Direction facing = tile.getFacingDirection();

View File

@ -38,6 +38,9 @@ public class EnderDrawerRenderer implements BlockEntityRenderer<EnderDrawerTile>
@Override @Override
public void render(EnderDrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { public void render(EnderDrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
if (Minecraft.getInstance().player != null && !tile.getBlockPos().closerThan(Minecraft.getInstance().player.getOnPos(), FunctionalStorageClientConfig.DRAWER_RENDER_RANGE)){
return;
}
matrixStack.pushPose(); matrixStack.pushPose();
Direction facing = tile.getFacingDirection(); Direction facing = tile.getFacingDirection();

View File

@ -0,0 +1,12 @@
package com.buuz135.functionalstorage.client;
import com.hrznstudio.titanium.annotation.config.ConfigFile;
import com.hrznstudio.titanium.annotation.config.ConfigVal;
@ConfigFile(value = "functionalstorage-client")
public class FunctionalStorageClientConfig {
@ConfigVal(comment = "Drawer content render range in blocks")
@ConfigVal.InRangeInt(min = 1)
public static int DRAWER_RENDER_RANGE = 16;
}