造简陋配件系统轮子
This commit is contained in:
parent
e5724fa0a3
commit
8a01cc63f5
22 changed files with 319 additions and 8 deletions
|
@ -125,6 +125,8 @@ public class ModUtils {
|
||||||
addNetworkMessage(ShootMessage.class, ShootMessage::encode, ShootMessage::decode, ShootMessage::handler);
|
addNetworkMessage(ShootMessage.class, ShootMessage::encode, ShootMessage::decode, ShootMessage::handler);
|
||||||
addNetworkMessage(ShootClientMessage.class, ShootClientMessage::encode, ShootClientMessage::decode, ShootClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(ShootClientMessage.class, ShootClientMessage::encode, ShootClientMessage::decode, ShootClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
addNetworkMessage(DrawClientMessage.class, DrawClientMessage::encode, DrawClientMessage::decode, DrawClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(DrawClientMessage.class, DrawClientMessage::encode, DrawClientMessage::decode, DrawClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
|
addNetworkMessage(EditModeMessage.class, EditModeMessage::encode, EditModeMessage::new, EditModeMessage::handler);
|
||||||
|
addNetworkMessage(EditMessage.class, EditMessage::encode, EditMessage::new, EditMessage::handler);
|
||||||
|
|
||||||
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
||||||
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
||||||
|
|
|
@ -60,10 +60,29 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
|
||||||
double fp = ClientEventHandler.firePos;
|
double fp = ClientEventHandler.firePos;
|
||||||
double fr = ClientEventHandler.fireRot;
|
double fr = ClientEventHandler.fireRot;
|
||||||
|
|
||||||
|
int type = stack.getOrCreateTag().getInt("scope_type");
|
||||||
|
|
||||||
|
float posY = 0;
|
||||||
|
float scaleZ = 0;
|
||||||
|
|
||||||
gun.setPosX(1.97f * (float) zp);
|
gun.setPosX(1.97f * (float) zp);
|
||||||
gun.setPosY(0.351f * (float) zp - (float) (0.2f * zpz));
|
if (type == 0) {
|
||||||
|
posY = 0.781f;
|
||||||
|
scaleZ = 0.55f;
|
||||||
|
} else if (type == 1) {
|
||||||
|
posY = 0.351f;
|
||||||
|
scaleZ = 0.4f;
|
||||||
|
} else if (type == 2) {
|
||||||
|
posY = 0.781f;
|
||||||
|
scaleZ = 0.55f;
|
||||||
|
} else if (type == 3) {
|
||||||
|
posY = 0.781f;
|
||||||
|
scaleZ = 0.55f;
|
||||||
|
}
|
||||||
|
|
||||||
|
gun.setPosY(posY * (float) zp - (float) (0.2f * zpz));
|
||||||
gun.setPosZ(2.8f * (float) zp + (float) (0.5f * zpz));
|
gun.setPosZ(2.8f * (float) zp + (float) (0.5f * zpz));
|
||||||
gun.setScaleZ(1f - (0.4f * (float) zp));
|
gun.setScaleZ(1f - (scaleZ * (float) zp));
|
||||||
scope.setScaleZ(1f - (0.4f * (float) zp));
|
scope.setScaleZ(1f - (0.4f * (float) zp));
|
||||||
|
|
||||||
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
||||||
|
@ -76,8 +95,8 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
|
||||||
shen.setRotZ((float) ((0.08f + 0.1 * fr) * ClientEventHandler.recoilHorizon));
|
shen.setRotZ((float) ((0.08f + 0.1 * fr) * ClientEventHandler.recoilHorizon));
|
||||||
|
|
||||||
shen.setPosX((float) (shen.getPosX() * (1 - 0.5 * zt)));
|
shen.setPosX((float) (shen.getPosX() * (1 - 0.5 * zt)));
|
||||||
shen.setPosY((float) (shen.getPosY() * (-1 + 0.4 * zt)));
|
shen.setPosY((float) (shen.getPosY() * (-1 + 0.8 * zt)));
|
||||||
shen.setPosZ((float) (shen.getPosZ() * (1 - 0.6 * zt)));
|
shen.setPosZ((float) (shen.getPosZ() * (1 - 0.3 * zt)));
|
||||||
shen.setRotX((float) (shen.getRotX() * (1 - 0.9 * zt)));
|
shen.setRotX((float) (shen.getRotX() * (1 - 0.9 * zt)));
|
||||||
shen.setRotY((float) (shen.getRotY() * (1 - 0.9 * zt)));
|
shen.setRotY((float) (shen.getRotY() * (1 - 0.9 * zt)));
|
||||||
shen.setRotZ((float) (shen.getRotZ() * (1 - 0.9 * zt)));
|
shen.setRotZ((float) (shen.getRotZ() * (1 - 0.9 * zt)));
|
||||||
|
|
|
@ -101,7 +101,20 @@ public class AK12ItemRenderer extends GeoItemRenderer<AK12Item> {
|
||||||
itemStack = player.getMainHandItem();
|
itemStack = player.getMainHandItem();
|
||||||
}
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden") || GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS);
|
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|
||||||
|
|| GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS
|
||||||
|
|| itemStack.getOrCreateTag().getInt("scope_type") != 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.equals("okp")) {
|
||||||
|
Player player = Minecraft.getInstance().player;
|
||||||
|
ItemStack itemStack = null;
|
||||||
|
if (player != null) {
|
||||||
|
itemStack = player.getMainHandItem();
|
||||||
|
}
|
||||||
|
if (player != null) {
|
||||||
|
bone.setHidden(itemStack.getOrCreateTag().getInt("scope_type") != 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.mcreator.superbwarfare.config.client.DisplayConfig;
|
||||||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.init.ModTags;
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.mcreator.superbwarfare.perk.AmmoPerk;
|
import net.mcreator.superbwarfare.perk.AmmoPerk;
|
||||||
import net.mcreator.superbwarfare.perk.Perk;
|
import net.mcreator.superbwarfare.perk.Perk;
|
||||||
import net.mcreator.superbwarfare.perk.PerkHelper;
|
import net.mcreator.superbwarfare.perk.PerkHelper;
|
||||||
|
@ -49,6 +50,8 @@ public class CrossHairOverlay {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return;
|
||||||
|
|
||||||
GuiGraphics guiGraphics = event.getGuiGraphics();
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
@ -33,6 +34,8 @@ public class JavelinHudOverlay {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return;
|
||||||
|
|
||||||
if ((stack.getItem() == ModItems.JAVELIN.get() && !stack.getOrCreateTag().getBoolean("HoloHidden")) && Minecraft.getInstance().options.getCameraType().isFirstPerson() && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
|
if ((stack.getItem() == ModItems.JAVELIN.get() && !stack.getOrCreateTag().getBoolean("HoloHidden")) && Minecraft.getInstance().options.getCameraType().isFirstPerson() && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
RenderSystem.depthMask(false);
|
RenderSystem.depthMask(false);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.minecraft.client.CameraType;
|
import net.minecraft.client.CameraType;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
@ -24,6 +25,10 @@ public class M79UIOverlay {
|
||||||
int w = event.getWindow().getGuiScaledWidth();
|
int w = event.getWindow().getGuiScaledWidth();
|
||||||
int h = event.getWindow().getGuiScaledHeight();
|
int h = event.getWindow().getGuiScaledHeight();
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
|
if (player != null && player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit)
|
||||||
|
return;
|
||||||
|
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
RenderSystem.depthMask(false);
|
RenderSystem.depthMask(false);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
|
|
|
@ -215,6 +215,7 @@ public class ClientEventHandler {
|
||||||
&& cantFireTime == 0
|
&& cantFireTime == 0
|
||||||
&& drawTime < 0.01
|
&& drawTime < 0.01
|
||||||
&& !notInGame()
|
&& !notInGame()
|
||||||
|
&& !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit
|
||||||
|| (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getDouble("minigun_rotation") >= 10
|
|| (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getDouble("minigun_rotation") >= 10
|
||||||
))) {
|
))) {
|
||||||
double customRpm = 0;
|
double customRpm = 0;
|
||||||
|
@ -490,7 +491,10 @@ public class ClientEventHandler {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
float times = 5 * Minecraft.getInstance().getDeltaFrameTime();
|
float times = 5 * Minecraft.getInstance().getDeltaFrameTime();
|
||||||
double speed = stack.getOrCreateTag().getDouble("zoom_speed");
|
double speed = stack.getOrCreateTag().getDouble("zoom_speed");
|
||||||
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS && !notInGame() && drawTime < 0.01) {
|
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS
|
||||||
|
&& !notInGame()
|
||||||
|
&& drawTime < 0.01
|
||||||
|
&& !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) {
|
||||||
if (Minecraft.getInstance().player != null) {
|
if (Minecraft.getInstance().player != null) {
|
||||||
Minecraft.getInstance().player.getPersistentData().putDouble("noRun", 5);
|
Minecraft.getInstance().player.getPersistentData().putDouble("noRun", 5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,11 @@ public class LivingEventHandler {
|
||||||
oldTags.putInt("sentinel_charge_time", 0);
|
oldTags.putInt("sentinel_charge_time", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
capability.edit = false;
|
||||||
|
capability.syncPlayerVariables(player);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.getItem() instanceof GunItem) {
|
if (newStack.getItem() instanceof GunItem) {
|
||||||
|
|
|
@ -103,6 +103,76 @@ public class ModKeyMappings {
|
||||||
public static final KeyMapping CONFIG = new KeyMapping("key.superbwarfare.config", KeyConflictContext.IN_GAME,
|
public static final KeyMapping CONFIG = new KeyMapping("key.superbwarfare.config", KeyConflictContext.IN_GAME,
|
||||||
KeyModifier.ALT, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "key.categories.superbwarfare");
|
KeyModifier.ALT, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "key.categories.superbwarfare");
|
||||||
|
|
||||||
|
public static final KeyMapping EDIT_MODE = new KeyMapping("key.superbwarfare.edit_mode", GLFW.GLFW_KEY_H, "key.categories.superbwarfare") {
|
||||||
|
private boolean isDownOld = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDown(boolean isDown) {
|
||||||
|
super.setDown(isDown);
|
||||||
|
if (isDownOld != isDown && isDown) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new EditModeMessage(0));
|
||||||
|
EditModeMessage.pressAction(Minecraft.getInstance().player, 0);
|
||||||
|
}
|
||||||
|
isDownOld = isDown;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final KeyMapping EDIT_SCOPE = new KeyMapping("key.superbwarfare.edit_scope", GLFW.GLFW_KEY_UP, "key.categories.superbwarfare") {
|
||||||
|
private boolean isDownOld = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDown(boolean isDown) {
|
||||||
|
super.setDown(isDown);
|
||||||
|
if (isDownOld != isDown && isDown) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new EditMessage(0));
|
||||||
|
EditMessage.pressAction(Minecraft.getInstance().player, 0);
|
||||||
|
}
|
||||||
|
isDownOld = isDown;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final KeyMapping EDIT_BARREL = new KeyMapping("key.superbwarfare.edit_barrel", GLFW.GLFW_KEY_LEFT, "key.categories.superbwarfare") {
|
||||||
|
private boolean isDownOld = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDown(boolean isDown) {
|
||||||
|
super.setDown(isDown);
|
||||||
|
if (isDownOld != isDown && isDown) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new EditMessage(1));
|
||||||
|
EditMessage.pressAction(Minecraft.getInstance().player, 1);
|
||||||
|
}
|
||||||
|
isDownOld = isDown;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final KeyMapping EDIT_MAGAZINE = new KeyMapping("key.superbwarfare.edit_magazine", GLFW.GLFW_KEY_DOWN, "key.categories.superbwarfare") {
|
||||||
|
private boolean isDownOld = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDown(boolean isDown) {
|
||||||
|
super.setDown(isDown);
|
||||||
|
if (isDownOld != isDown && isDown) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new EditMessage(2));
|
||||||
|
EditMessage.pressAction(Minecraft.getInstance().player, 2);
|
||||||
|
}
|
||||||
|
isDownOld = isDown;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final KeyMapping EDIT_STOCK = new KeyMapping("key.superbwarfare.edit_stock", GLFW.GLFW_KEY_RIGHT, "key.categories.superbwarfare") {
|
||||||
|
private boolean isDownOld = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDown(boolean isDown) {
|
||||||
|
super.setDown(isDown);
|
||||||
|
if (isDownOld != isDown && isDown) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new EditMessage(3));
|
||||||
|
EditMessage.pressAction(Minecraft.getInstance().player, 3);
|
||||||
|
}
|
||||||
|
isDownOld = isDown;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
|
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
|
||||||
event.register(RELOAD);
|
event.register(RELOAD);
|
||||||
|
@ -112,6 +182,11 @@ public class ModKeyMappings {
|
||||||
event.register(INTERACT);
|
event.register(INTERACT);
|
||||||
event.register(BREATH);
|
event.register(BREATH);
|
||||||
event.register(CONFIG);
|
event.register(CONFIG);
|
||||||
|
event.register(EDIT_MODE);
|
||||||
|
event.register(EDIT_SCOPE);
|
||||||
|
event.register(EDIT_BARREL);
|
||||||
|
event.register(EDIT_MAGAZINE);
|
||||||
|
event.register(EDIT_STOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
|
|
|
@ -48,6 +48,13 @@ public abstract class GunItem extends Item {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (entity instanceof Player player) {
|
||||||
|
// player.displayClientMessage(Component.literal(new java.text.DecimalFormat("##.##").format(itemstack.getOrCreateTag().getInt("scope_type"))
|
||||||
|
// + " " + new java.text.DecimalFormat("##.#").format(itemstack.getOrCreateTag().getInt("barrel_type"))
|
||||||
|
// + " " + new java.text.DecimalFormat("##.#").format(itemstack.getOrCreateTag().getInt("magazine_type"))
|
||||||
|
// + " " + new java.text.DecimalFormat("##.#").format(itemstack.getOrCreateTag().getInt("stock_type"))), true);
|
||||||
|
// }
|
||||||
|
|
||||||
if (!ItemNBTTool.getBoolean(itemstack, "init", false)) {
|
if (!ItemNBTTool.getBoolean(itemstack, "init", false)) {
|
||||||
GunsTool.initGun(level, itemstack, this.getDescriptionId().substring(this.getDescriptionId().lastIndexOf('.') + 1));
|
GunsTool.initGun(level, itemstack, this.getDescriptionId().substring(this.getDescriptionId().lastIndexOf('.') + 1));
|
||||||
GunsTool.genUUID(itemstack);
|
GunsTool.genUUID(itemstack);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
|
||||||
import net.mcreator.superbwarfare.init.ModTags;
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
import net.mcreator.superbwarfare.item.AnimatedItem;
|
import net.mcreator.superbwarfare.item.AnimatedItem;
|
||||||
import net.mcreator.superbwarfare.item.gun.GunItem;
|
import net.mcreator.superbwarfare.item.gun.GunItem;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.mcreator.superbwarfare.perk.Perk;
|
import net.mcreator.superbwarfare.perk.Perk;
|
||||||
import net.mcreator.superbwarfare.perk.PerkHelper;
|
import net.mcreator.superbwarfare.perk.PerkHelper;
|
||||||
import net.mcreator.superbwarfare.tools.GunsTool;
|
import net.mcreator.superbwarfare.tools.GunsTool;
|
||||||
|
@ -85,6 +86,10 @@ public class AK12Item extends GunItem implements GeoItem, AnimatedItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
|
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
|
||||||
|
|
||||||
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) {
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.edit"));
|
||||||
|
}
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")) {
|
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.reload_empty"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.reload_empty"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class ModVariables {
|
||||||
clone.breath = original.breath;
|
clone.breath = original.breath;
|
||||||
clone.breathTime = original.breathTime;
|
clone.breathTime = original.breathTime;
|
||||||
clone.breathExhaustion = original.breathExhaustion;
|
clone.breathExhaustion = original.breathExhaustion;
|
||||||
|
clone.edit = original.edit;
|
||||||
|
|
||||||
if (event.getEntity().level().isClientSide()) return;
|
if (event.getEntity().level().isClientSide()) return;
|
||||||
|
|
||||||
|
@ -222,6 +223,7 @@ public class ModVariables {
|
||||||
public boolean breath = false;
|
public boolean breath = false;
|
||||||
public int breathTime = 160;
|
public int breathTime = 160;
|
||||||
public boolean breathExhaustion = false;
|
public boolean breathExhaustion = false;
|
||||||
|
public boolean edit = false;
|
||||||
|
|
||||||
public void syncPlayerVariables(Entity entity) {
|
public void syncPlayerVariables(Entity entity) {
|
||||||
if (entity instanceof ServerPlayer)
|
if (entity instanceof ServerPlayer)
|
||||||
|
@ -245,6 +247,7 @@ public class ModVariables {
|
||||||
nbt.putBoolean("breath", breath);
|
nbt.putBoolean("breath", breath);
|
||||||
nbt.putInt("breathTime", breathTime);
|
nbt.putInt("breathTime", breathTime);
|
||||||
nbt.putBoolean("breathExhaustion", breathExhaustion);
|
nbt.putBoolean("breathExhaustion", breathExhaustion);
|
||||||
|
nbt.putBoolean("edit", edit);
|
||||||
|
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
@ -266,6 +269,7 @@ public class ModVariables {
|
||||||
breath = nbt.getBoolean("breath");
|
breath = nbt.getBoolean("breath");
|
||||||
breathTime = nbt.getInt("breathTime");
|
breathTime = nbt.getInt("breathTime");
|
||||||
breathExhaustion = nbt.getBoolean("breathExhaustion");
|
breathExhaustion = nbt.getBoolean("breathExhaustion");
|
||||||
|
edit = nbt.getBoolean("edit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +322,7 @@ public class ModVariables {
|
||||||
variables.breath = message.data.breath;
|
variables.breath = message.data.breath;
|
||||||
variables.breathTime = message.data.breathTime;
|
variables.breathTime = message.data.breathTime;
|
||||||
variables.breathExhaustion = message.data.breathExhaustion;
|
variables.breathExhaustion = message.data.breathExhaustion;
|
||||||
|
variables.edit = message.data.edit;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package net.mcreator.superbwarfare.network.message;
|
||||||
|
|
||||||
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class EditMessage {
|
||||||
|
private final int type;
|
||||||
|
|
||||||
|
public EditMessage(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditMessage(FriendlyByteBuf buffer) {
|
||||||
|
this.type = buffer.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(net.mcreator.superbwarfare.network.message.EditMessage message, FriendlyByteBuf buffer) {
|
||||||
|
buffer.writeInt(message.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handler(net.mcreator.superbwarfare.network.message.EditMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||||
|
NetworkEvent.Context context = contextSupplier.get();
|
||||||
|
context.enqueueWork(() -> pressAction(context.getSender(), message.type));
|
||||||
|
context.setPacketHandled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pressAction(Player player, int type) {
|
||||||
|
if (player == null) return;
|
||||||
|
if (!player.level().isLoaded(player.blockPosition()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
if (stack.is(ModTags.Items.GUN) && player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
stack.getOrCreateTag().putInt("scope_type", stack.getOrCreateTag().getInt("scope_type") + 1);
|
||||||
|
if (stack.getOrCreateTag().getInt("scope_type") == 4) {
|
||||||
|
stack.getOrCreateTag().putInt("scope_type", 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
stack.getOrCreateTag().putInt("barrel_type", stack.getOrCreateTag().getInt("barrel_type") + 1);
|
||||||
|
if (stack.getOrCreateTag().getInt("barrel_type") == 3) {
|
||||||
|
stack.getOrCreateTag().putInt("barrel_type", 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
stack.getOrCreateTag().putInt("magazine_type", stack.getOrCreateTag().getInt("magazine_type") + 1);
|
||||||
|
if (stack.getOrCreateTag().getInt("magazine_type") == 3) {
|
||||||
|
stack.getOrCreateTag().putInt("magazine_type", 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
stack.getOrCreateTag().putInt("stock_type", stack.getOrCreateTag().getInt("stock_type") + 1);
|
||||||
|
if (stack.getOrCreateTag().getInt("stock_type") == 3) {
|
||||||
|
stack.getOrCreateTag().putInt("stock_type", 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package net.mcreator.superbwarfare.network.message;
|
||||||
|
|
||||||
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class EditModeMessage {
|
||||||
|
private final int type;
|
||||||
|
|
||||||
|
public EditModeMessage(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditModeMessage(FriendlyByteBuf buffer) {
|
||||||
|
this.type = buffer.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(EditModeMessage message, FriendlyByteBuf buffer) {
|
||||||
|
buffer.writeInt(message.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handler(EditModeMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||||
|
NetworkEvent.Context context = contextSupplier.get();
|
||||||
|
context.enqueueWork(() -> pressAction(context.getSender(), message.type));
|
||||||
|
context.setPacketHandled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pressAction(Player player, int type) {
|
||||||
|
if (player == null) return;
|
||||||
|
// security measure to prevent arbitrary chunk generation
|
||||||
|
if (!player.level().isLoaded(player.blockPosition()))
|
||||||
|
return;
|
||||||
|
if (type == 0) {
|
||||||
|
EditMode(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EditMode(Player player) {
|
||||||
|
ItemStack mainHandItem = player.getMainHandItem();
|
||||||
|
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||||
|
|
||||||
|
if (mainHandItem.is(ModTags.Items.GUN)) {
|
||||||
|
cap.ifPresent(capability -> {
|
||||||
|
capability.edit = !cap.orElse(new ModVariables.PlayerVariables()).edit;
|
||||||
|
capability.syncPlayerVariables(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,6 +73,7 @@ public class FireMessage {
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
handlePlayerShoot(player);
|
handlePlayerShoot(player);
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
capability.edit = false;
|
||||||
capability.holdFire = true;
|
capability.holdFire = true;
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,6 +45,11 @@ public class ReloadMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
capability.edit = false;
|
||||||
|
capability.syncPlayerVariables(player);
|
||||||
|
});
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
var capability = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
|
var capability = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,11 @@ public class ZoomMessage {
|
||||||
if (message.type == 0) {
|
if (message.type == 0) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.zoom = true;
|
capability.zoom = true;
|
||||||
|
capability.edit = false;
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
|
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
|
||||||
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,28 @@
|
||||||
"animation.ak12.idle": {
|
"animation.ak12.idle": {
|
||||||
"animation_length": 1
|
"animation_length": 1
|
||||||
},
|
},
|
||||||
|
"animation.ak12.edit": {
|
||||||
|
"loop": "hold_on_last_frame",
|
||||||
|
"animation_length": 0.1,
|
||||||
|
"bones": {
|
||||||
|
"0": {
|
||||||
|
"rotation": {
|
||||||
|
"vector": [-22.5, -22.5, -22.5]
|
||||||
|
},
|
||||||
|
"position": {
|
||||||
|
"vector": [0.5, 2.5, -4.75]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Lefthand": {
|
||||||
|
"rotation": {
|
||||||
|
"vector": [-20.80188, -23.88158, -14.35972]
|
||||||
|
},
|
||||||
|
"position": {
|
||||||
|
"vector": [-4, -10, 20]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"animation.ak12.run": {
|
"animation.ak12.run": {
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"animation_length": 0.8,
|
"animation_length": 0.8,
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
"texture_width": 128,
|
"texture_width": 128,
|
||||||
"texture_height": 128,
|
"texture_height": 128,
|
||||||
"visible_bounds_width": 29,
|
"visible_bounds_width": 29,
|
||||||
"visible_bounds_height": 6,
|
"visible_bounds_height": 9,
|
||||||
"visible_bounds_offset": [0, 0, 0]
|
"visible_bounds_offset": [0, 1.5, 0]
|
||||||
},
|
},
|
||||||
"bones": [
|
"bones": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -332,6 +332,11 @@
|
||||||
"key.superbwarfare.interact": "Interact",
|
"key.superbwarfare.interact": "Interact",
|
||||||
"key.superbwarfare.breath": "Breathe",
|
"key.superbwarfare.breath": "Breathe",
|
||||||
"key.superbwarfare.config": "Open Config Screen",
|
"key.superbwarfare.config": "Open Config Screen",
|
||||||
|
"key.superbwarfare.edit_mode": "Edit Weapon",
|
||||||
|
"key.superbwarfare.edit_scope": "Switch Scope",
|
||||||
|
"key.superbwarfare.edit_barrel": "Switch Barrel",
|
||||||
|
"key.superbwarfare.edit_magazine": "Switch Magazine",
|
||||||
|
"key.superbwarfare.edit_stock": "Switch Stock",
|
||||||
|
|
||||||
"effect.superbwarfare.shock": "Shock",
|
"effect.superbwarfare.shock": "Shock",
|
||||||
"item.minecraft.potion.effect.superbwarfare_shock": "Potion of Shock",
|
"item.minecraft.potion.effect.superbwarfare_shock": "Potion of Shock",
|
||||||
|
|
|
@ -332,6 +332,11 @@
|
||||||
"key.superbwarfare.interact": "交互",
|
"key.superbwarfare.interact": "交互",
|
||||||
"key.superbwarfare.breath": "屏息",
|
"key.superbwarfare.breath": "屏息",
|
||||||
"key.superbwarfare.config": "打开配置界面",
|
"key.superbwarfare.config": "打开配置界面",
|
||||||
|
"key.superbwarfare.edit_mode": "改装",
|
||||||
|
"key.superbwarfare.edit_scope": "切换瞄准镜",
|
||||||
|
"key.superbwarfare.edit_barrel": "切换枪管配件",
|
||||||
|
"key.superbwarfare.edit_magazine": "切换弹匣",
|
||||||
|
"key.superbwarfare.edit_stock": "切换枪托",
|
||||||
|
|
||||||
"effect.superbwarfare.shock": "电击",
|
"effect.superbwarfare.shock": "电击",
|
||||||
"item.minecraft.potion.effect.superbwarfare_shock": "电击药水",
|
"item.minecraft.potion.effect.superbwarfare_shock": "电击药水",
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Loading…
Add table
Reference in a new issue