修复药水弹的粒子云问题

This commit is contained in:
17146 2025-04-03 03:54:30 +08:00
parent fcee385989
commit 60f79e9f62
3 changed files with 10 additions and 28 deletions

View file

@ -120,7 +120,7 @@ public class MortarEntity extends VehicleEntity implements GeoEntity {
Level level = this.level(); Level level = this.level();
if (level instanceof ServerLevel server) { if (level instanceof ServerLevel server) {
MortarShellEntity entityToSpawn = shell.createShell(player, level, stack); MortarShellEntity entityToSpawn = shell.createShell(player, level, stack);
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ()); entityToSpawn.setPos(this.getX(), this.getY() + this.getEyeY(), this.getZ());
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 11.4f, (float) 0.1); entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 11.4f, (float) 0.1);
level.addFreshEntity(entityToSpawn); level.addFreshEntity(entityToSpawn);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4, server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
@ -273,13 +273,6 @@ public class MortarEntity extends VehicleEntity implements GeoEntity {
return 100; return 100;
} }
public String getSyncedAnimation() {
return null;
}
public void setAnimation(String animation) {
}
@Override @Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) { public void registerControllers(AnimatableManager.ControllerRegistrar data) {
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate)); data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));

View file

@ -24,6 +24,7 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock; import net.minecraft.world.level.block.BellBlock;
@ -36,7 +37,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.animation.AnimatableManager; import software.bernie.geckolib.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@ -79,15 +79,11 @@ public class MortarShellEntity extends FastThrowableProjectile implements GeoEnt
public void setEffectsFromItem(ItemStack stack) { public void setEffectsFromItem(ItemStack stack) {
if (stack.is(ModItems.POTION_MORTAR_SHELL.get())) { if (stack.is(ModItems.POTION_MORTAR_SHELL.get())) {
var data = stack.get(DataComponents.POTION_CONTENTS); var potionContents = stack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
if (data != null) { this.potion = potionContents.potion().orElse(Potions.WATER).value();
data.potion().ifPresent(p -> this.potion = p.value());
Collection<MobEffectInstance> collection = data.customEffects(); for (MobEffectInstance mobeffectinstance : potionContents.getAllEffects()) {
if (!collection.isEmpty()) { this.effects.add(new MobEffectInstance(mobeffectinstance));
for (MobEffectInstance mobeffectinstance : collection) {
this.effects.add(new MobEffectInstance(mobeffectinstance));
}
}
} }
} else if (stack.is(ModItems.MORTAR_SHELL.get())) { } else if (stack.is(ModItems.MORTAR_SHELL.get())) {
this.potion = Potions.WATER.value(); this.potion = Potions.WATER.value();
@ -167,12 +163,6 @@ public class MortarShellEntity extends FastThrowableProjectile implements GeoEnt
} }
} }
// TODO AEP
// @Override
// public Packet<ClientGamePacketListener> getAddEntityPacket() {
// return NetworkHooks.getEntitySpawningPacket(this);
// }
@Override @Override
protected @NotNull Item getDefaultItem() { protected @NotNull Item getDefaultItem() {
return ModItems.MORTAR_SHELL.get(); return ModItems.MORTAR_SHELL.get();
@ -259,8 +249,9 @@ public class MortarShellEntity extends FastThrowableProjectile implements GeoEnt
AreaEffectCloud cloud = new AreaEffectCloud(level, this.getX() + 0.75 * getDeltaMovement().x, this.getY() + 0.5 * getBbHeight() + 0.75 * getDeltaMovement().y, this.getZ() + 0.75 * getDeltaMovement().z); AreaEffectCloud cloud = new AreaEffectCloud(level, this.getX() + 0.75 * getDeltaMovement().x, this.getY() + 0.5 * getBbHeight() + 0.75 * getDeltaMovement().y, this.getZ() + 0.75 * getDeltaMovement().z);
// TODO PotionContents for (MobEffectInstance effect : this.effects) {
// cloud.setPotion(this.potion); cloud.addEffect(effect);
}
cloud.setDuration((int) this.damage); cloud.setDuration((int) this.damage);
cloud.setRadius(this.radius); cloud.setRadius(this.radius);
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {

View file

@ -1,7 +1,5 @@
package com.atsuishio.superbwarfare.item.common.ammo; package com.atsuishio.superbwarfare.item.common.ammo;
//import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity; import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;