-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed placement of sings, skulls and banners
- Loading branch information
1 parent
33e40b0
commit dc8a26b
Showing
15 changed files
with
134 additions
and
67 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
...n/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RotatingBlockGuide.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,56 @@ | ||
package me.aleksilassila.litematica.printer.v1_19.guides.placement; | ||
|
||
import me.aleksilassila.litematica.printer.v1_19.PrinterPlacementContext; | ||
import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; | ||
import me.aleksilassila.litematica.printer.v1_19.actions.Action; | ||
import me.aleksilassila.litematica.printer.v1_19.actions.PrepareAction; | ||
import net.minecraft.block.*; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.math.Direction; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class RotatingBlockGuide extends BlockPlacementGuide { | ||
public RotatingBlockGuide(SchematicBlockState state) { | ||
super(state); | ||
} | ||
|
||
@Override | ||
protected List<Direction> getPossibleSides() { | ||
Block block = state.targetState.getBlock(); | ||
if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { | ||
Optional<Direction> side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); | ||
return side.map(Collections::singletonList).orElseGet(Collections::emptyList); | ||
} | ||
|
||
return Collections.singletonList(Direction.DOWN); | ||
} | ||
|
||
@Override | ||
public boolean skipOtherGuides() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public List<Action> execute(ClientPlayerEntity player) { | ||
PrinterPlacementContext ctx = getPlacementContext(player); | ||
|
||
if (ctx == null) return null; | ||
|
||
int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); | ||
if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { | ||
rotation = (rotation + 8) % 16; | ||
} | ||
|
||
int distTo0 = rotation > 8 ? 16 - rotation : rotation; | ||
float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); | ||
|
||
List<Action> actions = super.execute(player); | ||
actions.set(0, new PrepareAction(ctx, yaw, 0)); | ||
|
||
return actions; | ||
} | ||
} |
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
Oops, something went wrong.