use of org.spongepowered.common.interfaces.world.IMixinLocation in project SpongeCommon by SpongePowered.
the class LocationBasedTickPhaseState method handleBlockChangeWithUser.
@Override
public void handleBlockChangeWithUser(@Nullable BlockChange blockChange, Transaction<BlockSnapshot> snapshotTransaction, T context) {
final Location<World> location = getLocatableBlockSourceFromContext(context).getLocation();
final Block block = (Block) snapshotTransaction.getOriginal().getState().getType();
final Location<World> changedLocation = snapshotTransaction.getOriginal().getLocation().get();
final BlockPos changedBlockPos = ((IMixinLocation) (Object) changedLocation).getBlockPos();
final IMixinChunk changedMixinChunk = (IMixinChunk) ((WorldServer) changedLocation.getExtent()).getChunkFromBlockCoords(changedBlockPos);
final User user = context.getNotifier().orElse(TrackingUtil.getNotifierOrOwnerFromBlock(location));
if (user != null) {
changedMixinChunk.addTrackedBlockPosition(block, changedBlockPos, user, PlayerTracker.Type.NOTIFIER);
}
}
use of org.spongepowered.common.interfaces.world.IMixinLocation in project SpongeCommon by SpongePowered.
the class FlammablePropertyStore method getFor.
@Override
public Optional<FlammableProperty> getFor(Location<World> location, Direction direction) {
final net.minecraft.world.World world = (net.minecraft.world.World) location.getExtent();
final EnumFacing facing = toEnumFacing(direction);
final BlockPos pos = ((IMixinLocation) (Object) location).getBlockPos();
final boolean flammable = SpongeImplHooks.isBlockFlammable(world.getBlockState(pos).getBlock(), world, pos, facing);
return Optional.of(flammable ? TRUE : FALSE);
}
use of org.spongepowered.common.interfaces.world.IMixinLocation in project SpongeCommon by SpongePowered.
the class FlammablePropertyStore method getFor.
@Override
public Optional<FlammableProperty> getFor(Location<World> location) {
final net.minecraft.world.World world = (net.minecraft.world.World) location.getExtent();
final BlockPos pos = ((IMixinLocation) (Object) location).getBlockPos();
final Block block = world.getBlockState(pos).getBlock();
for (EnumFacing facing : EnumFacing.values()) {
if (SpongeImplHooks.isBlockFlammable(block, world, pos, facing)) {
return Optional.of(TRUE);
}
}
return Optional.of(FALSE);
}
use of org.spongepowered.common.interfaces.world.IMixinLocation in project SpongeCommon by SpongePowered.
the class GroundLuminancePropertyStore method getFor.
@Override
public Optional<GroundLuminanceProperty> getFor(PropertyHolder propertyHolder) {
if (propertyHolder instanceof Location && ((Location<?>) propertyHolder).getExtent() instanceof Chunk) {
final Chunk chunk = (Chunk) ((Location<?>) propertyHolder).getExtent();
final float light = chunk.getLightFor(EnumSkyBlock.BLOCK, ((IMixinLocation) propertyHolder).getBlockPos());
return Optional.of(new GroundLuminanceProperty(light));
}
return super.getFor(propertyHolder);
}
Aggregations