fix some villager and rendering jank
This commit is contained in:
parent
b743c8e7a2
commit
b0bdbb7d76
13 changed files with 43 additions and 31 deletions
|
@ -1,7 +1,6 @@
|
|||
package at.petrak.hexcasting.api.misc;
|
||||
|
||||
import at.petrak.hexcasting.api.addldata.Colorizer;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
|
@ -45,7 +44,7 @@ public record FrozenColorizer(ItemStack item, UUID owner) {
|
|||
|
||||
public CompoundTag serializeToNBT() {
|
||||
var out = new CompoundTag();
|
||||
out.put(TAG_STACK, HexUtils.serializeToNBT(this.item));
|
||||
out.put(TAG_STACK, this.item.save(new CompoundTag()));
|
||||
out.putUUID(TAG_OWNER, this.owner);
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
package at.petrak.hexcasting.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ClientTickCounter {
|
||||
public static long ticksInGame = 0L;
|
||||
public static float partialTicks = 0.0F;
|
||||
public static float delta = 0.0F;
|
||||
public static float total = 0.0F;
|
||||
|
||||
public static float getTotal() {
|
||||
return (float)ticksInGame + partialTicks;
|
||||
}
|
||||
|
||||
public static void renderTickStart(float renderTickTime) {
|
||||
partialTicks = renderTickTime;
|
||||
}
|
||||
|
||||
public static void renderTickEnd() {
|
||||
calcDelta();
|
||||
}
|
||||
|
||||
public static void clientTickEnd() {
|
||||
++ticksInGame;
|
||||
partialTicks = 0.0F;
|
||||
calcDelta();
|
||||
}
|
||||
|
||||
private static void calcDelta() {
|
||||
float oldTotal = total;
|
||||
total = (float)ticksInGame + partialTicks;
|
||||
delta = total - oldTotal;
|
||||
if (!Minecraft.getInstance().isPaused()) {
|
||||
++ticksInGame;
|
||||
partialTicks = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class HexAdditionalRenderers {
|
|||
sentinel.position().y - playerPos.y,
|
||||
sentinel.position().z - playerPos.z);
|
||||
|
||||
var time = ClientTickCounter.total / 2;
|
||||
var time = ClientTickCounter.getTotal() / 2;
|
||||
var bobSpeed = 1f / 20;
|
||||
var magnitude = 0.1f;
|
||||
ps.translate(0, Mth.sin(bobSpeed * time) * magnitude, 0);
|
||||
|
|
|
@ -185,7 +185,7 @@ fun makeZappy(points: List<Vec2>, hops: Int, variance: Float, speed: Float, flow
|
|||
return emptyList()
|
||||
}
|
||||
val scaleVariance = { it: Double -> 1.0.coerceAtMost(8 * (0.5 - abs(0.5 - it))) }
|
||||
val zSeed = ClientTickCounter.total.toDouble() * speed
|
||||
val zSeed = ClientTickCounter.getTotal().toDouble() * speed
|
||||
// Create our output list of zap points
|
||||
val zappyPts = mutableListOf(points[0])
|
||||
// For each segment in the original...
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PatternTooltipGreeble implements ClientTooltipComponent, TooltipCom
|
|||
outer, outer, null);
|
||||
RenderLib.drawLineSeq(mat, this.zappyPoints, 2f, 0,
|
||||
innerDark, innerLight,
|
||||
ClientTickCounter.total / 40f);
|
||||
ClientTickCounter.getTotal() / 40f);
|
||||
RenderLib.drawSpot(mat, this.zappyPoints.get(0), 2.5f, 1f, 0.1f, 0.15f, 0.6f);
|
||||
|
||||
for (var dot : this.pathfinderDots) {
|
||||
|
|
|
@ -31,7 +31,6 @@ object FabricHexClientInitializer : ClientModInitializer {
|
|||
}
|
||||
HudRenderCallback.EVENT.register(HexAdditionalRenderers::overlayGui)
|
||||
WorldRenderEvents.START.register { ClientTickCounter.renderTickStart(it.tickDelta()) }
|
||||
WorldRenderEvents.END.register { ClientTickCounter.renderTickEnd() }
|
||||
ClientTickEvents.END_CLIENT_TICK.register { ClientTickCounter.clientTickEnd() }
|
||||
|
||||
MouseScrollCallback.EVENT.register(ShiftScrollListener::onScroll)
|
||||
|
|
|
@ -3,7 +3,6 @@ package at.petrak.hexcasting.fabric.event;
|
|||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.npc.Villager;
|
||||
|
||||
// https://fabricmc.net/wiki/tutorial:events
|
||||
|
||||
|
@ -20,5 +19,5 @@ public interface VillagerConversionCallback {
|
|||
}
|
||||
});
|
||||
|
||||
void interact(Villager original, LivingEntity outcome);
|
||||
void interact(LivingEntity original, LivingEntity outcome);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public class VillagerEmiStack extends EmiStack {
|
|||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderEntity(poseStack, villager, level, x + 8, y + 16, ClientTickCounter.total, 8, 0,
|
||||
renderEntity(poseStack, villager, level, x + 8, y + 16, ClientTickCounter.getTotal(), 8, 0,
|
||||
mindless ? (it) -> new FakeBufferSource(it, HexRenderTypes::getGrayscaleLayer) : it -> it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class VillagerWidget extends Widget {
|
|||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderEntity(poseStack, displayVillager, level, 50 + x, 62.5f + y, ClientTickCounter.total, 20, 0);
|
||||
renderEntity(poseStack, displayVillager, level, 50 + x, 62.5f + y, ClientTickCounter.getTotal(), 20, 0);
|
||||
}
|
||||
|
||||
if (isMouseOver(mouseX, mouseY))
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package at.petrak.hexcasting.fabric.mixin;
|
||||
|
||||
import at.petrak.hexcasting.fabric.event.VillagerConversionCallback;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Mob.class)
|
||||
public class FabricMobMixin {
|
||||
@Inject(method = "convertTo", at = @At("RETURN"))
|
||||
public <T extends Mob> void onThunderHit(EntityType<T> entityType, boolean bl, CallbackInfoReturnable<T> cir) {
|
||||
var self = (Mob) (Object) this;
|
||||
var mob = cir.getReturnValue();
|
||||
if (mob != null) {
|
||||
VillagerConversionCallback.EVENT.invoker().interact(self, mob);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,12 +10,13 @@
|
|||
"FabricEnchantmentTableBlockMixin",
|
||||
"FabricItemEntityMixin",
|
||||
"FabricLivingEntityMixin",
|
||||
"FabricVillagerTurnIntoWitchMixin"
|
||||
"FabricVillagerTurnIntoWitchMixin",
|
||||
"FabricMobMixin"
|
||||
],
|
||||
"client": [
|
||||
"client.FabricAbstractTextureMixin",
|
||||
"client.FabricMixinGameRenderer",
|
||||
"client.FabricMouseHandlerMixin",
|
||||
"client.FabricParticleEngineMixin",
|
||||
"client.FabricMixinGameRenderer"
|
||||
"client.FabricParticleEngineMixin"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ public class ForgeHexClientInitializer {
|
|||
evBus.addListener((TickEvent.RenderTickEvent e) -> {
|
||||
if (e.phase == TickEvent.Phase.START) {
|
||||
ClientTickCounter.renderTickStart(e.renderTickTime);
|
||||
} else {
|
||||
ClientTickCounter.renderTickEnd();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public class BrainsweepRecipeCategory implements IRecipeCategory<BrainsweepRecip
|
|||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderEntity(stack, villager, level, 50, 62.5f, ClientTickCounter.total, 20, 0);
|
||||
renderEntity(stack, villager, level, 50, 62.5f, ClientTickCounter.getTotal(), 20, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue