Skip to content

Commit

Permalink
rebrand (#21)
Browse files Browse the repository at this point in the history
* rebrand to "magnetic"

* also rename media

* rename config screen class

* do not register enchantment under some circumstances

* use different approach

* rename data loader mixin
  • Loading branch information
btwonion authored Dec 8, 2024
1 parent 99c8565 commit e6c4958
Show file tree
Hide file tree
Showing 63 changed files with 232 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/readme-modrinth-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- uses: funnyboy-roks/[email protected]
with:
auth-token: ${{ secrets.MODRINTH_API_KEY }}
slug: 'telekinesis'
slug: 'magnetic'
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# telekinesis
# magnetic (pka. telekinesis)

> Adds auto-pickup functionality to the player. Also know as telekinesis from Hypixel Skyblock.
> Magnetically moves items and experience into your inventory. Also known as telekinesis from Hypixel Skyblock.
## Functionality

Check out the [Gallery](https://modrinth.com/plugin/telekinesis/gallery) for a preview.
Check out the [Gallery](https://modrinth.com/plugin/magnetic/gallery) for a preview.

With this mod you can automatically pickup drops, including experience, from mobs, blocks and entities.
With this mod you can automatically pick up drops, including experience, from mobs, blocks and other entities.

## Can I use the functionality without the enchantment?

Expand All @@ -21,19 +21,19 @@ enchanted on tools.
## Configuration

The configuration file can be found in the client/server directory.
-> `/config/telekinesis.json`
-> `/config/magnetic.json`

<details>
<summary>telekinesis.json</summary>
<summary>magnetic.json</summary>

```json5
{
"version": 1, // For migration purposes only, just ignore this.
"config": {
"needEnchantment": true, // Defines, whether telekinesis should without or with the enchantment on the tool.
"needSneak": false, // Defines. whether the player should have to sneak in order to use telekinesis.
"expAllowed": true, // Enables the use of telekinesis for exp drops.
"itemsAllowed": true // Enables the use of telekinesis for item drops.
"needEnchantment": true, // Defines, whether Magnetic should without or with the enchantment on the tool.
"needSneak": false, // Defines. whether the player should have to sneak in order to use Magnetic.
"expAllowed": true, // Enables the use of Magnetic for exp drops.
"itemsAllowed": true // Enables the use of Magnetic for item drops.
}
}
```
Expand All @@ -46,5 +46,4 @@ If you need help with any of my mods, join my [discord server](https://nyon.dev/

#### Paper Compatibility

The paper module of telekinesis is as of Minecraft version 1.20.2 discontinued cause of the lack of ability to
register the enchantment.
The paper module of magnetic is as of Minecraft version 1.20.2 discontinued cause of my lack of time to implement it.
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ val mcVersionName = property("versionName")!!.toString()
version = "$featureVersion-$mcVersionName"

group = "dev.nyon"
val githubRepo = "btwonion/telekinesis"
val githubRepo = "btwonion/magnetic"

base {
archivesName.set(rootProject.name)
Expand All @@ -36,7 +36,7 @@ loom {
}
}

accessWidenerPath = rootDir.resolve("src/main/resources/telekinesis.accesswidener")
accessWidenerPath = rootDir.resolve("src/main/resources/magnetic.accesswidener")
mixin { useLegacyMixinAp = false }
}

Expand Down Expand Up @@ -74,9 +74,9 @@ dependencies {
val javaVersion = if (stonecutter.eval(mcVersion, ">=1.20.6")) 21 else 17
tasks {
processResources {
val modId = "telekinesis"
val modName = "telekinesis"
val modDescription = "Adds auto-pickup functionality to the player. Also know as telekinesis from Hypixel Skyblock."
val modId = "magnetic"
val modName = "magnetic"
val modDescription = "Magnetically moves items and experience into your inventory. Also known as telekinesis from Hypixel Skyblock."

val props = mapOf(
"id" to modId,
Expand Down Expand Up @@ -163,7 +163,7 @@ publishing {
publications {
create<MavenPublication>("maven") {
groupId = "dev.nyon"
artifactId = "telekinesis"
artifactId = "magnetic"
version = project.version.toString()
from(components["java"])
}
Expand Down
5 changes: 2 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- change icon
- re-require yacl
- rename doubled function name in MobMixin
- rebrand mod to "magnetic"
- do not register telekinesis enchantment if "needEnchantment" is false
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "telekinesis"
rootProject.name = "magnetic"

pluginManagement {
repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.item.Item;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.animal.allay.Allay;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.nyon.telekinesis.DropEvent;
import dev.nyon.magnetic.DropEvent;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -22,7 +22,7 @@
import java.util.ArrayList;
import java.util.List;

import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal;
import static dev.nyon.magnetic.utils.MixinHelper.threadLocal;

@Mixin(Block.class)
public abstract class BlockMixin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.item.Item;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import net.minecraft.world.entity.vehicle.ChestBoat;
import org.spongepowered.asm.mixin.Mixin;
/*? if >1.20.2 && <1.21.2 {*/
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.world.damagesource.DamageSource;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

/*? if <1.21 {*/
/*import dev.nyon.telekinesis.MainKt;
import dev.nyon.telekinesis.TelekinesisEnchantment;
/*import dev.nyon.magnetic.MainKt;
import dev.nyon.magnetic.MagneticEnchantment;
import dev.nyon.magnetic.config.ConfigKt;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -20,21 +21,21 @@ public abstract class EnchantmentsMixin {

/*? if <1.21 {*/
/*@Unique
private static boolean isTelekinesisRegistered = false;
private static boolean isEnchantmentRegistered = false;
@Inject(
method = "register",
at = @At("RETURN")
)
private static void registerTelekinesis(
private static void registerEnchantment(
String identifier,
Enchantment enchantment,
CallbackInfoReturnable<Enchantment> cir
) {
if (!isTelekinesisRegistered) {
MainKt.setTelekinesis(new TelekinesisEnchantment());
isTelekinesisRegistered = true;
Registry.register(BuiltInRegistries.ENCHANTMENT, new ResourceLocation("telekinesis", "telekinesis"), MainKt.getTelekinesis());
if (!isEnchantmentRegistered && ConfigKt.getConfig().getNeedEnchantment()) {
MainKt.setMagnetic(new MagneticEnchantment());
isEnchantmentRegistered = true;
Registry.register(BuiltInRegistries.ENCHANTMENT, new ResourceLocation("magnetic", "magnetic"), MainKt.getMagnetic());
}
}
*//*?}*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.monster.EnderMan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyReceiver;
import dev.nyon.telekinesis.DropEvent;
import dev.nyon.magnetic.DropEvent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.player.Player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import dev.nyon.telekinesis.DropEvent;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.DropEvent;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
Expand All @@ -24,7 +24,7 @@
import java.util.List;
import java.util.function.Consumer;

import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal;
import static dev.nyon.magnetic.utils.MixinHelper.threadLocal;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import net.minecraft.world.entity.vehicle.MinecartTNT;
import org.spongepowered.asm.mixin.Mixin;

/*? if >1.20.2 && <1.21.2 {*/
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Mob;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.animal.Pig;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.monster.piglin.Piglin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.nyon.telekinesis.mixins;
package dev.nyon.magnetic.mixins;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.nyon.telekinesis.utils.MixinHelper;
import dev.nyon.magnetic.utils.MixinHelper;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package dev.nyon.magnetic.mixins;

import net.minecraft.resources.RegistryDataLoader;
import org.spongepowered.asm.mixin.Mixin;
/*? if >=1.21 {*/
import com.google.gson.JsonElement;
import com.mojang.serialization.Decoder;
import dev.nyon.magnetic.MagneticEnchantmentKt;
import dev.nyon.magnetic.config.ConfigKt;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.core.RegistrationInfo;
import net.minecraft.core.WritableRegistry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.RegistryOps;
import net.minecraft.server.packs.resources.Resource;
/*?}*/

@Mixin(RegistryDataLoader.class)
public class RegistryDataLoaderMixin {

/*? if >=1.21 {*/
@Inject(
method = "loadElementFromResource",
at = @At("HEAD"),
cancellable = true
)
private static <E> void cancelMagneticEnchantmentRegister(
WritableRegistry<E> registry,
Decoder<E> decoder,
RegistryOps<JsonElement> ops,
ResourceKey<E> registryKey,
Resource resource,
RegistrationInfo info,
CallbackInfo ci
) {
if (!ConfigKt.getConfig().getNeedEnchantment() && registryKey.location().equals(MagneticEnchantmentKt.getMagneticEnchantmentId())) ci.cancel();
}
/*?}*/
}
Loading

0 comments on commit e6c4958

Please sign in to comment.