Skip to content

Commit

Permalink
Added KeepInventoryResetXp rule
Browse files Browse the repository at this point in the history
(Deleted useless Dispenser Mixin)
  • Loading branch information
RLLD576 committed Jan 15, 2024
1 parent 47cf321 commit d87c7f9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 46 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/rober/robercarpet/RoberCarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ public class RoberCarpetSettings {

@Rule(desc="Falling blocks over walls would not have friction with the floor as in 1.12",category = {"rober","falling-block"})
public static boolean FallingBlockNoFrictionWithWalls = false;

@Rule(desc="If using keep inventory gamerule, the player xp wil be reset on death (vanilla if keep inventory off)",category = "rober")
public static boolean KeepInventoryResetXP = false;
}
45 changes: 0 additions & 45 deletions src/main/java/net/rober/robercarpet/mixin/FarmableClayMixin.java

This file was deleted.

24 changes: 24 additions & 0 deletions src/main/java/net/rober/robercarpet/mixin/KeepInventoryMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.rober.robercarpet.mixin;

import net.minecraft.server.network.ServerPlayerEntity;
import net.rober.robercarpet.RoberCarpetSettings;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ServerPlayerEntity.class)
public abstract class KeepInventoryMixin {
@Redirect(method= "copyFrom(Lnet/minecraft/server/network/ServerPlayerEntity;Z)V",at=@At(value = "FIELD",target = "Lnet/minecraft/server/network/ServerPlayerEntity;experienceLevel:I", opcode = Opcodes.PUTFIELD))
private void LevelMixin(ServerPlayerEntity player, int original){
player.experienceLevel = RoberCarpetSettings.KeepInventoryResetXP?0:original;
}
@Redirect(method= "copyFrom(Lnet/minecraft/server/network/ServerPlayerEntity;Z)V",at=@At(value = "FIELD",target = "Lnet/minecraft/server/network/ServerPlayerEntity;totalExperience:I", opcode = Opcodes.PUTFIELD))
private void TotalMixin(ServerPlayerEntity player, int original){
player.totalExperience = RoberCarpetSettings.KeepInventoryResetXP?0:original;
}
@Redirect(method= "copyFrom(Lnet/minecraft/server/network/ServerPlayerEntity;Z)V",at=@At(value = "FIELD",target = "Lnet/minecraft/server/network/ServerPlayerEntity;experienceProgress:F", opcode = Opcodes.PUTFIELD))
private void ProgressMixin(ServerPlayerEntity player, float original){
player.experienceProgress = RoberCarpetSettings.KeepInventoryResetXP?0:original;
}
}
3 changes: 2 additions & 1 deletion src/main/resources/robercarpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"mixins": [
"FallingBlockMixin",
"SleepingDelayMixin",
"ThunderWarnMixin"
"ThunderWarnMixin",
"KeepInventoryMixin"
],
"client": [],
"injectors": {
Expand Down

0 comments on commit d87c7f9

Please sign in to comment.