✨ Initial useful commit.
- /bank does nothing useful - /when is fun - do random shit with enchantments however you like
This commit is contained in:
parent
03c45caa74
commit
fb8dd46869
|
@ -10,7 +10,7 @@ public class CRSSMod implements DedicatedServerModInitializer {
|
|||
@Override
|
||||
public void onInitializeServer() {
|
||||
|
||||
LOGGER.info("Hello World!");
|
||||
LOGGER.info("CRSS initialising.");
|
||||
CommandRegister.registerCommands();
|
||||
}
|
||||
}
|
23
src/main/java/cc/crss/mod/command/BankCommand.java
Normal file
23
src/main/java/cc/crss/mod/command/BankCommand.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package cc.crss.mod.command;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.arguments.MessageArgumentType;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
|
||||
public class BankCommand {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
|
||||
dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) CommandManager.literal("bank"))
|
||||
.executes(BankCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
context.getSource().getMinecraftServer().sendMessage(new LiteralText("<CRSS> " + context.getSource().getName() + " is a little teapot."));
|
||||
context.getSource().getPlayer().sendMessage(new LiteralText("<CRSS> " + context.getSource().getName() + " is a little teapot."));
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -48,7 +48,10 @@ public class WhenCommand {
|
|||
randomDateString };
|
||||
String randomDate = datesSelection[rand.nextInt(datesSelection.length)];
|
||||
|
||||
context.getSource().sendFeedback(new LiteralText("[CRSS] " + randomDate), false);
|
||||
context.getSource().getMinecraftServer().sendMessage(new LiteralText("<" + context.getSource().getName() + "> " + context.getInput()));
|
||||
context.getSource().getPlayer().sendMessage(new LiteralText("<" + context.getSource().getName() + "> " + context.getInput()));
|
||||
context.getSource().getMinecraftServer().sendMessage(new LiteralText("<CRSS> " + randomDate));
|
||||
context.getSource().getPlayer().sendMessage(new LiteralText("<CRSS> " + randomDate));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
17
src/main/java/cc/crss/mod/mixin/AnvilContainerMixin.java
Normal file
17
src/main/java/cc/crss/mod/mixin/AnvilContainerMixin.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package cc.crss.mod.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.minecraft.container.AnvilContainer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(AnvilContainer.class)
|
||||
public class AnvilContainerMixin {
|
||||
/*@ModifyExpressionValue(
|
||||
method = "updateResult",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;isDifferent(Lnet/minecraft/enchantment/Enchantment;)Z")
|
||||
)
|
||||
private boolean isDifferent(boolean original) {
|
||||
return true;
|
||||
} */
|
||||
}
|
34
src/main/java/cc/crss/mod/mixin/EnchantmentMixin.java
Normal file
34
src/main/java/cc/crss/mod/mixin/EnchantmentMixin.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package cc.crss.mod.mixin;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.ProtectionEnchantment;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(Enchantment.class)
|
||||
public class EnchantmentMixin {
|
||||
|
||||
@Shadow
|
||||
protected boolean differs(Enchantment other) {
|
||||
return ((Object)this) != other;
|
||||
}
|
||||
|
||||
@Unique
|
||||
protected boolean inverseDiffers(Enchantment other) {
|
||||
return other != ((Object)this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author WorldWidePixel
|
||||
* @reason for 1.14 CRSS fun
|
||||
*/
|
||||
@Overwrite
|
||||
public final boolean isDifferent(Enchantment other) {
|
||||
if (other instanceof ProtectionEnchantment) {
|
||||
return true;
|
||||
}
|
||||
return this.differs(other) && inverseDiffers(other);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package cc.crss.mod.util;
|
||||
|
||||
import cc.crss.mod.command.BankCommand;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import cc.crss.mod.command.SkipNightCommand;
|
||||
import cc.crss.mod.command.WhenCommand;
|
||||
|
@ -7,6 +8,6 @@ import cc.crss.mod.command.WhenCommand;
|
|||
public class CommandRegister {
|
||||
public static void registerCommands() {
|
||||
CommandRegistrationCallback.EVENT.register(WhenCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(SkipNightCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(BankCommand::register);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"CRSSMixin",
|
||||
"PlayerEntityMixin"
|
||||
"EnchantmentMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue