generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'HighJump-DEV' into 1.18-DEV
- Loading branch information
Showing
14 changed files
with
280 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
12 changes: 12 additions & 0 deletions
12
src/main/java/me/av306/xenon/config/GeneralConfigGroup.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,12 @@ | ||
package me.av306.xenon.config; | ||
|
||
import me.lortseam.completeconfig.api.ConfigEntries; | ||
import me.lortseam.completeconfig.api.ConfigEntry; | ||
|
||
@ConfigEntries | ||
public class GeneralConfigGroup implements XenonConfigGroup | ||
{ | ||
@ConfigEntry.BoundedInteger( min = 0, max = 100 ) | ||
@ConfigEntry.Slider | ||
public static int interval = 5; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/me/av306/xenon/config/feature/HighJumpGroup.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,15 @@ | ||
package me.av306.xenon.config.feature; | ||
|
||
import me.av306.xenon.config.XenonConfigGroup; | ||
import me.lortseam.completeconfig.api.ConfigEntries; | ||
import me.lortseam.completeconfig.api.ConfigEntry; | ||
|
||
@ConfigEntries | ||
public class HighJumpGroup implements XenonConfigGroup | ||
{ | ||
@ConfigEntry.BoundedFloat( min = -1f, max = 200f ) | ||
public static float height = 0.0f; | ||
|
||
@ConfigEntry.BoundedFloat( min = 0f, max = 2f ) | ||
public static float multiplier = 0.1f; | ||
} |
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,6 @@ | ||
package me.av306.xenon.event; | ||
|
||
public class EventFields | ||
{ | ||
public static float JUMP_VELOCITY_MODIFIER = 0f; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/av306/xenon/event/GetJumpVelocityEvent.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,26 @@ | ||
package me.av306.xenon.event; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.ActionResult; | ||
|
||
public interface GetJumpVelocityEvent | ||
{ | ||
Event<GetJumpVelocityEvent> EVENT = EventFactory.createArrayBacked( | ||
GetJumpVelocityEvent.class, | ||
(listeners) -> () -> | ||
{ | ||
for ( GetJumpVelocityEvent listener : listeners ) | ||
{ | ||
ActionResult result = listener.interact(); | ||
|
||
if ( result != ActionResult.PASS ) return result; | ||
} | ||
|
||
return ActionResult.PASS; | ||
} | ||
); | ||
|
||
ActionResult interact(); | ||
} |
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
71 changes: 71 additions & 0 deletions
71
src/main/java/me/av306/xenon/features/HighJumpFeature.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,71 @@ | ||
package me.av306.xenon.features; | ||
|
||
import me.av306.xenon.Xenon; | ||
import me.av306.xenon.config.GeneralConfigGroup; | ||
import me.av306.xenon.config.feature.HighJumpGroup; | ||
import me.av306.xenon.event.EventFields; | ||
import me.av306.xenon.event.GetJumpVelocityEvent; | ||
import me.av306.xenon.event.RenderInGameHudEvent; | ||
import me.av306.xenon.feature.IToggleableFeature; | ||
import me.av306.xenon.mixin.ClientPlayerEntityMixin; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.ActionResult; | ||
|
||
public class HighJumpFeature extends IToggleableFeature | ||
{ | ||
//protected static HighJumpFeature instance; | ||
|
||
private short ticks = 0; | ||
|
||
public HighJumpFeature() | ||
{ | ||
super( "HighJump" ); | ||
|
||
RenderInGameHudEvent.AFTER_VIGNETTE.register( this::onRenderInGameHud ); | ||
GetJumpVelocityEvent.EVENT.register( this::onGetJumpVelocity ); | ||
|
||
//instance = this; | ||
} | ||
|
||
private ActionResult onRenderInGameHud( MatrixStack matrixStack, float tickDelta ) | ||
{ | ||
if ( ticks >= GeneralConfigGroup.interval ) | ||
{ | ||
ticks = 0; | ||
this.setName( "HighJump " + HighJumpGroup.height ); | ||
} | ||
else ticks++; | ||
|
||
return ActionResult.PASS; | ||
} | ||
|
||
private ActionResult onGetJumpVelocity() | ||
{ | ||
if ( !this.isEnabled ) return ActionResult.PASS; | ||
|
||
float height = HighJumpGroup.height * HighJumpGroup.multiplier; | ||
EventFields.JUMP_VELOCITY_MODIFIER = height; | ||
|
||
return ActionResult.PASS; | ||
} | ||
|
||
/*@Override | ||
public static HighJumpFeature getInstance() | ||
{ | ||
return instance; | ||
}*/ | ||
|
||
@Override | ||
protected void onEnable() | ||
{ | ||
float height = HighJumpGroup.height * HighJumpGroup.multiplier; | ||
EventFields.JUMP_VELOCITY_MODIFIER = height; | ||
this.setName( "HighJump (" + height + ")" ); | ||
} | ||
|
||
@Override | ||
protected void onDisable() | ||
{ | ||
EventFields.JUMP_VELOCITY_MODIFIER = 0f; // TODO: make way for other features that might want to modify this | ||
} | ||
} |
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,31 @@ | ||
package me.av306.xenon.features; | ||
|
||
import me.av306.xenon.Xenon; | ||
import me.av306.xenon.feature.IFeature; | ||
import me.av306.xenon.feature.IToggleableFeature; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class PanicFeature extends IFeature | ||
{ | ||
public PanicFeature() | ||
{ | ||
super( "Panic" ); | ||
} | ||
|
||
@Override | ||
protected void onEnable() | ||
{ | ||
// copy the list | ||
List<IToggleableFeature> list = new ArrayList<>( Xenon.INSTANCE.enabledFeatures ); | ||
|
||
// iterate over the enabled ITFs in the copy | ||
// and disable them | ||
list.forEach( | ||
IToggleableFeature::disable | ||
); | ||
|
||
// destroy the list | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/me/av306/xenon/mixin/ClientPlayerEntityMixin.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,28 @@ | ||
package me.av306.xenon.mixin; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import me.av306.xenon.config.feature.HighJumpGroup; | ||
import me.av306.xenon.event.EventFields; | ||
import me.av306.xenon.event.GetJumpVelocityEvent; | ||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.world.ClientWorld; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin( ClientPlayerEntity.class ) | ||
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity | ||
{ | ||
public ClientPlayerEntityMixin( ClientWorld world, GameProfile profile ) | ||
{ | ||
super( world, profile ); | ||
} | ||
|
||
@Override | ||
public float getJumpVelocity() | ||
{ | ||
GetJumpVelocityEvent.EVENT.invoker().interact(); | ||
return super.getJumpVelocity() + EventFields.JUMP_VELOCITY_MODIFIER; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.