This commit is contained in:
2026-03-11 15:28:26 +01:00
parent 20a755064b
commit d0d2183c77
14 changed files with 89 additions and 80 deletions

View File

@@ -6,7 +6,7 @@ minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10 yarn_mappings=1.20.1+build.10
loader_version=0.18.3 loader_version=0.18.3
# Mod Properties # Mod Properties
mod_version=26.3.11 mod_version=26.3.11.1
maven_group=dev.tggamesyt maven_group=dev.tggamesyt
archives_base_name=szar archives_base_name=szar
# Dependencies # Dependencies

View File

@@ -1,33 +0,0 @@
package dev.tggamesyt.szar.client;
import dev.tggamesyt.szar.Joint;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.item.ItemStack;
public class SmokeZoomHandler {
private static float smokeScale = 0.5f; // start scale
private static final float TARGET_SCALE = 1.05f; // max zoom
private static final float LERP_SPEED = 0.5f; // lerp speed
public static void register() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player == null) return;
ItemStack stack = client.player.getActiveItem();
boolean usingSmoke = stack.getItem() instanceof Joint;
float target = usingSmoke ? TARGET_SCALE : 0.5f;
// lerp smokeScale toward target like spyglass
smokeScale = lerp(LERP_SPEED * client.getTickDelta(), smokeScale, target);
});
}
private static float lerp(float delta, float start, float end) {
return start + delta * (end - start);
}
public static float getSmokeScale() {
return smokeScale;
}
}

View File

@@ -381,7 +381,6 @@ public class SzarClient implements ClientModInitializer {
var effect = hasEffect ? client.player.getStatusEffect(Szar.DROG_EFFECT) : null; var effect = hasEffect ? client.player.getStatusEffect(Szar.DROG_EFFECT) : null;
int amplifier = effect != null ? Math.min(effect.getAmplifier(), 2) : 0; int amplifier = effect != null ? Math.min(effect.getAmplifier(), 2) : 0;
float level = amplifier + 1f;
float time = client.player.age + tickDelta; float time = client.player.age + tickDelta;
float speed = 0.015f + amplifier * 0.012f; float speed = 0.015f + amplifier * 0.012f;
@@ -431,41 +430,14 @@ public class SzarClient implements ClientModInitializer {
scrambleMovement(client, chance); scrambleMovement(client, chance);
}); });
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null) return;
float scale = SmokeZoomHandler.getSmokeScale();
if (scale > 0.51f) { // only when smoking
client.inGameHud.spyglassScale = scale;
}
});
SmokeZoomHandler.register();
// In your mod initialization code // In your mod initialization code
FabricModelPredicateProviderRegistry.register(Szar.WEED_JOINT_ITEM, new Identifier("held"), FabricModelPredicateProviderRegistry.register(Szar.WEED_JOINT_ITEM, new Identifier("held"),
(stack, world, entity, seed) -> { (stack, world, entity, seed) -> entity != null && entity.getMainHandStack() == stack ? 1.0f : 0.0f);
return entity != null && entity.getMainHandStack() == stack ? 1.0f : 0.0f;
});
if (isDebugEnabled()) { if (isDebugEnabled()) {
ClientCommandRegistrationCallback.EVENT.register( ClientCommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess) -> PanoramaClientCommand.register(dispatcher) (dispatcher, registryAccess) -> PanoramaClientCommand.register(dispatcher)
); );
} }
/*ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (addedFeature) return; // only run once
MinecraftClient mc = MinecraftClient.getInstance();
if (mc.getEntityRenderDispatcher() == null) return;
for (EntityRenderer<?> renderer : mc.getEntityRenderDispatcher().renderers.values()) {
if (renderer instanceof PlayerEntityRenderer playerRenderer) {
playerRenderer.addFeature(new VideoHeadFeature(playerRenderer));
}
}
addedFeature = true; // prevent running again
});*/
} }
private boolean isDebugEnabled() { private boolean isDebugEnabled() {

View File

@@ -48,7 +48,7 @@ public abstract class HeldItemRendererMixin {
-0.5F -0.5F
); );
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(80.0F)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(95.0F));
matrices.translate(0.0F, equipProgress * -0.6F, 0.0F); matrices.translate(0.0F, equipProgress * -0.6F, 0.0F);
HeldItemRenderer self = (HeldItemRenderer)(Object)this; HeldItemRenderer self = (HeldItemRenderer)(Object)this;

View File

@@ -14,9 +14,12 @@ import net.minecraft.world.World;
public class BulletEntity extends ThrownItemEntity { public class BulletEntity extends ThrownItemEntity {
private int stillTicks = 0;
private double lastX, lastY, lastZ;
public BulletEntity(EntityType<? extends BulletEntity> type, World world) { public BulletEntity(EntityType<? extends BulletEntity> type, World world) {
super(type, world); super(type, world);
this.setNoGravity(true); // bullets fly straight this.setNoGravity(true);
} }
public BulletEntity(World world, LivingEntity owner) { public BulletEntity(World world, LivingEntity owner) {
@@ -25,9 +28,35 @@ public class BulletEntity extends ThrownItemEntity {
this.setPosition(owner.getX(), owner.getEyeY() - 0.1, owner.getZ()); this.setPosition(owner.getX(), owner.getEyeY() - 0.1, owner.getZ());
} }
@Override
public void tick() {
super.tick();
if (!getWorld().isClient) {
double dx = getX() - lastX;
double dy = getY() - lastY;
double dz = getZ() - lastZ;
double movedSq = dx * dx + dy * dy + dz * dz;
if (movedSq < 0.0001) {
stillTicks++;
if (stillTicks >= 3) { // discard after 3 ticks of no movement
discard();
return;
}
} else {
stillTicks = 0;
}
lastX = getX();
lastY = getY();
lastZ = getZ();
}
}
@Override @Override
protected Item getDefaultItem() { protected Item getDefaultItem() {
return Szar.AK_AMMO; // used by FlyingItemEntityRenderer return Szar.AK_AMMO;
} }
@Override @Override
@@ -43,11 +72,9 @@ public class BulletEntity extends ThrownItemEntity {
this, this,
livingOwner livingOwner
); );
target.damage(source, 13.0F); target.damage(source, 13.0F);
} }
discard(); discard();
} }
} }

View File

