update fabric api for new block break event. fix #3 and kyrptonaught/DiggusMaximus#23

This commit is contained in:
Flemmli97 2020-09-15 12:01:41 +02:00
parent e9c6812b92
commit ae0af14b96
4 changed files with 8 additions and 8 deletions

View File

@ -14,5 +14,5 @@ org.gradle.jvmargs=-Xmx2G
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.17.2+build.396-1.16
fabric_version=0.19.0+build.398-1.16
cca_version=2.5.0-nightly.1.16.2-rc2

View File

@ -9,8 +9,8 @@ import com.flemmli97.flan.event.ItemInteractEvents;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.event.player.UseEntityCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
@ -19,7 +19,7 @@ public class Flan implements ModInitializer {
@Override
public void onInitialize() {
AttackBlockCallback.EVENT.register(BlockInteractEvents::breakBlocks);
PlayerBlockBreakEvents.BEFORE.register(BlockInteractEvents::breakBlocks);
UseBlockCallback.EVENT.register(BlockInteractEvents::useBlocks);
UseEntityCallback.EVENT.register(EntityInteractEvents::useAtEntity);
AttackEntityCallback.EVENT.register(EntityInteractEvents::attackEntity);

View File

@ -32,19 +32,19 @@ import net.minecraft.world.World;
public class BlockInteractEvents {
public static ActionResult breakBlocks(PlayerEntity p, World world, Hand hand, BlockPos pos, Direction dir) {
public static boolean breakBlocks(World world, PlayerEntity p, BlockPos pos, BlockState state, BlockEntity tile){
if (world.isClient || p.isSpectator())
return ActionResult.PASS;
return true;
ServerPlayerEntity player = (ServerPlayerEntity) p;
ClaimStorage storage = ClaimStorage.get((ServerWorld) world);
Claim claim = storage.getClaimAt(pos);
if (claim != null) {
if (!claim.canInteract(player, EnumPermission.BREAK, pos, true)) {
PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
return ActionResult.SUCCESS;
return false;
}
}
return ActionResult.PASS;
return true;
}
//Right click block

View File

@ -28,7 +28,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"fabric": ">=0.19.0",
"minecraft": "1.16.x"
},
"suggests": {