From 3f33987ff1a14ef4450b22f3b7d49af464dcf4bd Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:08:07 -0500 Subject: [PATCH 1/2] Use blockstate type in TableModel instead of model property --- .../bibliocraft/client/model/TableModel.java | 6 ++++-- .../bibliocraft/content/table/TableBlockEntity.java | 9 --------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java b/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java index 763d191a..550cbedf 100644 --- a/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java +++ b/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java @@ -1,7 +1,6 @@ package com.github.minecraftschurlimods.bibliocraft.client.model; import com.github.minecraftschurlimods.bibliocraft.content.table.TableBlock; -import com.github.minecraftschurlimods.bibliocraft.content.table.TableBlockEntity; import com.github.minecraftschurlimods.bibliocraft.util.BCUtil; import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.PoseStack; @@ -54,7 +53,10 @@ public TableModel(boolean useAmbientOcclusion, boolean isGui3d, boolean usesBloc @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData extraData, @Nullable RenderType renderType) { - TableBlock.Type type = extraData.get(TableBlockEntity.TYPE_PROPERTY); + TableBlock.Type type = TableBlock.Type.NONE; + if (state != null && state.hasProperty(TableBlock.TYPE)) { + type = state.getValue(TableBlock.TYPE); + } return new ArrayList<>(baseMap.get(type).getQuads(state, side, rand, extraData, renderType)); } diff --git a/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/table/TableBlockEntity.java b/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/table/TableBlockEntity.java index 457977d6..00c67e5c 100644 --- a/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/table/TableBlockEntity.java +++ b/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/table/TableBlockEntity.java @@ -10,14 +10,10 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.neoforge.client.model.data.ModelData; -import net.neoforged.neoforge.client.model.data.ModelProperty; import java.util.Objects; public class TableBlockEntity extends BCBlockEntity { - public static final ModelProperty TYPE_PROPERTY = new ModelProperty<>(); - public TableBlockEntity(BlockPos pos, BlockState state) { super(BCBlockEntities.TABLE.get(), 2, pos, state); } @@ -42,9 +38,4 @@ public void setItem(int slot, ItemStack stack) { requestModelDataUpdate(); } } - - @Override - public ModelData getModelData() { - return ModelData.builder().with(TYPE_PROPERTY, getBlockState().getValue(TableBlock.TYPE)).build(); - } } From 0b5b6ecdb160969b37bfc6296c141f15bbde5dd6 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:09:18 -0500 Subject: [PATCH 2/2] Avoid extra list allocation in TableModel#getQuads --- .../bibliocraft/client/model/TableModel.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java b/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java index 550cbedf..f5ddac08 100644 --- a/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java +++ b/src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/TableModel.java @@ -30,7 +30,6 @@ import net.neoforged.neoforge.common.data.ExistingFileHelper; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -57,7 +56,7 @@ public List getQuads(@Nullable BlockState state, @Nullable Direction if (state != null && state.hasProperty(TableBlock.TYPE)) { type = state.getValue(TableBlock.TYPE); } - return new ArrayList<>(baseMap.get(type).getQuads(state, side, rand, extraData, renderType)); + return baseMap.get(type).getQuads(state, side, rand, extraData, renderType); } @Override