-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed commit porting fixes to Gliders compat forwards (v2 craft-di…
…e-repeat beta 1.20.1 -> master v2) ===================== Use the correct fabric.mod.json so that resources are processed Add a suggestion for gliders version Gliders no longer nuke you when you land gently after dis-engaging from a hook (Seems to fix most of #9) Add more GrappleModClientAPI Events & Utilities Fix deploying elytras (issue #16) & gliders (issue #9 part 1) Try to fix fall damage & debug activation for elytra Ticker changes Fix build.gradle for compat... again. Fix game crash in dev env for glider compat Fixed gradle for GlidersCompatModule
- Loading branch information
Showing
27 changed files
with
292 additions
and
83 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
21 changes: 16 additions & 5 deletions
21
...Gliders/src/main/java/me/cg360/mod/grapplemod/compat/gliders/GlidersCompatEntrypoint.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
28 changes: 26 additions & 2 deletions
28
Compat/Gliders/src/main/java/me/cg360/mod/grapplemod/compat/gliders/GlidersCompatModule.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 |
---|---|---|
@@ -1,13 +1,37 @@ | ||
package me.cg360.mod.grapplemod.compat.gliders; | ||
|
||
import com.mojang.logging.LogUtils; | ||
import com.yyon.grapplinghook.GrappleMod; | ||
import com.yyon.grapplinghook.client.api.GrappleModClientAPI; | ||
import com.yyon.grapplinghook.client.api.GrappleModClientEvents; | ||
import com.yyon.grapplinghook.content.physics.PhysicsControllers; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.venturecraft.gliders.util.GliderUtil; | ||
|
||
public class GlidersCompatModule { | ||
|
||
public GlidersCompatModule() { | ||
LogUtils.getLogger().info("Enabled Gliders Compatibility Module"); | ||
|
||
//TODO: Add module contents - this needs a 1.19.2 backport of GrappleMod v2 to be | ||
// completed before work can be done. | ||
//todo oh god | ||
// Limit speed on hook physics when gliding | ||
// Fix weird acceleration (seems to be like infinity downwards) | ||
// Add some way to deploy the glider after using a hook (ditch hook & just glide?) | ||
|
||
ClientTickEvents.START_WORLD_TICK.register(level -> { | ||
LocalPlayer player = Minecraft.getInstance().player; | ||
|
||
if(player == null) return; | ||
if(!GliderUtil.isGliderActive(player)) return; | ||
|
||
ResourceLocation currentPhysicsType = GrappleModClientAPI.getPhysicsTypeFor(player); | ||
|
||
if(currentPhysicsType == PhysicsControllers.AIR_FRICTION) { | ||
GrappleModClientAPI.abortAllPhysicsOverrides(player); | ||
} | ||
}); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...t/Gliders/src/main/java/me/cg360/mod/grapplemod/compat/gliders/mixin/GliderUtilMixin.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,49 @@ | ||
package me.cg360.mod.grapplemod.compat.gliders.mixin; | ||
|
||
import com.yyon.grapplinghook.GrappleMod; | ||
import com.yyon.grapplinghook.content.physics.PhysicsControllers; | ||
import com.yyon.grapplinghook.physics.PlayerPhysicsFrame; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.venturecraft.gliders.util.GliderUtil; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.Optional; | ||
|
||
@Mixin(GliderUtil.class) | ||
public class GliderUtilMixin { | ||
|
||
@Inject(method = "canDeployHere(Lnet/minecraft/world/entity/LivingEntity;)Z", | ||
at = @At("HEAD"), | ||
cancellable = true) | ||
private static void handleGrapplingDeployCondition(LivingEntity livingEntity, CallbackInfoReturnable<Boolean> cir) { | ||
if(!(livingEntity instanceof Player player)) return; | ||
|
||
|
||
Optional<PlayerPhysicsFrame> mostRecentFrame = GrappleMod.get().getServerPhysicsObserver() | ||
.getMostRecentFrame(player); | ||
|
||
// No record of physics so there's nothing to check. Use vanilla checks only. | ||
if(mostRecentFrame.isEmpty()) | ||
return; | ||
|
||
ResourceLocation controllerType = mostRecentFrame.get().getPhysicsControllerType(); | ||
|
||
// Sanity | ||
if(controllerType == null) return; | ||
|
||
boolean usingValidController = controllerType.equals(PhysicsControllers.AIR_FRICTION) || | ||
controllerType.equals(PhysicsControllers.GRAPPLING_HOOK); | ||
|
||
// Can't be deployed with forcefield either as that just feels jank. | ||
if(usingValidController) { | ||
cir.setReturnValue(true); | ||
cir.cancel(); | ||
} | ||
} | ||
|
||
} |
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
12 changes: 12 additions & 0 deletions
12
Compat/Gliders/src/main/resources/grapplemodcompat-vc-gliders.mixins.json
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,12 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "me.cg360.mod.grapplemod.compat.gliders.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"GliderUtilMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
Core/src/main/java/com/yyon/grapplinghook/client/api/GrappleModClientAPI.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 |
---|---|---|
@@ -1,7 +1,38 @@ | ||
package com.yyon.grapplinghook.client.api; | ||
|
||
import com.yyon.grapplinghook.client.GrappleModClient; | ||
import com.yyon.grapplinghook.client.physics.context.GrapplingHookPhysicsController; | ||
import com.yyon.grapplinghook.content.physics.PhysicsControllers; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.LivingEntity; | ||
|
||
public class GrappleModClientAPI { | ||
|
||
public static ResourceLocation getPhysicsTypeFor(LivingEntity entity) { | ||
if(entity == null) | ||
return PhysicsControllers.NONE; | ||
|
||
GrapplingHookPhysicsController controller = GrappleModClient.get() | ||
.getClientControllerManager() | ||
.getController(entity.getId()); | ||
|
||
return controller == null | ||
? PhysicsControllers.NONE | ||
: controller.getType(); | ||
} | ||
|
||
|
||
public static void abortAllPhysicsOverrides(LivingEntity entity) { | ||
if(entity == null) return; | ||
|
||
GrapplingHookPhysicsController controller = GrappleModClient.get() | ||
.getClientControllerManager() | ||
.getController(entity.getId()); | ||
|
||
if(controller == null) | ||
return; | ||
|
||
controller.disable(true); | ||
} | ||
|
||
} |
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.