Search in sources :

Example 1 with GameEvent

use of net.minecraft.world.event.GameEvent in project wildmod by Osmiooo.

the class SculkSensorBlockMixin method setActive.

@Inject(method = "setActive", at = @At("TAIL"))
private static void setActive(World world, BlockPos pos, BlockState state, int power, CallbackInfo info) {
    world.emitGameEvent(RegisterAccurateSculk.CLICK, pos.add(0.5, 0, 0.5));
    int lastEntity = SensorLastEntity.getLastEntity(pos);
    LivingEntity target = (LivingEntity) world.getEntityById(lastEntity);
    BlockPos lastEventPos = SensorLastEntity.getLastPos(pos);
    GameEvent event = SensorLastEntity.getLastEvent(pos);
    if (event != null && lastEntity != -1 && lastEventPos != null && target != null) {
        if (SculkSensorBlock.FREQUENCIES.containsKey(event)) {
            Box box = new Box(pos.getX() - 18, pos.getY() - 18, pos.getZ() - 18, pos.getX() + 18, pos.getY() + 18, pos.getZ() + 18);
            List<WardenEntity> list = world.getNonSpectatingEntities(WardenEntity.class, box);
            Iterator<WardenEntity> var11 = list.iterator();
            WardenEntity wardenEntity;
            while (var11.hasNext()) {
                wardenEntity = var11.next();
                if (wardenEntity.getBlockPos().isWithinDistance(pos, 16)) {
                    if (event != GameEvent.PROJECTILE_LAND && event != GameEvent.BLOCK_DESTROY && event != GameEvent.BLOCK_PLACE && event != GameEvent.BLOCK_ATTACH && event != GameEvent.BLOCK_CHANGE && event != GameEvent.BLOCK_CLOSE && event != GameEvent.BLOCK_OPEN && event != GameEvent.BLOCK_PRESS && event != GameEvent.BLOCK_SWITCH && event != GameEvent.BLOCK_DETACH && event != GameEvent.BLOCK_UNPRESS && event != GameEvent.BLOCK_UNSWITCH && event != GameEvent.RING_BELL) {
                        wardenEntity.listen(lastEventPos, wardenEntity.getWorld(), target, wardenEntity.eventSuspicionValue(event, target), pos);
                    } else {
                        wardenEntity.listen(lastEventPos, wardenEntity.getWorld(), null, 1, pos);
                    }
                }
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) WardenEntity(frozenblock.wild.mod.entity.WardenEntity) GameEvent(net.minecraft.world.event.GameEvent) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

WardenEntity (frozenblock.wild.mod.entity.WardenEntity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 Box (net.minecraft.util.math.Box)1 GameEvent (net.minecraft.world.event.GameEvent)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1