Skip to content

Commit

Permalink
some raycast (not final)
Browse files Browse the repository at this point in the history
  • Loading branch information
warior456 committed Jan 6, 2024
1 parent 4c79215 commit 3637cd7
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -18,8 +19,21 @@ public LesterSpawningBlock(Settings settings) {
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
if(world.isClient())return;
Entity entity = new LesterEntity(ModEntities.LESTER, (World) world);

entity.setPosition(pos.getX(),pos.getY(),pos.getZ());
System.out.println("yay");
int y = raycastup(pos, (World)world);
entity.setPosition(pos.getX(), pos.up(y).getY(), pos.getZ());
world.spawnEntity(entity);
}

public int raycastup (BlockPos pos, World world){
Block block = world.getBlockState(pos.up()).getBlock();
int i= 0;
System.out.println(i);
while (block == Blocks.AIR && !(i > 20)){
System.out.println(i);
i++;
block = world.getBlockState(pos.up(i)).getBlock();
}
return i;
}
}

0 comments on commit 3637cd7

Please sign in to comment.