diff --git a/fabric-events-interaction-v0/build.gradle b/fabric-events-interaction-v0/build.gradle index 2a27a0ecf..fafec5b5a 100644 --- a/fabric-events-interaction-v0/build.gradle +++ b/fabric-events-interaction-v0/build.gradle @@ -1,5 +1,5 @@ archivesBaseName = "fabric-events-interaction-v0" -version = getSubprojectVersion(project, "0.1.3") +version = getSubprojectVersion(project, "0.2.1") dependencies { compile project(path: ':fabric-api-base', configuration: 'dev') diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseItemCallback.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseItemCallback.java index 38e27d5b5..752eea77c 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseItemCallback.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseItemCallback.java @@ -19,8 +19,10 @@ package net.fabricmc.fabric.api.event.player; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; /** @@ -34,17 +36,17 @@ import net.minecraft.world.World; */ public interface UseItemCallback { public static final Event EVENT = EventFactory.createArrayBacked(UseItemCallback.class, - (listeners) -> (player, world, hand) -> { + listeners -> (player, world, hand) -> { for (UseItemCallback event : listeners) { - ActionResult result = event.interact(player, world, hand); - if (result != ActionResult.PASS) { + TypedActionResult result = event.interact(player, world, hand); + if (result.getResult() != ActionResult.PASS) { return result; } } - return ActionResult.PASS; + return TypedActionResult.method_22430(ItemStack.EMPTY); } ); - ActionResult interact(PlayerEntity player, World world, Hand hand); + TypedActionResult interact(PlayerEntity player, World world, Hand hand); } diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinClientPlayerInteractionManager.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinClientPlayerInteractionManager.java index 237153f2f..c1832de45 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinClientPlayerInteractionManager.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinClientPlayerInteractionManager.java @@ -24,11 +24,13 @@ import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.server.network.packet.PlayerInteractBlockC2SPacket; import net.minecraft.server.network.packet.PlayerInteractEntityC2SPacket; import net.minecraft.server.network.packet.PlayerInteractItemC2SPacket; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.math.BlockPos; @@ -87,10 +89,10 @@ public class MixinClientPlayerInteractionManager { } @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 0), method = "interactItem", cancellable = true) - public void interactItem(PlayerEntity player, World world, Hand hand, CallbackInfoReturnable info) { - ActionResult result = UseItemCallback.EVENT.invoker().interact(player, world, hand); - if (result != ActionResult.PASS) { - if (result == ActionResult.SUCCESS) { + public void interactItem(PlayerEntity player, World world, Hand hand, CallbackInfoReturnable> info) { + TypedActionResult result = UseItemCallback.EVENT.invoker().interact(player, world, hand); + if (result.getResult() != ActionResult.PASS) { + if (result.getResult() == ActionResult.SUCCESS) { this.networkHandler.sendPacket(new PlayerInteractItemC2SPacket(hand)); } info.setReturnValue(result); diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinServerPlayerInteractionManager.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinServerPlayerInteractionManager.java index 8955b3edd..7806c4ae7 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinServerPlayerInteractionManager.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/eventsinteraction/MixinServerPlayerInteractionManager.java @@ -28,6 +28,7 @@ import net.minecraft.server.network.packet.PlayerActionC2SPacket; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -68,9 +69,9 @@ public class MixinServerPlayerInteractionManager { @Inject(at = @At("HEAD"), method = "interactItem", cancellable = true) public void interactItem(PlayerEntity player, World world, ItemStack stack, Hand hand, CallbackInfoReturnable info) { - ActionResult result = UseItemCallback.EVENT.invoker().interact(player, world, hand); - if (result != ActionResult.PASS) { - info.setReturnValue(result); + TypedActionResult result = UseItemCallback.EVENT.invoker().interact(player, world, hand); + if (result.getResult() != ActionResult.PASS) { + info.setReturnValue(result.getResult()); info.cancel(); return; } diff --git a/fabric-events-interaction-v0/src/main/resources/fabric.mod.json b/fabric-events-interaction-v0/src/main/resources/fabric.mod.json index 18f860d4b..a87909b49 100644 --- a/fabric-events-interaction-v0/src/main/resources/fabric.mod.json +++ b/fabric-events-interaction-v0/src/main/resources/fabric.mod.json @@ -17,7 +17,8 @@ ], "depends": { "fabricloader": ">=0.4.0", - "fabric-api-base": "*" + "fabric-api-base": "*", + "minecraft": ">=1.15-alpha.19.37.a" }, "entrypoints": { "main": [ diff --git a/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/mixin/client/render/fluid/MixinFluidRenderer.java b/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/mixin/client/render/fluid/MixinFluidRenderer.java index 2bd6714f7..6128c8653 100644 --- a/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/mixin/client/render/fluid/MixinFluidRenderer.java +++ b/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/mixin/client/render/fluid/MixinFluidRenderer.java @@ -52,20 +52,21 @@ public class MixinFluidRenderer { public void tesselate(BlockRenderView view, BlockPos pos, BufferBuilder bufferBuilder, FluidState state, CallbackInfoReturnable info) { FluidRendererHookContainer ctr = fabric_renderHandler.get(); FluidRenderHandler handler = FluidRenderHandlerRegistryImpl.INSTANCE.getOverride(state.getFluid()); - if (handler == null) { - return; - } - - /* ActionResult hResult = handler.tesselate(view, pos, bufferBuilder, state); - if (hResult != ActionResult.PASS) { - info.setReturnValue(hResult == ActionResult.SUCCESS); - return; - } */ ctr.view = view; ctr.pos = pos; ctr.state = state; ctr.handler = handler; + + /* if (handler == null) { + return; + } + + ActionResult hResult = handler.tesselate(view, pos, bufferBuilder, state); + if (hResult != ActionResult.PASS) { + info.setReturnValue(hResult == ActionResult.SUCCESS); + return; + } */ } @Inject(at = @At("RETURN"), method = "tesselate") @@ -81,7 +82,7 @@ public class MixinFluidRenderer { // Has other uses but those have already happened by the time the hook is called. final FluidRendererHookContainer ctr = fabric_renderHandler.get(); - return chk || (ctr != null && !ctr.state.matches(FluidTags.WATER)); + return chk || !ctr.state.matches(FluidTags.WATER); } @ModifyVariable(at = @At(value = "INVOKE", target = "net/minecraft/client/render/block/FluidRenderer.isSameFluid(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/fluid/FluidState;)Z"), method = "tesselate", ordinal = 0)