Skip to content

Commit

Permalink
add more permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
xsun2001 committed Feb 16, 2018
1 parent f7102b0 commit 337d1c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/java/appeng/block/AEBaseTileBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.world.BlockEvent;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -259,6 +261,13 @@ public boolean onBlockActivated( final World w, final int x, final int y, final
return false;
}

BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( x, y, z, w, this, 0, player );
MinecraftForge.EVENT_BUS.post( event );
if( event.isCanceled() )
{
return false;
}

final ItemStack op = new ItemStack( this );
for( final ItemStack ol : drops )
{
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/appeng/parts/PartPlacement.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
Expand Down Expand Up @@ -104,8 +105,11 @@ public static boolean place( final ItemStack held, final int x, final int y, fin
final SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );

BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( x, y, z, world, block, world.getBlockMetadata( x, y, z ), player );
MinecraftForge.EVENT_BUS.post(event);
if(event.isCanceled()) return true;
MinecraftForge.EVENT_BUS.post( event );
if( event.isCanceled() )
{
return false;
}

if( sp.part != null )
{
Expand Down Expand Up @@ -361,6 +365,12 @@ else if( host != null && !host.canAddPart( held, side ) )
return false;
}

BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent( BlockSnapshot.getBlockSnapshot( world, x, y, z ), world.getBlock( x, y, z ), player );
MinecraftForge.EVENT_BUS.post( event );
if( event.isCanceled() )
{
return false;
}
final ForgeDirection mySide = host.addPart( held, side, player );
if( mySide != null )
{
Expand Down

0 comments on commit 337d1c8

Please sign in to comment.