use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class WeightedPressurePlateBlockMixin method arclight$entityInteract.
@Redirect(method = "computeRedstoneStrength", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/List;size()I"))
public int arclight$entityInteract(List<Entity> list, World worldIn, BlockPos pos) {
int i = 0;
for (Entity entity : list) {
Cancellable cancellable;
if (entity instanceof PlayerEntity) {
cancellable = CraftEventFactory.callPlayerInteractEvent((PlayerEntity) entity, Action.PHYSICAL, pos, null, null, null);
} else {
cancellable = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(worldIn, pos));
Bukkit.getPluginManager().callEvent((EntityInteractEvent) cancellable);
}
// We only want to block turning the plate on if all events are cancelled
if (!cancellable.isCancelled()) {
i++;
}
}
return i;
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class LeadItemMixin_1_15 method bindPlayerMobs.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public static ActionResultType bindPlayerMobs(PlayerEntity player, World worldIn, BlockPos fence) {
LeashKnotEntity leashknotentity = null;
boolean flag = false;
double d0 = 7.0D;
int i = fence.getX();
int j = fence.getY();
int k = fence.getZ();
for (MobEntity mobentity : worldIn.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB((double) i - 7.0D, (double) j - 7.0D, (double) k - 7.0D, (double) i + 7.0D, (double) j + 7.0D, (double) k + 7.0D))) {
if (mobentity.getLeashHolder() == player) {
if (leashknotentity == null) {
leashknotentity = LeashKnotEntity.create(worldIn, fence);
HangingPlaceEvent event = new HangingPlaceEvent((Hanging) ((EntityBridge) leashknotentity).bridge$getBukkitEntity(), player != null ? (Player) ((PlayerEntityBridge) player).bridge$getBukkitEntity() : null, CraftBlock.at(worldIn, fence), BlockFace.SELF);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
leashknotentity.remove();
return ActionResultType.PASS;
}
}
if (CraftEventFactory.callPlayerLeashEntityEvent(mobentity, leashknotentity, player).isCancelled()) {
continue;
}
mobentity.setLeashHolder(leashknotentity, true);
flag = true;
}
}
return flag ? ActionResultType.SUCCESS : ActionResultType.PASS;
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class EntityTeleportEventDispatcher method onTeleport.
@SubscribeEvent(receiveCanceled = true)
public void onTeleport(EnderTeleportEvent event) {
if (!(event.getEntity() instanceof EndermanEntity)) {
if (event.getEntity() instanceof ServerPlayerEntity) {
CraftPlayer player = ((ServerPlayerEntityBridge) event.getEntity()).bridge$getBukkitEntity();
PlayerTeleportEvent bukkitEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
} else {
CraftEntity entity = ((EntityBridge) event.getEntity()).bridge$getBukkitEntity();
EntityTeleportEvent bukkitEvent = new EntityTeleportEvent(entity, entity.getLocation(), new Location(entity.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()));
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
}
}
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class BlockBreakEventDispatcher method onFarmlandBreak.
@SubscribeEvent
public void onFarmlandBreak(BlockEvent.FarmlandTrampleEvent event) {
Entity entity = event.getEntity();
Cancellable cancellable;
if (entity instanceof PlayerEntity) {
cancellable = CraftEventFactory.callPlayerInteractEvent((PlayerEntity) entity, Action.PHYSICAL, event.getPos(), null, null, null);
} else {
cancellable = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(event.getWorld(), event.getPos()));
Bukkit.getPluginManager().callEvent((EntityInteractEvent) cancellable);
}
if (cancellable.isCancelled()) {
event.setCanceled(true);
return;
}
if (CraftEventFactory.callEntityChangeBlockEvent(entity, event.getPos(), Blocks.DIRT.getDefaultState()).isCancelled()) {
event.setCanceled(true);
}
}
Aggregations