移除靶子和铁丝网相关procedure

This commit is contained in:
17146 2024-05-07 23:15:03 +08:00
parent 4cdecaec32
commit 3392193d7a
9 changed files with 76 additions and 173 deletions

View file

@ -1,9 +1,11 @@
package net.mcreator.target.block; package net.mcreator.target.block;
import net.mcreator.target.procedures.BarbedWireShiTiZaiFangKuaiZhongPengZhuangShiProcedure;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
@ -17,6 +19,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
@ -81,6 +84,8 @@ public class BarbedWireBlock extends Block {
@Override @Override
public void entityInside(BlockState blockstate, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState blockstate, Level world, BlockPos pos, Entity entity) {
super.entityInside(blockstate, world, pos, entity); super.entityInside(blockstate, world, pos, entity);
BarbedWireShiTiZaiFangKuaiZhongPengZhuangShiProcedure.execute(world, entity);
entity.makeStuckInBlock(Blocks.AIR.defaultBlockState(), new Vec3(0.25, 0.05, 0.25));
entity.hurt(new DamageSource(world.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.CACTUS)), 1);
} }
} }

View file

@ -1,7 +1,11 @@
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.*; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.procedures.Target1DangShiTiGengXinKeShiProcedure;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
@ -9,6 +13,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; 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.sounds.SoundSource;
import net.minecraft.world.DifficultyInstance; import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -26,6 +31,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PlayMessages; import net.minecraftforge.network.PlayMessages;
import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.animatable.GeoEntity;
@ -44,9 +50,7 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<String> TEXTURE = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<String> TEXTURE = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.STRING);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
private boolean swinging;
private boolean lastloop;
private long lastSwing;
public String animationprocedure = "empty"; public String animationprocedure = "empty";
public Target1Entity(PlayMessages.SpawnEntity packet, Level world) { public Target1Entity(PlayMessages.SpawnEntity packet, Level world) {
@ -89,7 +93,7 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
@Override @Override
public MobType getMobType() { public MobType getMobType() {
return MobType.UNDEFINED; return super.getMobType();
} }
@Override @Override
@ -104,7 +108,12 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
@Override @Override
public boolean hurt(DamageSource source, float amount) { public boolean hurt(DamageSource source, float amount) {
Target1DangShiTiShouShangShiProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ()); if (!this.level().isClientSide()) {
this.level().playSound(null, BlockPos.containing(this.getX(), this.getY(), this.getZ()), TargetModSounds.HIT.get(), SoundSource.BLOCKS, 2, 1);
} else {
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), TargetModSounds.HIT.get(), SoundSource.BLOCKS, 2, 1, false);
}
if (source.is(DamageTypes.IN_FIRE)) if (source.is(DamageTypes.IN_FIRE))
return false; return false;
if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud) if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud)
@ -130,9 +139,16 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
@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 data = super.finalizeSpawn(world, difficulty, reason, livingdata, tag);
Target1ShiTiChuShiShengChengShiProcedure.execute(this);
return retval; this.setYRot(0);
this.setXRot(0);
this.setYBodyRot(this.getYRot());
this.setYHeadRot(this.getYRot());
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
return data;
} }
@Override @Override
@ -149,18 +165,32 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
} }
@Override @Override
public InteractionResult mobInteract(Player sourceentity, InteractionHand hand) { public InteractionResult mobInteract(Player player, InteractionHand hand) {
ItemStack itemstack = sourceentity.getItemInHand(hand); InteractionResult result = InteractionResult.sidedSuccess(this.level().isClientSide());
InteractionResult retval = InteractionResult.sidedSuccess(this.level().isClientSide()); super.mobInteract(player, hand);
super.mobInteract(sourceentity, hand);
double x = this.getX();
double y = this.getY();
double z = this.getZ();
Entity entity = this;
Level world = this.level();
Target1DangYouJiShiTiShiProcedure.execute(y, entity, sourceentity); if (player.isShiftKeyDown()) {
return retval; if (!this.level().isClientSide()) {
this.discard();
}
player.addItem(new ItemStack(TargetModItems.TARGET_DEPLOYER.get()));
} else {
if (!(player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
this.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((player.getX()), this.getY(), (player.getZ())));
this.setYRot(this.getYRot());
this.setXRot(0);
this.setYBodyRot(this.getYRot());
this.setYHeadRot(this.getYRot());
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
this.getPersistentData().putDouble("targetdown", 0);
}
}
return result;
} }
@Override @Override
@ -172,15 +202,17 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
@Override @Override
public EntityDimensions getDimensions(Pose p_33597_) { public EntityDimensions getDimensions(Pose p_33597_) {
Entity entity = this; float num;
if (this.getPersistentData().getDouble("targetdown") > 0) {
num = 0.1f;
} else {
num = 1f;
}
Level world = this.level(); return super.getDimensions(p_33597_).scale(num);
double x = this.getX();
double y = entity.getY();
double z = entity.getZ();
return super.getDimensions(p_33597_).scale((float) BazipengzhuangProcedure.execute(entity));
} }
@Override @Override
public boolean isPushable() { public boolean isPushable() {
return false; return false;
@ -225,14 +257,14 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
return builder; return builder;
} }
private PlayState movementPredicate(AnimationState event) { private PlayState movementPredicate(AnimationState<Target1Entity> event) {
if (this.animationprocedure.equals("empty")) { if (this.animationprocedure.equals("empty")) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.target.idle")); return event.setAndContinue(RawAnimation.begin().thenLoop("animation.target.idle"));
} }
return PlayState.STOP; return PlayState.STOP;
} }
private PlayState procedurePredicate(AnimationState event) { private PlayState procedurePredicate(AnimationState<Target1Entity> event) {
if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) { if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure)); event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) { if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {

View file

@ -5,7 +5,6 @@ import net.mcreator.target.headshot.IHeadshotBox;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.procedures.TaserBulletDangTouZhiWuJiZhongShiTiShiProcedure; import net.mcreator.target.procedures.TaserBulletDangTouZhiWuJiZhongShiTiShiProcedure;
import net.mcreator.target.procedures.TaserBulletTouZhiWuFeiXingKeProcedure;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
@ -74,14 +73,13 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
@Override @Override
protected void onHitEntity(EntityHitResult result) { protected void onHitEntity(EntityHitResult result) {
final Vec3 position = this.position();
Entity entity = result.getEntity(); Entity entity = result.getEntity();
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = _setval; capability.hitind = 25;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
living.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, living.position(), living.getRotationVector(), living.level() instanceof ServerLevel ? (ServerLevel) living.level() : null, 4, living.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, living.position(), living.getRotationVector(), living.level() instanceof ServerLevel ? (ServerLevel) living.level() : null, 4,
living.getName().getString(), living.getDisplayName(), living.level().getServer(), living), "playsound target:indication voice @a ~ ~ ~ 1 1"); living.getName().getString(), living.getDisplayName(), living.level().getServer(), living), "playsound target:indication voice @a ~ ~ ~ 1 1");
@ -113,9 +111,8 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
if (headshot) { if (headshot) {
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
setBaseDamage(getBaseDamage() * 1.5f); setBaseDamage(getBaseDamage() * 1.5f);
double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = _setval; capability.headind = 25;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
@ -135,7 +132,12 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
TaserBulletTouZhiWuFeiXingKeProcedure.execute(this);
this.getPersistentData().putDouble("live", (this.getPersistentData().getDouble("live") + 1));
if (this.getPersistentData().getDouble("live") == 5) {
this.setDeltaMovement(new Vec3(0, 0, 0));
}
if (this.tickCount > 200) { if (this.tickCount > 200) {
this.discard(); this.discard();
} }

View file

@ -1,18 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3;
public class BarbedWireShiTiZaiFangKuaiZhongPengZhuangShiProcedure {
public static void execute(LevelAccessor world, Entity entity) {
if (entity == null)
return;
entity.makeStuckInBlock(Blocks.AIR.defaultBlockState(), new Vec3(0.25, 0.05, 0.25));
entity.hurt(new DamageSource(world.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.CACTUS)), 1);
}
}

View file

@ -1,14 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.world.entity.Entity;
public class BazipengzhuangProcedure {
public static double execute(Entity entity) {
if (entity == null)
return 0;
if (entity.getPersistentData().getDouble("targetdown") > 0) {
return 0.1;
}
return 1;
}
}

View file

@ -1,20 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.registries.ForgeRegistries;
public class Target1DangShiTiShouShangShiProcedure {
public static void execute(LevelAccessor world, double x, double y, double z) {
if (world instanceof Level _level) {
if (!_level.isClientSide()) {
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:hit")), SoundSource.BLOCKS, 2, 1);
} else {
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:hit")), SoundSource.BLOCKS, 2, 1, false);
}
}
}
}

View file

@ -1,45 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.items.ItemHandlerHelper;
public class Target1DangYouJiShiTiShiProcedure {
public static void execute(double y, Entity entity, Entity sourceentity) {
if (entity == null || sourceentity == null)
return;
if (sourceentity.isShiftKeyDown()) {
if (!entity.level().isClientSide())
entity.discard();
if (sourceentity instanceof Player _player) {
ItemStack _setstack = new ItemStack(TargetModItems.TARGET_DEPLOYER.get());
_setstack.setCount(1);
ItemHandlerHelper.giveItemToPlayer(_player, _setstack);
}
} else {
if (!(sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
entity.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((sourceentity.getX()), y, (sourceentity.getZ())));
{
Entity _ent = entity;
_ent.setYRot(entity.getYRot());
_ent.setXRot(0);
_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();
}
}
entity.getPersistentData().putDouble("targetdown", 0);
}
}
}
}

View file

@ -1,24 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
public class Target1ShiTiChuShiShengChengShiProcedure {
public static void execute(Entity entity) {
if (entity == null)
return;
{
Entity _ent = entity;
_ent.setYRot(0);
_ent.setXRot(0);
_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();
}
}
}
}

View file

@ -1,15 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
public class TaserBulletTouZhiWuFeiXingKeProcedure {
public static void execute(Entity immediatesourceentity) {
if (immediatesourceentity == null)
return;
immediatesourceentity.getPersistentData().putDouble("live", (immediatesourceentity.getPersistentData().getDouble("live") + 1));
if (immediatesourceentity.getPersistentData().getDouble("live") == 5) {
immediatesourceentity.setDeltaMovement(new Vec3(0, 0, 0));
}
}
}