From 4fbe8a589df042b1c378e3a66e248cc4d44c8cca Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Fri, 9 May 2025 23:27:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0DPS=E5=8F=91=E7=94=B5?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../b69ee8a2655365569b979911c0440daa8c470ac2 | 3 +- .../models/item/dps_generator_deployer.json | 6 + .../client/layer/DPSGeneratorLayer.java | 27 ++ .../model/entity/DPSGeneratorModel.java | 24 ++ .../renderer/entity/DPSGeneratorRenderer.java | 45 ++++ .../datagen/ModItemModelProvider.java | 1 + .../entity/DPSGeneratorEntity.java | 236 ++++++++++++++++++ .../superbwarfare/init/ModEntities.java | 3 + .../init/ModEntityRenderers.java | 1 + .../superbwarfare/init/ModItems.java | 1 + .../item/DPSGeneratorDeployer.java | 89 +++++++ .../animations/dps_generator.animation.json | 83 ++++++ .../superbwarfare/geo/dps_generator.geo.json | 147 +++++++++++ .../assets/superbwarfare/lang/en_us.json | 1 + .../assets/superbwarfare/lang/zh_cn.json | 1 + .../textures/entity/dps_generator.png | Bin 0 -> 659 bytes .../textures/entity/dps_generator_e.png | Bin 0 -> 261 bytes .../textures/item/dps_generator_deployer.png | Bin 0 -> 428 bytes 18 files changed, 667 insertions(+), 1 deletion(-) create mode 100644 src/generated/resources/assets/superbwarfare/models/item/dps_generator_deployer.json create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/layer/DPSGeneratorLayer.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/model/entity/DPSGeneratorModel.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/DPSGeneratorRenderer.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/DPSGeneratorDeployer.java create mode 100644 src/main/resources/assets/superbwarfare/animations/dps_generator.animation.json create mode 100644 src/main/resources/assets/superbwarfare/geo/dps_generator.geo.json create mode 100644 src/main/resources/assets/superbwarfare/textures/entity/dps_generator.png create mode 100644 src/main/resources/assets/superbwarfare/textures/entity/dps_generator_e.png create mode 100644 src/main/resources/assets/superbwarfare/textures/item/dps_generator_deployer.png diff --git a/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 b/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 index 84d55441c..454193d54 100644 --- a/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 +++ b/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 @@ -1,4 +1,4 @@ -// 1.21.1 2025-05-09T21:50:05.0172065 Item Models: superbwarfare +// 1.21.1 2025-05-09T23:24:48.8440376 Item Models: superbwarfare 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/aa_12_blueprint.json 0a9bfb695c2b5668863a2de4770f5bfca663c1dc assets/superbwarfare/models/item/agm.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/ak_12_blueprint.json @@ -25,6 +25,7 @@ b0296c3d68f3b5ae4945b46384fa20a1ff32cac5 assets/superbwarfare/models/item/crowba d81b738e17048945459ff8b59f8f83e872171473 assets/superbwarfare/models/item/defuser.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/devotion_blueprint.json 6f4a829dc159f1740f52265d01730ecb6a840d81 assets/superbwarfare/models/item/dog_tag.json +9112aa14b3f057c3b29c932cfaa60a11b37757dc assets/superbwarfare/models/item/dps_generator_deployer.json dd455cf29eed0ef5eb5e90ef3d7140cb8de61efe assets/superbwarfare/models/item/drone.json 831ce33c5a4c90b71a42515f42f16d4c1a946c50 assets/superbwarfare/models/item/empty_perk.json 2419503d8b597c92684d1921895a12fca33fec69 assets/superbwarfare/models/item/epic_material_pack.json diff --git a/src/generated/resources/assets/superbwarfare/models/item/dps_generator_deployer.json b/src/generated/resources/assets/superbwarfare/models/item/dps_generator_deployer.json new file mode 100644 index 000000000..20102ecac --- /dev/null +++ b/src/generated/resources/assets/superbwarfare/models/item/dps_generator_deployer.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "superbwarfare:item/dps_generator_deployer" + } +} \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/client/layer/DPSGeneratorLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/DPSGeneratorLayer.java new file mode 100644 index 000000000..d9f6bc27f --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/layer/DPSGeneratorLayer.java @@ -0,0 +1,27 @@ +package com.atsuishio.superbwarfare.client.layer; + +import com.atsuishio.superbwarfare.Mod; +import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.resources.ResourceLocation; +import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.renderer.GeoRenderer; +import software.bernie.geckolib.renderer.layer.GeoRenderLayer; + +public class DPSGeneratorLayer extends GeoRenderLayer { + private static final ResourceLocation LAYER = Mod.loc("textures/entity/dps_generator_e.png"); + + public DPSGeneratorLayer(GeoRenderer entityRenderer) { + super(entityRenderer); + } + + @Override + public void render(PoseStack poseStack, DPSGeneratorEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + RenderType glowRenderType = RenderType.eyes(LAYER); + getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 0xFFFFFFFF); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/DPSGeneratorModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/DPSGeneratorModel.java new file mode 100644 index 000000000..2c1c42022 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/DPSGeneratorModel.java @@ -0,0 +1,24 @@ +package com.atsuishio.superbwarfare.client.model.entity; + +import com.atsuishio.superbwarfare.Mod; +import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity; +import net.minecraft.resources.ResourceLocation; +import software.bernie.geckolib.model.GeoModel; + +public class DPSGeneratorModel extends GeoModel { + + @Override + public ResourceLocation getAnimationResource(DPSGeneratorEntity entity) { + return Mod.loc("animations/dps_generator.animation.json"); + } + + @Override + public ResourceLocation getModelResource(DPSGeneratorEntity entity) { + return Mod.loc("geo/dps_generator.geo.json"); + } + + @Override + public ResourceLocation getTextureResource(DPSGeneratorEntity entity) { + return Mod.loc("textures/entity/dps_generator.png"); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/DPSGeneratorRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/DPSGeneratorRenderer.java new file mode 100644 index 000000000..aaea0f6ef --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/DPSGeneratorRenderer.java @@ -0,0 +1,45 @@ +package com.atsuishio.superbwarfare.client.renderer.entity; + +import com.atsuishio.superbwarfare.client.layer.DPSGeneratorLayer; +import com.atsuishio.superbwarfare.client.model.entity.DPSGeneratorModel; +import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; +import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.renderer.GeoEntityRenderer; + +public class DPSGeneratorRenderer extends GeoEntityRenderer { + public DPSGeneratorRenderer(EntityRendererProvider.Context renderManager) { + super(renderManager, new DPSGeneratorModel()); + this.shadowRadius = 0f; + this.addRenderLayer(new DPSGeneratorLayer(this)); + } + + @Override + public RenderType getRenderType(DPSGeneratorEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) { + return RenderType.entityTranslucent(getTextureLocation(animatable)); + } + + @Override + public void preRender(PoseStack poseStack, DPSGeneratorEntity animatable, BakedGeoModel model, @Nullable MultiBufferSource bufferSource, @Nullable VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int colour) { + float scale = 1f; + this.scaleHeight = scale; + this.scaleWidth = scale; + super.preRender(poseStack, animatable, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, colour); + } + + @Override + protected float getDeathMaxRotation(DPSGeneratorEntity entityLivingBaseIn) { + return 0.0F; + } + + @Override + public boolean shouldShowName(DPSGeneratorEntity animatable) { + return animatable.hasCustomName(); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java index f75256b8c..96634eb54 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java @@ -40,6 +40,7 @@ public class ModItemModelProvider extends ItemModelProvider { simpleItem(ModItems.HEAVY_ARMAMENT_MODULE); simpleItem(ModItems.TARGET_DEPLOYER); + simpleItem(ModItems.DPS_GENERATOR_DEPLOYER); simpleItem(ModItems.MORTAR_DEPLOYER); simpleItem(ModItems.MORTAR_BARREL); simpleItem(ModItems.MORTAR_BASE_PLATE); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java new file mode 100644 index 000000000..f41e1bd78 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java @@ -0,0 +1,236 @@ +package com.atsuishio.superbwarfare.entity; + +import com.atsuishio.superbwarfare.Mod; +import com.atsuishio.superbwarfare.init.ModItems; +import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.tools.FormatTool; +import com.atsuishio.superbwarfare.tools.SoundTool; +import net.minecraft.commands.arguments.EntityAnchorArgument; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; +import net.minecraft.world.entity.*; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.ThrownPotion; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.event.entity.living.LivingDeathEvent; +import org.jetbrains.annotations.NotNull; +import software.bernie.geckolib.animatable.GeoEntity; +import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.animation.AnimationState; +import software.bernie.geckolib.animation.*; +import software.bernie.geckolib.util.GeckoLibUtil; + +@EventBusSubscriber(modid = Mod.MODID) +public class DPSGeneratorEntity extends LivingEntity implements GeoEntity { + + public static final EntityDataAccessor DOWN_TIME = SynchedEntityData.defineId(DPSGeneratorEntity.class, EntityDataSerializers.INT); + private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); + + public DPSGeneratorEntity(EntityType type, Level world) { + super(type, world); + this.noCulling = true; + } + + @Override + protected void defineSynchedData(SynchedEntityData.@NotNull Builder builder) { + super.defineSynchedData(builder); + builder.define(DOWN_TIME, 0); + } + + + @Override + public @NotNull Iterable getArmorSlots() { + return NonNullList.withSize(1, ItemStack.EMPTY); + } + + @Override + public @NotNull ItemStack getItemBySlot(@NotNull EquipmentSlot pSlot) { + return ItemStack.EMPTY; + } + + @Override + public void setItemSlot(@NotNull EquipmentSlot pSlot, @NotNull ItemStack pStack) { + } + + @Override + public boolean causeFallDamage(float l, float d, @NotNull DamageSource source) { + return false; + } + + @Override + public boolean shouldRenderAtSqrDistance(double pDistance) { + return true; + } + + @Override + public boolean hurt(DamageSource source, float amount) { + if (source.is(DamageTypes.IN_FIRE) + || source.getDirectEntity() instanceof ThrownPotion + || source.getDirectEntity() instanceof AreaEffectCloud + || source.is(DamageTypes.FALL) + || source.is(DamageTypes.CACTUS) + || source.is(DamageTypes.DROWN) + || source.is(DamageTypes.LIGHTNING_BOLT) + || source.is(DamageTypes.FALLING_ANVIL) + || source.is(DamageTypes.DRAGON_BREATH) + || source.is(DamageTypes.WITHER) + || source.is(DamageTypes.WITHER_SKULL) + || source.is(DamageTypes.MAGIC) + || this.entityData.get(DOWN_TIME) > 0) { + return false; + } + + if (!this.level().isClientSide()) { + this.level().playSound(null, BlockPos.containing(this.getX(), this.getY(), this.getZ()), ModSounds.HIT.get(), SoundSource.BLOCKS, 1, 1); + } else { + this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), ModSounds.HIT.get(), SoundSource.BLOCKS, 1, 1, false); + } + return super.hurt(source, amount); + } + + @SubscribeEvent + public static void onTargetDown(LivingDeathEvent event) { + var entity = event.getEntity(); + var sourceEntity = event.getSource().getEntity(); + + if (entity instanceof DPSGeneratorEntity generatorEntity) { + event.setCanceled(true); + generatorEntity.setHealth(generatorEntity.getMaxHealth()); + + if (sourceEntity == null) return; + + if (sourceEntity instanceof Player player) { + player.displayClientMessage(Component.translatable("tips.superbwarfare.target.down", + FormatTool.format1D(entity.position().distanceTo(sourceEntity.position())), "m"), true); + SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 1, 1); + generatorEntity.entityData.set(DOWN_TIME, 40); + } + } + } + + @Override + public boolean isPickable() { + return this.entityData.get(DOWN_TIME) == 0; + } + + @Override + public void die(@NotNull DamageSource source) { + super.die(source); + } + + @Override + public @NotNull InteractionResult interact(Player player, @NotNull InteractionHand hand) { + if (player.isShiftKeyDown()) { + if (!this.level().isClientSide()) { + this.discard(); + } + + if (!player.getAbilities().instabuild) { + player.addItem(new ItemStack(ModItems.DPS_GENERATOR_DEPLOYER.get())); + } + } else { + this.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((player.getX()), this.getY(), (player.getZ()))); + this.setXRot(0); + this.xRotO = this.getXRot(); + this.entityData.set(DOWN_TIME, 0); + } + + return InteractionResult.sidedSuccess(this.level().isClientSide()); + } + + @Override + public void tick() { + super.tick(); + if (this.entityData.get(DOWN_TIME) > 0) { + this.entityData.set(DOWN_TIME, this.entityData.get(DOWN_TIME) - 1); + } + } + + @Override + public @NotNull Vec3 getDeltaMovement() { + return new Vec3(0, 0, 0); + } + + @Override + public boolean isPushable() { + return false; + } + + @Override + public @NotNull HumanoidArm getMainArm() { + return HumanoidArm.RIGHT; + } + + @Override + protected void doPush(@NotNull Entity entityIn) { + } + + @Override + protected void pushEntities() { + } + + @Override + public void setNoGravity(boolean ignored) { + super.setNoGravity(true); + } + + @Override + public void aiStep() { + super.aiStep(); + this.updateSwingTime(); + this.setNoGravity(true); + } + + public static AttributeSupplier.Builder createAttributes() { + return Mob.createMobAttributes() + .add(Attributes.MOVEMENT_SPEED, 0) + .add(Attributes.MAX_HEALTH, 40) + .add(Attributes.ARMOR, 0) + .add(Attributes.ATTACK_DAMAGE, 0) + .add(Attributes.FOLLOW_RANGE, 16) + .add(Attributes.KNOCKBACK_RESISTANCE, 10) + .add(Attributes.FLYING_SPEED, 0); + } + + @Override + protected void tickDeath() { + ++this.deathTime; + if (this.deathTime >= 100) { + this.spawnAtLocation(new ItemStack(ModItems.DPS_GENERATOR_DEPLOYER.get())); + this.remove(RemovalReason.KILLED); + } + } + + private PlayState movementPredicate(AnimationState event) { + if (this.entityData.get(DOWN_TIME) > 0) { + return event.setAndContinue(RawAnimation.begin().thenPlay("animation.target.down")); + } + return event.setAndContinue(RawAnimation.begin().thenLoop("animation.target.idle")); + } + + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar data) { + data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate)); + } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return this.cache; + } + +} diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java b/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java index ea3de4127..27b99a220 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java @@ -25,6 +25,8 @@ public class ModEntities { // Living Entities public static final DeferredHolder, EntityType> TARGET = register("target", EntityType.Builder.of(TargetEntity::new, MobCategory.CREATURE).setTrackingRange(64).setUpdateInterval(3).fireImmune().sized(0.875f, 2f)); + public static final DeferredHolder, EntityType> DPS_GENERATOR = register("dps_generator", + EntityType.Builder.of(DPSGeneratorEntity::new, MobCategory.CREATURE).setTrackingRange(64).setUpdateInterval(3).fireImmune().sized(0.875f, 2f)); public static final DeferredHolder, EntityType> SENPAI = register("senpai", EntityType.Builder.of(SenpaiEntity::new, MobCategory.MONSTER).setTrackingRange(64).setUpdateInterval(3) .sized(0.6f, 2f)); @@ -132,6 +134,7 @@ public class ModEntities { @SubscribeEvent public static void registerAttributes(EntityAttributeCreationEvent event) { event.put(TARGET.get(), TargetEntity.createAttributes().build()); + event.put(DPS_GENERATOR.get(), DPSGeneratorEntity.createAttributes().build()); event.put(SENPAI.get(), SenpaiEntity.createAttributes().build()); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModEntityRenderers.java b/src/main/java/com/atsuishio/superbwarfare/init/ModEntityRenderers.java index e1e75293a..55b603f90 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModEntityRenderers.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModEntityRenderers.java @@ -19,6 +19,7 @@ public class ModEntityRenderers { event.registerEntityRenderer(ModEntities.TASER_BULLET.get(), TaserBulletProjectileRenderer::new); event.registerEntityRenderer(ModEntities.GUN_GRENADE.get(), GunGrenadeRenderer::new); event.registerEntityRenderer(ModEntities.TARGET.get(), TargetRenderer::new); + event.registerEntityRenderer(ModEntities.DPS_GENERATOR.get(), DPSGeneratorRenderer::new); event.registerEntityRenderer(ModEntities.RPG_ROCKET.get(), RpgRocketRenderer::new); event.registerEntityRenderer(ModEntities.HELI_ROCKET.get(), HeliRocketRenderer::new); event.registerEntityRenderer(ModEntities.MORTAR_SHELL.get(), MortarShellRenderer::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index ff92aae87..c58173250 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -142,6 +142,7 @@ public class ModItems { public static final DeferredHolder DETONATOR = ITEMS.register("detonator", Detonator::new); public static final DeferredHolder TARGET_DEPLOYER = ITEMS.register("target_deployer", TargetDeployer::new); + public static final DeferredHolder DPS_GENERATOR_DEPLOYER = ITEMS.register("dps_generator_deployer", DPSGeneratorDeployer::new); public static final DeferredHolder KNIFE = ITEMS.register("knife", Knife::new); public static final DeferredHolder HAMMER = ITEMS.register("hammer", Hammer::new); public static final DeferredHolder CROWBAR = ITEMS.register("crowbar", Crowbar::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/DPSGeneratorDeployer.java b/src/main/java/com/atsuishio/superbwarfare/item/DPSGeneratorDeployer.java new file mode 100644 index 000000000..d522c4dae --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/DPSGeneratorDeployer.java @@ -0,0 +1,89 @@ +package com.atsuishio.superbwarfare.item; + +import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity; +import com.atsuishio.superbwarfare.init.ModEntities; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.stats.Stats; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class DPSGeneratorDeployer extends Item { + public DPSGeneratorDeployer() { + super(new Properties()); + } + + @Override + public @NotNull InteractionResult useOn(UseOnContext pContext) { + Level level = pContext.getLevel(); + if (!(level instanceof ServerLevel)) { + return InteractionResult.SUCCESS; + } else { + ItemStack itemstack = pContext.getItemInHand(); + BlockPos blockpos = pContext.getClickedPos(); + Direction direction = pContext.getClickedFace(); + BlockState blockstate = level.getBlockState(blockpos); + BlockPos pos; + if (blockstate.getCollisionShape(level, blockpos).isEmpty()) { + pos = blockpos; + } else { + pos = blockpos.relative(direction); + } + + if (ModEntities.DPS_GENERATOR.get().spawn((ServerLevel) level, itemstack, pContext.getPlayer(), pos, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, pos) && direction == Direction.UP) != null) { + itemstack.shrink(1); + level.gameEvent(pContext.getPlayer(), GameEvent.ENTITY_PLACE, blockpos); + } + + return InteractionResult.CONSUME; + } + } + + @Override + public @NotNull InteractionResultHolder use(@NotNull Level pLevel, Player pPlayer, @NotNull InteractionHand pHand) { + ItemStack itemstack = pPlayer.getItemInHand(pHand); + BlockHitResult blockhitresult = getPlayerPOVHitResult(pLevel, pPlayer, ClipContext.Fluid.SOURCE_ONLY); + if (blockhitresult.getType() != HitResult.Type.BLOCK) { + return InteractionResultHolder.pass(itemstack); + } else if (!(pLevel instanceof ServerLevel)) { + return InteractionResultHolder.success(itemstack); + } else { + BlockPos blockpos = blockhitresult.getBlockPos(); + if (!(pLevel.getBlockState(blockpos).getBlock() instanceof LiquidBlock)) { + return InteractionResultHolder.pass(itemstack); + } else if (pLevel.mayInteract(pPlayer, blockpos) && pPlayer.mayUseItemAt(blockpos, blockhitresult.getDirection(), itemstack)) { + DPSGeneratorEntity entity = ModEntities.DPS_GENERATOR.get().spawn((ServerLevel) pLevel, itemstack, pPlayer, blockpos, MobSpawnType.SPAWN_EGG, false, false); + if (entity == null) { + return InteractionResultHolder.pass(itemstack); + } else { + if (!pPlayer.getAbilities().instabuild) { + itemstack.shrink(1); + } + + pPlayer.awardStat(Stats.ITEM_USED.get(this)); + pLevel.gameEvent(pPlayer, GameEvent.ENTITY_PLACE, entity.position()); + return InteractionResultHolder.consume(itemstack); + } + } else { + return InteractionResultHolder.fail(itemstack); + } + } + } +} diff --git a/src/main/resources/assets/superbwarfare/animations/dps_generator.animation.json b/src/main/resources/assets/superbwarfare/animations/dps_generator.animation.json new file mode 100644 index 000000000..c7a5dad8a --- /dev/null +++ b/src/main/resources/assets/superbwarfare/animations/dps_generator.animation.json @@ -0,0 +1,83 @@ +{ + "format_version": "1.8.0", + "animations": { + "animation.target.idle": { + "loop": true, + "animation_length": 0.0417 + }, + "animation.target.down": { + "loop": "hold_on_last_frame", + "animation_length": 2, + "bones": { + "ba": { + "rotation": { + "0.0": { + "vector": [ + 0, + 0, + 0 + ] + }, + "0.125": { + "vector": [ + -90, + 0, + 0 + ], + "easing": "easeOutCubic" + }, + "0.25": { + "vector": [ + -80, + 0, + 0 + ], + "easing": "easeOutSine" + }, + "0.375": { + "vector": [ + -90, + 0, + 0 + ], + "easing": "easeInCubic" + }, + "0.5": { + "vector": [ + -88, + 0, + 0 + ], + "easing": "easeOutSine" + }, + "0.625": { + "vector": [ + -90, + 0, + 0 + ], + "easing": "easeInCubic" + }, + "1.5": { + "vector": [ + -90, + 0, + 0 + ], + "easing": "linear" + }, + "2.0": { + "vector": [ + 0, + 0, + 0 + ], + "easing": "easeInOutSine" + } + } + } + } + } + }, + "geckolib_format_version": 2 +} \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/geo/dps_generator.geo.json b/src/main/resources/assets/superbwarfare/geo/dps_generator.geo.json new file mode 100644 index 000000000..b4c03d488 --- /dev/null +++ b/src/main/resources/assets/superbwarfare/geo/dps_generator.geo.json @@ -0,0 +1,147 @@ +{ + "format_version": "1.12.0", + "minecraft:geometry": [ + { + "description": { + "identifier": "geometry.unknown", + "texture_width": 128, + "texture_height": 128, + "visible_bounds_width": 2, + "visible_bounds_height": 3.5, + "visible_bounds_offset": [ + 0, + 1.25, + 0 + ] + }, + "bones": [ + { + "name": "0", + "pivot": [ + 0, + 0, + 0 + ] + }, + { + "name": "zuo", + "parent": "0", + "pivot": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -8, + 2, + -1 + ], + "size": [ + 1, + 2, + 2 + ], + "uv": [ + 0, + 29 + ] + }, + { + "origin": [ + -8, + 0, + -4 + ], + "size": [ + 16, + 2, + 8 + ], + "uv": [ + 22, + 21 + ] + }, + { + "origin": [ + 7, + 2, + -1 + ], + "size": [ + 1, + 2, + 2 + ], + "uv": [ + 6, + 29 + ] + } + ] + }, + { + "name": "ba", + "parent": "0", + "pivot": [ + 0, + 3.5, + 0 + ], + "cubes": [ + { + "origin": [ + -7, + 4, + -0.5 + ], + "size": [ + 14, + 28, + 1 + ], + "uv": [ + 0, + 0 + ] + }, + { + "origin": [ + 6, + 3, + -0.5 + ], + "size": [ + 1, + 1, + 1 + ], + "uv": [ + 10, + 29 + ] + }, + { + "origin": [ + -7, + 3, + -0.5 + ], + "size": [ + 1, + 1, + 1 + ], + "uv": [ + 4, + 29 + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 36e491d8f..c37a8aeb6 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -176,6 +176,7 @@ "item.superbwarfare.firing_parameters": "Firing Parameters", "item.superbwarfare.ancient_cpu": "Ancient CPU", "item.superbwarfare.target_deployer": "Target", + "item.superbwarfare.dps_generator_deployer": "DPS Generator", "item.superbwarfare.senpai_spawn_egg": "Senpai Spawn Egg", "item.superbwarfare.knife": "Knife", "item.superbwarfare.hammer": "Hammer", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 1ca6ce9e0..e2e665c30 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -176,6 +176,7 @@ "item.superbwarfare.firing_parameters": "射击诸元", "item.superbwarfare.ancient_cpu": "古代处理器", "item.superbwarfare.target_deployer": "标靶", + "item.superbwarfare.dps_generator_deployer": "DPS发电机", "item.superbwarfare.senpai_spawn_egg": "野兽先辈刷怪蛋", "item.superbwarfare.knife": "军刀", "item.superbwarfare.hammer": "大锤", diff --git a/src/main/resources/assets/superbwarfare/textures/entity/dps_generator.png b/src/main/resources/assets/superbwarfare/textures/entity/dps_generator.png new file mode 100644 index 0000000000000000000000000000000000000000..d53314f4c6b24dae43bae4e3fdb73fdcfa59f0a8 GIT binary patch literal 659 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv=}#LT=BJwMkF1yemk zJ@f8s-z|Y^wxvdRrg?g5F>nAmtPE0&tPG4mmKP99L)jqLXfQH^#hHL?Lq;YB0U#X( z#F_0ZVDT&<8w3)77^ELYqgl$p%)l^#oq+|Y!obMbfN=rDRFDqV1rU>_0NEhG1T=>U ztTM>b0?2~uGBhv%$*Q`~>s@TJ^(fFbCr=m0kczmsHy>s;J4iG<^mgZH<-54`&T{S@ zVQm^y)?Ik!^3>_dtv><9_dhpiB%R=o*T464$~ryGzfb;#-3xxTZ~EW4+xGor7L++G zap33c&DI;QeSaNY|3!jP=CChAcK)mSb#s*)l6P=FSU)jghZ{p_#mn#JpU%#`wc>mV zLuB2l)4f(_*(Owedc9qO;cGO{fe-QfZ!(;kZg0>0br#QpnxER{uaXrtEW8gM>}AaH zWjLN7B{7GgN!X!)iNlZKAg98PyUQBoeJ{(uU7Q)A@ITeM-0uB!p83^bf!8?Sxiu6eW}G!VpIdY2`lhBZ@%Nz6Aq8B~UmAaH VYJNwFt*ItRpQo#z%Q~loCII)#z4-tD literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/superbwarfare/textures/entity/dps_generator_e.png b/src/main/resources/assets/superbwarfare/textures/entity/dps_generator_e.png new file mode 100644 index 0000000000000000000000000000000000000000..69296f5841ebd6d427e22dff009845b61133244f GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSoCO|{#S9GG!XV7ZFl&wkP;k4a zi(^Q|oVQmEg_;d`SR5=Thcl}_yzMzv$*`@E{Zro2gcT*}t_+X0?zfj#@2#$jS+;Xd z{n6YnEDOwaVy=JwfAnU7sr_^<2En(A*>!fi89P?Aul;Fh+s8LOQ;%)_?L>wX>vu9K zz4;?(!u;Ts{NX$XlX{s@AfaQ=c%cSpKUv_xExT>ON?S?~|HudF_jL7hS?83{1ORox BNkRYs literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/superbwarfare/textures/item/dps_generator_deployer.png b/src/main/resources/assets/superbwarfare/textures/item/dps_generator_deployer.png new file mode 100644 index 0000000000000000000000000000000000000000..2b705f6eb89b4da5afa6a00ad5fdd84886bbe969 GIT binary patch literal 428 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G~10G|-o4hDv+3=IGO|Bn>n28s#x9_9g3tR+Ey!9clBSEK+1B}!Z)N`mv#O3D+9QW*jgGxJLH{9Hp6O!W-)%)76Bw*;!$mKx!i z=IN=$zyUIrL5h);ff2~^0%B<>8{~2gMrN=$6Oe7l$OQID6p)?S&H@(C0$Nv;eZ8x(p2rK(eat z^LiJXY&{BO>U+94hG+yQCnP2&HZTjYw@5BzP&~lGc7jQvGK6t~4I^WT?u#}j##q)F c6B)R<8Kgy-R5jh~r-F>}boFyt=akR{08KJbyZ`_I literal 0 HcmV?d00001