@minecraft/server / TripWireTripAfterEvent
Class: TripWireTripAfterEvent ​
Defined in: @minecraft/server/index.d.ts:20927
Contains information related to changes to a trip wire trip.
Example ​
tripWireTripEvent.ts
typescript
import { world, system, BlockPermutation, TripWireTripAfterEvent, DimensionLocation } from '@minecraft/server';
import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
function tripWireTripEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
// set up a tripwire
const redstone = targetLocation.dimension.getBlock({
x: targetLocation.x,
y: targetLocation.y - 1,
z: targetLocation.z,
});
const tripwire = targetLocation.dimension.getBlock(targetLocation);
if (redstone === undefined || tripwire === undefined) {
log('Could not find block at location.');
return -1;
}
redstone.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.RedstoneBlock));
tripwire.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.TripWire));
world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => {
const eventLoc = tripWireTripEvent.block.location;
if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
log(
'Tripwire trip event at tick ' +
system.currentTick +
(tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : '')
);
}
});
}Extends ​
Properties ​
block ​
readonlyblock:Block
Defined in: @minecraft/server/index.d.ts:4790
Remarks ​
Block currently in the world at the location of this event.
Inherited from ​
dimension ​
readonlydimension:Dimension
Defined in: @minecraft/server/index.d.ts:4797
Remarks ​
Dimension that contains the block that is the subject of this event.
Inherited from ​
isPowered ​
readonlyisPowered:boolean
Defined in: @minecraft/server/index.d.ts:20934
Remarks ​
Whether or not the block has redstone power.
sources ​
readonlysources:Entity[]
Defined in: @minecraft/server/index.d.ts:20940
Remarks ​
The sources that triggered the trip wire to trip.