Updated tick
This commit is contained in:
parent
08fc14439a
commit
0ac3814cd5
3 changed files with 33 additions and 20 deletions
|
@ -6,6 +6,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -48,9 +50,11 @@ import ru.bclib.client.models.ModelsHelper;
|
|||
import ru.betterend.blocks.EndBlockProperties;
|
||||
import ru.betterend.blocks.EndBlockProperties.PedestalState;
|
||||
import ru.betterend.blocks.InfusionPedestal;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.rituals.InfusionRitual;
|
||||
|
||||
|
@ -428,6 +432,16 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockEntityType<T> blockEntityType) {
|
||||
return level.isClientSide() ? null : createTickerHelper(blockEntityType, EndBlockEntities.PEDESTAL, PedestalBlockEntity::tick);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> blockEntityType, BlockEntityType<E> blockEntityType2, BlockEntityTicker<? super E> blockEntityTicker) {
|
||||
return blockEntityType2 == blockEntityType ? blockEntityTicker : null;
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
|
||||
|
|
|
@ -2,6 +2,7 @@ package ru.betterend.blocks.entities;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
|
@ -9,8 +10,8 @@ import net.minecraft.world.entity.EquipmentSlot;
|
|||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ElytraItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TickableBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -20,18 +21,16 @@ import ru.betterend.registry.EndBlockEntities;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class BlockEntityHydrothermalVent extends BlockEntity implements TickableBlockEntity {
|
||||
public class BlockEntityHydrothermalVent extends BlockEntity {
|
||||
|
||||
private final static Vec3 POSITIVE_Y = new Vec3(0.0f, 1.0f, 0.0f);
|
||||
|
||||
public BlockEntityHydrothermalVent() {
|
||||
super(EndBlockEntities.HYDROTHERMAL_VENT);
|
||||
public BlockEntityHydrothermalVent(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.HYDROTHERMAL_VENT, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
public static void tick(Level level, BlockPos worldPosition, BlockState state, BlockEntityHydrothermalVent blockEntity) {
|
||||
if (level != null) {
|
||||
BlockState state = getBlockState();
|
||||
if (state.is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
boolean active = state.getValue(HydrothermalVentBlock.ACTIVATED);
|
||||
if (active && level.random.nextInt(20) == 0) {
|
||||
|
@ -56,7 +55,7 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
|
|||
double mult = active ? 3.0 : 5.0;
|
||||
float force = (float) ((1.0 - (mutable.getY() / box.maxY)) / mult);
|
||||
entities.stream().filter(entity -> (int) entity.getY() == mutable.getY() &&
|
||||
hasElytra(entity) && entity.isFallFlying())
|
||||
blockEntity.hasElytra(entity) && entity.isFallFlying())
|
||||
.forEach(entity -> entity.moveRelative(force, POSITIVE_Y));
|
||||
}
|
||||
mutable.move(Direction.UP);
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.TickableBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class PedestalBlockEntity extends BlockEntity implements Container, TickableBlockEntity, BlockEntityClientSerializable {
|
||||
public class PedestalBlockEntity extends BlockEntity implements Container, BlockEntityClientSerializable {
|
||||
private ItemStack activeItem = ItemStack.EMPTY;
|
||||
|
||||
private final int maxAge = 314;
|
||||
private int age;
|
||||
|
||||
public PedestalBlockEntity() {
|
||||
super(EndBlockEntities.PEDESTAL);
|
||||
public PedestalBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
public PedestalBlockEntity(BlockEntityType<?> type) {
|
||||
|
@ -103,8 +104,8 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Ticka
|
|||
}
|
||||
|
||||
@Override
|
||||
public void load(BlockState state, CompoundTag tag) {
|
||||
super.load(state, tag);
|
||||
public void load(CompoundTag tag) {
|
||||
super.load(tag);
|
||||
fromTag(tag);
|
||||
}
|
||||
|
||||
|
@ -131,12 +132,11 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Ticka
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (!isEmpty()) {
|
||||
age++;
|
||||
if (age > maxAge) {
|
||||
age = 0;
|
||||
public static void tick(Level tickLevel, BlockPos tickPos, BlockState tickState, PedestalBlockEntity blockEntity) {
|
||||
if (!blockEntity.isEmpty()) {
|
||||
blockEntity.age++;
|
||||
if (blockEntity.age > blockEntity.maxAge) {
|
||||
blockEntity.age = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue