Search in sources :

Example 16 with IMixinLocation

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);
    }
}
Also used : User(org.spongepowered.api.entity.living.player.User) IMixinLocation(org.spongepowered.common.interfaces.world.IMixinLocation) IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) LocatableBlock(org.spongepowered.api.world.LocatableBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(org.spongepowered.api.world.World)

Example 17 with IMixinLocation

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);
}
Also used : IMixinLocation(org.spongepowered.common.interfaces.world.IMixinLocation) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) World(org.spongepowered.api.world.World)

Example 18 with IMixinLocation

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);
}
Also used : IMixinLocation(org.spongepowered.common.interfaces.world.IMixinLocation) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(org.spongepowered.api.world.World)

Example 19 with IMixinLocation

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);
}
Also used : GroundLuminanceProperty(org.spongepowered.api.data.property.block.GroundLuminanceProperty) Chunk(net.minecraft.world.chunk.Chunk) Location(org.spongepowered.api.world.Location) IMixinLocation(org.spongepowered.common.interfaces.world.IMixinLocation)

Aggregations

IMixinLocation (org.spongepowered.common.interfaces.world.IMixinLocation)19 BlockPos (net.minecraft.util.math.BlockPos)17 World (org.spongepowered.api.world.World)16 ArrayList (java.util.ArrayList)8 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)7 ImmutableList (com.google.common.collect.ImmutableList)5 IBlockState (net.minecraft.block.state.IBlockState)5 Transaction (org.spongepowered.api.data.Transaction)5 ChangeBlockEvent (org.spongepowered.api.event.block.ChangeBlockEvent)4 SpongeBlockSnapshot (org.spongepowered.common.block.SpongeBlockSnapshot)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityItem (net.minecraft.entity.item.EntityItem)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 WorldServer (net.minecraft.world.WorldServer)3 Player (org.spongepowered.api.entity.living.player.Player)3 CauseStackManager (org.spongepowered.api.event.CauseStackManager)3 Location (org.spongepowered.api.world.Location)3 IMixinChunk (org.spongepowered.common.interfaces.IMixinChunk)3 Vector3i (com.flowpowered.math.vector.Vector3i)2 Collection (java.util.Collection)2