use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class EntityMixin method arclight$entityDropItem.
@Inject(method = "entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/ItemEntity;", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public void arclight$entityDropItem(ItemStack stack, float offsetY, CallbackInfoReturnable<ItemEntity> cir, ItemEntity itementity) {
EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) ((EntityBridge) itementity).bridge$getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(null);
}
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class EntityMixin method addPassenger.
public boolean addPassenger(Entity entity) {
if (entity.getRidingEntity() != (Object) this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
// CraftBukkit start
com.google.common.base.Preconditions.checkState(!((EntityBridge) entity).bridge$getPassengers().contains(this), "Circular entity riding! %s %s", this, entity);
CraftEntity craft = (CraftEntity) ((EntityBridge) entity).bridge$getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity());
// Suppress during worldgen
if (this.valid) {
Bukkit.getPluginManager().callEvent(event);
}
CraftEntity craftn = (CraftEntity) ((EntityBridge) entity).bridge$getBukkitEntity().getVehicle();
Entity n = craftn == null ? null : craftn.getHandle();
if (event.isCancelled() || n != orig) {
return false;
}
}
// CraftBukkit end
// Spigot start
org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent(((EntityBridge) entity).bridge$getBukkitEntity(), this.getBukkitEntity());
// Suppress during worldgen
if (this.valid) {
Bukkit.getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
return false;
}
// Spigot end
if (!this.world.isRemote && entity instanceof PlayerEntity && !(this.getControllingPassenger() instanceof PlayerEntity)) {
this.passengers.add(0, entity);
} else {
this.passengers.add(entity);
}
}
// CraftBukkit
return true;
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class PressurePlateBlockMixin method computeRedstoneStrength.
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected int computeRedstoneStrength(World worldIn, BlockPos pos) {
AxisAlignedBB axisalignedbb = PRESSURE_AABB.offset(pos);
List<? extends Entity> list;
switch(this.sensitivity) {
case EVERYTHING:
list = worldIn.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
break;
case MOBS:
list = worldIn.getEntitiesWithinAABB(LivingEntity.class, axisalignedbb);
break;
default:
return 0;
}
if (!list.isEmpty()) {
for (Entity entity : list) {
if (this.getRedstoneStrength(worldIn.getBlockState(pos)) == 0) {
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()) {
continue;
}
}
if (!entity.doesEntityNotTriggerPressurePlate()) {
return 15;
}
}
}
return 0;
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class MobEntityMixin method arclight$attackCombust.
@Redirect(method = "attackEntityAsMob", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setFire(I)V"))
public void arclight$attackCombust(Entity entity, int seconds) {
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), seconds);
org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
if (!combustEvent.isCancelled()) {
((EntityBridge) entity).bridge$setOnFire(combustEvent.getDuration(), false);
}
}
use of io.izzel.arclight.common.bridge.entity.EntityBridge in project Arclight by IzzelAliz.
the class PhaseManagerMixin method setPhase.
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void setPhase(PhaseType<?> phaseIn) {
if (this.phase == null || phaseIn != this.phase.getType()) {
if (this.phase != null) {
this.phase.removeAreaEffect();
}
EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent((CraftEnderDragon) ((EntityBridge) this.dragon).bridge$getBukkitEntity(), (this.phase == null) ? null : CraftEnderDragon.getBukkitPhase(this.phase.getType()), CraftEnderDragon.getBukkitPhase(phaseIn));
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
phaseIn = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
this.phase = this.getPhase(phaseIn);
if (!this.dragon.world.isRemote) {
this.dragon.getDataManager().set(EnderDragonEntity.PHASE, phaseIn.getId());
}
LOGGER.debug("Dragon is now in phase {} on the {}", phaseIn, this.dragon.world.isRemote ? "client" : "server");
this.phase.initPhase();
}
}
Aggregations