@@ -8,9 +8,12 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.SpyglassItem; import net.minecraft.item.SpyglassItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats; import net.minecraft.stat.Stats;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@@ -24,25 +27,19 @@ import java.util.Random;
import static dev.tggamesyt.szar.Szar.MOD_ID; import static dev.tggamesyt.szar.Szar.MOD_ID;
public class Joint extends SpyglassItem { public class Joint extends SpyglassItem {
public Joint(Settings settings) { public Joint(Settings settings) {
super(settings.maxDamage(20)); // max durability super(settings.maxDamage(20)); // max durability
} }
private static final int COOLDOWN_TICKS = 20 * 5; private static final int COOLDOWN_TICKS = 20 * 5;
@Override @Override
public UseAction getUseAction(ItemStack stack) { public UseAction getUseAction(ItemStack stack) {
return UseAction.SPYGLASS; // keeps spyglass hold animation return UseAction.SPYGLASS;
}
@Override
public int getMaxUseTime(ItemStack stack) {
return 40; // shorter “smoking” duration
} }
@Override @Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
// play custom smoke sound // play custom smoke sound
user.playSound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK, 1.0F, 1.0F); user.playSound(Szar.BESZIV, 1.0F, 1.0F);
user.incrementStat(Stats.USED.getOrCreateStat(this)); user.incrementStat(Stats.USED.getOrCreateStat(this));
user.setCurrentHand(hand); // start using user.setCurrentHand(hand); // start using
return TypedActionResult.consume(user.getStackInHand(hand)); return TypedActionResult.consume(user.getStackInHand(hand));
@@ -164,7 +161,7 @@ public class Joint extends SpyglassItem {
)); ));
// Optional: play inhale / stop sound // Optional: play inhale / stop sound
user.playSound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK, 1.0F, 1.0F); user.playSound(Szar.KIFUJ, 1.0F, 1.0F);
if (world.isClient) { if (world.isClient) {
// get the direction the player is facing // get the direction the player is facing
double yawRad = Math.toRadians(user.getYaw()); double yawRad = Math.toRadians(user.getYaw());

View File

@@ -10,9 +10,14 @@ import net.minecraft.nbt.NbtList;
import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ArrayPropertyDelegate; import net.minecraft.screen.ArrayPropertyDelegate;
import net.minecraft.screen.PropertyDelegate; import net.minecraft.screen.PropertyDelegate;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -21,9 +26,11 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import static dev.tggamesyt.szar.Szar.MOD_ID;
public class RouletteBlockEntity extends BlockEntity { public class RouletteBlockEntity extends BlockEntity {
public int wheelWaitSeconds = 10; public int wheelWaitSeconds = 10;
public int wheelRollingSeconds = 5; public int wheelRollingSeconds = 10;
public int intermissionSeconds = 20; public int intermissionSeconds = 20;
private static final int[] WHEEL_ORDER = { private static final int[] WHEEL_ORDER = {
@@ -232,7 +239,6 @@ public class RouletteBlockEntity extends BlockEntity {
} }
// ─── Tick ───────────────────────────────────────────────────────────────── // ─── Tick ─────────────────────────────────────────────────────────────────
public static void tick(World world, BlockPos pos, BlockState state, RouletteBlockEntity be) { public static void tick(World world, BlockPos pos, BlockState state, RouletteBlockEntity be) {
if (world.isClient) return; if (world.isClient) return;
@@ -242,6 +248,7 @@ public class RouletteBlockEntity extends BlockEntity {
if (be.nextspinTime > 0) { if (be.nextspinTime > 0) {
// still counting down to spin // still counting down to spin
} else if (be.nextspinTime == 0) { } else if (be.nextspinTime == 0) {
world.playSound(null, pos, Szar.ROULETTE_SOUND, SoundCategory.BLOCKS, 1.0F, 1.0F);
// Spin is starting — pick winner and clear all bets // Spin is starting — pick winner and clear all bets
be.winnernum = new Random().nextInt(37); be.winnernum = new Random().nextInt(37);
be.isIntermission = false; be.isIntermission = false;

View File

@@ -87,6 +87,21 @@ public class Szar implements ModInitializer {
public static final String MOD_ID = "szar"; public static final String MOD_ID = "szar";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID); public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static MinecraftServer SERVER; public static MinecraftServer SERVER;
public static final SoundEvent BESZIV = Registry.register(
Registries.SOUND_EVENT,
new Identifier(MOD_ID, "besziv"),
SoundEvent.of(new Identifier(MOD_ID, "besziv"))
);
public static final SoundEvent KIFUJ = Registry.register(
Registries.SOUND_EVENT,
new Identifier(MOD_ID, "kifuj"),
SoundEvent.of(new Identifier(MOD_ID, "kifuj"))
);
public static final SoundEvent ROULETTE_SOUND = Registry.register(
Registries.SOUND_EVENT,
new Identifier(MOD_ID, "roulette"),
SoundEvent.of(new Identifier(MOD_ID, "roulette"))
);
public static final SoundEvent SLOT_MACHINE_BASE = public static final SoundEvent SLOT_MACHINE_BASE =
Registry.register( Registry.register(
Registries.SOUND_EVENT, Registries.SOUND_EVENT,

View File

@@ -122,5 +122,29 @@
"stream": true "stream": true
} }
] ]
},
"besziv": {
"sounds": [
{
"name": "szar:besziv",
"stream": true
}
]
},
"kifuj": {
"sounds": [
{
"name": "szar:kifuj",
"stream": true
}
]
},
"roulette": {
"sounds": [
{
"name": "szar:roulette",
"stream": true
}
]
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.