use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelperImpl method applyPhysics.
@Override
public void applyPhysics(Location location) {
BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
((CraftWorld) location.getWorld()).getHandle().updateNeighborsAt(pos, CraftMagicNumbers.getBlock(location.getBlock().getType()));
}
use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelperImpl method doRandomTick.
@Override
public void doRandomTick(Location location) {
BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
LevelChunk nmsChunk = ((CraftChunk) location.getChunk()).getHandle();
net.minecraft.world.level.block.state.BlockState nmsBlock = nmsChunk.getBlockState(pos);
ServerLevel nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
if (nmsBlock.isRandomlyTicking()) {
nmsBlock.randomTick(nmsWorld, pos, nmsWorld.random);
}
try {
// FluidState fluid = nmsBlock.getFluidState();
// if (fluid.isRandomlyTicking()) {
// fluid.animateTick(nmsWorld, pos, nmsWorld.random);
// }
Object fluid = BLOCKSTATEBASE_GETFLUIDSTATE.invoke(nmsBlock);
if ((boolean) FLUIDSTATE_ISRANDOMLYTICKING.invoke(fluid)) {
FLUIDSTATE_ANIMATETICK.invoke(fluid, nmsWorld, pos, nmsWorld.random);
}
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of net.minecraft.core.BlockPos in project MinecraftForge by MinecraftForge.
the class ModelDataManager method refreshModelData.
private static void refreshModelData(Level world, ChunkPos chunk) {
cleanCaches(world);
Set<BlockPos> needUpdate = needModelDataRefresh.remove(chunk);
if (needUpdate != null) {
Map<BlockPos, IModelData> data = modelDataCache.computeIfAbsent(chunk, $ -> new ConcurrentHashMap<>());
for (BlockPos pos : needUpdate) {
BlockEntity toUpdate = world.getBlockEntity(pos);
if (toUpdate != null && !toUpdate.isRemoved()) {
data.put(pos, toUpdate.getModelData());
} else {
data.remove(pos);
}
}
}
}
use of net.minecraft.core.BlockPos in project MinecraftForge by MinecraftForge.
the class ForgeEventFactory method fireSleepingLocationCheck.
public static boolean fireSleepingLocationCheck(LivingEntity player, BlockPos sleepingLocation) {
SleepingLocationCheckEvent evt = new SleepingLocationCheckEvent(player, sleepingLocation);
MinecraftForge.EVENT_BUS.post(evt);
Result canContinueSleep = evt.getResult();
if (canContinueSleep == Result.DEFAULT) {
return player.getSleepingPos().map(pos -> {
BlockState state = player.level.getBlockState(pos);
return state.getBlock().isBed(state, player.level, pos, player);
}).orElse(false);
} else
return canContinueSleep == Result.ALLOW;
}
use of net.minecraft.core.BlockPos in project MinecraftForge by MinecraftForge.
the class DispenseFluidContainer method fillContainer.
/**
* Picks up fluid in front of a Dispenser and fills a container with it.
*/
@Nonnull
private ItemStack fillContainer(@Nonnull BlockSource source, @Nonnull ItemStack stack) {
Level world = source.getLevel();
Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING);
BlockPos blockpos = source.getPos().relative(dispenserFacing);
FluidActionResult actionResult = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite());
ItemStack resultStack = actionResult.getResult();
if (!actionResult.isSuccess() || resultStack.isEmpty()) {
return super.execute(source, stack);
}
if (stack.getCount() == 1) {
return resultStack;
} else if (((DispenserBlockEntity) source.getEntity()).addItem(resultStack) < 0) {
this.dispenseBehavior.dispense(source, resultStack);
}
ItemStack stackCopy = stack.copy();
stackCopy.shrink(1);
return stackCopy;
}
Aggregations