Changes

251 bytes added ,  13:31, 20 April 2021
add client checks
Line 14: Line 14:  
public void onBlockBreak(final BlockEvent.BreakEvent event)
 
public void onBlockBreak(final BlockEvent.BreakEvent event)
 
     {
 
     {
         if (event.getState().is(Tags.Blocks.SAND)) // use the base event to get the state and see what it is
+
         if (!world.isClientSide() && event.getState().is(Tags.Blocks.SAND)) // use the base event to get the state and see what it is
 
         {
 
         {
 
             event.setExpToDrop(10); // change the amount of experience we'll be dropping
 
             event.setExpToDrop(10); // change the amount of experience we'll be dropping
Line 47: Line 47:  
     {
 
     {
 
         Entity entity = event.getEntity();
 
         Entity entity = event.getEntity();
         if (entity != null) // check if the entity is null
+
         if (!world.isClientSide() && entity != null) // check if the entity is null
 
         {
 
         {
 
             Block block = event.getState().getBlock(); // get the block that was placed
 
             Block block = event.getState().getBlock(); // get the block that was placed
Line 81: Line 81:  
public void onNeighborNotify(final BlockEvent.BreakEvent event)
 
public void onNeighborNotify(final BlockEvent.BreakEvent event)
 
     {
 
     {
 +
        if (world.isClientSide()) return;
 
         BlockPos eventPos = event.getPos();
 
         BlockPos eventPos = event.getPos();
 
         for (Direction direction : event.getNotifiedSides()) // cycle through notified directions
 
         for (Direction direction : event.getNotifiedSides()) // cycle through notified directions
Line 105: Line 106:  
public void onNeighborNotify(final BlockEvent.BreakEvent event)
 
public void onNeighborNotify(final BlockEvent.BreakEvent event)
 
     {
 
     {
         if (event.getPos().getY() > 100)
+
         if (!world.isClientSide() && event.getPos().getY() > 100)
 
         {
 
         {
 
             event.setResult(Event.Result.DENY); // prevent source creation above y = 100
 
             event.setResult(Event.Result.DENY); // prevent source creation above y = 100
Line 127: Line 128:  
public void onBreak(final BlockEvent.BreakEvent event)
 
public void onBreak(final BlockEvent.BreakEvent event)
 
     {
 
     {
 +
        if (world.isClientSide()) return;
 
         BlockState newState = event.getNewState();
 
         BlockState newState = event.getNewState();
 
         if (newState.is(Blocks.FIRE))
 
         if (newState.is(Blocks.FIRE))
Line 155: Line 157:  
public void onCropGrowPre(final BlockEvent.CropGrowEvent.Pre event)
 
public void onCropGrowPre(final BlockEvent.CropGrowEvent.Pre event)
 
     {
 
     {
 +
        if (world.isClientSide()) return;
 
         BlockState state = event.getState();
 
         BlockState state = event.getState();
 
         if (state.is(Blocks.WHEAT))
 
         if (state.is(Blocks.WHEAT))
Line 186: Line 189:  
public void onTrample(final BlockEvent.FarmlandTrampleEvent event)
 
public void onTrample(final BlockEvent.FarmlandTrampleEvent event)
 
     {
 
     {
         if (event.getFallDistance() < 10.0F)
+
         if (!world.isClientSide() && event.getFallDistance() < 10.0F)
 
         {
 
         {
 
             event.setCanceled(true); // change conditions for trampling
 
             event.setCanceled(true); // change conditions for trampling
Line 211: Line 214:  
public void onToolInteract(final BlockEvent.BlockToolInteractEvent event)
 
public void onToolInteract(final BlockEvent.BlockToolInteractEvent event)
 
     {
 
     {
         if (event.getFinalState().is(Blocks.FARMLAND) && event.getHeldItemStack().getItem() == Items.NETHERITE_HOE)
+
         if (!world.isClientSide() && event.getFinalState().is(Blocks.FARMLAND) && event.getHeldItemStack().getItem() == Items.NETHERITE_HOE)
 
         {
 
         {
 
             event.setFinalState(Blocks.NETHERRACK.defaultBlockState()); // change the final state under certain conditions
 
             event.setFinalState(Blocks.NETHERRACK.defaultBlockState()); // change the final state under certain conditions
16

edits