Skip to content

Commit

Permalink
Merge branch 'HighJump-DEV' into 1.18-DEV
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 committed May 28, 2022
2 parents 825177c + 5c4a867 commit 842a22f
Show file tree
Hide file tree
Showing 14 changed files with 280 additions and 46 deletions.
23 changes: 0 additions & 23 deletions PanicFeature.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/me/av306/xenon/Xenon.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public void initialise()
new ShareLocationFeature();
new TimerFeature();
new WailaFeature();
new HighJumpFeature();
new PanicFeature();
}


Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/av306/xenon/config/FeatureConfigGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
@ConfigEntries
public class FeatureConfigGroup implements XenonConfigGroup
{
@Transitive
private final GeneralConfigGroup generalConfigGroup = new GeneralConfigGroup();

@Transitive
private final QuickChatGroup autoreply = new QuickChatGroup();

Expand All @@ -26,4 +29,7 @@ public class FeatureConfigGroup implements XenonConfigGroup

@Transitive
private final FastBreakGroup fastBreakGroup = new FastBreakGroup();

@Transitive
private final HighJumpGroup highJumpGroup = new HighJumpGroup();
}
12 changes: 12 additions & 0 deletions src/main/java/me/av306/xenon/config/GeneralConfigGroup.java
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 src/main/java/me/av306/xenon/config/feature/HighJumpGroup.java
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;
}
6 changes: 6 additions & 0 deletions src/main/java/me/av306/xenon/event/EventFields.java
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 src/main/java/me/av306/xenon/event/GetJumpVelocityEvent.java
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();
}
12 changes: 11 additions & 1 deletion src/main/java/me/av306/xenon/feature/IToggleableFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ public abstract class IToggleableFeature extends IFeature
{
//protected int key = GLFW.GLFW_KEY_UNKNOWN;

//protected static IToggleableFeature instance;

protected IToggleableFeature( String name )
{
super( name );

//instance = this;
}

/*public static IToggleableFeature getInstance()
{
return instance;
}*/

/*@Override
protected ActionResult onKeyboardKey( long window, int key, int scanCode, int action, int modifiers )
{
Expand All @@ -24,7 +33,8 @@ protected ActionResult onKeyboardKey( long window, int key, int scanCode, int ac
}*/

@Override
protected void registerKeyEvent() {
protected void registerKeyEvent()
{
if ( this.keyBinding.wasPressed() )
this.toggle();
}
Expand Down
71 changes: 71 additions & 0 deletions src/main/java/me/av306/xenon/features/HighJumpFeature.java
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
}
}
31 changes: 31 additions & 0 deletions src/main/java/me/av306/xenon/features/PanicFeature.java
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 src/main/java/me/av306/xenon/mixin/ClientPlayerEntityMixin.java
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;
}


}
Loading

0 comments on commit 842a22f

Please sign in to comment.