Merge remote-tracking branch 'origin/1.15' into 1.15

# Conflicts:
#	fabric-events-interaction-v0/build.gradle
This commit is contained in:
modmuss50 2019-09-21 11:30:30 +01:00
commit c208a44d66
6 changed files with 31 additions and 24 deletions

View file

@ -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')

View file

@ -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<UseItemCallback> 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<ItemStack> 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<ItemStack> interact(PlayerEntity player, World world, Hand hand);
}

View file

@ -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<ActionResult> 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<TypedActionResult<ItemStack>> info) {
TypedActionResult<ItemStack> 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);

View file

@ -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<ActionResult> info) {
ActionResult result = UseItemCallback.EVENT.invoker().interact(player, world, hand);
if (result != ActionResult.PASS) {
info.setReturnValue(result);
TypedActionResult<ItemStack> result = UseItemCallback.EVENT.invoker().interact(player, world, hand);
if (result.getResult() != ActionResult.PASS) {
info.setReturnValue(result.getResult());
info.cancel();
return;
}

View file

@ -17,7 +17,8 @@
],
"depends": {
"fabricloader": ">=0.4.0",
"fabric-api-base": "*"
"fabric-api-base": "*",
"minecraft": ">=1.15-alpha.19.37.a"
},
"entrypoints": {
"main": [

View file

@ -52,20 +52,21 @@ public class MixinFluidRenderer {
public void tesselate(BlockRenderView view, BlockPos pos, BufferBuilder bufferBuilder, FluidState state, CallbackInfoReturnable<Boolean> 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)