Search in sources :

Example 11 with BlockGetter

use of net.minecraft.world.level.BlockGetter in project Flywheel by Jozufozu.

the class EntityInstanceManager method canCreateInstance.

@Override
protected boolean canCreateInstance(Entity entity) {
    if (!entity.isAlive())
        return false;
    Level world = entity.level;
    if (Backend.isFlywheelWorld(world)) {
        BlockPos pos = entity.blockPosition();
        BlockGetter existingChunk = world.getChunkForCollisions(pos.getX() >> 4, pos.getZ() >> 4);
        return existingChunk != null;
    }
    return false;
}
Also used : BlockGetter(net.minecraft.world.level.BlockGetter) Level(net.minecraft.world.level.Level) BlockPos(net.minecraft.core.BlockPos)

Example 12 with BlockGetter

use of net.minecraft.world.level.BlockGetter in project Flywheel by Jozufozu.

the class BlockEntityInstanceManager method canCreateInstance.

@Override
protected boolean canCreateInstance(BlockEntity blockEntity) {
    if (blockEntity.isRemoved())
        return false;
    Level world = blockEntity.getLevel();
    if (world == null)
        return false;
    if (world.isEmptyBlock(blockEntity.getBlockPos()))
        return false;
    if (Backend.isFlywheelWorld(world)) {
        BlockPos pos = blockEntity.getBlockPos();
        BlockGetter existingChunk = world.getChunkForCollisions(pos.getX() >> 4, pos.getZ() >> 4);
        return existingChunk != null;
    }
    return false;
}
Also used : BlockGetter(net.minecraft.world.level.BlockGetter) Level(net.minecraft.world.level.Level) BlockPos(net.minecraft.core.BlockPos)

Example 13 with BlockGetter

use of net.minecraft.world.level.BlockGetter in project ConnectedTexturesMod by Chisel-Team.

the class RegionCache method getPassthrough.

private BlockGetter getPassthrough() {
    BlockGetter ret = passthrough.get();
    Preconditions.checkNotNull(ret);
    return ret;
}
Also used : BlockGetter(net.minecraft.world.level.BlockGetter)

Example 14 with BlockGetter

use of net.minecraft.world.level.BlockGetter in project Tetra-Pak by Noobulus.

the class CorundumEffect method corundumToolsBreakBlocksFaster.

@SubscribeEvent
public void corundumToolsBreakBlocksFaster(PlayerEvent.BreakSpeed event) {
    int effectLevel = getEffectLevel(event.getPlayer().getMainHandItem());
    if (effectLevel <= 0)
        return;
    BlockPos pos = event.getPos();
    BlockGetter world = event.getEntityLiving().level;
    boolean matches = CorundumMap.COLOR_MAP.get(world.getBlockState(event.getPos()).getMapColor(world, pos)) == effectLevel;
    event.setNewSpeed((float) (event.getOriginalSpeed() * (matches ? Config.MATCHING_CRYSTAL_FACTOR.get() : Config.NON_MATCHING_CRYSTAL_FACTOR.get())));
}
Also used : BlockGetter(net.minecraft.world.level.BlockGetter) BlockPos(net.minecraft.core.BlockPos) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

BlockGetter (net.minecraft.world.level.BlockGetter)14 BlockPos (net.minecraft.core.BlockPos)8 Level (net.minecraft.world.level.Level)4 ServerLevel (net.minecraft.server.level.ServerLevel)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 VoxelShape (net.minecraft.world.phys.shapes.VoxelShape)3 ExtendedAbstractBlockState (ca.spottedleaf.starlight.common.blockstate.ExtendedAbstractBlockState)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)2 Player (net.minecraft.world.entity.player.Player)2 ChunkPos (net.minecraft.world.level.ChunkPos)2 AllBlocks (com.simibubi.create.AllBlocks)1 AllShapes (com.simibubi.create.AllShapes)1 AllTileEntities (com.simibubi.create.AllTileEntities)1 ITE (com.simibubi.create.foundation.block.ITE)1 BlockHelper (com.simibubi.create.foundation.utility.BlockHelper)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 Direction (net.minecraft.core.Direction)1 NonNullList (net.minecraft.core.NonNullList)1 CompoundTag (net.minecraft.nbt.CompoundTag)1