Skip to content

Commit

Permalink
fancy crafter BER
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabeHunger54 committed Dec 23, 2024
1 parent 90a5078 commit 1d2373e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.minecraftschurlimods.bibliocraft.client.ber.DiscRackBER;
import com.github.minecraftschurlimods.bibliocraft.client.ber.DisplayCaseBER;
import com.github.minecraftschurlimods.bibliocraft.client.ber.FancyArmorStandBER;
import com.github.minecraftschurlimods.bibliocraft.client.ber.FancyCrafterBER;
import com.github.minecraftschurlimods.bibliocraft.client.ber.LabelBER;
import com.github.minecraftschurlimods.bibliocraft.client.ber.PotionShelfBER;
import com.github.minecraftschurlimods.bibliocraft.client.ber.ShelfBER;
Expand Down Expand Up @@ -88,6 +89,7 @@ private static void registerRenderers(EntityRenderersEvent.RegisterRenderers eve
event.registerBlockEntityRenderer(BCBlockEntities.DISPLAY_CASE.get(), $ -> new DisplayCaseBER());
event.registerBlockEntityRenderer(BCBlockEntities.DISC_RACK.get(), $ -> new DiscRackBER());
event.registerBlockEntityRenderer(BCBlockEntities.FANCY_ARMOR_STAND.get(), $ -> new FancyArmorStandBER());
event.registerBlockEntityRenderer(BCBlockEntities.FANCY_CRAFTER.get(), $ -> new FancyCrafterBER());
event.registerBlockEntityRenderer(BCBlockEntities.LABEL.get(), $ -> new LabelBER());
event.registerBlockEntityRenderer(BCBlockEntities.POTION_SHELF.get(), $ -> new PotionShelfBER());
event.registerBlockEntityRenderer(BCBlockEntities.SHELF.get(), $ -> new ShelfBER());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.github.minecraftschurlimods.bibliocraft.client.ber;

import com.github.minecraftschurlimods.bibliocraft.content.fancycrafter.FancyCrafterBlock;
import com.github.minecraftschurlimods.bibliocraft.content.fancycrafter.FancyCrafterBlockEntity;
import com.github.minecraftschurlimods.bibliocraft.util.ClientUtil;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;

import java.util.Objects;

public class FancyCrafterBER implements BlockEntityRenderer<FancyCrafterBlockEntity> {
@Override
public void render(FancyCrafterBlockEntity blockEntity, float partialTick, PoseStack stack, MultiBufferSource buffer, int light, int overlay) {
Level level = Objects.requireNonNull(blockEntity.getLevel());
BlockPos pos = blockEntity.getBlockPos();
Direction direction = blockEntity.getBlockState().getValue(FancyCrafterBlock.FACING);
stack.pushPose();
ClientUtil.setupCenteredBER(stack, blockEntity);
if (!level.getBlockState(pos.above()).isSolidRender(level, pos.above())) {
stack.pushPose();
stack.translate(-0.1875f, 0.5, -0.1875f);
stack.mulPose(Axis.XP.rotationDegrees(90));
stack.mulPose(Axis.ZP.rotationDegrees(180));
stack.scale(0.1875f, 0.1875f, 0.1875f);
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
stack.pushPose();
stack.translate(-x, -y, 0);
ClientUtil.renderFixedItem(blockEntity.getItem(y * 3 + x), stack, buffer, light, overlay);
stack.popPose();
}
}
stack.popPose();
}
if (!level.getBlockState(pos.offset(direction.getNormal())).isSolidRender(level, pos.offset(direction.getNormal()))) {
stack.pushPose();
stack.translate(-0.28125f, 0.03125, 0.25f);
stack.mulPose(Axis.YP.rotationDegrees(180));
stack.scale(0.1875f, 0.1875f, 0.1875f);
for (int y = 0; y < 2; y++) {
for (int x = 0; x < 4; x++) {
stack.pushPose();
stack.translate(-x, -y, 0);
ClientUtil.renderFixedItem(blockEntity.getItem(y * 2 + x + 10), stack, buffer, light, overlay);
stack.popPose();
}
}
stack.popPose();
}
stack.popPose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ private void calculateRecipe() {
RecipeManager recipes = Objects.requireNonNull(level).getRecipeManager();
CraftingInput input = CraftingInput.of(3, 3, getInputs());
recipe = recipes.getRecipeFor(RecipeType.CRAFTING, input, level).orElse(null);
if (recipe != null) {
items.setStackInSlot(9, recipe.value().getResultItem(level.registryAccess()).copy());
}
items.setStackInSlot(9, recipe == null ? ItemStack.EMPTY : recipe.value().getResultItem(level.registryAccess()).copy());
}

private ItemStack tryDispense(Level level, BlockPos pos, ItemStack stack, BlockState state) {
Expand Down

0 comments on commit 1d2373e

Please sign in to comment.