添加DPS发电机
This commit is contained in:
parent
46d88ec777
commit
4fbe8a589d
18 changed files with 667 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/dps_generator_deployer"
|
||||
}
|
||||
}
|
|
@ -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<DPSGeneratorEntity> {
|
||||
private static final ResourceLocation LAYER = Mod.loc("textures/entity/dps_generator_e.png");
|
||||
|
||||
public DPSGeneratorLayer(GeoRenderer<DPSGeneratorEntity> 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);
|
||||
}
|
||||
}
|
|
@ -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<DPSGeneratorEntity> {
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
|
@ -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<DPSGeneratorEntity> {
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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<Integer> DOWN_TIME = SynchedEntityData.defineId(DPSGeneratorEntity.class, EntityDataSerializers.INT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
||||
public DPSGeneratorEntity(EntityType<DPSGeneratorEntity> 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<ItemStack> 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<DPSGeneratorEntity> 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,8 @@ public class ModEntities {
|
|||
// Living Entities
|
||||
public static final DeferredHolder<EntityType<?>, EntityType<TargetEntity>> TARGET = register("target",
|
||||
EntityType.Builder.of(TargetEntity::new, MobCategory.CREATURE).setTrackingRange(64).setUpdateInterval(3).fireImmune().sized(0.875f, 2f));
|
||||
public static final DeferredHolder<EntityType<?>, EntityType<DPSGeneratorEntity>> 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<?>, EntityType<SenpaiEntity>> 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -142,6 +142,7 @@ public class ModItems {
|
|||
|
||||
public static final DeferredHolder<Item, Detonator> DETONATOR = ITEMS.register("detonator", Detonator::new);
|
||||
public static final DeferredHolder<Item, TargetDeployer> TARGET_DEPLOYER = ITEMS.register("target_deployer", TargetDeployer::new);
|
||||
public static final DeferredHolder<Item, DPSGeneratorDeployer> DPS_GENERATOR_DEPLOYER = ITEMS.register("dps_generator_deployer", DPSGeneratorDeployer::new);
|
||||
public static final DeferredHolder<Item, Knife> KNIFE = ITEMS.register("knife", Knife::new);
|
||||
public static final DeferredHolder<Item, Hammer> HAMMER = ITEMS.register("hammer", Hammer::new);
|
||||
public static final DeferredHolder<Item, Crowbar> CROWBAR = ITEMS.register("crowbar", Crowbar::new);
|
||||
|
|
|
@ -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<ItemStack> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -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": "大锤",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 659 B |
Binary file not shown.
After Width: | Height: | Size: 261 B |
Binary file not shown.
After Width: | Height: | Size: 428 B |
Loading…
Add table
Reference in a new issue