fix comparator output not showing on fabric

This commit is contained in:
yrsegal@gmail.com 2022-06-04 10:24:31 -04:00
parent f08959d90e
commit e61b5c1255
4 changed files with 6 additions and 9 deletions

View file

@ -85,7 +85,7 @@ public class ItemLens extends Item implements Wearable {
private static final Map<ServerPlayer, Pair<BlockPos, Integer>> comparatorDataMap = new WeakHashMap<>(); private static final Map<ServerPlayer, Pair<BlockPos, Integer>> comparatorDataMap = new WeakHashMap<>();
private void sendComparatorDataToClient(ServerPlayer player) { private void sendComparatorDataToClient(ServerPlayer player) {
double reachAttribute = player.getAttribute(IXplatAbstractions.INSTANCE.getReachDistance()).getValue(); double reachAttribute = IXplatAbstractions.INSTANCE.getReachDistance(player);
double distance = player.isCreative() ? reachAttribute : reachAttribute - 0.5; double distance = player.isCreative() ? reachAttribute : reachAttribute - 0.5;
var hitResult = player.pick(distance, 0, false); var hitResult = player.pick(distance, 0, false);
if (hitResult.getType() == HitResult.Type.BLOCK) { if (hitResult.getType() == HitResult.Type.BLOCK) {

View file

@ -19,7 +19,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
@ -61,7 +60,7 @@ public interface IXplatAbstractions {
// https://github.com/VazkiiMods/Botania/blob/13b7bcd9cbb6b1a418b0afe455662d29b46f1a7f/Xplat/src/main/java/vazkii/botania/xplat/IXplatAbstractions.java#L157 // https://github.com/VazkiiMods/Botania/blob/13b7bcd9cbb6b1a418b0afe455662d29b46f1a7f/Xplat/src/main/java/vazkii/botania/xplat/IXplatAbstractions.java#L157
Packet<?> toVanillaClientboundPacket(IMessage message); Packet<?> toVanillaClientboundPacket(IMessage message);
Attribute getReachDistance(); double getReachDistance(Player player);
// Things that used to be caps // Things that used to be caps

View file

@ -41,7 +41,6 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.npc.Villager; import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -90,8 +89,8 @@ public class FabricXplatImpl implements IXplatAbstractions {
} }
@Override @Override
public Attribute getReachDistance() { public double getReachDistance(Player player) {
return ReachEntityAttributes.REACH; return ReachEntityAttributes.getReachDistance(player, 5.0);
} }
@Override @Override

View file

@ -42,7 +42,6 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.npc.Villager; import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -101,8 +100,8 @@ public class ForgeXplatImpl implements IXplatAbstractions {
} }
@Override @Override
public Attribute getReachDistance() { public double getReachDistance(Player player) {
return ForgeMod.REACH_DISTANCE.get(); return player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());
} }
@Override @Override