Skip to content

Commit

Permalink
Fix includeData in pick events (#4232)
Browse files Browse the repository at this point in the history
* Fix includeData in pick events

* Fix javadoc
  • Loading branch information
apple502j authored Nov 18, 2024
1 parent a884cf3 commit f12498d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ default void clearMusic() {
}

/**
* @see BiomeEffects#method_65135()
* @see BiomeEffects.Builder#method_65137(int)
* @see BiomeEffects#getMusicVolume()
* @see BiomeEffects.Builder#musicVolume(float)
*/
void setMusicVolume(float volume);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* <p>Fabric implements this on {@link Entity}, {@link BlockEntity}, {@link ServerWorld} and {@link Chunk} via mixin.</p>
*
* <p>Note about {@link BlockEntity} and {@link Chunk} targets: these objects need to be notified of changes to their
* state (using {@link BlockEntity#markDirty()} and {@link Chunk#setNeedsSaving(boolean)} respectively), otherwise the modifications will not take effect properly.
* state (using {@link BlockEntity#markDirty()} and {@link Chunk#markNeedsSaving()} respectively), otherwise the modifications will not take effect properly.
* The {@link #setAttached(AttachmentType, Object)} method handles this automatically, but this needs to be done manually
* when attached data is mutable, for example:
* <pre>{@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import net.minecraft.data.recipe.CraftingRecipeJsonBuilder;
import net.minecraft.data.recipe.RecipeExporter;
import net.minecraft.data.recipe.RecipeGenerator;
import net.minecraft.data.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.data.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.recipe.Recipe;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/**
* Convenience interface for blocks that want more stack picking context than what
* {@link Block#getPickStack(WorldView, BlockPos, BlockState)} provides.
* {@link Block#getPickStack(WorldView, BlockPos, BlockState, boolean)} provides.
*
* <p>The hit result is guaranteed to be a {@link BlockHitResult} that did not miss.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ private void onPickItem(ItemStack stack) {
}

@WrapOperation(method = "onPickItemFromBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getPickStack(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;Z)Lnet/minecraft/item/ItemStack;"))
public ItemStack onPickItemFromBlock(BlockState state, WorldView world, BlockPos pos, boolean bl, Operation<ItemStack> operation, @Local PickItemFromBlockC2SPacket packet) {
ItemStack stack = PlayerPickItemEvents.BLOCK.invoker().onPickItemFromBlock(player, pos, state, packet.includeData());
public ItemStack onPickItemFromBlock(BlockState state, WorldView world, BlockPos pos, boolean includeData, Operation<ItemStack> operation, @Local PickItemFromBlockC2SPacket packet) {
ItemStack stack = PlayerPickItemEvents.BLOCK.invoker().onPickItemFromBlock(player, pos, state, includeData);

if (stack == null) {
return operation.call(state, world, pos, bl);
return operation.call(state, world, pos, includeData);
} else if (!stack.isEmpty()) {
this.onPickItem(stack);
}
Expand All @@ -63,7 +63,7 @@ public ItemStack onPickItemFromBlock(BlockState state, WorldView world, BlockPos

@WrapOperation(method = "onPickItemFromEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPickBlockStack()Lnet/minecraft/item/ItemStack;"))
public ItemStack onPickItemFromEntity(Entity entity, Operation<ItemStack> operation, @Local PickItemFromEntityC2SPacket packet) {
ItemStack stack = PlayerPickItemEvents.ENTITY.invoker().onPickItemFromEntity(player, entity, packet.includeData());
ItemStack stack = PlayerPickItemEvents.ENTITY.invoker().onPickItemFromEntity(player, entity, packet.includeData() && player.isInCreativeMode());

if (stack == null) {
return operation.call(entity);
Expand Down

0 comments on commit f12498d

Please sign in to comment.