Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lebonq/Automatic-Path
Browse files Browse the repository at this point in the history
  • Loading branch information
lebonq committed Mar 26, 2021
2 parents f2e8e8a + f33c162 commit b1b76a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/fr/lebon/autopath/mixin/BlockOnStepped.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

@Mixin(Block.class)
public class BlockOnStepped {
@Inject(method = "onSteppedOn", cancellable = true, at = @At(value = "HEAD"))
private void transformGrassToPathWhenSteppedOn(World world, BlockPos pos, Entity entity,CallbackInfo cir) {
if(world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)){ //select grass
if(world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK) && (entity instanceof LivingEntity)){ //select grass and if entity is a mob or player
world.setBlockState(pos,AutoPath.PATH_BLOCK.getDefaultState()); //On remplace par un block path
cir.cancel();
}
Expand Down

0 comments on commit b1b76a2

Please sign in to comment.