Skip to content

Commit

Permalink
fix: Allow manually wearing elytra if on ground; fix restocking for w…
Browse files Browse the repository at this point in the history
…ater buckets (changed an injecting point) (#12)

* fix: Allow manually wearing elytra if on ground; fix restocking for water buckets (changed an injecting point)

* fix
  • Loading branch information
zly2006 authored Jul 8, 2024
1 parent e976a99 commit 3620207
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fi.dy.masa.tweakeroo.mixin;

import net.minecraft.entity.data.TrackedData;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -35,6 +36,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Shadow protected int ticksLeftToDoubleTapSprint;
@Shadow public float prevNauseaIntensity;
@Shadow public float nauseaIntensity;
@Shadow private boolean falling;
@Unique private final DummyMovementInput dummyMovementInput = new DummyMovementInput(null);
@Unique private Input realInput;
@Unique private float realNauseaIntensity;
Expand Down Expand Up @@ -151,30 +153,34 @@ private void onFallFlyingCheckChestSlot(CallbackInfo ci)
}
}

@Inject(method = "tickMovement", at = @At("RETURN"))
private void onMovementEnd(CallbackInfo ci)

@Inject(method = "onTrackedDataSet", at = @At("RETURN"))
private void onStopFlying(TrackedData<?> data, CallbackInfo ci)
{
if (FeatureToggle.TWEAK_AUTO_SWITCH_ELYTRA.getBooleanValue())
{
if (!this.isFallFlying() && this.getEquippedStack(EquipmentSlot.CHEST).isOf(Items.ELYTRA))
if (FLAGS.equals(data) && this.falling)
{
if (!this.autoSwitchElytraChestplate.isEmpty())
if (!this.isFallFlying() && this.getEquippedStack(EquipmentSlot.CHEST).isOf(Items.ELYTRA))
{
if (this.playerScreenHandler.getCursorStack().isEmpty())
if (!this.autoSwitchElytraChestplate.isEmpty() && !this.autoSwitchElytraChestplate.isOf(Items.ELYTRA))
{
int targetSlot = InventoryUtils.findSlotWithItem(this.playerScreenHandler, this.autoSwitchElytraChestplate, true, false);

if (targetSlot >= 0)
if (this.playerScreenHandler.getCursorStack().isEmpty())
{
InventoryUtils.swapItemToEquipmentSlot(this, EquipmentSlot.CHEST, targetSlot);
this.autoSwitchElytraChestplate = ItemStack.EMPTY;
int targetSlot = InventoryUtils.findSlotWithItem(this.playerScreenHandler, this.autoSwitchElytraChestplate, true, false);

if (targetSlot >= 0)
{
InventoryUtils.swapItemToEquipmentSlot(this, EquipmentSlot.CHEST, targetSlot);
this.autoSwitchElytraChestplate = ItemStack.EMPTY;
}
}
}
}
else
{
// if cached previous item is empty, try to swap back to the default chest plate.
InventoryUtils.swapElytraWithChestPlate(this);
else
{
// if cached previous item is empty, try to swap back to the default chest plate.
InventoryUtils.swapElytraWithChestPlate(this);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,14 @@ private void onProcessRightClickFirst(PlayerEntity player, Hand hand, CallbackIn
}
}

@Inject(method = "method_41929",
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/item/ItemStack;use(" +
"Lnet/minecraft/world/World;" +
"Lnet/minecraft/entity/player/PlayerEntity;" +
"Lnet/minecraft/util/Hand;" +
")Lnet/minecraft/util/TypedActionResult;")),
at = @At("RETURN"))
private void onProcessRightClickPost(Hand hand, PlayerEntity playerEntity,
MutableObject<?> mutableObject, int sequence,
CallbackInfoReturnable<Packet<?>> cir)
@Inject(method = "interactItem",
at = @At("TAIL"))
private void onProcessRightClickPost(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir)
{
PlacementTweaks.onProcessRightClickPost(playerEntity, hand);
if (cir.getReturnValue().isAccepted())
{
PlacementTweaks.onProcessRightClickPost(player, hand);
}
}

@Inject(method = "interactEntity(" +
Expand Down

0 comments on commit 3620207

Please sign in to comment.