Skip to content

Commit

Permalink
Add staff of teleportation (#89)
Browse files Browse the repository at this point in the history
* Add teleport staff

* Add support for long-range travel anchor teleportation

* Update buildscript + apply spotless

* Replace creative staff of travelling

* Add missing mapping handler and fix extract energy
  • Loading branch information
D-Cysteine authored Jan 27, 2023
1 parent d9b99f6 commit 0902a89
Show file tree
Hide file tree
Showing 20 changed files with 467 additions and 98 deletions.
28 changes: 21 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1671313514
//version: 1674409054
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -144,6 +144,7 @@ propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)

String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
Expand Down Expand Up @@ -319,9 +320,17 @@ if (file('addon.gradle').exists()) {
apply from: 'repositories.gradle'

configurations {
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
// TODO: remove Compile after all uses are refactored to Implementation
for (config in [
shadowImplementation,
shadowCompile,
shadeCompile
]) {
compileClasspath.extendsFrom(config)
runtimeClasspath.extendsFrom(config)
testCompileClasspath.extendsFrom(config)
testRuntimeClasspath.extendsFrom(config)
}
}

repositories {
Expand Down Expand Up @@ -350,7 +359,8 @@ dependencies {
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.3:processor')
if (usesMixinDebug.toBoolean()) {
runtimeOnly('org.jetbrains:intellij-fernflower:1.2.1.16')
runtimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
testRuntimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
Expand Down Expand Up @@ -406,7 +416,9 @@ shadowJar {
attributes(getManifestAttributes())
}

minimize() // This will only allow shading for actually used classes
if (minimizeShadowedDependencies.toBoolean()) {
minimize() // This will only allow shading for actually used classes
}
configurations = [
project.configurations.shadowImplementation,
project.configurations.shadowCompile
Expand Down Expand Up @@ -549,7 +561,9 @@ task shadowDevJar(type: ShadowJar) {
attributes(getManifestAttributes())
}

minimize() // This will only allow shading for actually used classes
if (minimizeShadowedDependencies.toBoolean()) {
minimize() // This will only allow shading for actually used classes
}
configurations = [
project.configurations.shadowImplementation,
project.configurations.shadowCompile
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
31 changes: 14 additions & 17 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand All @@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
25 changes: 7 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

Expand All @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -61,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/crazypants/enderio/EnderIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.api.IMC;
import crazypants.enderio.block.BlockDarkSteelAnvil;
Expand Down Expand Up @@ -150,7 +152,7 @@
import crazypants.enderio.material.endergy.ItemGrindingBallEndergy;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.rail.BlockEnderRail;
import crazypants.enderio.teleport.ItemInfiniteTravelStaff;
import crazypants.enderio.teleport.ItemTeleportStaff;
import crazypants.enderio.teleport.ItemTravelStaff;
import crazypants.enderio.teleport.TeleportRecipes;
import crazypants.enderio.teleport.TravelController;
Expand Down Expand Up @@ -229,7 +231,7 @@ public class EnderIO {
public static BlockTelePad blockTelePad;
public static ItemCoordSelector itemCoordSelector;
public static ItemTravelStaff itemTravelStaff;
public static ItemInfiniteTravelStaff itemInfiniteTravelStaff;
public static ItemTeleportStaff itemTeleportStaff;

// Painter
public static BlockPainter blockPainter;
Expand Down Expand Up @@ -481,7 +483,7 @@ public void preInit(FMLPreInitializationEvent event) {
itemYetaWench = ItemYetaWrench.create();
itemEnderface = ItemEnderface.create();
itemTravelStaff = ItemTravelStaff.create();
itemInfiniteTravelStaff = ItemInfiniteTravelStaff.create();
itemTeleportStaff = ItemTeleportStaff.create();
itemConduitProbe = ItemConduitProbe.create();

itemXpTransfer = ItemXpTransfer.create();
Expand Down Expand Up @@ -883,4 +885,14 @@ public void worldSaved(WorldEvent.Save event) {
public void serverStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
}

@EventHandler
public void remap(FMLMissingMappingsEvent event) {
for (FMLMissingMappingsEvent.MissingMapping missingMapping : event.getAll()) {
if (missingMapping.type == GameRegistry.Type.ITEM
&& missingMapping.name.equals("EnderIO:itemInfiniteTravelStaff")) {
missingMapping.remap(itemTeleportStaff);
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/crazypants/enderio/ModObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public enum ModObject {

itemEnderFood,

itemInfiniteTravelStaff;
itemTeleportStaff;

public final String unlocalisedName;

Expand Down
32 changes: 29 additions & 3 deletions src/main/java/crazypants/enderio/api/teleport/TravelSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ public float getPowerCostPerBlockTraveledRF() {
return Config.travelStaffPowerPerBlockRF;
}
},

TELEPORT_STAFF() {
@Override
public int getMaxDistanceTravelled() {
return Config.teleportStaffMaxDistance;
}

@Override
public float getPowerCostPerBlockTraveledRF() {
return 0f;
}
},
TELEPORT_STAFF_BLINK() {
@Override
public int getMaxDistanceTravelled() {
return Config.teleportStaffMaxBlinkDistance;
}

@Override
public float getPowerCostPerBlockTraveledRF() {
return 0f;
}
},
TELEPAD(EnderIO.DOMAIN + ":telepad.teleport");

public static int getMaxDistance() {
Expand All @@ -51,9 +74,12 @@ public static int getMaxDistanceSq() {
return 0;
}

return TravelController.instance.isTravelItemActive(player)
? TravelSource.STAFF.getMaxDistanceTravelledSq()
: TravelSource.BLOCK.getMaxDistanceTravelledSq();
TravelSource source = TravelController.instance.getTravelItemTravelSource(player);
if (source == null) {
return TravelSource.BLOCK.getMaxDistanceTravelledSq();
} else {
return source.getMaxDistanceTravelledSq();
}
}

public final String sound;
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/crazypants/enderio/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ public String lc() {
public static float travelAnchorZoomScale = 0.2f;
public static boolean travelStaffSearchOptimize = true;

/** The max distance for travelling to a Travel Anchor. */
public static int teleportStaffMaxDistance = 2048;
/** The max distance for travelling to player look. */
public static int teleportStaffMaxBlinkDistance = 512;
/**
* The distance travelled when no block is found within {@link #teleportStaffMaxBlinkDistance}.
*/
public static int teleportStaffFailedBlinkDistance = 64;

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

Expand Down Expand Up @@ -1181,6 +1190,27 @@ public static void processConfig(Configuration config) {
+ "This config is experimental, so if you encounter any strange behavior, please report to GTNH developer.")
.getBoolean(travelStaffSearchOptimize);

teleportStaffMaxDistance = config.get(
sectionStaff.name,
"teleportStaffMaxDistance",
teleportStaffMaxDistance,
"Max number of blocks teleported when travelling to a Travel Anchor.")
.getInt(teleportStaffMaxDistance);

teleportStaffMaxBlinkDistance = config.get(
sectionStaff.name,
"teleportStaffMaxBlinkDistance",
teleportStaffMaxBlinkDistance,
"Max number of blocks teleported when travelling to player look.")
.getInt(teleportStaffMaxBlinkDistance);

teleportStaffFailedBlinkDistance = config.get(
sectionStaff.name,
"teleportStaffFailedBlinkDistance",
teleportStaffFailedBlinkDistance,
"Number of blocks teleported when no block is being looked at.")
.getInt(teleportStaffFailedBlinkDistance);

enderIoRange = config.get(
sectionEfficiency.name,
"enderIoRange",
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/crazypants/enderio/nei/NEIEnderIOConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void loadConfig() {
}
if (!Config.travelAnchorEnabled) {
API.hideItem(new ItemStack(EnderIO.itemTravelStaff));
API.hideItem(new ItemStack(EnderIO.itemInfiniteTravelStaff));
API.hideItem(new ItemStack(EnderIO.itemTeleportStaff));
}
if (!Config.reinforcedObsidianEnabled) {
API.hideItem(new ItemStack(EnderIO.blockReinforcedObsidian));
Expand Down
Loading

0 comments on commit 0902a89

Please sign in to comment.