Skip to content

Commit

Permalink
PostModification Event.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlgorithmX2 committed Nov 9, 2016
1 parent 53b75e3 commit eec0a0e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
@@ -0,0 +1,32 @@
package mod.chiselsandbits.api;

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Event;

public class EventBlockBitPostModification extends Event
{

private final World w;
private final BlockPos pos;

public EventBlockBitPostModification(
final World w,
final BlockPos pos )
{

this.w = w;
this.pos = pos;
}

public World getWorld()
{
return w;
}

public BlockPos getPos()
{
return pos;
}

}
Expand Up @@ -3,6 +3,7 @@
import java.util.Collection;
import java.util.Collections;

import mod.chiselsandbits.api.EventBlockBitPostModification;
import mod.chiselsandbits.api.EventFullBlockRestoration;
import mod.chiselsandbits.api.ItemType;
import mod.chiselsandbits.chiseledblock.data.VoxelBlob;
Expand Down Expand Up @@ -242,6 +243,15 @@ public IBlockState getBlockState(
public void setState(
final IExtendedBlockState state )
{
final VoxelBlobStateReference originalRef = getBasicState().getValue( BlockChiseled.UProperty_VoxelBlob );
final VoxelBlobStateReference newRef = state.getValue( BlockChiseled.UProperty_VoxelBlob );

if ( originalRef != null && newRef != null && !newRef.equals( originalRef ) )
{
final EventBlockBitPostModification bmm = new EventBlockBitPostModification( getWorld(), getPos() );
MinecraftForge.EVENT_BUS.post( bmm );
}

this.state = state;
}

Expand Down

0 comments on commit eec0a0e

Please sign in to comment.