Skip to content

Commit

Permalink
Changed toggle print keybind from M+O to caps lock
Browse files Browse the repository at this point in the history
Added a hold keybind for printing
Fixed (partly) skulls and observers
  • Loading branch information
aleksilassila committed Dec 17, 2021
1 parent 55e19ab commit 62d2080
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public static ImmutableList<IConfigBase> getConfigList() {
}

// Hotkeys
public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "M,O", "Allows quickly toggling on/off Printing mode");
public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", "Prints while pressed");
public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", "Allows quickly toggling on/off Printing mode");

public static List<ConfigHotkey> getHotkeyList() {
List<ConfigHotkey> list = new java.util.ArrayList<>(List.copyOf(Hotkeys.HOTKEY_LIST));
list.add(PRINT);
list.add(TOGGLE_PRINTING_MODE);

return ImmutableList.copyOf(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayNetworkHandler.class)
public class ClientPlayNetworkHandlerMixin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public void tick(CallbackInfo ci) {
return;
}

if (SchematicWorldHandler.getSchematicWorld() == null || !LitematicaMixinMod.PRINT_MODE.getBooleanValue()) return;
if (SchematicWorldHandler.getSchematicWorld() == null ||
!(LitematicaMixinMod.PRINT_MODE.getBooleanValue() || LitematicaMixinMod.PRINT.getKeybind().isPressed()))
return;

printer.onTick();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum PlacementGuide {
AMETHYST(AmethystClusterBlock.class),
DOOR(DoorBlock.class),
COCOA(CocoaBlock.class),
OBSERVER(ObserverBlock.class),
WALLSKULL(WallSkullBlock.class),
SKIP(SkullBlock.class, GrindstoneBlock.class, SignBlock.class, AbstractLichenBlock.class, VineBlock.class),
DEFAULT;

Expand All @@ -51,7 +53,7 @@ private static PlacementGuide getGuide(BlockState requiredState) {

public static Placement getPlacement(BlockState requiredState) {
switch (getGuide(requiredState)) {
case WALLTORCH, ROD, AMETHYST -> { // FIXME check if the wall exists?
case WALLTORCH, ROD, AMETHYST, SHULKER -> {
return new Placement(((Direction) getPropertyByName(requiredState, "FACING")).getOpposite(),
null,
null);
Expand Down Expand Up @@ -91,15 +93,15 @@ public static Placement getPlacement(BlockState requiredState) {
Direction side = switch ((WallMountLocation) getPropertyByName(requiredState, "FACE")) {
case FLOOR -> Direction.DOWN;
case CEILING -> Direction.UP;
default -> (Direction) getPropertyByName(requiredState, "FACING");
default -> ((Direction) getPropertyByName(requiredState, "FACING")).getOpposite();
};

Direction look = getPropertyByName(requiredState, "FACE") == WallMountLocation.WALL ?
null : (Direction) getPropertyByName(requiredState, "FACING");

return new Placement(side,
null,
look);
look).setCantPlaceInAir(true);
}
// case GRINDSTONE -> { // Tese are broken
// Direction side = switch ((WallMountLocation) getPropertyByName(requiredState, "FACE")) {
Expand All @@ -120,11 +122,6 @@ public static Placement getPlacement(BlockState requiredState) {
null,
(Direction) getPropertyByName(requiredState, "FACING"));
}
case SHULKER -> {
return new Placement(requiredState.get(ShulkerBoxBlock.FACING).getOpposite(),
null,
null);
}
case BED -> {
if (requiredState.get(BedBlock.PART) != BedPart.FOOT) {
return new Placement();
Expand Down Expand Up @@ -160,6 +157,9 @@ public static Placement getPlacement(BlockState requiredState) {
hitModifier,
requiredState.get(DoorBlock.FACING));
}
case WALLSKULL -> {
return new Placement(requiredState.get(WallSkullBlock.FACING).getOpposite(), null, null);
}
case SKIP -> {
return new Placement();
}
Expand Down Expand Up @@ -207,7 +207,9 @@ public static class Placement {
@Nullable
public final Direction look;

final boolean sideIsAxis;
boolean sideIsAxis = false;

boolean cantPlaceInAir = false;
boolean skip;

public Placement(@Nullable Direction side, @Nullable Vec3d hitModifier, @Nullable Direction look, boolean sideIsAxis) {
Expand All @@ -227,5 +229,16 @@ public Placement() {
this(null, null, null, false);
this.skip = true;
}

public Placement setSideIsAxis(boolean sideIsAxis) {
this.sideIsAxis = sideIsAxis;

return this;
}

public Placement setCantPlaceInAir(boolean cantPlaceInAir) {
this.cantPlaceInAir = cantPlaceInAir;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void onTick() {
} else if (shouldPrintHere(pos, placement) && playerHasAccessToItem(requiredState.getBlock().asItem())) {
boolean doubleChest = requiredState.contains(ChestBlock.CHEST_TYPE) && requiredState.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE;
Direction side = placement.side == null ? Direction.DOWN : placement.side;
BlockPos neighbor = pos; // If placing in air, there's no neighbor
BlockPos neighbor = placement.cantPlaceInAir ? pos.offset(side) : pos; // If placing in air, there's no neighbor

Vec3d hit = Vec3d.ofCenter(pos).add(Vec3d.of(side.getVector()).multiply(0.5));

Expand Down

0 comments on commit 62d2080

Please sign in to comment.