优化代码,添加配方
This commit is contained in:
parent
cd4eb50d7d
commit
f08a4c4cde
7 changed files with 65 additions and 27 deletions
|
@ -7,10 +7,12 @@ import net.mcreator.superbwarfare.init.ModEntities;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.init.ModParticleTypes;
|
import net.mcreator.superbwarfare.init.ModParticleTypes;
|
||||||
import net.mcreator.superbwarfare.init.ModSounds;
|
import net.mcreator.superbwarfare.init.ModSounds;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
|
@ -144,21 +146,7 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult interact(Player player, InteractionHand hand) {
|
public InteractionResult interact(Player player, InteractionHand hand) {
|
||||||
ItemStack mainHandItem = player.getMainHandItem();
|
ItemStack mainHandItem = player.getMainHandItem();
|
||||||
if (player.getMainHandItem().getItem() == ModItems.FIRING_PARAMETERS.get()) {
|
|
||||||
setTarget(player.getMainHandItem());
|
|
||||||
player.swing(InteractionHand.MAIN_HAND);
|
|
||||||
}
|
|
||||||
if (player.getOffhandItem().getItem() == ModItems.FIRING_PARAMETERS.get()) {
|
|
||||||
setTarget(player.getOffhandItem());
|
|
||||||
player.swing(InteractionHand.OFF_HAND);
|
|
||||||
}
|
|
||||||
if (player.isShiftKeyDown()) {
|
|
||||||
if (mainHandItem.getItem() == ModItems.CROWBAR.get()) {
|
|
||||||
this.discard();
|
|
||||||
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MORTAR_DEPLOYER.get()));
|
|
||||||
}
|
|
||||||
this.entityData.set(Y_ROT, player.getYRot());
|
|
||||||
}
|
|
||||||
if (mainHandItem.getItem() == ModItems.MORTAR_SHELLS.get() && !player.isShiftKeyDown() && this.entityData.get(FIRE_TIME) == 0) {
|
if (mainHandItem.getItem() == ModItems.MORTAR_SHELLS.get() && !player.isShiftKeyDown() && this.entityData.get(FIRE_TIME) == 0) {
|
||||||
this.entityData.set(FIRE_TIME, 25);
|
this.entityData.set(FIRE_TIME, 25);
|
||||||
|
|
||||||
|
@ -184,10 +172,38 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.getMainHandItem().getItem() == ModItems.FIRING_PARAMETERS.get()) {
|
||||||
|
if (setTarget(player.getMainHandItem())) {
|
||||||
|
player.swing(InteractionHand.MAIN_HAND);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
} else {
|
||||||
|
player.displayClientMessage(Component.translatable("des.superbwarfare.target.warn").withStyle(ChatFormatting.RED), true);
|
||||||
|
return InteractionResult.FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (player.getOffhandItem().getItem() == ModItems.FIRING_PARAMETERS.get()) {
|
||||||
|
if (setTarget(player.getOffhandItem())) {
|
||||||
|
player.swing(InteractionHand.OFF_HAND);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
} else {
|
||||||
|
player.displayClientMessage(Component.translatable("des.superbwarfare.target.warn").withStyle(ChatFormatting.RED), true);
|
||||||
|
return InteractionResult.FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.isShiftKeyDown()) {
|
||||||
|
if (mainHandItem.getItem() == ModItems.CROWBAR.get()) {
|
||||||
|
this.discard();
|
||||||
|
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MORTAR_DEPLOYER.get()));
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
this.entityData.set(Y_ROT, player.getYRot());
|
||||||
|
}
|
||||||
|
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(ItemStack stack) {
|
public boolean setTarget(ItemStack stack) {
|
||||||
int targetX = stack.getOrCreateTag().getInt("TargetX");
|
int targetX = stack.getOrCreateTag().getInt("TargetX");
|
||||||
int targetY = stack.getOrCreateTag().getInt("TargetY");
|
int targetY = stack.getOrCreateTag().getInt("TargetY");
|
||||||
int targetZ = stack.getOrCreateTag().getInt("TargetZ");
|
int targetZ = stack.getOrCreateTag().getInt("TargetZ");
|
||||||
|
@ -201,10 +217,11 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
||||||
angles);
|
angles);
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.entityData.set(PITCH, (float)angles[1]);
|
this.entityData.set(PITCH, (float) angles[1]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
private void look(EntityAnchorArgument.Anchor pAnchor, Vec3 pTarget) {
|
private void look(EntityAnchorArgument.Anchor pAnchor, Vec3 pTarget) {
|
||||||
Vec3 vec3 = pAnchor.apply(this);
|
Vec3 vec3 = pAnchor.apply(this);
|
||||||
|
|
|
@ -110,8 +110,6 @@ public class ModItems {
|
||||||
*/
|
*/
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ModUtils.MODID);
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ModUtils.MODID);
|
||||||
|
|
||||||
public static final RegistryObject<Item> FIRING_PARAMETERS = ITEMS.register("firing_parameters", FiringParameters::new);
|
|
||||||
|
|
||||||
public static final RegistryObject<Item> SENPAI_SPAWN_EGG = ITEMS.register("senpai_spawn_egg", () -> new ForgeSpawnEggItem(ModEntities.SENPAI, -11584987, -14014413, new Item.Properties()));
|
public static final RegistryObject<Item> SENPAI_SPAWN_EGG = ITEMS.register("senpai_spawn_egg", () -> new ForgeSpawnEggItem(ModEntities.SENPAI, -11584987, -14014413, new Item.Properties()));
|
||||||
public static final RegistryObject<Item> ANCIENT_CPU = ITEMS.register("ancient_cpu", () -> new Item(new Item.Properties().rarity(Rarity.RARE)));
|
public static final RegistryObject<Item> ANCIENT_CPU = ITEMS.register("ancient_cpu", () -> new Item(new Item.Properties().rarity(Rarity.RARE)));
|
||||||
public static final RegistryObject<Item> PROPELLER = ITEMS.register("propeller", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> PROPELLER = ITEMS.register("propeller", () -> new Item(new Item.Properties()));
|
||||||
|
@ -159,6 +157,7 @@ public class ModItems {
|
||||||
public static final RegistryObject<Item> DOG_TAG = ITEMS.register("dog_tag", DogTag::new);
|
public static final RegistryObject<Item> DOG_TAG = ITEMS.register("dog_tag", DogTag::new);
|
||||||
public static final RegistryObject<Item> SHIELD_CELL = ITEMS.register("shield_cell", () -> new Item(new Item.Properties().rarity(Rarity.RARE)));
|
public static final RegistryObject<Item> SHIELD_CELL = ITEMS.register("shield_cell", () -> new Item(new Item.Properties().rarity(Rarity.RARE)));
|
||||||
public static final RegistryObject<Item> TRANSCRIPT = ITEMS.register("transcript", Transcript::new);
|
public static final RegistryObject<Item> TRANSCRIPT = ITEMS.register("transcript", Transcript::new);
|
||||||
|
public static final RegistryObject<Item> FIRING_PARAMETERS = ITEMS.register("firing_parameters", FiringParameters::new);
|
||||||
|
|
||||||
public static final RegistryObject<Item> TUNGSTEN_ROD = ITEMS.register("tungsten_rod", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> TUNGSTEN_ROD = ITEMS.register("tungsten_rod", () -> new Item(new Item.Properties()));
|
||||||
public static final RegistryObject<Item> IRON_BARREL = ITEMS.register("iron_barrel", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> IRON_BARREL = ITEMS.register("iron_barrel", () -> new Item(new Item.Properties()));
|
||||||
|
|
|
@ -50,7 +50,6 @@ public class DroneFireMessage {
|
||||||
boolean lookAtEntity = false;
|
boolean lookAtEntity = false;
|
||||||
|
|
||||||
Entity lookingEntity = TraceTool.findLookingEntity(drone, 520);
|
Entity lookingEntity = TraceTool.findLookingEntity(drone, 520);
|
||||||
|
|
||||||
Vec3 looking = Vec3.atLowerCornerOf(player.level().clip(new ClipContext(drone.getEyePosition(), drone.getEyePosition().add(drone.getLookAngle().scale(512)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos());
|
Vec3 looking = Vec3.atLowerCornerOf(player.level().clip(new ClipContext(drone.getEyePosition(), drone.getEyePosition().add(drone.getLookAngle().scale(512)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos());
|
||||||
|
|
||||||
if (lookingEntity != null) {
|
if (lookingEntity != null) {
|
||||||
|
|
|
@ -36,10 +36,7 @@ public class SetFiringParametersMessage {
|
||||||
Player player = context.getSender();
|
Player player = context.getSender();
|
||||||
|
|
||||||
ItemStack stack = player.getOffhandItem();
|
ItemStack stack = player.getOffhandItem();
|
||||||
|
|
||||||
boolean lookAtEntity = false;
|
boolean lookAtEntity = false;
|
||||||
|
|
||||||
|
|
||||||
Entity lookingEntity = TraceTool.findLookingEntity(player, 520);
|
Entity lookingEntity = TraceTool.findLookingEntity(player, 520);
|
||||||
|
|
||||||
Vec3 looking = Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(512)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos());
|
Vec3 looking = Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(512)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos());
|
||||||
|
|
|
@ -411,7 +411,9 @@
|
||||||
"des.superbwarfare.perk_speed_reduce": "Velocity -",
|
"des.superbwarfare.perk_speed_reduce": "Velocity -",
|
||||||
"des.superbwarfare.perk_speed_plus": "Velocity +",
|
"des.superbwarfare.perk_speed_plus": "Velocity +",
|
||||||
"des.superbwarfare.perk_slug": "Slug",
|
"des.superbwarfare.perk_slug": "Slug",
|
||||||
|
|
||||||
"des.superbwarfare.mortar.yaw": "Yaw:",
|
"des.superbwarfare.mortar.yaw": "Yaw:",
|
||||||
"des.superbwarfare.mortar.pitch": "Pitch:",
|
"des.superbwarfare.mortar.pitch": "Pitch:",
|
||||||
"des.superbwarfare.target.pos": "Target Position:"
|
"des.superbwarfare.target.pos": "Target Position:",
|
||||||
|
"des.superbwarfare.target.warn": "迫击炮无法瞄准该位置"
|
||||||
}
|
}
|
|
@ -148,7 +148,6 @@
|
||||||
"item.superbwarfare.ap_5_inches": "穿甲弹",
|
"item.superbwarfare.ap_5_inches": "穿甲弹",
|
||||||
"item.superbwarfare.javelin_missile": "标枪导弹",
|
"item.superbwarfare.javelin_missile": "标枪导弹",
|
||||||
|
|
||||||
|
|
||||||
"item.superbwarfare.firing_parameters": "射击诸元",
|
"item.superbwarfare.firing_parameters": "射击诸元",
|
||||||
"item.superbwarfare.ancient_cpu": "古代处理器",
|
"item.superbwarfare.ancient_cpu": "古代处理器",
|
||||||
"item.superbwarfare.target_deployer": "标靶",
|
"item.superbwarfare.target_deployer": "标靶",
|
||||||
|
@ -415,5 +414,6 @@
|
||||||
|
|
||||||
"des.superbwarfare.mortar.yaw": "水平朝向:",
|
"des.superbwarfare.mortar.yaw": "水平朝向:",
|
||||||
"des.superbwarfare.mortar.pitch": "俯仰角度:",
|
"des.superbwarfare.mortar.pitch": "俯仰角度:",
|
||||||
"des.superbwarfare.target.pos": "目标坐标:"
|
"des.superbwarfare.target.pos": "目标坐标:",
|
||||||
|
"des.superbwarfare.target.warn": "迫击炮无法瞄准该位置"
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "misc",
|
||||||
|
"pattern": [
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"a": {
|
||||||
|
"item": "minecraft:target"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"item": "minecraft:paper"
|
||||||
|
},
|
||||||
|
"c": {
|
||||||
|
"tag": "minecraft:planks"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "superbwarfare:firing_parameters",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue