generated from neoforged/MDK
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
books render! they don't rotate yet tho
- Loading branch information
1 parent
4452ff2
commit b221b27
Showing
6 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/BookcaseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.github.minecraftschurlimods.bibliocraft.client.model; | ||
|
||
import com.github.minecraftschurlimods.bibliocraft.Bibliocraft; | ||
import com.github.minecraftschurlimods.bibliocraft.block.bookcase.BookcaseBlockEntity; | ||
import net.minecraft.Util; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.renderer.block.model.BakedQuad; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.client.resources.model.ModelManager; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.neoforged.neoforge.client.model.BakedModelWrapper; | ||
import net.neoforged.neoforge.client.model.data.ModelData; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BookcaseModel extends BakedModelWrapper<BakedModel> { | ||
private static final List<ResourceLocation> BOOKS = Util.make(new ArrayList<>(), list -> { | ||
for (int i = 0; i < BookcaseBlockEntity.MODEL_PROPERTIES.size(); i++) { | ||
list.add(new ResourceLocation(Bibliocraft.MOD_ID, "block/bookcase/book_" + i)); | ||
} | ||
}); | ||
|
||
public BookcaseModel(BakedModel originalModel) { | ||
super(originalModel); | ||
} | ||
|
||
@SuppressWarnings("DataFlowIssue") | ||
@Override | ||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData extraData, @Nullable RenderType renderType) { | ||
List<BakedQuad> list = new ArrayList<>(super.getQuads(state, side, rand, extraData, renderType)); | ||
ModelManager models = Minecraft.getInstance().getModelManager(); | ||
for (int i = 0; i < BookcaseBlockEntity.MODEL_PROPERTIES.size(); i++) { | ||
if (extraData.has(BookcaseBlockEntity.MODEL_PROPERTIES.get(i)) && extraData.get(BookcaseBlockEntity.MODEL_PROPERTIES.get(i))) { | ||
list.addAll(models.getModel(BOOKS.get(i)).getQuads(state, side, rand, ModelData.EMPTY, renderType)); | ||
} | ||
} | ||
return list; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/github/minecraftschurlimods/bibliocraft/client/model/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
package com.github.minecraftschurlimods.bibliocraft.client.model; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |