Skip to content

Commit

Permalink
update, some messing around
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 committed Jan 23, 2024
1 parent b27ccdd commit f84d2f9
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 40 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

Expand Down
4 changes: 2 additions & 2 deletions changelog_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Changes since previous:

**[]**
- [text here]


**Known issues**No
### Known issues
2 changes: 1 addition & 1 deletion compatability → compatibility
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Each line represents a (comma-space-seperated) set of versions whose builds are
# compatible with one another.
# E.g. A hyppthetical 1.20.1 build that can be used on 1.20, and vice versa
# E.g. A hypothetical 1.20.1 build that can be used on 1.20, and vice versa

1.18
No support, try at your own risk
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version = 1.20.1
yarn_mappings = 1.20.1+build.10
loader_version = 0.15.3
minecraft_version = 1.20.4
yarn_mappings = 1.20.4+build.3
loader_version = 0.15.6

# Fabric api
fabric_version = 0.91.0+1.20.1
fabric_version = 0.95.1+1.20.4

# Mod Properties
mod_version = 4.4.0+1.20.1
mod_version = 4.5.0+1.20.4
maven_group = me.av306
archives_base_name = xenon

# Complete Config
complete_config_version = 2.5.1
complete_config_version = 2.5.3

# SLF4J
slf4j_version = 2.0.7

# GSON version
gson_version = 2.10.1
#gson_version = 2.10.1

mixin.debug.export = true
2 changes: 0 additions & 2 deletions known_issues

This file was deleted.

35 changes: 27 additions & 8 deletions src/main/java/me/av306/xenon/command/Command.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package me.av306.xenon.command;

import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.*;

import com.mojang.brigadier.arguments.StringArgumentType;

import me.av306.xenon.Xenon;
import me.av306.xenon.util.text.TextFactory;
import net.minecraft.text.Text;
Expand All @@ -19,11 +23,18 @@ public Command( String name )
ClientCommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess) -> dispatcher.register(
ClientCommandManager.literal( name )
.executes( context ->
.executes( context ->
{
context.getSource().sendFeedback( TextFactory.createLiteral( "Executed command for " + name ) );
this.execute( null );
return 1;
} )
/*.then( argument( "arguments", StringArgumentType.greedyString() ))
.executes( context ->
{
//context.getSource().sendFeedback( TextFactory.createLiteral( "Executed command for " + name ) );
this.execute( StringArgumentType.getString( context, "arguments" ).split( " " ) );
return 1;
} )*/ // FIXME: I really have no idea why string arguments don't work
)
);
}
Expand All @@ -38,18 +49,26 @@ public Command( String name, String... aliases )
ClientCommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess) -> dispatcher.register(
ClientCommandManager.literal( alias )
.executes( context ->
{
context.getSource().sendFeedback( TextFactory.createLiteral( "Executed command for " + alias ) );
return 1;
} )
.executes( context ->
{
this.execute( null );
return 1;
} )

/*.then( argument( "args", StringArgumentType.greedyString() ))
.executes( context ->
{
//context.getSource().sendFeedback( TextFactory.createLiteral( "Executed command for " + name ) );
this.execute( StringArgumentType.getString( context, "args" ).split( " " ) );
return 1;
} )*/
)
);
}
}

/**
* Implementations must handle empty arguments
* Implementations must handle empty or null arguments, to allow customisable default arguments
*/
public abstract void execute( String[] args );

Expand Down
33 changes: 31 additions & 2 deletions src/main/java/me/av306/xenon/feature/IFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ protected IFeature( String name, int key )

this.commandBuilder.then( literal( "enable" ).executes( context -> { this.enable(); return 1; } ) );
this.commandBuilder.then( literal( "e" ).executes( context -> { this.enable(); return 1; } ) ); // Enable alias
this.commandBuilder.then( literal( "help" ) )
.executes( context ->
{
this.sendInfoMessage( this.getHelpText( null ) );
return 1;
} )
/*.then( argument( "keyword", StringArgumentType.word() ) )
.executes( context ->
{
this.sendInfoMessage( this.getHelpText( StringArgumentType.getString( context, "keyword" ) ) );
return 1;
} )*/;

/*this.commandBuilder.then( literal( "set" ) )
.then( argument( "config", StringArgumentType.greedyString() ) )
Expand Down Expand Up @@ -320,13 +332,30 @@ public void requestExecuteAction( String[] action )
/**
* Method to retrieve help text for a feature.
*/
public Text getHelpText( String[] args )
public Text getHelpText( String argument )
{
// TODO: add formatting
return TextFactory.createLiteral( "Whoops! This Feature doesn't have any documentation :(" );
}



protected void sendInfoMessage( Text text )
{
Text message = Xenon.INSTANCE.getNamePrefixCopy().append(
TextFactory.createTranslatable(
"text.xenon.message",
this.name,
text
)
);

try
{
Xenon.INSTANCE.client.player.sendMessage( message );
}
catch ( NullPointerException ignored ) {}
}

protected void sendInfoMessage( String key, Object... args )
{
Text message = Xenon.INSTANCE.getNamePrefixCopy().append(
Expand Down
16 changes: 4 additions & 12 deletions src/main/java/me/av306/xenon/features/CommandProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,15 @@ protected boolean onRequestExecuteAction( String[] action )
}

@Override
public Text getHelpText( String[] args )
public Text getHelpText( String arg )
{
// example: !cp help listf
// args[0]

MutableText helpText = MutableText.of( TextContent.EMPTY ).append( "[CommandProcessor] " );
// 23-01-2024: I have no clue what this does, also I have no memory of making this but it seems neat
MutableText helpText = TextFactory.createLiteral( "[CommandProcessor] " );

if ( args.length < 1 )
{
// Whoops! No help arguments were passed in.
// Change the args variable to point to a new String[]
// with exactly one help argument
// so that it will proceed to the default branch without an NPE.
args = new String[]{ " " };
}

switch( args[0] )
switch( arg )
{
case "listf", "listfeatures", "features", "lf", "aliases" ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class WailaFeature extends IToggleableFeature

public WailaFeature()
{
super("WAILA");
super( "WAILA" );

// register event
RenderInGameHudEvent.AFTER_VIGNETTE.register( this::onInGameHudRender );
Expand Down Expand Up @@ -87,12 +87,12 @@ private void createDataText( HitResult hit )
Block block = blockState.getBlock(); // finally.

//Block block = Xenon.INSTANCE.client.world.getBlockState(((BlockHitResult) hit).getBlockPos()).getBlock();
// The sharp-eyed may notice that we're just sending over the block hardness,
// not the avtual break time (which depends on the tool).
// The sharp-eyed may notice that we're just sending over the block hardness,
// not the actual break time (which depends on the tool).
// This is intentional; I didn't implement the break time calculations
// because the chances that someone will even *use* Xenon are so astronomically small,
// and there are so many other *good* WAILA mods,
// so there was no point.
// so I figured there was no point.
this.dataText = TextFactory.createTranslatable(
"text.xenon.waila.blocktype",
block.getName(),
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/me/av306/xenon/mixin/BowItemMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package me.av306.xenon.mixin;

import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import me.av306.xenon.Xenon;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;

@Mixin( BowItem.class )
public class BowItemMixin
{
@Inject(
at = @At( "HEAD" ),
method = "use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/TypedActionResult;",
cancellable = true
)
private void onUse( World world, PlayerEntity plater, Hand hand, CallbackInfoReturnable<TypedActionResult> cir )
{
Xenon.INSTANCE.sendInfoMessage( "Bow use" );
}

@Inject(
at = @At( "HEAD" ),
method = "onStoppedUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)V",
cancellable = true
)
private void onStoppedUsing( ItemStack stack, World world, LivingEntity entity, int remainingUseTicks, CallbackInfo ci )
{
Xenon.INSTANCE.sendInfoMessage( "Bow stop use" );
}
}

0 comments on commit f84d2f9

Please sign in to comment.