Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 112
src/main/java/com/kodari/carpetwitherdeath/CarpetWitherDeath.java
package com.kodari.carpetwitherdeath;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.entity.LivingEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
public class CarpetWitherDeath implements ModInitializer {
@Override
public void onInitialize() {
ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource) -> {
if (!isCarpetFakePlayer(entity)) {
return;
}
entity.getEntityWorld().playSound(
null,
entity.getX(),
entity.getY(),
entity.getZ(),
SoundEvents.ENTITY_WITHER_SPAWN,
SoundCategory.HOSTILE,
1.0f,
1.0f
);
});
}
private static boolean isCarpetFakePlayer(LivingEntity entity) {
for (Class<?> type = entity.getClass(); type != null; type = type.getSuperclass()) {
if (type.getName().equals("carpet.patches.EntityPlayerMPFake")) {
return true;
}
}
return false;
}
}