mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-13 00:47:52 +00:00
Added handling case for mods that call removeBlockByPlayer when the player isn't looking at the block.
Added guard for mods that recursively call PlayerInteractEvent. Fixed npe when obtaining class bytes in ASMMixinCompiler
This commit is contained in:
1 parent
09c387ae6c
commit
e7ec7db447
3 files changed
+31
-9
No files matched your search
@@ -95,13 +95,14 @@ trait BlockMultipart extends Block
|
||||
|
||||
override def removeBlockByPlayer(world:World, player:EntityPlayer, x:Int, y:Int, z:Int):Boolean =
|
||||
{
|
||||
val hit = RayTracer.retraceBlock(world, player, x, y, z);
|
||||
if(hit == null)
|
||||
return false;
|
||||
|
||||
val hit = RayTracer.retraceBlock(world, player, x, y, z)
|
||||
val tile = getTile(world, x, y, z)
|
||||
if(tile == null)
|
||||
return false
|
||||
|
||||
if(hit == null || tile == null)
|
||||
{
|
||||
dropAndDestroy(world, x, y, z)
|
||||
return true
|
||||
}
|
||||
|
||||
val hitInfo:(Int, _) = ExtendedMOP.getData(hit)
|
||||
if(world.isRemote)
|
||||
@@ -113,6 +114,15 @@ trait BlockMultipart extends Block
|
||||
return tile.harvestPart(hitInfo._1, !player.capabilities.isCreativeMode);
|
||||
}
|
||||
|
||||
def dropAndDestroy(world:World, x:Int, y:Int, z:Int)
|
||||
{
|
||||
val tile = getTile(world, x, y, z)
|
||||
if(tile != null && !world.isRemote)
|
||||
tile.dropItems(getBlockDropped(world, x, y, z, 0, 0))
|
||||
|
||||
world.setBlockToAir(x, y, z)
|
||||
}
|
||||
|
||||
override def quantityDropped(meta:Int, fortune:Int, random:Random) = 0
|
||||
|
||||
override def getBlockDropped(world:World, x:Int, y:Int, z:Int, meta:Int, fortune:Int):ArrayList[ItemStack] =
|
||||
|
||||
@@ -78,7 +78,10 @@ object ASMMixinCompiler
|
||||
def getBytes(name:String) =
|
||||
{
|
||||
val jName = name.replace('/', '.')
|
||||
m_runTransformers.invoke(cl, jName, jName, cl.getClassBytes(jName)).asInstanceOf[Array[Byte]]
|
||||
cl.getClassBytes(jName) match {
|
||||
case null => null
|
||||
case v => m_runTransformers.invoke(cl, jName, jName, v).asInstanceOf[Array[Byte]]
|
||||
}
|
||||
}
|
||||
|
||||
def internalDefine(name:String, bytes:Array[Byte])
|
||||
|
||||
@@ -19,11 +19,20 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
|
||||
public class EventHandler
|
||||
{
|
||||
private ThreadLocal<Object> placing = new ThreadLocal<Object>();
|
||||
|
||||
@ForgeSubscribe
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote && place(event.entityPlayer, event.entityPlayer.worldObj))
|
||||
event.setCanceled(true);
|
||||
if(event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote)
|
||||
{
|
||||
if(placing.get() != null)
|
||||
return;//for mods that do dumb stuff and call this event like MFR
|
||||
placing.set(event);
|
||||
if(place(event.entityPlayer, event.entityPlayer.worldObj))
|
||||
event.setCanceled(true);
|
||||
placing.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean place(EntityPlayer player, World world)
|
||||
|
||||
Reference in new issue
Block a user