Skip to content

Commit

Permalink
Fix Abacus getting glitchy af when you walk really far with it
Browse files Browse the repository at this point in the history
  • Loading branch information
quat1024 committed Dec 7, 2023
1 parent 8ec2273 commit 91a6332
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.violetmoon.quark.content.tools.item;

import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.util.Mth;
import net.minecraft.world.item.CreativeModeTabs;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -71,7 +73,7 @@ public static int getCount(ItemStack stack, BlockPos target, Level world) {
BlockPos pos = getBlockPos(stack);

if(pos != null && !world.isEmptyBlock(target))
return target.distManhattan(pos);
return Mth.clamp(target.distManhattan(pos), 0, MAX_COUNT);

return -1;
}
Expand All @@ -93,12 +95,12 @@ public static int getCount(ItemStack stack, LivingEntity entityIn) {
return count;
}

public static float count(ItemStack stack, ClientLevel world, LivingEntity entityIn, int id) {
public static final ClampedItemPropertyFunction ITEM_PROPERTY_FUNCTION = (stack, level, entityIn, id) -> {
int count = getCount(stack, entityIn);
if(count == -1)
return 9999;
return 1F;

return 0.01F * count + 0.005F;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static class Client extends AbacusModule {

@LoadEvent
public void clientSetup(ZClientSetup e) {
e.enqueueWork(() -> ItemProperties.register(abacus, new ResourceLocation("count"), AbacusItem.Client::count));
e.enqueueWork(() -> ItemProperties.register(abacus, new ResourceLocation("count"), AbacusItem.Client.ITEM_PROPERTY_FUNCTION));
}

@PlayEvent
Expand Down

0 comments on commit 91a6332

Please sign in to comment.