use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class LeadItemMixin_1_14 method attachToFence.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public static boolean attachToFence(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 false;
}
}
if (CraftEventFactory.callPlayerLeashEntityEvent(mobentity, leashknotentity, player).isCancelled()) {
continue;
}
mobentity.setLeashHolder(leashknotentity, true);
flag = true;
}
}
return flag;
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class ZombiePigmanEntityMixin_1_14 method arclight$anger.
@Inject(method = "becomeAngryAt", cancellable = true, at = @At("HEAD"))
private void arclight$anger(Entity entity, CallbackInfoReturnable<Boolean> cir) {
PigZombieAngerEvent event = new PigZombieAngerEvent((PigZombie) this.bridge$getBukkitEntity(), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), this.func_223336_ef());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(false);
} else {
arclight$capture = event.getNewAnger();
}
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class CraftEventFactoryMixin method arclight$unhandledDamage.
@Inject(method = "handleEntityDamageEvent(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/DamageSource;Ljava/util/Map;Ljava/util/Map;Z)Lorg/bukkit/event/entity/EntityDamageEvent;", cancellable = true, at = @At(value = "NEW", target = "java/lang/IllegalStateException"))
private static void arclight$unhandledDamage(Entity entity, DamageSource source, Map<EntityDamageEvent.DamageModifier, Double> modifiers, Map<EntityDamageEvent.DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled, CallbackInfoReturnable<EntityDamageEvent> cir) {
// todo blockDamage is lost
EntityDamageEvent event;
if (source.getTrueSource() != null) {
ArclightMod.LOGGER.debug("Unhandled damage of {} by {} from {}", entity, source.getTrueSource(), source.damageType);
event = new EntityDamageByEntityEvent(((EntityBridge) source.getTrueSource()).bridge$getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), EntityDamageEvent.DamageCause.CUSTOM, modifiers, modifierFunctions);
} else {
ArclightMod.LOGGER.debug("Unhandled damage of {} from {}", entity, source.damageType);
event = new EntityDamageEvent(((EntityBridge) entity).bridge$getBukkitEntity(), EntityDamageEvent.DamageCause.CUSTOM, modifiers, modifierFunctions);
}
event.setCancelled(cancelled);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
((EntityBridge) entity).bridge$getBukkitEntity().setLastDamageCause(event);
}
cir.setReturnValue(event);
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class ServerWorldMixin method arclight$lightningEvent.
@Inject(method = "addLightningBolt", cancellable = true, at = @At("HEAD"))
public void arclight$lightningEvent(LightningBoltEntity entityIn, CallbackInfo ci) {
LightningStrikeEvent event = new LightningStrikeEvent(this.getWorld(), (LightningStrike) ((EntityBridge) entityIn).bridge$getBukkitEntity(), arclight$cause);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
ci.cancel();
}
arclight$cause = null;
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class CauldronBlockMixin_1_15 method changeLevel.
private boolean changeLevel(World world, BlockPos pos, BlockState state, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
int newLevel = MathHelper.clamp(i, 0, 3);
CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(CraftBlock.at(world, pos), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), reason, state.get(CauldronBlock.LEVEL), newLevel);
Bukkit.getPluginManager().callEvent(event);
return !event.isCancelled();
}
Aggregations