内联标靶生成过程
This commit is contained in:
parent
bc123df16a
commit
2ed3095bca
4 changed files with 52 additions and 64 deletions
|
@ -76,7 +76,7 @@ public class TargetModItems {
|
|||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TargetMod.MODID);
|
||||
|
||||
public static final RegistryObject<Item> SENPAI_SPAWN_EGG = ITEMS.register("senpai_spawn_egg", () -> new ForgeSpawnEggItem(TargetModEntities.SENPAI, -11584987, -14014413, new Item.Properties()));
|
||||
public static final RegistryObject<Item> TARGET_DEPLOYER = ITEMS.register("target_deployer", Targetdeployer::new);
|
||||
public static final RegistryObject<Item> TARGET_DEPLOYER = ITEMS.register("target_deployer", TargetDeployer::new);
|
||||
public static final RegistryObject<Item> SANDBAG = block(TargetModBlocks.SANDBAG);
|
||||
public static final RegistryObject<Item> BARBED_WIRE = block(TargetModBlocks.BARBED_WIRE);
|
||||
public static final RegistryObject<Item> CLAYMORE_MINE = ITEMS.register("claymore_mine", ClaymoreMineItem::new);
|
||||
|
|
51
src/main/java/net/mcreator/target/item/TargetDeployer.java
Normal file
51
src/main/java/net/mcreator/target/item/TargetDeployer.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package net.mcreator.target.item;
|
||||
|
||||
import net.mcreator.target.init.TargetModEntities;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TargetDeployer extends Item {
|
||||
public TargetDeployer() {
|
||||
super(new Item.Properties().stacksTo(1).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
super.useOn(context);
|
||||
|
||||
var clickedPos = context.getClickedPos();
|
||||
var player = context.getPlayer();
|
||||
if (player == null) return InteractionResult.FAIL;
|
||||
|
||||
if (context.getLevel() instanceof ServerLevel level) {
|
||||
Entity entityToSpawn = TargetModEntities.TARGET_1.get().spawn(level, BlockPos.containing(clickedPos.getX() + 0.5, clickedPos.getY() + 1, clickedPos.getZ() + 0.5), MobSpawnType.MOB_SUMMONED);
|
||||
if (entityToSpawn != null) {
|
||||
entityToSpawn.setDeltaMovement(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().clearOrCountMatchingItems(p -> TargetModItems.TARGET_DEPLOYER.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package net.mcreator.target.item;
|
||||
|
||||
import net.mcreator.target.procedures.TargetdeployerDangYouJianDianJiFangKuaiShiProcedure;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Targetdeployer extends Item {
|
||||
public Targetdeployer() {
|
||||
super(new Item.Properties().stacksTo(1).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
super.useOn(context);
|
||||
TargetdeployerDangYouJianDianJiFangKuaiShiProcedure.execute(context.getLevel(), context.getClickedPos().getX(), context.getClickedPos().getY(), context.getClickedPos().getZ(), context.getPlayer());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModEntities;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
public class TargetdeployerDangYouJianDianJiFangKuaiShiProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (world instanceof ServerLevel _level) {
|
||||
Entity entityToSpawn = TargetModEntities.TARGET_1.get().spawn(_level, BlockPos.containing(x + 0.5, y + 1, z + 0.5), MobSpawnType.MOB_SUMMONED);
|
||||
if (entityToSpawn != null) {
|
||||
entityToSpawn.setDeltaMovement(0, 0, 0);
|
||||
}
|
||||
}
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.TARGET_DEPLOYER.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue