-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced legacy javascript asm with mixins
- Loading branch information
Showing
5 changed files
with
73 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/******************************************************************************* | ||
* Copyright 2023, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package toughasnails.mixin; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.food.FoodData; | ||
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 toughasnails.thirst.ThirstHooks; | ||
|
||
@Mixin(FoodData.class) | ||
public abstract class MixinFoodData | ||
{ | ||
@Inject(method="tick", at=@At(value="HEAD"), cancellable = true) | ||
public void onTick(Player player, CallbackInfo ci) | ||
{ | ||
ThirstHooks.doFoodDataTick((FoodData)(Object)this, player); | ||
ci.cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright 2023, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package toughasnails.mixin; | ||
|
||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Abilities; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.food.FoodData; | ||
import net.minecraft.world.level.Level; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import toughasnails.thirst.ThirstHooks; | ||
|
||
@Mixin(Player.class) | ||
public abstract class MixinPlayer extends LivingEntity | ||
{ | ||
@Shadow | ||
protected FoodData foodData = new FoodData(); | ||
|
||
@Shadow | ||
@Final | ||
private Abilities abilities; | ||
|
||
private MixinPlayer(EntityType<? extends LivingEntity> type, Level level) | ||
{ | ||
super(type, level); | ||
} | ||
|
||
@Inject(method="causeFoodExhaustion", at=@At(value="HEAD")) | ||
public void onCauseFoodExhaustion(float exhaustion, CallbackInfo ci) | ||
{ | ||
if (!this.abilities.invulnerable) | ||
{ | ||
if (!this.level().isClientSide) | ||
{ | ||
ThirstHooks.onCauseFoodExhaustion((Player)(Object)this, exhaustion); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.