fahh
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<? extends BulletEntity> 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<ItemStack> 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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/assets/szar/sounds/besziv.m4a
Normal file
BIN
src/main/resources/assets/szar/sounds/besziv.m4a
Normal file
Binary file not shown.
BIN
src/main/resources/assets/szar/sounds/besziv.ogg
Normal file
BIN
src/main/resources/assets/szar/sounds/besziv.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/szar/sounds/kifuj.m4a
Normal file
BIN
src/main/resources/assets/szar/sounds/kifuj.m4a
Normal file
Binary file not shown.
BIN
src/main/resources/assets/szar/sounds/kifuj.ogg
Normal file
BIN
src/main/resources/assets/szar/sounds/kifuj.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/szar/sounds/roulette.ogg
Normal file
BIN
src/main/resources/assets/szar/sounds/roulette.ogg
Normal file
Binary file not shown.
Reference in New Issue
Block a user