mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-25 20:22:23 +00:00
allow small overshoot of power use for traveling (#133)
This commit is contained in:
1 parent
070660efe4
commit
349bcc0926
4 files changed
+61
-38
No files matched your search
+17
-13
@@ -1,4 +1,4 @@
|
||||
//version: 1690104383
|
||||
//version: 1692122114
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -69,7 +69,7 @@ plugins {
|
||||
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.21'
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
|
||||
}
|
||||
|
||||
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
||||
@@ -401,9 +401,13 @@ if (identifiedVersion == versionOverride) {
|
||||
|
||||
group = "com.github.GTNewHorizons"
|
||||
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
|
||||
archivesBaseName = customArchiveBaseName
|
||||
base {
|
||||
archivesName = customArchiveBaseName
|
||||
}
|
||||
} else {
|
||||
archivesBaseName = modId
|
||||
base {
|
||||
archivesName = modId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -558,9 +562,6 @@ repositories {
|
||||
maven {
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
mavenContent {
|
||||
excludeGroup("net.minecraftforge") // missing the `universal` artefact
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
@@ -627,6 +628,8 @@ def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}
|
||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||
ext.mixinProviderSpec = mixinProviderSpec
|
||||
|
||||
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
|
||||
|
||||
dependencies {
|
||||
if (usesMixins.toBoolean()) {
|
||||
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
|
||||
@@ -638,7 +641,7 @@ dependencies {
|
||||
}
|
||||
}
|
||||
if (usesMixins.toBoolean()) {
|
||||
implementation(modUtils.enableMixins(mixinProviderSpec))
|
||||
implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap))
|
||||
} else if (forceEnableMixins.toBoolean()) {
|
||||
runtimeOnlyNonPublishable(mixinProviderSpec)
|
||||
}
|
||||
@@ -691,8 +694,6 @@ if (file('dependencies.gradle.kts').exists()) {
|
||||
throw new RuntimeException("Missing dependencies.gradle[.kts]")
|
||||
}
|
||||
|
||||
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
|
||||
|
||||
tasks.register('generateAssets') {
|
||||
group = "GTNH Buildscript"
|
||||
description = "Generates a mixin config file at /src/main/resources/mixins.modid.json if needed"
|
||||
@@ -775,10 +776,10 @@ dependencies {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
if (modId != 'hodgepodge') {
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.19')
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26')
|
||||
}
|
||||
|
||||
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
|
||||
java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false}
|
||||
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
|
||||
@@ -1148,7 +1149,10 @@ tasks.named("processIdeaSettings").configure {
|
||||
|
||||
tasks.named("ideVirtualMainClasses").configure {
|
||||
// Make IntelliJ "Build project" build the mod jars
|
||||
dependsOn("jar", "reobfJar", "spotlessCheck")
|
||||
dependsOn("jar", "reobfJar")
|
||||
if (!disableSpotless) {
|
||||
dependsOn("spotlessCheck")
|
||||
}
|
||||
}
|
||||
|
||||
// workaround variable hiding in pom processing
|
||||
|
||||
+8
-8
@@ -1,22 +1,22 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:EnderCore:0.2.16:dev')
|
||||
implementation('com.github.GTNewHorizons:ForestryMC:4.6.13:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.76-GTNH:dev')
|
||||
api('com.github.GTNewHorizons:EnderCore:0.2.17:dev')
|
||||
implementation('com.github.GTNewHorizons:ForestryMC:4.6.14:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.4.2-GTNH:dev')
|
||||
implementation("com.github.GTNewHorizons:GTNHLib:0.0.13:dev")
|
||||
api('com.github.GTNewHorizons:BuildCraft:7.1.36:dev')
|
||||
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
|
||||
shadowImplementation('cglib:cglib-nodep:3.3.0')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:waila:1.6.0:api') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-240-GTNH:api') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-254-GTNH:api') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.43.140:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Railcraft:9.14.6:api') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.16-pre-experimental:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Railcraft:9.15.0:api') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.12.0-GTNH:api') {transitive = false}
|
||||
implementation('com.github.GTNewHorizons:Chisel:2.11.3-GTNH:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.12-GTNH:api') {transitive = false}
|
||||
implementation('com.github.GTNewHorizons:Chisel:2.11.4-GTNH:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.15-GTNH:api') {transitive = false}
|
||||
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
|
||||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
compileOnly('curse.maven:ee3-65509:2305023') // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
|
||||
|
||||
@@ -111,42 +111,55 @@ public class TravelController {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean validatePacketTravelEvent(EntityPlayerMP toTp, int x, int y, int z, int powerUse,
|
||||
/**
|
||||
* @return the error message, or null if the packet is valid.
|
||||
*/
|
||||
public String validatePacketTravelEvent(EntityPlayerMP toTp, int x, int y, int z, int powerUse,
|
||||
boolean conserveMotion, TravelSource source) {
|
||||
BlockCoord target = new BlockCoord(x, y, z);
|
||||
double dist = getDistanceSquared(toTp, target);
|
||||
// allow 15% overshoot to account for rounding
|
||||
if (dist * 100 > source.getMaxDistanceTravelledSq() * 115) return false;
|
||||
if (powerUse < getRequiredPower(toTp, source, target)) return false;
|
||||
if (dist * 100 > source.getMaxDistanceTravelledSq() * 115) return "dist check fail";
|
||||
// allow 4 blocks of c/s player pos desync
|
||||
if (getPower(toTp, source, target, -4F) > powerUse) return "power use too little";
|
||||
ItemStack equippedItem = toTp.getCurrentEquippedItem();
|
||||
switch (source) {
|
||||
case TELEPAD:
|
||||
// this source is invalid for this type of packet
|
||||
return false;
|
||||
return "invalid travel source";
|
||||
case BLOCK:
|
||||
// this source is only triggered when player is on any active travel anchor
|
||||
BlockCoord on = getActiveTravelBlock(toTp);
|
||||
if (on == null) return false;
|
||||
if (on == null) return "on anchor is null";
|
||||
// target must be a valid selectedCoord
|
||||
// selectedCoord can either be a block right above/below when the player is on anchor...
|
||||
if (on.x == x && on.z == z) return true;
|
||||
if (on.x == x && on.z == z) return null;
|
||||
// or another anchor
|
||||
TileEntity maybeAnchor = target.getTileEntity(toTp.worldObj);
|
||||
if (!(maybeAnchor instanceof ITravelAccessable)) return false;
|
||||
if (!(maybeAnchor instanceof ITravelAccessable)) return "not anchor";
|
||||
ITravelAccessable anchor = (ITravelAccessable) maybeAnchor;
|
||||
return anchor.canBlockBeAccessed(toTp) || !isValidTarget(toTp, target, TravelSource.BLOCK);
|
||||
if (!anchor.canBlockBeAccessed(toTp) && isValidTarget(toTp, target, TravelSource.BLOCK)) {
|
||||
return "not valid target";
|
||||
}
|
||||
return null;
|
||||
case STAFF:
|
||||
case STAFF_BLINK:
|
||||
if (equippedItem == null || !(equippedItem.getItem() instanceof IItemOfTravel)) return false;
|
||||
if (!((IItemOfTravel) equippedItem.getItem()).isActive(toTp, equippedItem)) return false;
|
||||
if (equippedItem == null || !(equippedItem.getItem() instanceof IItemOfTravel)) return "not staff";
|
||||
if (!((IItemOfTravel) equippedItem.getItem()).isActive(toTp, equippedItem)) return "staff not active";
|
||||
int energy = ((IItemOfTravel) equippedItem.getItem()).canExtractInternal(equippedItem, powerUse);
|
||||
return energy == -1 || energy == powerUse;
|
||||
if (energy != -1 && energy != powerUse) {
|
||||
return "not enough power";
|
||||
}
|
||||
return null;
|
||||
case TELEPORT_STAFF_BLINK:
|
||||
case TELEPORT_STAFF:
|
||||
// tp staff is creative version of traveling staff
|
||||
// no energy check or anything else needed
|
||||
// but the player must actually be equipped with one of these
|
||||
return equippedItem != null && equippedItem.getItem() instanceof ItemTeleportStaff;
|
||||
if (equippedItem != null && equippedItem.getItem() instanceof ItemTeleportStaff) {
|
||||
return null;
|
||||
}
|
||||
return "not staff";
|
||||
default:
|
||||
throw new AssertionError("unidentified travel source");
|
||||
}
|
||||
@@ -662,7 +675,7 @@ public class TravelController {
|
||||
}
|
||||
int requiredPower;
|
||||
ItemStack staff = player.getCurrentEquippedItem();
|
||||
requiredPower = (int) (getDistance(player, coord) * source.getPowerCostPerBlockTraveledRF());
|
||||
requiredPower = getPower(player, source, coord, 0F);
|
||||
int canUsePower = getEnergyInTravelItem(staff);
|
||||
if (requiredPower > canUsePower) {
|
||||
// make sure chat is sent only once per trial
|
||||
@@ -675,6 +688,10 @@ public class TravelController {
|
||||
return requiredPower;
|
||||
}
|
||||
|
||||
private int getPower(EntityPlayer player, TravelSource source, BlockCoord coord, float distanceWavier) {
|
||||
return (int) ((getDistance(player, coord) + distanceWavier) * source.getPowerCostPerBlockTraveledRF());
|
||||
}
|
||||
|
||||
private boolean isInRangeTarget(EntityPlayer player, BlockCoord bc, float maxSq) {
|
||||
return getDistanceSquared(player, bc) <= maxSq;
|
||||
}
|
||||
|
||||
@@ -83,12 +83,14 @@ public class PacketTravelEvent implements IMessage, IMessageHandler<PacketTravel
|
||||
|
||||
TravelSource source = TravelSource.values()[message.source];
|
||||
|
||||
if (!TravelController.instance
|
||||
.validatePacketTravelEvent(toTp, x, y, z, message.powerUse, message.conserveMotion, source)) {
|
||||
String error = TravelController.instance
|
||||
.validatePacketTravelEvent(toTp, x, y, z, message.powerUse, message.conserveMotion, source);
|
||||
if (error != null) {
|
||||
Log.LOGGER.warn(
|
||||
Log.securityMarker,
|
||||
"Player {} tried to tp without valid prereq.",
|
||||
ctx.getServerHandler().playerEntity.getGameProfile());
|
||||
"Player {} tried to tp without valid prereq: {}",
|
||||
ctx.getServerHandler().playerEntity.getGameProfile(),
|
||||
error);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user