-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21bb801
commit 110dfdf
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...a/me/aleksilassila/litematica/printer/v1_19_4/implementation/PrinterPlacementContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + | ||
'}'; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...e/aleksilassila/litematica/printer/v1_19_4/implementation/actions/InteractActionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters