Adds the block restore code to the Runner
This commit is contained in:
parent
01f269e123
commit
7472db98d5
1 changed files with 29 additions and 0 deletions
|
@ -1,8 +1,20 @@
|
|||
package dev.zontreck.libzontreck.memory.world;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3d;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockRestoreRunner implements Runnable
|
||||
{
|
||||
private BlockRestoreQueue queue;
|
||||
public final SoundEvent pop = SoundEvents.ITEM_PICKUP;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -10,6 +22,23 @@ public class BlockRestoreRunner implements Runnable
|
|||
|
||||
PrimitiveBlock prim = queue.getNextBlock();
|
||||
|
||||
Level level = prim.level;
|
||||
|
||||
// Everything is restored, play sound
|
||||
SoundSource ss = SoundSource.NEUTRAL;
|
||||
BlockPos pos = prim.position;
|
||||
Random rng = new Random();
|
||||
|
||||
level.playSound(null, pos, pop, ss, rng.nextFloat(0.75f,1.0f), rng.nextFloat(1));
|
||||
|
||||
level.setBlock(pos, prim.blockState, Block.UPDATE_NONE, 0);
|
||||
|
||||
BlockEntity entity = level.getBlockEntity(pos);
|
||||
if(entity != null)
|
||||
{
|
||||
entity.load(prim.blockEntity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue