Skip to content

Commit

Permalink
Merge pull request #17 from aria1th/Experimental-AccurateBlockPlacement
Browse files Browse the repository at this point in the history
support Accurate block placement
  • Loading branch information
aria1th authored Aug 16, 2021
2 parents 5a812c2 + fe49594 commit 2893f38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class LitematicaMixinMod implements ModInitializer {
public static final ConfigBoolean CLEAR_AREA_MODE = new ConfigBoolean("easyPlaceModeClearFluids", false, "It will try to place slime blocks at fluids anywhere to clear");
public static final ConfigBoolean CLEAR_AREA_MODE_COBBLESTONE = new ConfigBoolean("ClearFluidsUseCobblestone", false, "It will try to place Cobblestone at anywhere to clear");
public static final ConfigBoolean CLEAR_AREA_MODE_SNOWPREVENT = new ConfigBoolean("ClearSnowLayer", false, "It will try to place string when snow layer is found");
public static final ConfigBoolean ACCURATE_BLOCK_PLACEMENT = new ConfigBoolean("AccurateBlockPlacement",false,"if carpet extra/quickcarpet enabled it, turn on");

public static final ImmutableList<IConfigBase> betterList = ImmutableList.of(
Configs.Generic.AREAS_PER_WORLD,
//BETTER_RENDER_ORDER,
Expand Down Expand Up @@ -57,7 +59,8 @@ public class LitematicaMixinMod implements ModInitializer {
FLIPPIN_CACTUS,
CLEAR_AREA_MODE,
CLEAR_AREA_MODE_COBBLESTONE,
CLEAR_AREA_MODE_SNOWPREVENT
CLEAR_AREA_MODE_SNOWPREVENT,
ACCURATE_BLOCK_PLACEMENT

);
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static io.github.eatmyvenom.litematicin.LitematicaMixinMod.CLEAR_AREA_MODE;
import static io.github.eatmyvenom.litematicin.LitematicaMixinMod.CLEAR_AREA_MODE_COBBLESTONE;
import static io.github.eatmyvenom.litematicin.LitematicaMixinMod.CLEAR_AREA_MODE_SNOWPREVENT;
import static io.github.eatmyvenom.litematicin.LitematicaMixinMod.ACCURATE_BLOCK_PLACEMENT;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
Expand All @@ -28,6 +29,7 @@
import fi.dy.masa.litematica.util.InventoryUtils;
import fi.dy.masa.litematica.util.RayTraceUtils;
import fi.dy.masa.litematica.util.RayTraceUtils.RayTraceWrapper;
import fi.dy.masa.litematica.util.WorldUtils;
import fi.dy.masa.litematica.world.SchematicWorldHandler;
import fi.dy.masa.malilib.util.IntBoundingBox;
import fi.dy.masa.malilib.util.LayerRange;
Expand Down Expand Up @@ -271,6 +273,7 @@ public static ActionResult doPrinterAction(MinecraftClient mc) {
int posZ = tracePos.getZ();
boolean ClearArea = CLEAR_AREA_MODE.getBooleanValue(); // if its true, will ignore everything and remove fluids.
boolean UseCobble = CLEAR_AREA_MODE_COBBLESTONE.getBooleanValue();
boolean CanUseProtocol = ACCURATE_BLOCK_PLACEMENT.getBooleanValue();
SubChunkPos cpos = new SubChunkPos(tracePos);
List<PlacementPart> list = DataManager.getSchematicPlacementManager().getAllPlacementsTouchingSubChunk(cpos);

Expand Down Expand Up @@ -611,7 +614,7 @@ else if (sBlock instanceof ObserverBlock || sBlock instanceof PistonBlock) {
.getFirstPropertyFacingValue(stateSchematic);
if (facing != null) {
FacingData facedata = getFacingData(stateSchematic);
if (!canPlaceFace(facedata, stateSchematic, mc.player, primaryFacing, horizontalFacing))
if (!CanUseProtocol && !canPlaceFace(facedata, stateSchematic, mc.player, primaryFacing, horizontalFacing))
continue;

if ((stateSchematic.getBlock() instanceof DoorBlock
Expand Down Expand Up @@ -745,6 +748,7 @@ else if (sBlock instanceof ObserverBlock || sBlock instanceof PistonBlock) {
Vec3d hitPos = new Vec3d(offX, offY, offZ);
// Carpet Accurate Placement protocol support, plus BlockSlab support
hitPos = applyHitVec(npos, stateSchematic, hitPos, side);
if(CanUseProtocol) {hitPos = WorldUtils.applyCarpetProtocolHitVec(npos,stateSchematic,hitPos);} else {hitPos = applyHitVec(npos, stateSchematic, hitPos, side);}

// Mark that this position has been handled (use the non-offset position that is
// checked above)
Expand Down

0 comments on commit 2893f38

Please sign in to comment.