Skip to content

Commit

Permalink
First attempt at lectern repair
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Sep 15, 2024
1 parent 5fa5389 commit f56c945
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.countercraft.movecraft.repair.tasks;

import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.world.block.BaseBlock;
import org.bukkit.Location;

public class LecternRepair extends RepairTask {
private final BaseBlock block;

public LecternRepair(Location location, BaseBlock block) {
super(location);
this.block = block;
}

@Override
public void execute() {
try {
BukkitAdapter.adapt(location.getWorld()).setBlock(BukkitAdapter.asBlockVector(location), block, SideEffectSet.none());
} catch (WorldEditException e) {
throw new RuntimeException("Unable to set block", e);
}
done = true;
}

@Override
public int getPriority() {
return -10000;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.UUID;

import net.countercraft.movecraft.repair.config.Config;
import net.countercraft.movecraft.repair.tasks.LecternRepair;
import net.countercraft.movecraft.util.hitboxes.BitmapHitBox;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand Down Expand Up @@ -152,6 +153,17 @@ public ProtoRepair execute(@NotNull Sign sign) throws WorldEditException, ProtoR
queue.add(signRepair);
}

// Handle lectern repair
if (schematicMaterial == Material.LECTERN && blockRepair != null) {
LecternRepair lecternRepair = new LecternRepair(
worldPosition,
schematicBlock
);
lecternRepair.setDependency(blockRepair);
queue.add(lecternRepair);
continue;
}

// Handle inventory repair
Counter<Material> schematicContents = WEUtils.getBlockContents(schematicBlock);
Pair<Boolean, Counter<Material>> inventoryRepair = RepairUtils.checkInventoryRepair(worldMaterial, worldState, schematicContents);
Expand Down

0 comments on commit f56c945

Please sign in to comment.