优化钢管落地音效实现方式
This commit is contained in:
parent
b7e69a1e2b
commit
99a2482f7f
3 changed files with 30 additions and 10 deletions
|
@ -1,6 +1,5 @@
|
|||
package com.atsuishio.superbwarfare.event;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.api.event.PreKillEvent;
|
||||
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
|
||||
|
@ -46,7 +45,6 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.common.util.TriState;
|
||||
import net.neoforged.neoforge.event.entity.item.ItemTossEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.*;
|
||||
import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
@ -658,12 +656,4 @@ public class LivingEventHandler {
|
|||
event.setResult(MobEffectEvent.Applicable.Result.DO_NOT_APPLY);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onItemSpawned(ItemTossEvent event) {
|
||||
if (event.getEntity().getItem().getItem() == ModItems.STEEL_PIPE.get()) {
|
||||
Mod.queueServerWork(5, () ->
|
||||
event.getEntity().level().playSound(null, event.getEntity().getOnPos(), ModSounds.STEEL_PIPE_DROP.get(), SoundSource.PLAYERS, 2, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.atsuishio.superbwarfare.mixins;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class SteelPipeFallMixin {
|
||||
|
||||
@Shadow public abstract boolean onGround();
|
||||
|
||||
@Inject(method = "setOnGroundWithMovement", at = @At("HEAD"))
|
||||
public void playSteelPipeDropSound(boolean onGround, Vec3 movement, CallbackInfo ci) {
|
||||
if (!onGround || onGround()) return;
|
||||
|
||||
var entity = (Entity) (Object) this;
|
||||
if (entity instanceof ItemEntity itemEntity && itemEntity.getItem().getItem() == ModItems.STEEL_PIPE.get()) {
|
||||
entity.level().playSound(null, entity.getOnPos(), ModSounds.STEEL_PIPE_DROP.get(), SoundSource.PLAYERS, 2, 1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
"LivingEntityMixin",
|
||||
"PlayerMixin",
|
||||
"ProjectileUtilMixin",
|
||||
"SteelPipeFallMixin",
|
||||
"VillagerMixin"
|
||||
],
|
||||
"client": [
|
||||
|
|
Loading…
Add table
Reference in a new issue