Skip to content

Commit

Permalink
Fixed 1.19.4 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksilassila committed Apr 18, 2023
1 parent 21bb801 commit 110dfdf
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package me.aleksilassila.litematica.printer.v1_19_4.implementation;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;

public class PrinterPlacementContext extends ItemPlacementContext {
public final @Nullable Direction lookDirection;
public final boolean shouldSneak;
public final BlockHitResult hitResult;
public final int requiredItemSlot;

public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) {
this(player, hitResult, requiredItem, requiredItemSlot, null, false);
}

public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) {
super(player, Hand.MAIN_HAND, requiredItem, hitResult);

this.lookDirection = lookDirection;
this.shouldSneak = requiresSneaking;
this.hitResult = hitResult;
this.requiredItemSlot = requiredItemSlot;
}

@Override
public Direction getPlayerLookDirection() {
return lookDirection == null ? super.getPlayerLookDirection() : lookDirection;
}

@Override
public Direction getVerticalPlayerLookDirection() {
if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection())
return lookDirection;
return super.getVerticalPlayerLookDirection();
}

@Override
public Direction getHorizontalPlayerFacing() {
if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getHorizontalPlayerFacing();

return lookDirection;
}

@Override
public String toString() {
return "PrinterPlacementContext{" +
"lookDirection=" + lookDirection +
", requiresSneaking=" + shouldSneak +
", blockPos=" + hitResult.getBlockPos() +
", side=" + hitResult.getSide() +
// ", hitVec=" + hitResult +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.aleksilassila.litematica.printer.v1_19_4.implementation.actions;

import me.aleksilassila.litematica.printer.v1_19_4.PrinterPlacementContext;
import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext;
import me.aleksilassila.litematica.printer.v1_19_4.actions.InteractAction;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
Expand Down

0 comments on commit 110dfdf

Please sign in to comment.