more code, simpler mixin
This commit is contained in:
1 parent
28a5e7acf1
commit
f5900cffc6
1 file changed
+12
-10
@@ -1,8 +1,11 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -10,26 +13,25 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ExperienceOrbEntity.class)
|
||||
public abstract class ExperienceOrbEntityMixin {
|
||||
public abstract class ExperienceOrbEntityMixin extends Entity
|
||||
{
|
||||
@Shadow
|
||||
private int pickingCount;
|
||||
|
||||
@Shadow
|
||||
private int amount;
|
||||
|
||||
public ExperienceOrbEntityMixin(EntityType<?> type, World world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
protected abstract int repairPlayerGears(PlayerEntity player, int amount);
|
||||
|
||||
@Inject(
|
||||
method = "onPlayerCollision",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "net/minecraft/entity/player/PlayerEntity.experiencePickUpDelay:I",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
@Inject(method = "onPlayerCollision", at = @At("HEAD"))
|
||||
private void addXP(PlayerEntity player, CallbackInfo ci) {
|
||||
if (CarpetSettings.xpNoCooldown) {
|
||||
if (CarpetSettings.xpNoCooldown && !world.isClient) {
|
||||
player.experiencePickUpDelay = 0;
|
||||
// reducing the count to 1 and leaving vanilla to deal with it
|
||||
while (this.pickingCount > 1) {
|
||||
|
||||
Reference in new issue
Block a user