Added pedestals
This commit is contained in:
parent
a7dcba05a9
commit
f34226e944
75 changed files with 806 additions and 414 deletions
|
@ -1,10 +1,14 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
public class BlockProperties {
|
||||
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class);
|
||||
public final static EnumProperty<State> STATE = EnumProperty.of("state", State.class);
|
||||
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
|
||||
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
|
||||
|
||||
public static enum TripleShape implements StringIdentifiable {
|
||||
TOP("top"),
|
||||
|
@ -27,4 +31,16 @@ public class BlockProperties {
|
|||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum State implements StringIdentifiable {
|
||||
DEFAULT,
|
||||
BOTTOM,
|
||||
TOP,
|
||||
PILLAR;
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,67 +5,67 @@ import java.util.List;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import ru.betterend.blocks.basis.BlockSlab;
|
||||
import ru.betterend.blocks.entities.EternalPedestalBlockEntity;
|
||||
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EternalPedestal extends BlockSlab implements BlockEntityProvider {
|
||||
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
|
||||
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
|
||||
public class EternalPedestal extends BlockPedestal {
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||
|
||||
public EternalPedestal() {
|
||||
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
|
||||
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false).with(HAS_ITEM, false));
|
||||
this.setDefaultState(this.getDefaultState().with(ACTIVATED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (world.isClient) return ActionResult.CONSUME;
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EternalPedestalBlockEntity && state.isOf(this)) {
|
||||
EternalPedestalBlockEntity pedestal = (EternalPedestalBlockEntity) blockEntity;
|
||||
if (pedestal.isEmpty()) {
|
||||
ItemStack itemStack = player.getStackInHand(hand);
|
||||
if (itemStack.isEmpty()) return ActionResult.CONSUME;
|
||||
if (itemStack.getItem().equals(EndItems.ETERNAL_CRYSTAL)) {
|
||||
world.setBlockState(pos, state.with(ACTIVATED, true).with(HAS_ITEM, true));
|
||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
||||
if (result.equals(ActionResult.SUCCESS)) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof PedestalBlockEntity) {
|
||||
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
|
||||
BlockState updatedState = world.getBlockState(pos);
|
||||
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
|
||||
world.setBlockState(pos, updatedState.with(ACTIVATED, false));
|
||||
} else {
|
||||
world.setBlockState(pos, state.with(HAS_ITEM, true));
|
||||
}
|
||||
pedestal.setStack(0, itemStack.split(1));
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
ItemStack itemStack = pedestal.getStack(0);
|
||||
if (player.giveItemStack(itemStack)) {
|
||||
if (state.get(ACTIVATED)) {
|
||||
world.setBlockState(pos, state.with(ACTIVATED, false).with(HAS_ITEM, false));
|
||||
} else {
|
||||
world.setBlockState(pos, state.with(HAS_ITEM, false));
|
||||
ItemStack itemStack = pedestal.getStack(0);
|
||||
if (itemStack.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
world.setBlockState(pos, updatedState.with(ACTIVATED, true));
|
||||
}
|
||||
pedestal.removeStack(0);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
BlockState updated = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
||||
BlockProperties.State updatedState = state.get(BlockProperties.STATE);
|
||||
if (updatedState.equals(BlockProperties.State.BOTTOM) || updatedState.equals(BlockProperties.State.PILLAR)) {
|
||||
return updated.with(ACTIVATED, false);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,17 +85,26 @@ public class EternalPedestal extends BlockSlab implements BlockEntityProvider {
|
|||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Lists.newArrayList();
|
||||
if (state.isOf(this)) {
|
||||
BlockProperties.State currentState = state.get(BlockProperties.STATE);
|
||||
if (currentState.equals(BlockProperties.State.BOTTOM) || currentState.equals(BlockProperties.State.PILLAR)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
List<ItemStack> drop = Lists.newArrayList();
|
||||
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
|
||||
if (blockEntity != null && blockEntity instanceof PedestalBlockEntity) {
|
||||
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
|
||||
if (!pedestal.isEmpty()) {
|
||||
drop.add(pedestal.getStack(0));
|
||||
}
|
||||
}
|
||||
return drop;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
super.appendProperties(stateManager);
|
||||
stateManager.add(ACTIVATED, HAS_ITEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new EternalPedestalBlockEntity();
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import ru.betterend.util.BlocksHelper;
|
|||
import ru.betterend.util.PortalFrameHelper;
|
||||
|
||||
public class RunedFlavolite extends BlockBase {
|
||||
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||
|
||||
public RunedFlavolite() {
|
||||
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> {
|
||||
|
|
235
src/main/java/ru/betterend/blocks/basis/BlockPedestal.java
Normal file
235
src/main/java/ru/betterend/blocks/basis/BlockPedestal.java
Normal file
|
@ -0,0 +1,235 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.State;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvider {
|
||||
public final static EnumProperty<State> STATE = BlockProperties.STATE;
|
||||
public static final BooleanProperty HAS_ITEM = BlockProperties.HAS_ITEM;
|
||||
|
||||
private static final VoxelShape SHAPE_DEFAULT = VoxelShapes.cuboid(0, 0, 0, 16, 14, 16);
|
||||
private static final VoxelShape SHAPE_PILLAR = VoxelShapes.cuboid(3, 0, 3, 13, 16, 13);
|
||||
private static final VoxelShape SHAPE_BOTTOM;
|
||||
private static final VoxelShape SHAPE_TOP;
|
||||
|
||||
public BlockPedestal(Block parent) {
|
||||
super(FabricBlockSettings.copyOf(parent));
|
||||
this.setDefaultState(stateManager.getDefaultState().with(STATE, State.DEFAULT).with(HAS_ITEM, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME;
|
||||
State currentState = state.get(STATE);
|
||||
if (currentState.equals(State.BOTTOM) || currentState.equals(State.PILLAR)) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof PedestalBlockEntity) {
|
||||
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
|
||||
if (pedestal.isEmpty()) {
|
||||
ItemStack itemStack = player.getStackInHand(hand);
|
||||
if (itemStack.isEmpty()) return ActionResult.CONSUME;
|
||||
world.setBlockState(pos, state.with(HAS_ITEM, true));
|
||||
pedestal.setStack(0, itemStack.split(1));
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
ItemStack itemStack = pedestal.getStack(0);
|
||||
if (player.giveItemStack(itemStack)) {
|
||||
world.setBlockState(pos, state.with(HAS_ITEM, false));
|
||||
pedestal.removeStack(0);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockState getPlacementState(ItemPlacementContext context) {
|
||||
BlockPos pos = context.getBlockPos();
|
||||
Block down = context.getWorld().getBlockState(pos.down()).getBlock();
|
||||
Block up = context.getWorld().getBlockState(pos.up()).getBlock();
|
||||
if (down instanceof BlockPedestal && up instanceof BlockPedestal) {
|
||||
return this.getDefaultState().with(STATE, State.PILLAR);
|
||||
} else if (down instanceof BlockPedestal) {
|
||||
return this.getDefaultState().with(STATE, State.TOP);
|
||||
} else if (up instanceof BlockPedestal) {
|
||||
return this.getDefaultState().with(STATE, State.BOTTOM);
|
||||
}
|
||||
return this.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
if (newState.getBlock() instanceof BlockPedestal) {
|
||||
if (direction.equals(Direction.DOWN)) {
|
||||
if (world.getBlockState(pos.up()).getBlock() instanceof BlockPedestal) {
|
||||
this.moveStoredStack(world, state, pos);
|
||||
return state.with(STATE, State.PILLAR);
|
||||
}
|
||||
return state.with(STATE, State.TOP);
|
||||
} else if (direction.equals(Direction.UP)) {
|
||||
this.moveStoredStack(world, state, pos);
|
||||
if (world.getBlockState(pos.down()).getBlock() instanceof BlockPedestal) {
|
||||
return state.with(STATE, State.PILLAR);
|
||||
}
|
||||
return state.with(STATE, State.BOTTOM);
|
||||
}
|
||||
} else {
|
||||
if (direction.equals(Direction.DOWN)) {
|
||||
if (world.getBlockState(pos.up()).getBlock() instanceof BlockPedestal) {
|
||||
this.moveStoredStack(world, state, pos);
|
||||
return state.with(STATE, State.BOTTOM);
|
||||
}
|
||||
return state.with(STATE, State.DEFAULT);
|
||||
} else if (direction.equals(Direction.UP)) {
|
||||
if (world.getBlockState(pos.down()).getBlock() instanceof BlockPedestal) {
|
||||
return state.with(STATE, State.TOP);
|
||||
}
|
||||
return state.with(STATE, State.DEFAULT);
|
||||
}
|
||||
}
|
||||
return super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> drop = super.getDroppedStacks(state, builder);
|
||||
if (state.isOf(this)) {
|
||||
State currentState = state.get(STATE);
|
||||
if (currentState.equals(State.BOTTOM) || currentState.equals(State.PILLAR)) {
|
||||
return drop;
|
||||
} else {
|
||||
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
|
||||
if (blockEntity != null && blockEntity instanceof PedestalBlockEntity) {
|
||||
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
|
||||
if (!pedestal.isEmpty()) {
|
||||
drop.add(pedestal.getStack(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return drop;
|
||||
}
|
||||
|
||||
private void moveStoredStack(WorldAccess world, BlockState state, BlockPos pos) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof PedestalBlockEntity && state.isOf(this)) {
|
||||
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
|
||||
stack = pedestal.getStack(0);
|
||||
pedestal.clear();
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state.with(HAS_ITEM, false));
|
||||
}
|
||||
if (!stack.isEmpty()) {
|
||||
BlockPos upPos = pos.up();
|
||||
this.moveStoredStack(world, stack, world.getBlockState(upPos), upPos);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveStoredStack(WorldAccess world, ItemStack stack, BlockState state, BlockPos pos) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (state.get(STATE).equals(State.PILLAR)) {
|
||||
BlockPos upPos = pos.up();
|
||||
this.moveStoredStack(world, stack, world.getBlockState(upPos), upPos);
|
||||
} else if (blockEntity instanceof PedestalBlockEntity) {
|
||||
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
|
||||
if (pedestal.isEmpty()) {
|
||||
pedestal.setStack(0, stack);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state.with(HAS_ITEM, true));
|
||||
} else {
|
||||
this.dropStoredStack(world, stack, pos);
|
||||
}
|
||||
} else {
|
||||
this.dropStoredStack(world, stack, pos);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropStoredStack(WorldAccess world, ItemStack stack, BlockPos pos) {
|
||||
Block.dropStack((World) world, this.getDropPos(world, pos), stack);
|
||||
}
|
||||
|
||||
private BlockPos getDropPos(WorldAccess world, BlockPos pos) {
|
||||
BlockPos dropPos;
|
||||
for(int i = 2; i < Direction.values().length; i++) {
|
||||
dropPos = pos.offset(Direction.byId(i));
|
||||
if (world.getBlockState(dropPos).isAir()) {
|
||||
return dropPos.toImmutable();
|
||||
}
|
||||
}
|
||||
return this.getDropPos(world, pos.up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (state.isOf(this)) {
|
||||
switch(state.get(STATE)) {
|
||||
case BOTTOM: {
|
||||
return SHAPE_BOTTOM;
|
||||
}
|
||||
case TOP: {
|
||||
return SHAPE_TOP;
|
||||
}
|
||||
case PILLAR: {
|
||||
return SHAPE_PILLAR;
|
||||
}
|
||||
default: {
|
||||
return SHAPE_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(STATE, HAS_ITEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new PedestalBlockEntity();
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelShape basin = VoxelShapes.cuboid(0, 0, 0, 16, 4, 16);
|
||||
VoxelShape top = VoxelShapes.cuboid(1, 12, 1, 15, 14, 15);
|
||||
VoxelShape pillar = VoxelShapes.cuboid(3, 0, 3, 13, 14, 13);
|
||||
SHAPE_BOTTOM = VoxelShapes.union(basin, SHAPE_PILLAR);
|
||||
SHAPE_TOP = VoxelShapes.union(top, pillar);
|
||||
}
|
||||
}
|
|
@ -10,12 +10,12 @@ import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
|
|||
import net.minecraft.util.Tickable;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EternalPedestalBlockEntity extends BlockEntity implements Inventory, Tickable {
|
||||
public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable {
|
||||
private ItemStack activeItem = ItemStack.EMPTY;
|
||||
|
||||
private int age;
|
||||
|
||||
public EternalPedestalBlockEntity() {
|
||||
public PedestalBlockEntity() {
|
||||
super(EndBlockEntities.ETERNAL_PEDESTAL);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class EternalPedestalBlockEntity extends BlockEntity implements Inventory
|
|||
public void tick() {
|
||||
if (!isEmpty()) {
|
||||
this.age++;
|
||||
if (age > 10000) {
|
||||
if (age > 314) {
|
||||
this.age = 0;
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ package ru.betterend.blocks.entities.render;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.enums.SlabType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
|
@ -17,44 +17,42 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.entities.EternalPedestalBlockEntity;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EternalPedestalItemRenderer extends BlockEntityRenderer<EternalPedestalBlockEntity> {
|
||||
public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntity> {
|
||||
private static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/end_gateway_beam.png");
|
||||
|
||||
public EternalPedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(EternalPedestalBlockEntity entity, float tickDelta, MatrixStack matrices,
|
||||
public void render(PedestalBlockEntity blockEntity, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
|
||||
if (entity.isEmpty()) return;
|
||||
if (blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = entity.getWorld().getBlockState(entity.getPos());
|
||||
SlabType type = state.get(EternalPedestal.TYPE);
|
||||
|
||||
ItemStack activeItem = entity.getStack(0);
|
||||
BlockState state = blockEntity.getWorld().getBlockState(blockEntity.getPos());
|
||||
ItemStack activeItem = blockEntity.getStack(0);
|
||||
matrices.push();
|
||||
if (type.equals(SlabType.DOUBLE)) {
|
||||
matrices.translate(0.5, 1.5, 0.5);
|
||||
} else {
|
||||
matrices.translate(0.5, 1.0, 0.5);
|
||||
}
|
||||
float altitude = MathHelper.sin((entity.getAge() + tickDelta) / 10.0F) * 0.1F;
|
||||
float rotation = (entity.getAge() + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.translate(0.5, 1.1, 0.5);
|
||||
float rotation = (blockEntity.getAge() + tickDelta) / 25.0F + 6.0F;
|
||||
float altitude = MathHelper.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
MinecraftClient minecraft = MinecraftClient.getInstance();
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, light, overlay, matrices, vertexConsumers);
|
||||
float[] colors = DyeColor.MAGENTA.getColorComponents();
|
||||
int y = entity.getPos().getY();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(BEAM_TEXTURE, true));
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumer, tickDelta, -y, 1024 - y, colors, 0.25F, 0.15F, 0.2F);
|
||||
if (state.isOf(EndBlocks.ETERNAL_PEDESTAL) && state.get(EternalPedestal.ACTIVATED)) {
|
||||
float[] colors = DyeColor.MAGENTA.getColorComponents();
|
||||
int y = blockEntity.getPos().getY();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(BEAM_TEXTURE, true));
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumer, tickDelta, -y, 1024 - y, colors, 0.25F, 0.15F, 0.2F);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue