Infusion ritual fix
This commit is contained in:
parent
92f6f47058
commit
2ea71cf8d6
3 changed files with 22 additions and 17 deletions
|
@ -58,7 +58,7 @@ public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped {
|
||||||
VoxelShape top = Block.box(5, 15, 5, 11, 16, 11);
|
VoxelShape top = Block.box(5, 15, 5, 11, 16, 11);
|
||||||
SHAPE_BIG = Shapes.or(lantern, cap, top);
|
SHAPE_BIG = Shapes.or(lantern, cap, top);
|
||||||
|
|
||||||
lantern = Block.box(1, 7, 1, 15, 13, 15);
|
lantern = Block.box(5, 7, 5, 11, 13, 11);
|
||||||
cap = Block.box(4, 12, 4, 12, 15, 12);
|
cap = Block.box(4, 12, 4, 12, 15, 12);
|
||||||
top = Block.box(6, 15, 6, 10, 16, 10);
|
top = Block.box(6, 15, 6, 10, 16, 10);
|
||||||
SHAPE_SMALL = Shapes.or(lantern, cap, top);
|
SHAPE_SMALL = Shapes.or(lantern, cap, top);
|
||||||
|
|
|
@ -6,12 +6,16 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||||
|
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||||
import ru.betterend.rituals.InfusionRitual;
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -73,6 +77,12 @@ public class InfusionPedestal extends PedestalBlock {
|
||||||
return super.getShape(state, world, pos, context);
|
return super.getShape(state, world, pos, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
|
||||||
|
return InfusionPedestalEntity::tickEnity;
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
|
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
|
||||||
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);
|
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.entities;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.betterend.registry.EndBlockEntities;
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
import ru.betterend.rituals.InfusionRitual;
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
|
@ -26,15 +27,6 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevelAndPosition(Level world, BlockPos pos) {
|
|
||||||
if (hasRitual()) {
|
|
||||||
linkedRitual.setLocation(world, pos);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
linkRitual(new InfusionRitual(this, world, pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void linkRitual(InfusionRitual ritual) {
|
public void linkRitual(InfusionRitual ritual) {
|
||||||
linkedRitual = ritual;
|
linkedRitual = ritual;
|
||||||
}
|
}
|
||||||
|
@ -47,13 +39,6 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||||
return linkedRitual != null;
|
return linkedRitual != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tick(Level tickLevel, BlockPos tickPos, BlockState tickState, InfusionPedestalEntity blockEntity) {
|
|
||||||
if (blockEntity.hasRitual()) {
|
|
||||||
blockEntity.linkedRitual.tick();
|
|
||||||
}
|
|
||||||
PedestalBlockEntity.tick(tickLevel, tickPos, tickState, blockEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save(CompoundTag tag) {
|
public CompoundTag save(CompoundTag tag) {
|
||||||
if (hasRitual()) {
|
if (hasRitual()) {
|
||||||
|
@ -70,4 +55,14 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||||
linkedRitual.fromTag(tag.getCompound("ritual"));
|
linkedRitual.fromTag(tag.getCompound("ritual"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends BlockEntity> void tickEnity(Level level, BlockPos blockPos, BlockState blockState, T uncastedEntity) {
|
||||||
|
if (uncastedEntity instanceof InfusionPedestalEntity) {
|
||||||
|
InfusionPedestalEntity blockEntity = (InfusionPedestalEntity) uncastedEntity;
|
||||||
|
if (blockEntity.hasRitual()) {
|
||||||
|
blockEntity.linkedRitual.tick();
|
||||||
|
}
|
||||||
|
PedestalBlockEntity.tick(level, blockPos, blockState, blockEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue