Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
id 'fabric-loom' version '1.10-SNAPSHOT' apply(false)
id 'fabric-loom' version '1.11-SNAPSHOT' apply(false)
id 'net.neoforged.moddev' version '2.0.115' apply(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IBlockChain extends IBlockPillar {
*/
static boolean canBeChained(BlockState state, boolean tryConnectUnder) {
Block block = state.getBlock();
if(block == Blocks.CHAIN) {
if(block == Blocks.IRON_CHAIN) {
return state.getValue(RotatedPillarBlock.AXIS) == Direction.Axis.Y;
}
if(block instanceof IBlockChain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public void onProjectileHit(final Level worldIn, final BlockState state, final B
}

@Override
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entityIn, InsideBlockEffectApplier effectApplier) {
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entityIn, InsideBlockEffectApplier effectApplier, boolean intersects) {
if (!entityIn.fireImmune() && state.getValue(FireplaceBlock.LIT) && entityIn instanceof LivingEntity && !(EnchantmentHelper.getEnchantmentLevel(entityIn.level().registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.FROST_WALKER), (LivingEntity) entityIn) > 0)) {
entityIn.hurt(entityIn.damageSources().inFire(), 1.0F);
}
super.entityInside(state, world, pos, entityIn, effectApplier);
super.entityInside(state, world, pos, entityIn, effectApplier, intersects);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt

@Override
public InteractionResult useWithoutItem(BlockState state, Level worldIn, BlockPos pos, Player player, BlockHitResult hit) {
if(!worldIn.isClientSide) {
if(!worldIn.isClientSide()) {
if(player.isCrouching()) {
boolean isTop = state.getValue(HALF) == Half.TOP;
BlockPos otherPos = (isTop) ? pos.relative(state.getValue(FACING)) : pos.relative(state.getValue(FACING).getOpposite());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public InteractionResult useWithoutItem(BlockState state, Level worldIn, BlockPo

@Override
public void onProjectileHit(Level worldIn, BlockState state, BlockHitResult hit, Projectile projectile) {
if(!worldIn.isClientSide && projectile instanceof AbstractArrow) {
if(!worldIn.isClientSide() && projectile instanceof AbstractArrow) {
AbstractArrow abstractarrowentity = (AbstractArrow) projectile;
if(abstractarrowentity.isOnFire() && !state.getValue(LIT) && !state.getValue(WATERLOGGED)) {
BlockPos pos = hit.getBlockPos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public boolean[] getWaterTrickleOutPut(BlockState currentState) {
@Override
public InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos,
Player player, BlockHitResult hit) {
if (world.isClientSide) {
if (world.isClientSide()) {
world.playSound(player, pos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, 0.6F);
world.playSound(player, pos, SoundEvents.WATER_AMBIENT, SoundSource.BLOCKS, 0.3F, 1.0F);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public TeapotSpecialDisplayBlock(Properties properties, VoxelShape[] shapes) {

@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rand) {
if (!level.isClientSide) return;
if (!level.isClientSide()) return;

BlockState state1 = level.getBlockState(pos.below());
if (state1.getBlock() != DoTBBlocksRegistry.INSTANCE.IRORI_FIREPLACE.get()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static BlockState addConnection(BlockState state, Direction face, Vertic
@Override
public InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos,
Player player, BlockHitResult hit) {
if (world.isClientSide) {
if (world.isClientSide()) {
world.playSound(player, pos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, 0.6F);
world.playSound(player, pos, SoundEvents.WATER_AMBIENT, SoundSource.BLOCKS, 0.3F, 1.0F);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public enum CreativeInventoryCategories {
DoTBBlocksRegistry.INSTANCE.OCHRE_ROOF_TILES_WALL.get().asItem(),
DoTBBlocksRegistry.INSTANCE.TERRACOTTA_WALL.get().asItem(),
Blocks.BIRCH_LEAVES.asItem(),
Blocks.CHAIN.asItem(),
Blocks.IRON_CHAIN.asItem(),
DoTBBlocksRegistry.INSTANCE.IRON_FANCY_LANTERN.get().asItem(),
Blocks.LANTERN.asItem(),
DoTBItemsRegistry.INSTANCE.UNFIRED_CLAY_TILE.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,112 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.world.item.*;
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
import net.minecraft.client.renderer.item.ItemModelResolver;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.dawnoftime.dawnoftime.block.IBlockSpecialDisplay;
import org.dawnoftime.dawnoftime.block.templates.DisplayerBlock;
import org.dawnoftime.dawnoftime.blockentity.DisplayerBlockEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class DisplayerBERenderer implements BlockEntityRenderer<DisplayerBlockEntity> {
public DisplayerBERenderer(BlockEntityRendererProvider.Context context) {
public class DisplayerBERenderer implements BlockEntityRenderer<DisplayerBlockEntity, DisplayerRenderState> {
private final ItemModelResolver itemModelResolver;

}
public DisplayerBERenderer(BlockEntityRendererProvider.Context context) {
this.itemModelResolver = context.itemModelResolver();
}

@Override
public void render(DisplayerBlockEntity blockEntity, float pPartialTick, @NotNull PoseStack stack, @NotNull MultiBufferSource buffer, int light, int overlay, Vec3 vec3) {
BlockState state = blockEntity.getBlockState();
Level level = blockEntity.getLevel();
DisplayerBlock block = (DisplayerBlock) state.getBlock();
double xStart = block.getDisplayerX(state);
double yStart = block.getDisplayerY(state);
double zStart = block.getDisplayerZ(state);
@Override
public void extractRenderState(DisplayerBlockEntity blockEntity, DisplayerRenderState state, float partialTick, Vec3 cameraPos, @Nullable ModelFeatureRenderer.CrumblingOverlay crumblingOverlay) {
BlockEntityRenderer.super.extractRenderState(blockEntity, state, partialTick, cameraPos, crumblingOverlay);
state.items.clear();
final Level level = blockEntity.getLevel();
final int seedBase = (int) blockEntity.getBlockPos().asLong();

ItemStack itemStack;
float rotationAngle;
// Pré-resolve os modelos dos 9 slots
for (int i = 0; i < 9; i++) {
ItemStack stack = blockEntity.getItem(i);
ItemStackRenderState itemState = new ItemStackRenderState();
this.itemModelResolver.updateForTopItem(
itemState,
stack,
ItemDisplayContext.FIXED,
level,
null,
seedBase + i
);
state.items.add(itemState);
}
}

int j = (int) blockEntity.getBlockPos().asLong();
@Override
public void submit(DisplayerRenderState renderState, @NotNull PoseStack stack, @NotNull SubmitNodeCollector nodeCollector, @NotNull CameraRenderState cameraRenderState) {
BlockState state = renderState.blockState;
Level level = Minecraft.getInstance().level;
if (level == null) return;
DisplayerBlock block = (DisplayerBlock) state.getBlock();
double xStart = block.getDisplayerX(state);
double yStart = block.getDisplayerY(state);
double zStart = block.getDisplayerZ(state);

for(int i = 0; i < 9; i++) {
//After checking if the capability is there and set all the variables, we render each of the non-empty itemStack
itemStack = blockEntity.getItem(i);
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
float rotationAngle;

if (!itemStack.isEmpty()) {
stack.pushPose();
stack.translate(xStart, yStart, zStart);
stack.translate((0.5D - xStart) * (i % 3), 0.015D, (0.5D - zStart) * Math.floor((double) i / 3));
if (i == 0 || i == 8) rotationAngle = 20.0F;
else if (i == 2 || i == 6) rotationAngle = -20.0F;
else rotationAngle = 0.0F;
Item item = itemStack.getItem();
if (item instanceof BlockItem) {
stack.mulPose(Axis.YP.rotationDegrees(rotationAngle));
Block blockFromItem = ((BlockItem) item).getBlock();
if (blockFromItem instanceof IBlockSpecialDisplay) {
float scale = ((IBlockSpecialDisplay) blockFromItem).getDisplayScale();
stack.scale(scale, scale, scale);
stack.translate(0.0F, 0.485F, 0.0F);
} else {
stack.scale(0.2F, 0.2F, 0.2F);
stack.translate(0.0F, 0.45F, 0.0F);
}
itemRenderer.renderStatic(itemStack, ItemDisplayContext.NONE, light, overlay, stack, buffer, level, i + j);
} else {
stack.scale(0.3F, 0.3F, 0.3F);
stack.mulPose(Axis.YP.rotationDegrees(rotationAngle + 90.0F));
stack.mulPose(Axis.XN.rotationDegrees(90.0F));
itemRenderer.renderStatic(itemStack, ItemDisplayContext.FIXED, light, overlay, stack, buffer, level, i + j);
}
stack.popPose();
}
}
}
}
for (int i = 0; i < 9; i++) {
BlockEntity be = level.getBlockEntity(renderState.blockPos);
if (!(be instanceof DisplayerBlockEntity displayerBlockEntity)) return;

ItemStack itemStack = displayerBlockEntity.getItem(i);
ItemStackRenderState itemStackRenderState = (i < renderState.items.size()) ? renderState.items.get(i) : null;

if (itemStackRenderState == null || itemStackRenderState.isEmpty()) continue;

stack.pushPose();
stack.translate(xStart, yStart, zStart);
stack.translate((0.5D - xStart) * (i % 3), 0.015D, (0.5D - zStart) * Math.floor((double) i / 3));
if (i == 0 || i == 8) rotationAngle = 20.0F;
else if (i == 2 || i == 6) rotationAngle = -20.0F;
else rotationAngle = 0.0F;

Item item = itemStack.getItem();
if (item instanceof BlockItem) {
stack.mulPose(Axis.YP.rotationDegrees(rotationAngle));
Block blockFromItem = ((BlockItem) item).getBlock();
if (blockFromItem instanceof IBlockSpecialDisplay special) {
float scale = special.getDisplayScale();
stack.scale(scale, scale, scale);
stack.translate(0.0F, 0.485F, 0.0F);
} else {
stack.scale(0.2F, 0.2F, 0.2F);
stack.translate(0.0F, 0.45F, 0.0F);
}
itemStackRenderState.submit(stack, nodeCollector, renderState.lightCoords, OverlayTexture.NO_OVERLAY, 0);
} else {
stack.scale(0.3F, 0.3F, 0.3F);
stack.mulPose(Axis.YP.rotationDegrees(rotationAngle + 90.0F));
stack.mulPose(Axis.XN.rotationDegrees(90.0F));
itemStackRenderState.submit(stack, nodeCollector, renderState.lightCoords, OverlayTexture.NO_OVERLAY, 0);
}
stack.popPose();
}
}

@Override
public @NotNull DisplayerRenderState createRenderState() {
return new DisplayerRenderState();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.dawnoftime.dawnoftime.client.renderer.blockentity;

import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
import net.minecraft.client.renderer.item.ItemStackRenderState;

import java.util.ArrayList;
import java.util.List;

public class DisplayerRenderState extends BlockEntityRenderState {
public final List<ItemStackRenderState> items = new ArrayList<>(9);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static InteractionResult createEntity(final Level level, final BlockPos p
if(seats.isEmpty()) {
final ChairEntity seat = new ChairEntity(level, pos, direction, pixelsXOffset, pixelsYOffset, pixelsZOffset);
level.addFreshEntity(seat);
if(player.startRiding(seat, false)) {
if(player.startRiding(seat, false, true)) {
return InteractionResult.SUCCESS;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ public abstract class DoTBBlocksRegistry {
// public Supplier<Block> WAXED_OAK_CANOPY_BED_WOOD;
public final Supplier<Block> STONE_BRICKS_POOL = register("stone_bricks_pool", () -> new PoolBlock(Block.Properties.ofFullCopy(Blocks.STONE).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_bricks_pool"))), 16, 14, POOL_SHAPES), false, Utils.TOOLTIP_ADD_COLUMN);
public final Supplier<Block> STONE_BRICKS_SMALL_POOL = register("stone_bricks_small_pool", () -> new SmallPoolBlock(Block.Properties.ofFullCopy(Blocks.STONE).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_bricks_small_pool")))));
public final Supplier<Block> STONE_BRICKS_FAUCET = register("stone_bricks_faucet", () -> new FaucetBlock(Block.Properties.ofFullCopy(Blocks.STONE).noOcclusion().noCollission().randomTicks().setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_bricks_faucet")))));
public final Supplier<Block> STONE_BRICKS_WATER_JET = register("stone_bricks_water_jet", () -> new WaterJetBlock(Block.Properties.ofFullCopy(Blocks.STONE).noOcclusion().noCollission().setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_bricks_water_jet")))));
public final Supplier<Block> STONE_BRICKS_FAUCET = register("stone_bricks_faucet", () -> new FaucetBlock(Block.Properties.ofFullCopy(Blocks.STONE).noOcclusion().noCollision().randomTicks().setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_bricks_faucet")))));
public final Supplier<Block> STONE_BRICKS_WATER_JET = register("stone_bricks_water_jet", () -> new WaterJetBlock(Block.Properties.ofFullCopy(Blocks.STONE).noOcclusion().noCollision().setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_bricks_water_jet")))));

// Japanese
public final Supplier<Block> CHARRED_SPRUCE_PLANKS = register("charred_spruce_planks", () -> new BlockDoT(Block.Properties.ofFullCopy(Blocks.OAK_WOOD).mapColor(MapColor.COLOR_BLACK).strength(2.0F, 6.0F).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "charred_spruce_planks")))).setBurnable(2, 3), BlockTags.MINEABLE_WITH_AXE);
Expand Down Expand Up @@ -294,7 +294,7 @@ public abstract class DoTBBlocksRegistry {
public final Supplier<Block> PAPER_WALL_WINDOWS = register("paper_wall_window", () -> new PillarPaneBlock(Block.Properties.ofFullCopy(Blocks.WHITE_WOOL).strength(1.5F, 1.5F).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "paper_wall_window")))), BlockTags.MINEABLE_WITH_AXE);
public final Supplier<Block> PAPER_WALL_FLOWERY = register("paper_wall_flowery", () -> new PillarPaneBlock(Block.Properties.ofFullCopy(Blocks.WHITE_WOOL).strength(1.5F, 1.5F).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "paper_wall_flowery")))), BlockTags.MINEABLE_WITH_AXE);
public final Supplier<Block> PAPER_FOLDING_SCREEN = register("paper_folding_screen", () -> new FoldingScreenBlock(Block.Properties.ofFullCopy(Blocks.WHITE_WOOL).strength(1.5F, 1.5F).noOcclusion().setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "paper_folding_screen"))), FULL_SHAPE), BlockTags.MINEABLE_WITH_AXE);
public final Supplier<Block> RED_PAPER_LANTERN = register("red_paper_lantern", () -> new PaperLanternBlock(Block.Properties.ofFullCopy(Blocks.RED_WOOL).noOcclusion().noCollission().lightLevel(state -> 12).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "red_paper_lantern")))), BlockTags.MINEABLE_WITH_AXE);
public final Supplier<Block> RED_PAPER_LANTERN = register("red_paper_lantern", () -> new PaperLanternBlock(Block.Properties.ofFullCopy(Blocks.RED_WOOL).noOcclusion().noCollision().lightLevel(state -> 12).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "red_paper_lantern")))), BlockTags.MINEABLE_WITH_AXE);
public final Supplier<Block> PAPER_LAMP = register("paper_lamp", () -> new PaperLampBlock(Block.Properties.ofFullCopy(Blocks.WHITE_WOOL).noOcclusion().lightLevel(state -> 14).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "paper_lamp")))), BlockTags.MINEABLE_WITH_AXE);
public final Supplier<Block> STONE_LANTERN = register("stone_lantern", () -> new LanternBlock(Block.Properties.ofFullCopy(Blocks.STONE_BRICKS).noOcclusion().lightLevel(state -> 15).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "stone_lantern"))), STONE_LANTERN_SHAPES));
public final Supplier<Block> SMALL_TATAMI_MAT = register("small_tatami_mat", () -> new SmallTatamiMatBlock(Block.Properties.ofFullCopy(Blocks.WHITE_CARPET).setId(ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(DoTBCommon.MOD_ID, "small_tatami_mat")))), true, null, BlockTags.MINEABLE_WITH_AXE);
Expand Down
Loading