优化更多过程
This commit is contained in:
parent
a9e8dedc9b
commit
3f0698cf6e
8 changed files with 196 additions and 294 deletions
|
@ -1,9 +1,12 @@
|
||||||
package net.mcreator.target.entity;
|
package net.mcreator.target.entity;
|
||||||
|
|
||||||
|
import net.mcreator.target.TargetMod;
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.procedures.ClaymoreDangShiTiGengXinKeShiProcedure;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.procedures.ClaymoreDangShiTiSiWangShiProcedure;
|
import net.mcreator.target.procedures.MedexpProcedure;
|
||||||
import net.mcreator.target.procedures.ClaymoreYouJiShiTiShiProcedure;
|
import net.minecraft.commands.CommandSource;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -14,6 +17,8 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
@ -21,15 +26,19 @@ 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.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.SpawnEggItem;
|
import net.minecraft.world.item.SpawnEggItem;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
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;
|
||||||
|
@ -41,6 +50,8 @@ import software.bernie.geckolib.core.animation.RawAnimation;
|
||||||
import software.bernie.geckolib.core.object.PlayState;
|
import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
// TODO 重写阔剑地雷
|
// TODO 重写阔剑地雷
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ClaymoreEntity extends TamableAnimal implements GeoEntity, AnimatedEntity {
|
public class ClaymoreEntity extends TamableAnimal implements GeoEntity, AnimatedEntity {
|
||||||
|
@ -129,7 +140,15 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
||||||
@Override
|
@Override
|
||||||
public void die(DamageSource source) {
|
public void die(DamageSource source) {
|
||||||
super.die(source);
|
super.die(source);
|
||||||
ClaymoreDangShiTiSiWangShiProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ(), this);
|
|
||||||
|
if (level() instanceof ServerLevel server) {
|
||||||
|
server.explode(null, this.getX(), this.getY(), this.getZ(), 6.5f, Level.ExplosionInteraction.NONE);
|
||||||
|
server.explode(this, this.getX(), this.getY(), this.getZ(), 6.5f, Level.ExplosionInteraction.NONE);
|
||||||
|
|
||||||
|
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), "target:mediumexp");
|
||||||
|
this.discard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,33 +165,33 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult mobInteract(Player sourceentity, InteractionHand hand) {
|
public InteractionResult mobInteract(Player player, InteractionHand hand) {
|
||||||
ItemStack itemstack = sourceentity.getItemInHand(hand);
|
ItemStack itemstack = player.getItemInHand(hand);
|
||||||
InteractionResult retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
InteractionResult retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||||
Item item = itemstack.getItem();
|
Item item = itemstack.getItem();
|
||||||
if (itemstack.getItem() instanceof SpawnEggItem) {
|
if (itemstack.getItem() instanceof SpawnEggItem) {
|
||||||
retval = super.mobInteract(sourceentity, hand);
|
retval = super.mobInteract(player, hand);
|
||||||
} else if (this.level().isClientSide()) {
|
} else if (this.level().isClientSide()) {
|
||||||
retval = (this.isTame() && this.isOwnedBy(sourceentity) || this.isFood(itemstack)) ? InteractionResult.sidedSuccess(this.level().isClientSide()) : InteractionResult.PASS;
|
retval = (this.isTame() && this.isOwnedBy(player) || this.isFood(itemstack)) ? InteractionResult.sidedSuccess(this.level().isClientSide()) : InteractionResult.PASS;
|
||||||
} else {
|
} else {
|
||||||
if (this.isTame()) {
|
if (this.isTame()) {
|
||||||
if (this.isOwnedBy(sourceentity)) {
|
if (this.isOwnedBy(player)) {
|
||||||
if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
|
if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
|
||||||
this.usePlayerItem(sourceentity, hand, itemstack);
|
this.usePlayerItem(player, hand, itemstack);
|
||||||
this.heal((float) item.getFoodProperties().getNutrition());
|
this.heal((float) item.getFoodProperties().getNutrition());
|
||||||
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||||
} else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
|
} else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
|
||||||
this.usePlayerItem(sourceentity, hand, itemstack);
|
this.usePlayerItem(player, hand, itemstack);
|
||||||
this.heal(4);
|
this.heal(4);
|
||||||
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||||
} else {
|
} else {
|
||||||
retval = super.mobInteract(sourceentity, hand);
|
retval = super.mobInteract(player, hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.isFood(itemstack)) {
|
} else if (this.isFood(itemstack)) {
|
||||||
this.usePlayerItem(sourceentity, hand, itemstack);
|
this.usePlayerItem(player, hand, itemstack);
|
||||||
if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, sourceentity)) {
|
if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player)) {
|
||||||
this.tame(sourceentity);
|
this.tame(player);
|
||||||
this.level().broadcastEntityEvent(this, (byte) 7);
|
this.level().broadcastEntityEvent(this, (byte) 7);
|
||||||
} else {
|
} else {
|
||||||
this.level().broadcastEntityEvent(this, (byte) 6);
|
this.level().broadcastEntityEvent(this, (byte) 6);
|
||||||
|
@ -180,26 +199,85 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
||||||
this.setPersistenceRequired();
|
this.setPersistenceRequired();
|
||||||
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||||
} else {
|
} else {
|
||||||
retval = super.mobInteract(sourceentity, hand);
|
retval = super.mobInteract(player, hand);
|
||||||
if (retval == InteractionResult.SUCCESS || retval == InteractionResult.CONSUME)
|
if (retval == InteractionResult.SUCCESS || retval == InteractionResult.CONSUME)
|
||||||
this.setPersistenceRequired();
|
this.setPersistenceRequired();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Entity entity = this;
|
|
||||||
|
|
||||||
ClaymoreYouJiShiTiShiProcedure.execute(entity, sourceentity);
|
if (this.isOwnedBy(player) && player.isShiftKeyDown()) {
|
||||||
|
if (!this.level().isClientSide()) this.discard();
|
||||||
|
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(TargetModItems.CLAYMORE_MINE.get()));
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
var data = this.getPersistentData();
|
||||||
|
var level = this.level();
|
||||||
|
var x = this.getX();
|
||||||
|
var y = this.getY();
|
||||||
|
var z = this.getZ();
|
||||||
|
|
||||||
if (this.getPersistentData().getDouble("claymore") > 0) {
|
if (data.getDouble("claymore") > 0) {
|
||||||
this.getPersistentData().putDouble("claymore", (this.getPersistentData().getDouble("claymore") - 1));
|
data.putDouble("claymore", data.getDouble("claymore") - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.putDouble("life", data.getDouble("life") + 1);
|
||||||
|
if (data.getDouble("life") >= 12000) {
|
||||||
|
if (!this.level().isClientSide()) this.discard();
|
||||||
|
}
|
||||||
|
if (data.getDouble("def") >= 100) {
|
||||||
|
if (!this.level().isClientSide() && this.getServer() != null) {
|
||||||
|
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), "playsound minecraft:item.shield.break player @p ~ ~ ~ 1 1");
|
||||||
|
}
|
||||||
|
if (!this.level().isClientSide()) this.discard();
|
||||||
|
|
||||||
|
if (!level.isClientSide()) {
|
||||||
|
level.playSound(null, BlockPos.containing(x, y, z), SoundEvents.SHIELD_BREAK, SoundSource.PLAYERS, 1, 1);
|
||||||
|
} else {
|
||||||
|
level.playLocalSound(x, y, z, SoundEvents.SHIELD_BREAK, SoundSource.PLAYERS, 1, 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level instanceof ServerLevel server) {
|
||||||
|
ItemEntity entityToSpawn = new ItemEntity(server, x, y, z, new ItemStack(TargetModItems.CLAYMORE_MINE.get()));
|
||||||
|
entityToSpawn.setPickUpDelay(10);
|
||||||
|
server.addFreshEntity(entityToSpawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.removeAllEffects();
|
||||||
|
this.clearFire();
|
||||||
|
if (data.getDouble("trigger") <= 60) {
|
||||||
|
data.putDouble("trigger", data.getDouble("trigger") + 1);
|
||||||
|
}
|
||||||
|
if (data.getDouble("trigger") >= 40) {
|
||||||
|
final Vec3 center = new Vec3(x + 1.5 * this.getLookAngle().x, y + 1.5 * this.getLookAngle().y, z + 1.5 * this.getLookAngle().z);
|
||||||
|
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(2.5 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||||
|
var condition = this.getOwner() != target
|
||||||
|
&& target instanceof LivingEntity
|
||||||
|
&& !(target instanceof ClaymoreEntity)
|
||||||
|
&& !(target instanceof Target1Entity)
|
||||||
|
&& !(target instanceof Player player && (player.isCreative() || player.isSpectator()))
|
||||||
|
&& (!this.isAlliedTo(target) || target.getTeam() == null || target.getTeam().getName().equals("TDM"))
|
||||||
|
&& !target.isShiftKeyDown();
|
||||||
|
if (!condition) continue;
|
||||||
|
|
||||||
|
if (!level.isClientSide()) {
|
||||||
|
MedexpProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ());
|
||||||
|
this.discard();
|
||||||
|
}
|
||||||
|
target.getPersistentData().putDouble("claymore", 5);
|
||||||
|
TargetMod.queueServerWork(1, () -> {
|
||||||
|
if (!level.isClientSide())
|
||||||
|
level.explode(this.getOwner(), target.getX(), target.getY(), target.getZ(), 6.5f, Level.ExplosionInteraction.NONE);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClaymoreDangShiTiGengXinKeShiProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ(), this);
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,19 @@ import net.mcreator.target.client.renderer.item.DevotionItemRenderer;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.init.TargetModSounds;
|
import net.mcreator.target.init.TargetModSounds;
|
||||||
import net.mcreator.target.item.AnimatedItem;
|
import net.mcreator.target.item.AnimatedItem;
|
||||||
import net.mcreator.target.procedures.DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure;
|
import net.mcreator.target.procedures.WeaponDrawProcedure;
|
||||||
|
import net.mcreator.target.tools.GunInfo;
|
||||||
|
import net.mcreator.target.tools.GunReload;
|
||||||
import net.mcreator.target.tools.GunsTool;
|
import net.mcreator.target.tools.GunsTool;
|
||||||
import net.mcreator.target.tools.TooltipTool;
|
import net.mcreator.target.tools.TooltipTool;
|
||||||
import net.minecraft.client.Minecraft;
|
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.commands.CommandSource;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -159,7 +164,61 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(itemstack, world, entity, slot, selected);
|
super.inventoryTick(itemstack, world, entity, slot, selected);
|
||||||
DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure.execute(entity, itemstack);
|
|
||||||
|
var itemTag = itemstack.getOrCreateTag();
|
||||||
|
var id = itemTag.getDouble("id");
|
||||||
|
var mainHandItem = entity instanceof LivingEntity living ? living.getMainHandItem() : ItemStack.EMPTY;
|
||||||
|
var mainHandItemTag = mainHandItem.getOrCreateTag();
|
||||||
|
|
||||||
|
if (mainHandItemTag.getDouble("id") != itemTag.getDouble("id")) {
|
||||||
|
itemTag.putDouble("emptyreload", 0);
|
||||||
|
itemTag.putDouble("reloading", 0);
|
||||||
|
itemTag.putDouble("reloadtime", 0);
|
||||||
|
}
|
||||||
|
if (itemTag.getDouble("reloading") == 1 && itemTag.getDouble("ammo") == 0) {
|
||||||
|
if (itemTag.getDouble("reloadtime") == 71) {
|
||||||
|
entity.getPersistentData().putDouble("id", id);
|
||||||
|
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||||
|
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||||
|
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:devotion_reload_empty player @s ~ ~ ~ 100 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mainHandItem.getItem() == itemstack.getItem()
|
||||||
|
&& mainHandItemTag.getDouble("id") == id) {
|
||||||
|
if (itemTag.getDouble("reloadtime") > 0) {
|
||||||
|
itemTag.putDouble("reloadtime", itemTag.getDouble("reloadtime") - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemTag.putDouble("reloading", 0);
|
||||||
|
itemTag.putDouble("emptyreload", 0);
|
||||||
|
itemTag.putDouble("reloadtime", 0);
|
||||||
|
}
|
||||||
|
if (itemTag.getDouble("reloadtime") == 1 && mainHandItemTag.getDouble("id") == id) {
|
||||||
|
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||||
|
}
|
||||||
|
} else if (itemTag.getDouble("reloading") == 1 && itemTag.getDouble("ammo") > 0) {
|
||||||
|
if (itemTag.getDouble("reloadtime") == 51) {
|
||||||
|
entity.getPersistentData().putDouble("id", id);
|
||||||
|
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||||
|
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||||
|
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:devotion_reload_normal player @s ~ ~ ~ 100 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mainHandItem.getItem() == itemstack.getItem()
|
||||||
|
&& mainHandItemTag.getDouble("id") == id) {
|
||||||
|
if (itemTag.getDouble("reloadtime") > 0) {
|
||||||
|
itemTag.putDouble("reloadtime", (itemTag.getDouble("reloadtime") - 1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemTag.putDouble("reloading", 0);
|
||||||
|
itemTag.putDouble("emptyreload", 0);
|
||||||
|
itemTag.putDouble("reloadtime", 0);
|
||||||
|
}
|
||||||
|
if (itemTag.getDouble("reloadtime") == 1 && mainHandItemTag.getDouble("id") == id) {
|
||||||
|
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WeaponDrawProcedure.execute(entity, itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.mcreator.target.TargetMod;
|
|
||||||
import net.mcreator.target.entity.ClaymoreEntity;
|
|
||||||
import net.mcreator.target.entity.Target1Entity;
|
|
||||||
import net.mcreator.target.init.TargetModItems;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.TamableAnimal;
|
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
import net.minecraft.world.phys.AABB;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ClaymoreDangShiTiGengXinKeShiProcedure {
|
|
||||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
boolean target = false;
|
|
||||||
entity.getPersistentData().putDouble("life", (entity.getPersistentData().getDouble("life") + 1));
|
|
||||||
if (entity.getPersistentData().getDouble("life") >= 12000) {
|
|
||||||
if (!entity.level().isClientSide())
|
|
||||||
entity.discard();
|
|
||||||
}
|
|
||||||
if (entity.getPersistentData().getDouble("def") >= 100) {
|
|
||||||
{
|
|
||||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
|
||||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
|
||||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound minecraft:item.shield.break player @p ~ ~ ~ 1 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!entity.level().isClientSide())
|
|
||||||
entity.discard();
|
|
||||||
if (world instanceof Level _level) {
|
|
||||||
if (!_level.isClientSide()) {
|
|
||||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("item.shield.break")), SoundSource.PLAYERS, 1, 1);
|
|
||||||
} else {
|
|
||||||
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("item.shield.break")), SoundSource.PLAYERS, 1, 1, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (world instanceof ServerLevel _level) {
|
|
||||||
ItemEntity entityToSpawn = new ItemEntity(_level, x, y, z, new ItemStack(TargetModItems.CLAYMORE_MINE.get()));
|
|
||||||
entityToSpawn.setPickUpDelay(10);
|
|
||||||
_level.addFreshEntity(entityToSpawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entity instanceof LivingEntity _entity)
|
|
||||||
_entity.removeAllEffects();
|
|
||||||
entity.clearFire();
|
|
||||||
if (entity.getPersistentData().getDouble("trigger") <= 60) {
|
|
||||||
entity.getPersistentData().putDouble("trigger", (entity.getPersistentData().getDouble("trigger") + 1));
|
|
||||||
}
|
|
||||||
if (entity.getPersistentData().getDouble("trigger") >= 40) {
|
|
||||||
{
|
|
||||||
final Vec3 _center = new Vec3((x + 1.5 * entity.getLookAngle().x), (y + 1.5 * entity.getLookAngle().y), (z + 1.5 * entity.getLookAngle().z));
|
|
||||||
List<Entity> _entfound = world.getEntitiesOfClass(Entity.class, new AABB(_center, _center).inflate(2.5 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_center))).toList();
|
|
||||||
for (Entity entityiterator : _entfound) {
|
|
||||||
target = !((entity instanceof TamableAnimal _tamEnt ? (Entity) _tamEnt.getOwner() : null) == entityiterator) && entityiterator instanceof LivingEntity && !(entityiterator instanceof ClaymoreEntity)
|
|
||||||
&& !(entityiterator instanceof Target1Entity)
|
|
||||||
&& !(entityiterator instanceof Player player && (player.isCreative() || player.isSpectator()))
|
|
||||||
&& (!entity.isAlliedTo(entityiterator) || entityiterator.getTeam() == null || entityiterator.getTeam().getName().equals("TDM"))
|
|
||||||
&& !entityiterator.isShiftKeyDown();
|
|
||||||
if (target) {
|
|
||||||
{
|
|
||||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
|
||||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
|
||||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "target:mediumexp");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!entity.level().isClientSide())
|
|
||||||
entity.discard();
|
|
||||||
entityiterator.getPersistentData().putDouble("claymore", 5);
|
|
||||||
TargetMod.queueServerWork(1, () -> {
|
|
||||||
if (world instanceof Level _level && !_level.isClientSide())
|
|
||||||
_level.explode((entity instanceof TamableAnimal _tamEnt ? _tamEnt.getOwner() : null), (entityiterator.getX()), (entityiterator.getY()), (entityiterator.getZ()), 6.5f, Level.ExplosionInteraction.NONE);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +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;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
|
|
||||||
public class ClaymoreDangShiTiSiWangShiProcedure {
|
|
||||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
if (world instanceof Level _level && !_level.isClientSide())
|
|
||||||
_level.explode(entity, x, y, z, 6.5f, Level.ExplosionInteraction.NONE);
|
|
||||||
if (world instanceof Level _level && !_level.isClientSide())
|
|
||||||
_level.explode(null, x, y, z, 6.5f, Level.ExplosionInteraction.NONE);
|
|
||||||
{
|
|
||||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
|
||||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
|
||||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "target:mediumexp");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!entity.level().isClientSide())
|
|
||||||
entity.discard();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModItems;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.TamableAnimal;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
|
|
||||||
public class ClaymoreYouJiShiTiShiProcedure {
|
|
||||||
public static void execute(Entity entity, Entity sourceentity) {
|
|
||||||
if (entity == null || sourceentity == null)
|
|
||||||
return;
|
|
||||||
if ((entity instanceof TamableAnimal _tamIsTamedBy && sourceentity instanceof LivingEntity _livEnt && _tamIsTamedBy.isOwnedBy(_livEnt)) && sourceentity.isShiftKeyDown()) {
|
|
||||||
if (!entity.level().isClientSide())
|
|
||||||
entity.discard();
|
|
||||||
if (sourceentity instanceof Player _player) {
|
|
||||||
ItemStack _setstack = new ItemStack(TargetModItems.CLAYMORE_MINE.get());
|
|
||||||
_setstack.setCount(1);
|
|
||||||
ItemHandlerHelper.giveItemToPlayer(_player, _setstack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.mcreator.target.tools.GunInfo;
|
|
||||||
import net.mcreator.target.tools.GunReload;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
|
|
||||||
public class DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|
||||||
public static void execute(Entity entity, ItemStack itemstack) {
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
double id = 0;
|
|
||||||
id = itemstack.getOrCreateTag().getDouble("id");
|
|
||||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") != itemstack.getOrCreateTag().getDouble("id")) {
|
|
||||||
itemstack.getOrCreateTag().putDouble("emptyreload", 0);
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloading", 0);
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
|
||||||
}
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") == 0) {
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 71) {
|
|
||||||
entity.getPersistentData().putDouble("id", id);
|
|
||||||
{
|
|
||||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
|
||||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
|
||||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:devotion_reload_empty player @s ~ ~ ~ 100 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == itemstack.getItem()
|
|
||||||
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") > 0) {
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloadtime", (itemstack.getOrCreateTag().getDouble("reloadtime") - 1));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloading", 0);
|
|
||||||
itemstack.getOrCreateTag().putDouble("emptyreload", 0);
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
|
||||||
}
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
|
||||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
|
||||||
}
|
|
||||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 51) {
|
|
||||||
entity.getPersistentData().putDouble("id", id);
|
|
||||||
{
|
|
||||||
Entity _ent = entity;
|
|
||||||
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), "playsound target:devotion_reload_normal player @s ~ ~ ~ 100 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == itemstack.getItem()
|
|
||||||
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") > 0) {
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloadtime", (itemstack.getOrCreateTag().getDouble("reloadtime") - 1));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloading", 0);
|
|
||||||
itemstack.getOrCreateTag().putDouble("emptyreload", 0);
|
|
||||||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
|
||||||
}
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
|
||||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WeaponDrawProcedure.execute(entity, itemstack);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
|
import net.mcreator.target.init.TargetModSounds;
|
||||||
import net.minecraft.commands.CommandSource;
|
import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -8,45 +9,30 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
import net.minecraft.world.phys.Vec2;
|
import net.minecraft.world.phys.Vec2;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
public class HugeexpProcedure {
|
public class HugeexpProcedure {
|
||||||
public static void execute(LevelAccessor world, double x, double y, double z) {
|
public static void execute(Level world, double x, double y, double z) {
|
||||||
if (world instanceof Level _level) {
|
if (!world.isClientSide()) {
|
||||||
if (!_level.isClientSide()) {
|
world.playSound(null, BlockPos.containing(x, y + 1, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:c4exp")), SoundSource.BLOCKS, 12, 1);
|
||||||
_level.playSound(null, BlockPos.containing(x, y + 1, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:c4exp")), SoundSource.BLOCKS, 12, 1);
|
world.playSound(null, BlockPos.containing(x, y + 1, z), TargetModSounds.EXPFAR.get(), SoundSource.BLOCKS, 24, 1);
|
||||||
} else {
|
world.playSound(null, BlockPos.containing(x, y + 1, z), TargetModSounds.EXPVERYFAR.get(), SoundSource.BLOCKS, 64, 1);
|
||||||
_level.playLocalSound(x, (y + 1), z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:c4exp")), SoundSource.BLOCKS, 12, 1, false);
|
} else {
|
||||||
}
|
world.playLocalSound(x, (y + 1), z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:c4exp")), SoundSource.BLOCKS, 12, 1, false);
|
||||||
|
world.playLocalSound(x, (y + 1), z, TargetModSounds.EXPFAR.get(), SoundSource.BLOCKS, 24, 1, false);
|
||||||
|
world.playLocalSound(x, (y + 1), z, TargetModSounds.EXPVERYFAR.get(), SoundSource.BLOCKS, 64, 1, false);
|
||||||
}
|
}
|
||||||
if (world instanceof Level _level) {
|
if (world instanceof ServerLevel server) {
|
||||||
if (!_level.isClientSide()) {
|
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
||||||
_level.playSound(null, BlockPos.containing(x, y + 1, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:expfar")), SoundSource.BLOCKS, 24, 1);
|
|
||||||
} else {
|
|
||||||
_level.playLocalSound(x, (y + 1), z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:expfar")), SoundSource.BLOCKS, 24, 1, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (world instanceof Level _level) {
|
|
||||||
if (!_level.isClientSide()) {
|
|
||||||
_level.playSound(null, BlockPos.containing(x, y + 1, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:expveryfar")), SoundSource.BLOCKS, 64, 1);
|
|
||||||
} else {
|
|
||||||
_level.playLocalSound(x, (y + 1), z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:expveryfar")), SoundSource.BLOCKS, 64, 1, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (world instanceof ServerLevel _level)
|
|
||||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
|
||||||
"particle minecraft:campfire_cosy_smoke ~ ~ ~ 1 3 1 0.04 200 force");
|
"particle minecraft:campfire_cosy_smoke ~ ~ ~ 1 3 1 0.04 200 force");
|
||||||
if (world instanceof ServerLevel _level)
|
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
||||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
|
||||||
"particle minecraft:large_smoke ~ ~1 ~ 1 3 1 0.02 1000 force");
|
"particle minecraft:large_smoke ~ ~1 ~ 1 3 1 0.02 1000 force");
|
||||||
if (world instanceof ServerLevel _level)
|
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
||||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
|
||||||
"particle minecraft:campfire_cosy_smoke ~ ~ ~ 6 0.01 6 0.02 500 force");
|
"particle minecraft:campfire_cosy_smoke ~ ~ ~ 6 0.01 6 0.02 500 force");
|
||||||
if (world instanceof ServerLevel _level)
|
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
||||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
|
||||||
"particle target:firestar ~ ~ ~ 0 0 0 0.5 600 force");
|
"particle target:firestar ~ ~ ~ 0 0 0 0.5 600 force");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModItems;
|
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -11,27 +10,27 @@ import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
public class WeaponDrawLightProcedure {
|
public class WeaponDrawLightProcedure {
|
||||||
public static void execute(Entity entity, ItemStack itemStack) {
|
public static void execute(Entity entity, ItemStack itemStack) {
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
CompoundTag tag = itemStack.getOrCreateTag();
|
CompoundTag tag = itemStack.getOrCreateTag();
|
||||||
Item mainHandItem = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem();
|
Item mainHandItem = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem();
|
||||||
if (tag.getDouble("draw") == 1) {
|
if (tag.getDouble("draw") == 1) {
|
||||||
tag.putDouble("draw", 0);
|
tag.putDouble("draw", 0);
|
||||||
tag.putDouble("drawtime", 0);
|
tag.putDouble("drawtime", 0);
|
||||||
if (entity instanceof Player _player)
|
if (entity instanceof Player _player)
|
||||||
_player.getCooldowns().addCooldown(itemStack.getItem(), 11);
|
_player.getCooldowns().addCooldown(itemStack.getItem(), 11);
|
||||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.zooming = false;
|
capability.zooming = false;
|
||||||
capability.syncPlayerVariables(entity);
|
capability.syncPlayerVariables(entity);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (mainHandItem == itemStack.getItem()) {
|
|
||||||
if (tag.getDouble("drawtime") < 11) {
|
|
||||||
tag.putDouble("drawtime", (tag.getDouble("drawtime") + 1));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (tag.getDouble("fireanim") > 0) {
|
if (mainHandItem == itemStack.getItem()) {
|
||||||
tag.putDouble("fireanim", (tag.getDouble("fireanim") - 1));
|
if (tag.getDouble("drawtime") < 11) {
|
||||||
|
tag.putDouble("drawtime", (tag.getDouble("drawtime") + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tag.getDouble("fireanim") > 0) {
|
||||||
|
tag.putDouble("fireanim", (tag.getDouble("fireanim") - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue