-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
221 additions
and
317 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
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 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 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 |
---|---|---|
|
@@ -2,38 +2,32 @@ | |
* Patch for MC-123450 | ||
* | ||
* Authored for CraftBukkit/Spigot by Phoenix616 <[email protected]> on November 5, 2022. | ||
* Ported to Fabric by Rektroth <[email protected]> on April 26, 2024. | ||
* Ported to Fabric by Rektroth <[email protected]> on April 27, 2024. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.mc123450; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import net.minecraft.component.DataComponentTypes; | ||
import net.minecraft.component.type.MapIdComponent; | ||
import net.minecraft.entity.decoration.ItemFrameEntity; | ||
import net.minecraft.item.ItemStack; | ||
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 org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ItemFrameEntity.class) | ||
public abstract class ItemFrameEntityMixin { | ||
/** | ||
* Sets the map ID to the ID of the map in the player's item stack rather than the already removed map, | ||
* so that the map ID is not null when it tries to remove the green marker. | ||
* @param stack The item stack. | ||
* @param ci boilerplate | ||
* @param mapIdComponent The map ID. | ||
* Redirects checking if the item frame is empty to check both that and if the item frame was updated, | ||
* so that the item frame only plays a sound when updated. | ||
* @param value The item stack. | ||
* @param update Whether the item frame was updated. | ||
* @return True if the item frame should play its place sound, false otherwise. | ||
*/ | ||
@Inject( | ||
at = @At( | ||
target = "Lnet/minecraft/entity/decoration/ItemFrameEntity;getMapId()Lnet/minecraft/component/type/MapIdComponent;", | ||
value = "INVOKE_ASSIGN"), | ||
method = "removeFromFrame" | ||
@Redirect( | ||
at = @At(target = "Lnet/minecraft/item/ItemStack;isEmpty()Z", value = "INVOKE", ordinal = 1), | ||
method = "setHeldItemStack(Lnet/minecraft/item/ItemStack;Z)V" | ||
) | ||
private void getMapIdFromItem(ItemStack stack, CallbackInfo ci, @Local LocalRef<MapIdComponent> mapIdComponent) { | ||
mapIdComponent.set(stack.get(DataComponentTypes.MAP_ID)); | ||
private boolean shouldPlaySound(ItemStack value, @Local(argsOnly = true) boolean update) { | ||
return !(!value.isEmpty() && update); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,32 +2,40 @@ | |
* Patch for MC-123848 | ||
* | ||
* Authored for CraftBukkit/Spigot by Jake Potrebic <[email protected]> on July 11, 2022. | ||
* Ported to Fabric by Rektroth <[email protected]> on April 27, 2024. | ||
* Ported to Fabric by Rektroth <[email protected]> on April 25, 2024. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.mc123848; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.ItemEntity; | ||
import net.minecraft.entity.decoration.AbstractDecorationEntity; | ||
import net.minecraft.entity.decoration.ItemFrameEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ItemFrameEntity.class) | ||
public abstract class ItemFrameEntityMixin { | ||
public abstract class ItemFrameEntityMixin extends AbstractDecorationEntity { | ||
/** | ||
* Redirects checking if the item frame is empty to check both that and if the item frame was updated, | ||
* so that the item frame only plays a sound when updated. | ||
* @param value The item stack. | ||
* @param update Whether the item frame was updated. | ||
* @return True if the item frame should play its place sound, false otherwise. | ||
* boilerplate | ||
* @param entityType boilerplate | ||
* @param world boilerplate | ||
*/ | ||
@Redirect( | ||
at = @At(target = "Lnet/minecraft/item/ItemStack;isEmpty()Z", value = "INVOKE", ordinal = 1), | ||
method = "setHeldItemStack(Lnet/minecraft/item/ItemStack;Z)V" | ||
) | ||
private boolean shouldPlaySound(ItemStack value, @Local(argsOnly = true) boolean update) { | ||
return !(!value.isEmpty() && update); | ||
protected ItemFrameEntityMixin(EntityType<? extends AbstractDecorationEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
/** | ||
* Overrides the parent method to drop the item stack as an entity *below* the item frame when facing down. | ||
* @param stack The item stack. | ||
* @return The item entity to drop. | ||
*/ | ||
@Nullable | ||
@Override | ||
public ItemEntity dropStack(ItemStack stack) { | ||
return this.dropStack(stack, getMovementDirection().equals(Direction.DOWN) ? -0.6F : 0.0F); | ||
} | ||
} |
Oops, something went wrong.