fahh
This commit is contained in:
@@ -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