Compare commits

..

17 Commits

Author SHA1 Message Date
d8a7331b84 chore: bump to 1.3 2025-12-03 18:43:28 +01:00
39065c8e98 fix: silly me, forgot to add it to mixins 2025-12-03 17:19:21 +01:00
c82c5f911f feat: add leash distance gamerules 2025-12-03 04:14:36 +01:00
75fed26c3c feat: ender eye break chance is a gamerule 2025-12-03 04:07:54 +01:00
790568b04d feat: divergence and power for the pearl are now gamerules 2025-12-03 04:01:39 +01:00
81590fd70d chore: capitalize name, add authors, add desc, fix repo -> sources 2025-12-03 03:48:36 +01:00
6832c058ef feat: change the icon 2025-12-03 03:45:27 +01:00
f00fcea551 feat: make creeper fuse time a gamerule 2025-12-03 03:44:51 +01:00
90a5d8ea95 chore: optimize imports 2025-12-03 03:33:26 +01:00
37310b3d61 feat: make crit damage multiplier a gamerule 2025-12-03 03:31:08 +01:00
fe7a1992b6 feat: make shield disable cooldown also a gamerule 2025-12-03 03:24:26 +01:00
88620d9d24 fix: negative ticks might not be a good idea 2025-12-03 03:18:12 +01:00
11649caaee fix: spacing 2025-12-03 03:16:21 +01:00
699b006cee chore: gamerules should use SCREAMING instead of Pascal_Snake_Case 2025-12-03 02:29:24 +01:00
73f605e0e4 fix: enderpearl -> enderPearl 2025-12-03 02:28:33 +01:00
c55d51bd05 chore: optimize imports 2025-12-03 02:27:57 +01:00
3a9833ed65 feat: go back to 1.21.3, cause we can 2025-12-03 02:27:36 +01:00
14 changed files with 273 additions and 21 deletions

View File

@@ -1,12 +1,12 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
minecraft_version=1.21.8
yarn_mappings=1.21.8+build.1
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.14
# Fabric API
fabric_version=0.129.0+1.21.8
fabric_version=0.107.3+1.21.3
# Mod Properties
mod_version=1.2.5
mod_version=1.3
maven_group=systems.brn
archives_base_name=tweaks

View File

@@ -6,10 +6,36 @@ import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
import net.minecraft.world.GameRules;
public class Tweaks implements ModInitializer {
public static final GameRules.Key<GameRules.IntRule> Entity_Portal_Cooldown =
GameRuleRegistry.register("entityPortalCooldown", GameRules.Category.MOBS, GameRuleFactory.createIntRule(300));
public static final GameRules.Key<GameRules.IntRule> Enderpearl_Damage =
GameRuleRegistry.register("enderpearlDamage", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(5));
public static final GameRules.Key<GameRules.IntRule> ENTITY_PORTAL_COOLDOWN =
GameRuleRegistry.register("entityPortalCooldown", GameRules.Category.MOBS, GameRuleFactory.createIntRule(300, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> ENDER_PEARL_DAMAGE =
GameRuleRegistry.register("enderPearlDamage", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(5, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> SHIELD_AXE_COOLDOWN =
GameRuleRegistry.register("shieldAxeCooldown", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(100, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> CRITICAL_MULTIPLIER =
GameRuleRegistry.register("criticalHitMultiplier", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(150, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> CREEPER_FUSE_TIME =
GameRuleRegistry.register("creeperDefaultFuseTime", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(30, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> ENDER_PEARL_POWER =
GameRuleRegistry.register("enderPearlPower", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(150, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> ENDER_PEARL_DIVERGENCE =
GameRuleRegistry.register("enderPearlDivergence", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(100, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> ENDER_EYE_POP_CHANCE =
GameRuleRegistry.register("enderEyePopChance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(20, 0, 100));
public static final GameRules.Key<GameRules.IntRule> LEASH_BREAK_DISTANCE =
GameRuleRegistry.register("leashBreakDistance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(10, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> LEASH_ELASTIC_DISTANCE =
GameRuleRegistry.register("leashElasticDistance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(6, 0, Integer.MAX_VALUE));
@Override
public void onInitialize() {
}

View File

@@ -0,0 +1,29 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import systems.brn.tweaks.Tweaks;
import systems.brn.tweaks.mixin.accessors.CreeperEntityAccessor;
@Mixin(CreeperEntity.class)
public abstract class CreeperEntityMixin {
@Inject(
method = "<init>",
at = @At("TAIL")
)
private void onConstructor(EntityType<? extends CreeperEntity> entityType, World world, CallbackInfo ci) {
CreeperEntity creeper = (CreeperEntity)(Object)this;
if (!world.isClient) {
ServerWorld serverWorld = (ServerWorld) world;
GameRules.IntRule rule = serverWorld.getGameRules().get(Tweaks.CREEPER_FUSE_TIME);
((CreeperEntityAccessor) creeper).setFuseTime(rule.get());
}
}
}

View File

@@ -1,15 +1,13 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import static systems.brn.tweaks.Tweaks.Enderpearl_Damage;
import static systems.brn.tweaks.Tweaks.ENDER_PEARL_DAMAGE;
@Mixin(net.minecraft.entity.projectile.thrown.EnderPearlEntity.class)
public class DontHurtMePearlMixin {
@@ -17,7 +15,7 @@ public class DontHurtMePearlMixin {
@Redirect(method = "onCollision(Lnet/minecraft/util/hit/HitResult;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;damage(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/damage/DamageSource;F)Z"))
private boolean redirectDamage(ServerPlayerEntity entity, ServerWorld world, DamageSource source, float amount) {
entity.damage(world, source, world.getGameRules().getInt(Enderpearl_Damage));
entity.damage(world, source, world.getGameRules().getInt(ENDER_PEARL_DAMAGE));
return false;
}
}

View File

@@ -0,0 +1,57 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.thrown.EnderPearlEntity;
import net.minecraft.item.EnderPearlItem;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import systems.brn.tweaks.Tweaks;
@Mixin(EnderPearlItem.class)
public class EnderPearlItemMixin {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
private void injectCustomVelocity(World world, PlayerEntity user, Hand hand,
CallbackInfoReturnable<ActionResult> cir) {
if (!(world instanceof ServerWorld serverWorld)) return;
ItemStack stack = user.getStackInHand(hand);
float power = serverWorld.getGameRules().getInt(Tweaks.ENDER_PEARL_POWER) / 100f;
float divergence = serverWorld.getGameRules().getInt(Tweaks.ENDER_PEARL_DIVERGENCE) / 100f;
world.playSound(
null,
user.getX(),
user.getY(),
user.getZ(),
net.minecraft.sound.SoundEvents.ENTITY_ENDER_PEARL_THROW,
net.minecraft.sound.SoundCategory.NEUTRAL,
0.5F,
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
);
net.minecraft.entity.projectile.ProjectileEntity.spawnWithVelocity(
EnderPearlEntity::new,
serverWorld,
stack,
user,
0f,
power,
divergence
);
user.incrementStat(net.minecraft.stat.Stats.USED.getOrCreateStat((EnderPearlItem)(Object)this));
stack.decrementUnlessCreative(1, user);
cir.setReturnValue(ActionResult.SUCCESS);
}
}

View File

@@ -0,0 +1,39 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.EyeOfEnderEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import systems.brn.tweaks.Tweaks;
import systems.brn.tweaks.mixin.accessors.EyeOfEnderEntityAccessor;
@Mixin(EyeOfEnderEntity.class)
public class EyeOfEnderMixin {
@Inject(
method = "initTargetPos",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/entity/EyeOfEnderEntity;dropsItem:Z",
ordinal = 0,
shift = At.Shift.AFTER
)
)
private void applyCustomBreakChance(CallbackInfo ci) {
EyeOfEnderEntity self = (EyeOfEnderEntity)(Object)this;
World world = self.getWorld();
if (!(world instanceof ServerWorld serverWorld))
return;
int popChance = serverWorld.getGameRules().getInt(Tweaks.ENDER_EYE_POP_CHANCE);
int roll = self.getRandom().nextInt(100);
boolean dropsItem = roll >= popChance;
((EyeOfEnderEntityAccessor) self).setDropsItem(dropsItem);
}
}

View File

@@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static systems.brn.tweaks.Tweaks.Entity_Portal_Cooldown;
import static systems.brn.tweaks.Tweaks.ENTITY_PORTAL_COOLDOWN;
@Mixin(net.minecraft.entity.Entity.class)
public class JustTeleportAlreadyMixin {
@@ -21,7 +21,7 @@ public class JustTeleportAlreadyMixin {
cancellable = true)
private void getDefaultPortalCooldown(CallbackInfoReturnable<Integer> cir) {
if (world instanceof ServerWorld sWorld) {
cir.setReturnValue(sWorld.getGameRules().getInt(Entity_Portal_Cooldown));
cir.setReturnValue(sWorld.getGameRules().getInt(ENTITY_PORTAL_COOLDOWN));
}
}
@@ -31,7 +31,7 @@ public class JustTeleportAlreadyMixin {
@Inject(method = "tickPortalCooldown", at = @At(value = "RETURN"))
private void tickPortalCooldown(CallbackInfo ci) {
if (world instanceof ServerWorld sWorld) {
int maxCooldown = sWorld.getGameRules().getInt(Entity_Portal_Cooldown);
int maxCooldown = sWorld.getGameRules().getInt(ENTITY_PORTAL_COOLDOWN);
if (portalCooldown > maxCooldown) {
portalCooldown = maxCooldown;
}

View File

@@ -0,0 +1,32 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Leashable;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import systems.brn.tweaks.Tweaks;
@Mixin(Leashable.class)
public interface LeashableMixin {
@ModifyConstant(
method = "tickLeash",
constant = @Constant(doubleValue = 10.0)
)
private static double modifyLeashBreakDistance(double original, ServerWorld world, Entity entity) {
GameRules.IntRule rule = world.getGameRules().get(Tweaks.LEASH_BREAK_DISTANCE);
return rule.get();
}
@ModifyConstant(
method = "tickLeash",
constant = @Constant(doubleValue = 6.0)
)
private static double modifyLeashElasticDistance(double original, ServerWorld world, Entity entity) {
GameRules.IntRule rule = world.getGameRules().get(Tweaks.LEASH_ELASTIC_DISTANCE);
return rule.get();
}
}

View File

@@ -0,0 +1,39 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import systems.brn.tweaks.Tweaks;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin {
@ModifyConstant(
method = "disableShield(Lnet/minecraft/item/ItemStack;)V",
constant = @Constant(intValue = 100)
)
private int modifyShieldCooldownConstant(int original) {
PlayerEntity player = (PlayerEntity)(Object)this;
if (player.getWorld() != null && player.getWorld() instanceof ServerWorld sWorld) {
GameRules.IntRule rule = sWorld.getGameRules().get(Tweaks.SHIELD_AXE_COOLDOWN);
return rule.get();
}
return original;
}
@ModifyConstant(
method = "attack",
constant = @Constant(floatValue = 1.5F)
)
private float modifyCriticalMultiplier(float original) {
PlayerEntity player = (PlayerEntity)(Object)this;
if (player.getWorld() != null && player.getWorld() instanceof ServerWorld serverWorld) {
GameRules.IntRule rule = serverWorld.getGameRules().get(Tweaks.CRITICAL_MULTIPLIER);
return rule.get() / 100.0F;
}
return original;
}
}

View File

@@ -0,0 +1,14 @@
package systems.brn.tweaks.mixin.accessors;
import net.minecraft.entity.mob.CreeperEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(CreeperEntity.class)
public interface CreeperEntityAccessor {
@Accessor("fuseTime")
void setFuseTime(int fuseTime);
@Accessor("fuseTime")
int getFuseTime();
}

View File

@@ -0,0 +1,11 @@
package systems.brn.tweaks.mixin.accessors;
import net.minecraft.entity.EyeOfEnderEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(EyeOfEnderEntity.class)
public interface EyeOfEnderEntityAccessor {
@Accessor("dropsItem")
void setDropsItem(boolean value);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -2,11 +2,11 @@
"schemaVersion": 1,
"id": "tweaks",
"version": "${version}",
"name": "tweaks",
"description": "",
"authors": [],
"name": "Tweaks",
"description": "Change some values in Minecraft using gamerules",
"authors": ["BRNSystems", "Akis"],
"contact": {
"repo": "https://git.brn.systems/BRNSystems/tweaks"
"sources": "https://git.brn.systems/BRNSystems/tweaks"
},
"license": "MIT",
"icon": "assets/icon.png",
@@ -22,6 +22,6 @@
"depends": {
"fabricloader": ">=${loader_version}",
"fabric": "*",
"minecraft": "${minecraft_version}"
"minecraft": ">=${minecraft_version}"
}
}

View File

@@ -4,8 +4,15 @@
"package": "systems.brn.tweaks.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"CreeperEntityMixin",
"DontHurtMePearlMixin",
"JustTeleportAlreadyMixin"
"EnderPearlItemMixin",
"EyeOfEnderMixin",
"JustTeleportAlreadyMixin",
"LeashableMixin",
"PlayerEntityMixin",
"accessors.CreeperEntityAccessor",
"accessors.EyeOfEnderEntityAccessor"
],
"injectors": {
"defaultRequire": 1