Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to EnderIO travel + teleportation #158

Merged
merged 17 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/main/java/crazypants/enderio/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,34 @@ public String lc() {
*/
public static int teleportStaffFailedBlinkDistance = 64;

/**
* Sets the teleport staff right-click action.
*
* <p>
* Values:
* <ul>
* <li><b>0:</b> Do nothing
* <li><b>1:</b> Teleport to look
* <li><b>2:</b> Teleport to anchor
* <li><b>3:</b> Teleport to anchor, or to look if no anchor <em>(default)</em>
* </ul>
*/
public static int teleportStaffAction = 3;

/**
* Sets the teleport staff sneak right-click action.
*
* <p>
* Values:
* <ul>
* <li><b>0:</b> Do nothing
* <li><b>1:</b> Teleport to look <em>(default)</em>
* <li><b>2:</b> Teleport to anchor
* <li><b>3:</b> Teleport to anchor, or to look if no anchor
* </ul>
*/
public static int teleportStaffSneakAction = 1;

public static int enderIoRange = 8;
public static boolean enderIoMeAccessEnabled = true;

Expand Down Expand Up @@ -1269,6 +1297,27 @@ public static void processConfig(Configuration config) {
"Number of blocks teleported when no block is being looked at.")
.getInt(teleportStaffFailedBlinkDistance);

teleportStaffAction = config.get(
sectionStaff.name,
"teleportStaffAction",
teleportStaffAction,
"Sets the action for right-click with the staff of teleportation. Values:\n" + " 0: Do nothing\n"
+ " 1: Teleport to look\n"
+ " 2: Teleport to anchor\n"
+ " 3: Teleport to anchor, or look if no anchor (default)")
.getInt(teleportStaffAction);

teleportStaffSneakAction = config.get(
sectionStaff.name,
"teleportStaffSneakAction",
teleportStaffSneakAction,
"Sets the action for sneak right-click with the staff of teleportation. Values:\n"
+ " 0: Do nothing\n"
+ " 1: Teleport to look (default)\n"
+ " 2: Teleport to anchor\n"
+ " 3: Teleport to anchor, or look if no anchor")
.getInt(teleportStaffSneakAction);

enderIoRange = config.get(
sectionEfficiency.name,
"enderIoRange",
Expand Down
29 changes: 23 additions & 6 deletions src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import crazypants.enderio.EnderIO;
import crazypants.enderio.ModObject;
import crazypants.enderio.api.teleport.TravelSource;
import crazypants.enderio.config.Config;
import crazypants.enderio.machine.power.PowerDisplayUtil;

public class ItemTeleportStaff extends ItemTravelStaff {
Expand Down Expand Up @@ -56,14 +57,30 @@ public void registerIcons(IIconRegister IIconRegister) {
@Override
public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
if (world.isRemote) {
if (player.isSneaking()) {
TravelController.instance
.activateTravelAccessable(equipped, world, player, TravelSource.TELEPORT_STAFF);
} else {
TravelController.instance.doTeleport(player);
int action = player.isSneaking() ? Config.teleportStaffSneakAction : Config.teleportStaffAction;
switch (action) {
case 0:
// Do nothing.
break;

case 1:
TravelController.instance.doTeleport(player);
player.swingItem();
break;

case 2:
TravelController.instance
.activateTravelAccessable(equipped, world, player, TravelSource.TELEPORT_STAFF);
player.swingItem();
break;

case 3:
TravelController.instance
.activateTravelAccessable(equipped, world, player, TravelSource.TELEPORT_STAFF, true);
player.swingItem();
break;
}
}
player.swingItem();
return equipped;
}

Expand Down
Loading