Skip to content

Commit

Permalink
fix multiplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Wudji committed Jun 10, 2023
1 parent e27a914 commit 5032b29
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/main/java/troy/autofish/monitor/FishMonitorMPMotion.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package troy.autofish.monitor;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.projectile.FishingBobberEntity;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
Expand All @@ -30,7 +31,7 @@ public class FishMonitorMPMotion implements FishMonitorMP {

@Override
public void hookTick(Autofish autofish, MinecraftClient minecraft, FishingBobberEntity hook) {
if (worldContainsBlockWithMaterial(hook.getWorld(), hook.getBoundingBox())) {
if (worldContainsBlockWithMaterial(hook.getWorld(), hook.getBoundingBox(), Blocks.WATER)) {
hasHitWater = true;
}
}
Expand Down Expand Up @@ -71,18 +72,13 @@ public void handlePacket(Autofish autofish, Packet<?> packet, MinecraftClient mi
}
}

public static boolean worldContainsBlockWithMaterial(World world, Box box/*, Material material*/) {
public static boolean worldContainsBlockWithMaterial(World world, Box box, Block block) {
int i = MathHelper.floor(box.minX);
int j = MathHelper.ceil(box.maxX);
int k = MathHelper.floor(box.minY);
int l = MathHelper.ceil(box.maxY);
int m = MathHelper.floor(box.minZ);
int n = MathHelper.ceil(box.maxZ);
// MaterialPredicate materialPredicate = MaterialPredicate.create(material);
return BlockPos.stream(i, k, m, j - 1, l - 1, n - 1).anyMatch((blockPos) -> {
// world.getBlockState(blockPos).contains(new Property<T>() {});
return world.getBlockState(blockPos).contains(Properties.LEVEL_8);
// return materialPredicate.test(world.getBlockState(blockPos));
});
return BlockPos.stream(i, k, m, j - 1, l - 1, n - 1).anyMatch((blockPos) -> world.getBlockState(blockPos).getBlock() == block);
}
}

0 comments on commit 5032b29

Please sign in to comment.