fix comparator output not showing on fabric
This commit is contained in:
parent
f08959d90e
commit
e61b5c1255
4 changed files with 6 additions and 9 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue