diff --git a/gradle.properties b/gradle.properties index 23344d4..971fa9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.18.3 # Mod Properties -mod_version=26.3.11 +mod_version=26.3.11.1 maven_group=dev.tggamesyt archives_base_name=szar # Dependencies diff --git a/src/client/java/dev/tggamesyt/szar/client/SmokeZoomHandler.java b/src/client/java/dev/tggamesyt/szar/client/SmokeZoomHandler.java deleted file mode 100644 index 33bbb6f..0000000 --- a/src/client/java/dev/tggamesyt/szar/client/SmokeZoomHandler.java +++ /dev/null @@ -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; - } -} diff --git a/src/client/java/dev/tggamesyt/szar/client/SzarClient.java b/src/client/java/dev/tggamesyt/szar/client/SzarClient.java index 02b9b29..cc93f83 100644 --- a/src/client/java/dev/tggamesyt/szar/client/SzarClient.java +++ b/src/client/java/dev/tggamesyt/szar/client/SzarClient.java @@ -381,7 +381,6 @@ public class SzarClient implements ClientModInitializer { var effect = hasEffect ? client.player.getStatusEffect(Szar.DROG_EFFECT) : null; int amplifier = effect != null ? Math.min(effect.getAmplifier(), 2) : 0; - float level = amplifier + 1f; float time = client.player.age + tickDelta; float speed = 0.015f + amplifier * 0.012f; @@ -431,41 +430,14 @@ public class SzarClient implements ClientModInitializer { 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 FabricModelPredicateProviderRegistry.register(Szar.WEED_JOINT_ITEM, new Identifier("held"), - (stack, world, entity, seed) -> { - return entity != null && entity.getMainHandStack() == stack ? 1.0f : 0.0f; - }); + (stack, world, entity, seed) -> entity != null && entity.getMainHandStack() == stack ? 1.0f : 0.0f); if (isDebugEnabled()) { ClientCommandRegistrationCallback.EVENT.register( (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() { diff --git a/src/client/java/dev/tggamesyt/szar/client/mixin/HeldItemRendererMixin.java b/src/client/java/dev/tggamesyt/szar/client/mixin/HeldItemRendererMixin.java index f7b3f1f..eb9673b 100644 --- a/src/client/java/dev/tggamesyt/szar/client/mixin/HeldItemRendererMixin.java +++ b/src/client/java/dev/tggamesyt/szar/client/mixin/HeldItemRendererMixin.java @@ -48,7 +48,7 @@ public abstract class HeldItemRendererMixin { -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); HeldItemRenderer self = (HeldItemRenderer)(Object)this; diff --git a/src/main/java/dev/tggamesyt/szar/BulletEntity.java b/src/main/java/dev/tggamesyt/szar/BulletEntity.java index 9a09412..4f0fc6f 100644 --- a/src/main/java/dev/tggamesyt/szar/BulletEntity.java +++ b/src/main/java/dev/tggamesyt/szar/BulletEntity.java @@ -14,9 +14,12 @@ import net.minecraft.world.World; public class BulletEntity extends ThrownItemEntity { + private int stillTicks = 0; + private double lastX, lastY, lastZ; + public BulletEntity(EntityType type, World world) { super(type, world); - this.setNoGravity(true); // bullets fly straight + this.setNoGravity(true); } 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()); } + @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 protected Item getDefaultItem() { - return Szar.AK_AMMO; // used by FlyingItemEntityRenderer + return Szar.AK_AMMO; } @Override @@ -43,11 +72,9 @@ public class BulletEntity extends ThrownItemEntity { this, livingOwner ); - target.damage(source, 13.0F); } discard(); } - -} +} \ No newline at end of file diff --git a/src/main/java/dev/tggamesyt/szar/Joint.java b/src/main/java/dev/tggamesyt/szar/Joint.java index 3ca9da5..996eea3 100644 --- a/src/main/java/dev/tggamesyt/szar/Joint.java +++ b/src/main/java/dev/tggamesyt/szar/Joint.java @@ -8,9 +8,12 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.SpyglassItem; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.stat.Stats; import net.minecraft.util.Hand; @@ -24,25 +27,19 @@ import java.util.Random; import static dev.tggamesyt.szar.Szar.MOD_ID; public class Joint extends SpyglassItem { - public Joint(Settings settings) { super(settings.maxDamage(20)); // max durability } private static final int COOLDOWN_TICKS = 20 * 5; @Override public UseAction getUseAction(ItemStack stack) { - return UseAction.SPYGLASS; // keeps spyglass hold animation - } - - @Override - public int getMaxUseTime(ItemStack stack) { - return 40; // shorter “smoking” duration + return UseAction.SPYGLASS; } @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { // 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.setCurrentHand(hand); // start using return TypedActionResult.consume(user.getStackInHand(hand)); @@ -164,7 +161,7 @@ public class Joint extends SpyglassItem { )); // 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) { // get the direction the player is facing double yawRad = Math.toRadians(user.getYaw()); diff --git a/src/main/java/dev/tggamesyt/szar/RouletteBlockEntity.java b/src/main/java/dev/tggamesyt/szar/RouletteBlockEntity.java index c007852..2c6e071 100644 --- a/src/main/java/dev/tggamesyt/szar/RouletteBlockEntity.java +++ b/src/main/java/dev/tggamesyt/szar/RouletteBlockEntity.java @@ -10,9 +10,14 @@ import net.minecraft.nbt.NbtList; import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.packet.Packet; 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.PropertyDelegate; 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.world.World; @@ -21,9 +26,11 @@ import java.util.Map; import java.util.Random; import java.util.UUID; +import static dev.tggamesyt.szar.Szar.MOD_ID; + public class RouletteBlockEntity extends BlockEntity { public int wheelWaitSeconds = 10; - public int wheelRollingSeconds = 5; + public int wheelRollingSeconds = 10; public int intermissionSeconds = 20; private static final int[] WHEEL_ORDER = { @@ -232,7 +239,6 @@ public class RouletteBlockEntity extends BlockEntity { } // ─── Tick ───────────────────────────────────────────────────────────────── - public static void tick(World world, BlockPos pos, BlockState state, RouletteBlockEntity be) { if (world.isClient) return; @@ -242,6 +248,7 @@ public class RouletteBlockEntity extends BlockEntity { if (be.nextspinTime > 0) { // still counting down to spin } 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 be.winnernum = new Random().nextInt(37); be.isIntermission = false; diff --git a/src/main/java/dev/tggamesyt/szar/Szar.java b/src/main/java/dev/tggamesyt/szar/Szar.java index 75d7a07..30a34e6 100644 --- a/src/main/java/dev/tggamesyt/szar/Szar.java +++ b/src/main/java/dev/tggamesyt/szar/Szar.java @@ -87,6 +87,21 @@ public class Szar implements ModInitializer { public static final String MOD_ID = "szar"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); 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 = Registry.register( Registries.SOUND_EVENT, diff --git a/src/main/resources/assets/szar/sounds.json b/src/main/resources/assets/szar/sounds.json index 754d100..fa3101a 100644 --- a/src/main/resources/assets/szar/sounds.json +++ b/src/main/resources/assets/szar/sounds.json @@ -122,5 +122,29 @@ "stream": true } ] + }, + "besziv": { + "sounds": [ + { + "name": "szar:besziv", + "stream": true + } + ] + }, + "kifuj": { + "sounds": [ + { + "name": "szar:kifuj", + "stream": true + } + ] + }, + "roulette": { + "sounds": [ + { + "name": "szar:roulette", + "stream": true + } + ] } } diff --git a/src/main/resources/assets/szar/sounds/besziv.m4a b/src/main/resources/assets/szar/sounds/besziv.m4a new file mode 100644 index 0000000..065b33e Binary files /dev/null and b/src/main/resources/assets/szar/sounds/besziv.m4a differ diff --git a/src/main/resources/assets/szar/sounds/besziv.ogg b/src/main/resources/assets/szar/sounds/besziv.ogg new file mode 100644 index 0000000..a703a59 Binary files /dev/null and b/src/main/resources/assets/szar/sounds/besziv.ogg differ diff --git a/src/main/resources/assets/szar/sounds/kifuj.m4a b/src/main/resources/assets/szar/sounds/kifuj.m4a new file mode 100644 index 0000000..41d7d88 Binary files /dev/null and b/src/main/resources/assets/szar/sounds/kifuj.m4a differ diff --git a/src/main/resources/assets/szar/sounds/kifuj.ogg b/src/main/resources/assets/szar/sounds/kifuj.ogg new file mode 100644 index 0000000..43e2000 Binary files /dev/null and b/src/main/resources/assets/szar/sounds/kifuj.ogg differ diff --git a/src/main/resources/assets/szar/sounds/roulette.ogg b/src/main/resources/assets/szar/sounds/roulette.ogg new file mode 100644 index 0000000..8829561 Binary files /dev/null and b/src/main/resources/assets/szar/sounds/roulette.ogg differ