Skip to content

Commit

Permalink
Add fit Neighbor setting to wrench
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai-Z-JP committed Jun 6, 2021
1 parent 8063eef commit b44704b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/main/java/jp/ngt/rtm/item/ItemWrench.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ public void onRightClickMarker(ItemStack itemStack, World world, EntityPlayer pl
case 9:
this.changeMarkerAnchor(world, player, marker);
break;
case 10:
marker.fitNeighbor ^= true;
if (world.isRemote) {
NGTLog.sendChatMessage(player, "Set fit neighbor rail: " + marker.fitNeighbor);
}
break;
}
}

private void changeMode(World world, ItemStack itemStack, EntityPlayer player) {
int i = (itemStack.getItemDamage() + 1) % 10;
int i = (itemStack.getItemDamage() + 1) % 11;
if (i >= 2 && i <= 5) {
i = 6;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/jp/ngt/rtm/rail/BlockMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ public boolean onMarkerActivated(World world, int x, int y, int z, EntityPlayer
.sorted(Comparator.comparingInt(o -> Math.abs(o.yCoord - y)))
.map(TileEntityMarker::getMarkerRP)
.collect(Collectors.toList());
list.forEach(rp -> rp.addHeight(prop.blockHeight - 0.0625F));
}

if (list.size() == 2 && list.stream().allMatch(rp -> rp.switchType == 1)) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/jp/ngt/rtm/rail/RenderMarkerBlock1122.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private boolean changeAnchor(TileEntityMarker marker) {
float cantLimit = 80.0F;
float cant = (pitchDif < -cantLimit) ? -cantLimit : (Math.min(pitchDif, cantLimit));
RailPosition neighborRP = getNeighborRail(marker);
if (neighborRP != null) {
if (neighborRP != null && marker.fitNeighbor) {
cant = -neighborRP.cantEdge;
}
rp.cantEdge = cant;
Expand Down Expand Up @@ -389,14 +389,14 @@ private boolean changeAnchor(TileEntityMarker marker) {
float length = (float) (dx / MathHelper.sin(dirRad));
float yaw = NGTMath.toDegrees(dirRad);
if (curElm == MarkerElement.HORIZONTIAL) {
if (neighborRP != null) {
if (neighborRP != null && marker.fitNeighbor) {
yaw = MathHelper.wrapAngleTo180_float(neighborRP.anchorYaw + 180.0F);
}
rp.anchorYaw = yaw;
rp.anchorLengthHorizontal = length;
} else if (curElm == MarkerElement.VERTICAL) {
float pitch = MathHelper.wrapAngleTo180_float(yaw - rp.anchorYaw);
if (neighborRP != null) {
if (neighborRP != null && marker.fitNeighbor) {
pitch = -neighborRP.anchorPitch;
} else if (fitOpposite) {
double dy = targetVec.yCoord - rp.posY;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/jp/ngt/rtm/rail/RenderMarkerBlock1710.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ private void changeAnchor(TileEntityMarker tileEntity)//Minecraft.1518-this.obje
float yaw = NGTMath.toDegrees(dirRad);

if (curElm == MarkerElement.HORIZONTIAL) {
if (neighborRP != null) {
if (neighborRP != null && tileEntity.fitNeighbor) {
yaw = MathHelper.wrapAngleTo180_float(neighborRP.anchorYaw + 180.0F);
}
rp.anchorYaw = yaw;
rp.anchorLengthHorizontal = length;
} else if (curElm == MarkerElement.VERTICAL) {
float pitch = MathHelper.wrapAngleTo180_float(yaw - rp.anchorYaw);
if (neighborRP != null) {
if (neighborRP != null && tileEntity.fitNeighbor) {
pitch = -neighborRP.anchorPitch;
} else if (fitOpposite) {
double dy = vec3.yCoord - rp.posY;
Expand All @@ -186,7 +186,7 @@ private void changeAnchor(TileEntityMarker tileEntity)//Minecraft.1518-this.obje
rp.anchorLengthVertical = length;
} else if (curElm == MarkerElement.CANT) {
float cant = MathHelper.wrapAngleTo180_float(yaw - rp.anchorYaw);
if (neighborRP != null) {
if (neighborRP != null && tileEntity.fitNeighbor) {
cant = -neighborRP.cantEdge;
}
rp.cantEdge = cant;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/jp/ngt/rtm/rail/TileEntityMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class TileEntityMarker extends TileEntity {

private int count;

public boolean fitNeighbor = true;

public TileEntityMarker() {
this.markerState = MarkerState.DISTANCE.set(this.markerState, true);
this.markerState = MarkerState.GRID.set(this.markerState, false);
Expand Down

0 comments on commit b44704b

Please sign in to comment.