内联更多过程
This commit is contained in:
parent
c5be3f7551
commit
22eb461697
7 changed files with 43 additions and 102 deletions
|
@ -1,8 +1,7 @@
|
||||||
package net.mcreator.target.entity;
|
package net.mcreator.target.entity;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.procedures.MortarDangXiaoShiShiJianDaoShiProcedure;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.procedures.MortarShiTiChuShiShengChengShiProcedure;
|
|
||||||
import net.mcreator.target.procedures.MortarYouJiShiTiShiProcedure;
|
import net.mcreator.target.procedures.MortarYouJiShiTiShiProcedure;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -11,6 +10,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.DifficultyInstance;
|
import net.minecraft.world.DifficultyInstance;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@ -20,6 +20,7 @@ import net.minecraft.world.damagesource.DamageTypes;
|
||||||
import net.minecraft.world.entity.*;
|
import net.minecraft.world.entity.*;
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.projectile.ThrownPotion;
|
import net.minecraft.world.entity.projectile.ThrownPotion;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -134,7 +135,14 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
||||||
@Override
|
@Override
|
||||||
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData livingdata, @Nullable CompoundTag tag) {
|
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData livingdata, @Nullable CompoundTag tag) {
|
||||||
SpawnGroupData retval = super.finalizeSpawn(world, difficulty, reason, livingdata, tag);
|
SpawnGroupData retval = super.finalizeSpawn(world, difficulty, reason, livingdata, tag);
|
||||||
MortarShiTiChuShiShengChengShiProcedure.execute(this);
|
this.setYRot(this.getYRot());
|
||||||
|
this.setXRot(-70);
|
||||||
|
this.setYBodyRot(this.getYRot());
|
||||||
|
this.setYHeadRot(this.getYRot());
|
||||||
|
this.yRotO = this.getYRot();
|
||||||
|
this.xRotO = this.getXRot();
|
||||||
|
this.yBodyRotO = this.getYRot();
|
||||||
|
this.yHeadRotO = this.getYRot();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +246,21 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
||||||
if (this.deathTime == 5) {
|
if (this.deathTime == 5) {
|
||||||
this.remove(MortarEntity.RemovalReason.KILLED);
|
this.remove(MortarEntity.RemovalReason.KILLED);
|
||||||
this.dropExperience();
|
this.dropExperience();
|
||||||
MortarDangXiaoShiShiJianDaoShiProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ());
|
if (this.level() instanceof ServerLevel level) {
|
||||||
|
var x = this.getX();
|
||||||
|
var y = this.getY();
|
||||||
|
var z = this.getZ();
|
||||||
|
level.explode(null, x, y, z, 0, Level.ExplosionInteraction.NONE);
|
||||||
|
ItemEntity barrel = new ItemEntity(level, x, (y + 1), z, new ItemStack(TargetModItems.MORTAR_BARREL.get()));
|
||||||
|
barrel.setPickUpDelay(10);
|
||||||
|
level.addFreshEntity(barrel);
|
||||||
|
ItemEntity bipod = new ItemEntity(level, x, (y + 1), z, new ItemStack(TargetModItems.MORTAR_BIPOD.get()));
|
||||||
|
bipod.setPickUpDelay(10);
|
||||||
|
level.addFreshEntity(bipod);
|
||||||
|
ItemEntity plate = new ItemEntity(level, x, (y + 1), z, new ItemStack(TargetModItems.MORTAR_BASE_PLATE.get()));
|
||||||
|
plate.setPickUpDelay(10);
|
||||||
|
level.addFreshEntity(plate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ package net.mcreator.target.entity;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.procedures.MedexpProcedure;
|
import net.mcreator.target.procedures.MedexpProcedure;
|
||||||
import net.mcreator.target.procedures.MortarShellDanSheWuFeiXingShiMeiKeFaShengProcedure;
|
import net.minecraft.commands.CommandSource;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -88,9 +89,12 @@ public class MortarShellEntity extends AbstractArrow implements ItemSupplier {
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
MortarShellDanSheWuFeiXingShiMeiKeFaShengProcedure.execute(this);
|
if (this.getServer() != null) {
|
||||||
if (this.inGround)
|
// TODO 修改为正确的粒子效果播放方法
|
||||||
this.discard();
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 2 force");
|
||||||
|
}
|
||||||
|
if (this.inGround) this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MortarShellEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
public static MortarShellEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.google.common.collect.Multimap;
|
||||||
import net.mcreator.target.client.renderer.item.BocekItemRenderer;
|
import net.mcreator.target.client.renderer.item.BocekItemRenderer;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.item.AnimatedItem;
|
import net.mcreator.target.item.AnimatedItem;
|
||||||
import net.mcreator.target.procedures.BocekReloadProcedure;
|
import net.mcreator.target.procedures.WeaponDrawProcedure;
|
||||||
import net.mcreator.target.tools.GunsTool;
|
import net.mcreator.target.tools.GunsTool;
|
||||||
import net.mcreator.target.tools.RarityTool;
|
import net.mcreator.target.tools.RarityTool;
|
||||||
import net.mcreator.target.tools.TooltipTool;
|
import net.mcreator.target.tools.TooltipTool;
|
||||||
|
@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.HumanoidModel;
|
import net.minecraft.client.model.HumanoidModel;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -147,7 +148,13 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
itemstack.getOrCreateTag().putDouble("maxammo", getAmmoCount(player));
|
itemstack.getOrCreateTag().putDouble("maxammo", getAmmoCount(player));
|
||||||
}
|
}
|
||||||
BocekReloadProcedure.execute(entity, itemstack);
|
|
||||||
|
// TODO 合并至GunReload
|
||||||
|
CompoundTag tag = itemstack.getOrCreateTag();
|
||||||
|
if (tag.getDouble("arrowempty") > 0) {
|
||||||
|
tag.putDouble("arrowempty", tag.getDouble("arrowempty") - 1);
|
||||||
|
}
|
||||||
|
WeaponDrawProcedure.execute(entity, itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getAmmoCount(Player player) {
|
public static double getAmmoCount(Player player) {
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
|
|
||||||
public class BocekReloadProcedure {
|
|
||||||
// TODO 合并至GunReload
|
|
||||||
public static void execute(Entity entity, ItemStack itemstack) {
|
|
||||||
if (entity == null) return;
|
|
||||||
|
|
||||||
CompoundTag tag = itemstack.getOrCreateTag();
|
|
||||||
if (tag.getDouble("arrowempty") > 0) {
|
|
||||||
tag.putDouble("arrowempty", tag.getDouble("arrowempty") - 1);
|
|
||||||
}
|
|
||||||
WeaponDrawProcedure.execute(entity, itemstack);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModItems;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
|
|
||||||
public class MortarDangXiaoShiShiJianDaoShiProcedure {
|
|
||||||
public static void execute(LevelAccessor world, double x, double y, double z) {
|
|
||||||
if (world instanceof Level _level && !_level.isClientSide())
|
|
||||||
_level.explode(null, x, y, z, 0, Level.ExplosionInteraction.NONE);
|
|
||||||
if (world instanceof ServerLevel _level) {
|
|
||||||
ItemEntity entityToSpawn = new ItemEntity(_level, x, (y + 1), z, new ItemStack(TargetModItems.MORTAR_BARREL.get()));
|
|
||||||
entityToSpawn.setPickUpDelay(10);
|
|
||||||
_level.addFreshEntity(entityToSpawn);
|
|
||||||
}
|
|
||||||
if (world instanceof ServerLevel _level) {
|
|
||||||
ItemEntity entityToSpawn = new ItemEntity(_level, x, (y + 1), z, new ItemStack(TargetModItems.MORTAR_BIPOD.get()));
|
|
||||||
entityToSpawn.setPickUpDelay(10);
|
|
||||||
_level.addFreshEntity(entityToSpawn);
|
|
||||||
}
|
|
||||||
if (world instanceof ServerLevel _level) {
|
|
||||||
ItemEntity entityToSpawn = new ItemEntity(_level, x, (y + 1), z, new ItemStack(TargetModItems.MORTAR_BASE_PLATE.get()));
|
|
||||||
entityToSpawn.setPickUpDelay(10);
|
|
||||||
_level.addFreshEntity(entityToSpawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.commands.CommandSource;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
|
|
||||||
public class MortarShellDanSheWuFeiXingShiMeiKeFaShengProcedure {
|
|
||||||
public static void execute(Entity immediatesourceentity) {
|
|
||||||
if (immediatesourceentity == null)
|
|
||||||
return;
|
|
||||||
{
|
|
||||||
Entity _ent = immediatesourceentity;
|
|
||||||
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
|
|
||||||
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
|
|
||||||
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 2 force");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
|
|
||||||
public class MortarShiTiChuShiShengChengShiProcedure {
|
|
||||||
public static void execute(Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
{
|
|
||||||
Entity _ent = entity;
|
|
||||||
_ent.setYRot(entity.getYRot());
|
|
||||||
_ent.setXRot(-70);
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue