mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Add GetCollisionBoxesEvent. Allows manipulation of the collision boxes for moving entities and entities stuck in walls. (#3397)
This commit is contained in:
1 parent
6b52023a5c
commit
2f802b6d71
3 files changed
+91
No files matched your search
@@ -109,6 +109,15 @@
|
||||
this.field_184239_as = null;
|
||||
entity.func_184225_p(this);
|
||||
}
|
||||
@@ -2182,7 +2201,7 @@
|
||||
double d1 = p_145771_3_ - (double)blockpos.func_177956_o();
|
||||
double d2 = p_145771_5_ - (double)blockpos.func_177952_p();
|
||||
List<AxisAlignedBB> list = this.field_70170_p.func_147461_a(this.func_174813_aQ());
|
||||
-
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.GetCollisionBoxesEvent(this.field_70170_p, this, this.func_174813_aQ(), list));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
return false;
|
||||
@@ -2336,6 +2355,7 @@
|
||||
{
|
||||
if (!this.field_70170_p.field_72995_K && !this.field_70128_L)
|
||||
|
||||
@@ -206,6 +206,15 @@
|
||||
this.func_72964_e(i, j).func_76612_a(p_72838_1_);
|
||||
this.field_72996_f.add(p_72838_1_);
|
||||
this.func_72923_a(p_72838_1_);
|
||||
@@ -1221,7 +1284,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.GetCollisionBoxesEvent(this, p_184144_1_, p_184144_2_, list));
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1296,7 +1359,6 @@
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.event.world;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This event is fired after {@link Entity#pushOutOfBlocks(double, double, double)} calls {@link World#getCollisionBoxes(AxisAlignedBB)}
|
||||
* and before returning the list in {@link World#getCollisionBoxes(Entity, AxisAlignedBB)}<br>
|
||||
* <br>
|
||||
* {@link #entity} contains the entity calling {@link Entity#pushOutOfBlocks(double, double, double)} or the entity passed in the {@link World#getCollisionBoxes(Entity, AxisAlignedBB)}. <b>Can be null.</b><br>
|
||||
* {@link #aabb} contains the AxisAlignedBB passed in the method.<br>
|
||||
* {@link #collisionBoxesList} contains the list of detected collision boxes intersecting with {@link #aabb}. The list can be modified.<br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult} <br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public class GetCollisionBoxesEvent extends WorldEvent
|
||||
{
|
||||
private final Entity entity;
|
||||
private final AxisAlignedBB aabb;
|
||||
private final List<AxisAlignedBB> collisionBoxesList;
|
||||
|
||||
public GetCollisionBoxesEvent(World world, @Nullable Entity entity, AxisAlignedBB aabb, List<AxisAlignedBB> collisionBoxesList)
|
||||
{
|
||||
super(world);
|
||||
this.entity = entity;
|
||||
this.aabb = aabb;
|
||||
this.collisionBoxesList = collisionBoxesList;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAabb()
|
||||
{
|
||||
return aabb;
|
||||
}
|
||||
|
||||
public List<AxisAlignedBB> getCollisionBoxesList()
|
||||
{
|
||||
return collisionBoxesList;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user