mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Merge pull request #1723 from Geforce132/master
Add an EntityMountEvent.
This commit is contained in:
commit
888bab92c3
4 files changed
+96
-6
No files matched your search
@@ -39,6 +39,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.brewing.PotionBrewEvent;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityMountEvent;
|
||||
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
||||
@@ -341,6 +342,19 @@ public class ForgeEventFactory
|
||||
{
|
||||
return !MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(player, entity));
|
||||
}
|
||||
|
||||
public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting)
|
||||
{
|
||||
boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.worldObj, isMounting));
|
||||
|
||||
if(isCanceled)
|
||||
{
|
||||
entityMounting.setPositionAndRotation(entityMounting.posX, entityMounting.posY, entityMounting.posZ, entityMounting.prevRotationYaw, entityMounting.prevRotationPitch);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EnumStatus onPlayerSleepInBed(EntityPlayer player, BlockPos pos)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
|
||||
|
||||
/**
|
||||
* This event gets fired whenever a entity mounts/dismounts another entity.<br>
|
||||
* <b>entityBeingMounted can be null</b>, be sure to check for that.
|
||||
* <br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
* If this event is canceled, the entity does not mount/dismount the other entity.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
*<br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
*
|
||||
*/
|
||||
|
||||
@Cancelable
|
||||
public class EntityMountEvent extends EntityEvent
|
||||
{
|
||||
|
||||
public final Entity entityMounting;
|
||||
public final Entity entityBeingMounted;
|
||||
public final World worldObj;
|
||||
|
||||
private final boolean isMounting;
|
||||
|
||||
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, World entityWorld, boolean isMounting)
|
||||
{
|
||||
super(entityMounting);
|
||||
this.entityMounting = entityMounting;
|
||||
this.entityBeingMounted = entityBeingMounted;
|
||||
this.worldObj = entityWorld;
|
||||
this.isMounting = isMounting;
|
||||
}
|
||||
|
||||
public boolean isMounting()
|
||||
{
|
||||
return isMounting;
|
||||
}
|
||||
|
||||
public boolean isDismounting()
|
||||
{
|
||||
return !isMounting;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user