Getting for first maintenance release for 1.7.10
This commit is contained in:
parent
afcaffc9b9
commit
bd3a04505d
14
build.gradle
14
build.gradle
|
@ -44,7 +44,7 @@ def travisbuildnumber = (System.getenv("TRAVIS_BUILD_NUMBER") ?: -111).toInteger
|
|||
version = "${config.mod_version}." + (buildnumber ?: travisbuildnumber)
|
||||
group= "${config.group_id}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "${config.mod_id}"
|
||||
def numina_version = (System.getenv("NUMINA_VERSION") ?:"0.4.0.131")
|
||||
def numina_version = (System.getenv("NUMINA_VERSION") ?:"0.4.1.100")
|
||||
|
||||
minecraft {
|
||||
version = "${config.minecraft_version}-${config.forge_version}"
|
||||
|
@ -63,9 +63,6 @@ def getLibrary(filename) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
compile 'codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev'
|
||||
compile 'codechicken:NotEnoughItems:1.7.10-1.0.5.120:dev'
|
||||
|
@ -90,15 +87,6 @@ dependencies {
|
|||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//getLibrary("CoFHCore-[1.7.10]3.0.3-303-dev.jar")
|
||||
////getLibrary("industrialcraft-2-2.2.765-experimental-api.jar")
|
||||
//getLibrary("ThermalExpansion-[1.7.10]4.0.3B1-218-dev.jar")
|
||||
|
|
91
src/main/java/net/machinemuse/api/omniwrench/OmniWrench.txt
Normal file
91
src/main/java/net/machinemuse/api/omniwrench/OmniWrench.txt
Normal file
|
@ -0,0 +1,91 @@
|
|||
//package net.machinemuse.api
|
||||
//
|
||||
//import buildcraft.api.tools.IToolWrench
|
||||
//import cofh.api.item.IToolHammer
|
||||
//import cpw.mods.fml.common.FMLCommonHandler
|
||||
//import mods.railcraft.api.core.items.IToolCrowbar
|
||||
//import net.machinemuse.api.electricity.IModularItem
|
||||
//import net.machinemuse.powersuits.powermodule.tool.{MFFSFieldTeleporterModule, OmniWrenchModule}
|
||||
//import net.machinemuse.utils.ElectricItemUtils
|
||||
//import net.minecraft.entity.item.EntityMinecart
|
||||
//import net.minecraft.entity.player.EntityPlayer
|
||||
//import net.minecraft.item.ItemStack
|
||||
//import net.minecraft.util.ChatComponentText
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 5:06 PM, 29/04/13
|
||||
// */
|
||||
//trait OmniWrench
|
||||
// extends IModularWrench
|
||||
// with IModularCrowbar
|
||||
// with ModularHammer
|
||||
// with ForceFieldManipulator {
|
||||
//
|
||||
//}
|
||||
//
|
||||
//trait IModularCrowbar extends IToolCrowbar {
|
||||
// def canWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int): Boolean = {
|
||||
// return ModuleManager.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
// }
|
||||
//
|
||||
// def onWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int) {
|
||||
// player.swingItem
|
||||
// }
|
||||
//
|
||||
// def canLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
|
||||
// return ModuleManager.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
// }
|
||||
//
|
||||
// def onLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
|
||||
// player.swingItem
|
||||
// }
|
||||
//
|
||||
// def canBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
|
||||
// return ModuleManager.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
// }
|
||||
//
|
||||
// def onBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
|
||||
// player.swingItem
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// Buildcraft wrench
|
||||
//trait IModularWrench
|
||||
// extends IToolWrench {
|
||||
//
|
||||
// def canWrench(player: EntityPlayer, x: Int, y: Int, z: Int): Boolean = {
|
||||
// if (player.getCurrentEquippedItem != null && player.getCurrentEquippedItem.getItem.isInstanceOf[IModularItem]) {
|
||||
// return ModuleManager.itemHasActiveModule(player.getCurrentEquippedItem, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// def wrenchUsed(player: EntityPlayer, x: Int, y: Int, z: Int) {
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// MFR wrench
|
||||
//trait ModularHammer extends IToolHammer {
|
||||
// def isActive(stack: ItemStack): Boolean = ModuleManager.itemHasActiveModule(stack, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
//}
|
||||
//
|
||||
//trait ForceFieldManipulator extends IFieldTeleporter {
|
||||
// def canFieldTeleport(player: EntityPlayer, stack: ItemStack, teleportCost: Int): Boolean = {
|
||||
// if (ModuleManager.itemHasModule(stack, MFFSFieldTeleporterModule.MODULE_FIELD_TELEPORTER)) {
|
||||
// if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION)) {
|
||||
// return true
|
||||
// }
|
||||
// else if (FMLCommonHandler.instance.getEffectiveSide.isServer)
|
||||
// player.addChatComponentMessage(new ChatComponentText("[Field Security] Could not teleport through forcefield. 20,000J is required to teleport."))
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// def onFieldTeleportSuccess(player: EntityPlayer, stack: ItemStack, teleportCost: Int) {
|
||||
// ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION))
|
||||
// }
|
||||
//
|
||||
// def onFieldTeleportFailed(player: EntityPlayer, stack: ItemStack, teleportCost: Int) {
|
||||
// }
|
||||
//}
|
415
src/main/java/net/machinemuse/powersuits/common/Config.java
Normal file
415
src/main/java/net/machinemuse/powersuits/common/Config.java
Normal file
|
@ -0,0 +1,415 @@
|
|||
package net.machinemuse.powersuits.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.api.electricity.IModularItem;
|
||||
import net.machinemuse.numina.basemod.Numina;
|
||||
import net.machinemuse.numina.general.MuseLogger;
|
||||
import net.machinemuse.powersuits.common.proxy.CommonProxy;
|
||||
import net.machinemuse.powersuits.powermodule.armor.*;
|
||||
import net.machinemuse.powersuits.powermodule.energy.*;
|
||||
import net.machinemuse.powersuits.powermodule.misc.*;
|
||||
import net.machinemuse.powersuits.powermodule.movement.*;
|
||||
import net.machinemuse.powersuits.powermodule.tool.*;
|
||||
import net.machinemuse.powersuits.powermodule.weapon.*;
|
||||
import net.machinemuse.utils.MuseStringUtils;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.CopyOption;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Initial attempt at storing all tweakable/configurable values in one class.
|
||||
* This got really messy really fast so it's in the process of being
|
||||
* reworked.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class Config {
|
||||
public static final String RESOURCE_PREFIX = "powersuits:";
|
||||
public static final String TEXTURE_PREFIX = "powersuits:textures/";
|
||||
public static final String SOUND_PREFIX = RESOURCE_PREFIX + "sound/";
|
||||
public static final String LANG_PREFIX = RESOURCE_PREFIX + "lang/";
|
||||
public static final String SEBK_ARMOR_PATH = TEXTURE_PREFIX + "models/sebkarmor.png";
|
||||
public static final String SEBK_ARMORPANTS_PATH = TEXTURE_PREFIX + "models/sebkarmorpants.png";
|
||||
public static final String TINKERTABLE_TEXTURE_PATH = TEXTURE_PREFIX + "models/tinkertable_tx.png";
|
||||
public static final String ARMOR_TEXTURE_PATH = TEXTURE_PREFIX + "models/diffuse.png";
|
||||
public static final String BLANK_ARMOR_MODEL_PATH = TEXTURE_PREFIX + "models/blankarmor.png";
|
||||
public static final String SEBK_TOOL_TEXTURE = TEXTURE_PREFIX + "models/tool.png";
|
||||
public static final String LIGHTNING_TEXTURE = TEXTURE_PREFIX + "gui/lightning-medium.png";
|
||||
public static final String CITIZENJOE_ARMOR_PATH = TEXTURE_PREFIX + "models/joearmor.png";
|
||||
public static final String CITIZENJOE_ARMORPANTS_PATH = TEXTURE_PREFIX + "models/joearmorpants.png";
|
||||
public static final String GLASS_TEXTURE = TEXTURE_PREFIX + "gui/glass.png";
|
||||
static File configFolder = null;
|
||||
private static Configuration config = null;
|
||||
public static boolean canUseShaders = false;
|
||||
|
||||
public static boolean keybindHUDon() {
|
||||
return config.get("HUD", "Display HUD", true).getBoolean();
|
||||
}
|
||||
|
||||
public static double keybindHUDx() {
|
||||
return config.get("HUD", "x position", 8.0).getDouble();
|
||||
}
|
||||
|
||||
public static double keybindHUDy() {
|
||||
return config.get("HUD", "y position", 32.0).getDouble();
|
||||
}
|
||||
|
||||
public static boolean toggleModuleSpam() {
|
||||
return config.get("HUD", "Chat message when toggling modules", false).getBoolean();
|
||||
}
|
||||
|
||||
public static double getWeightCapacity() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Weight Limit (grams)", 25000.0).getDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in post-init. Extracts recipes if the configuration value is not found.
|
||||
*/
|
||||
public static void extractRecipes() {
|
||||
String key = "Auto-extract recipes";
|
||||
if (!config.hasKey(Configuration.CATEGORY_GENERAL, key) || config.get(Configuration.CATEGORY_GENERAL, key, false).getBoolean()) {
|
||||
config.get(Configuration.CATEGORY_GENERAL, key, false);
|
||||
boolean found=false;
|
||||
// Thermal Expansion
|
||||
if(ModCompatibility.isThermalExpansionLoaded()) {
|
||||
found=true;
|
||||
copyRecipe("mps-thermalexpansion.recipes");
|
||||
}
|
||||
// Industrialcraft 2
|
||||
if (ModCompatibility.isIndustrialCraftLoaded()) {
|
||||
found=true;
|
||||
copyRecipe("mps-ic2.recipes");
|
||||
}
|
||||
// EnderIO
|
||||
if (ModCompatibility.isEnderIOLoaded()) {
|
||||
found=true;
|
||||
copyRecipe("mps-enderio.recipes");
|
||||
}
|
||||
// Vanilla
|
||||
if(!found) {
|
||||
copyRecipe("mps-vanilla.recipes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyRecipe(String inFile) {
|
||||
InputStream src = CommonProxy.class.getClassLoader().getResourceAsStream(inFile);
|
||||
File dest = new File(Numina.configDir.toString() + "/machinemuse/recipes/" + inFile);
|
||||
if(!dest.exists()) {
|
||||
try {
|
||||
Files.copy(src, dest.toPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in the pre-init phase of initialization, informs Forge that we
|
||||
* want the following blockIDs.
|
||||
*
|
||||
* @param configuration The Forge configuration object which will handle such
|
||||
* requests.
|
||||
*/
|
||||
public static void init(Configuration configuration) {
|
||||
config = configuration;
|
||||
config.load();
|
||||
config.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* The packet channel for this mod. We will only listen for and send packets
|
||||
* on this 'channel'. Max of 16 characters.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getNetworkChannelName() {
|
||||
return "powerSuits";
|
||||
}
|
||||
|
||||
/**
|
||||
* The default creative tab to add all these items to. This behaviour may
|
||||
* change if more items are added, but for now there are only 5 items and 1
|
||||
* block, so misc is the most appropriate target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static CreativeTabs getCreativeTab() {
|
||||
return new MPSCreativeTab();
|
||||
}
|
||||
|
||||
/**
|
||||
* Chance of each item being returned when salvaged.
|
||||
*
|
||||
* @return percent chance, 0.0 to 1.0
|
||||
*/
|
||||
public static double getSalvageChance() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Salvage Ratio", 0.9).getDouble(0.9);
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum amount of armor contribution allowed per armor piece. Total
|
||||
* armor when the full set is worn can never exceed 4 times this amount.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static double getMaximumArmorPerPiece() {
|
||||
return Math.max(0.0, config.get(Configuration.CATEGORY_GENERAL, "Maximum Armor per Piece", 6.0).getDouble(6.0));
|
||||
}
|
||||
|
||||
public static double getMaximumFlyingSpeedmps() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Maximum flight speed (in m/s)", 25.0).getDouble(25.0);
|
||||
}
|
||||
|
||||
public static boolean useMouseWheel() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use Mousewheel to change modes", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static void addModule(IPowerModule module) {
|
||||
ModuleManager.addModule(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* The power drain for the Applied Energistics2 and ExtraCells2 wireless terminals
|
||||
*/
|
||||
public static double appengMultiplier() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Energy per AE", 5.0).getDouble(5.0);
|
||||
}
|
||||
|
||||
public static boolean useAdvancedOreScannerMessage() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use Detailed Ore Scanner Message", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static boolean useOldAutoFeeder() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use Old Auto Feeder Method", false).getBoolean(false);
|
||||
}
|
||||
|
||||
public static boolean useCheatyLeatherRecipe() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use Cheaty Leather Recipe (Requires Thermal Expansion)", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static boolean useHUDStuff() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use HUD for certain modules (Auto Feeder, Compass, Clock, etc.", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static boolean use24hClock() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use a 24h clock instead of 12h", false).getBoolean(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the modules in the config file into memory. Eventually. For now,
|
||||
* they are hardcoded.
|
||||
*/
|
||||
public static void loadPowerModules() {
|
||||
List<IModularItem> ARMORONLY = Arrays.asList(
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorHead,
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorTorso,
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorLegs,
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorFeet);
|
||||
|
||||
List<IModularItem> ALLITEMS = Arrays.asList(
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorHead,
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorTorso,
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorLegs,
|
||||
(IModularItem)MPSItems.INSTANCE.powerArmorFeet,
|
||||
(IModularItem)MPSItems.INSTANCE.powerTool);
|
||||
|
||||
List<IModularItem> HEADONLY = Collections.singletonList((IModularItem)MPSItems.INSTANCE.powerArmorHead);
|
||||
List<IModularItem> TORSOONLY = Collections.singletonList((IModularItem)MPSItems.INSTANCE.powerArmorTorso);
|
||||
List<IModularItem> LEGSONLY = Collections.singletonList((IModularItem)MPSItems.INSTANCE.powerArmorLegs);
|
||||
List<IModularItem> FEETONLY = Collections.singletonList((IModularItem)MPSItems.INSTANCE.powerArmorFeet);
|
||||
List<IModularItem> TOOLONLY = Collections.singletonList((IModularItem)MPSItems.INSTANCE.powerTool);
|
||||
|
||||
addModule(new BasicPlatingModule(ARMORONLY));
|
||||
addModule(new DiamondPlatingModule(ARMORONLY));
|
||||
addModule(new EnergyShieldModule(ARMORONLY));
|
||||
addModule(new HeatSinkModule(ARMORONLY));
|
||||
addModule(new AxeModule(TOOLONLY));
|
||||
addModule(new PickaxeModule(TOOLONLY));
|
||||
addModule(new ShovelModule(TOOLONLY));
|
||||
addModule(new ShearsModule(TOOLONLY));
|
||||
addModule(new HoeModule(TOOLONLY));
|
||||
addModule(new LuxCapacitor(TOOLONLY));
|
||||
// addModule(new OmniWrenchModule(TOOLONLY)) // Requires COFH lib/core
|
||||
addModule(new FieldTinkerModule(TOOLONLY));
|
||||
addModule(new MeleeAssistModule(TOOLONLY));
|
||||
addModule(new PlasmaCannonModule(TOOLONLY));
|
||||
addModule(new RailgunModule(TOOLONLY));
|
||||
addModule(new BladeLauncherModule(TOOLONLY));
|
||||
addModule(new BasicBatteryModule(ALLITEMS));
|
||||
addModule(new AdvancedBatteryModule(ALLITEMS));
|
||||
addModule(new EliteBatteryModule(ALLITEMS));
|
||||
addModule(new ParachuteModule(TORSOONLY));
|
||||
addModule(new GliderModule(TORSOONLY));
|
||||
addModule(new JetPackModule(TORSOONLY));
|
||||
addModule(new SprintAssistModule(LEGSONLY));
|
||||
addModule(new JumpAssistModule(LEGSONLY));
|
||||
addModule(new SwimAssistModule(LEGSONLY));
|
||||
addModule(new ClimbAssistModule(LEGSONLY));
|
||||
addModule(new JetBootsModule(FEETONLY));
|
||||
addModule(new ShockAbsorberModule(FEETONLY));
|
||||
addModule(new WaterElectrolyzerModule(HEADONLY));
|
||||
addModule(new NightVisionModule(HEADONLY));
|
||||
addModule(new BinocularsModule(HEADONLY));
|
||||
addModule(new FlightControlModule(HEADONLY));
|
||||
addModule(new InvisibilityModule(TORSOONLY));
|
||||
addModule(new BlinkDriveModule(TOOLONLY));
|
||||
addModule(new DiamondPickUpgradeModule(TOOLONLY));
|
||||
addModule(new AquaAffinityModule(TOOLONLY));
|
||||
addModule(new CoolingSystemModule(TORSOONLY));
|
||||
addModule(new TintModule(TOOLONLY));
|
||||
addModule(new TransparentArmorModule(ARMORONLY));
|
||||
addModule(new CosmeticGlowModule(ARMORONLY));
|
||||
addModule(new InPlaceAssemblerModule(TOOLONLY));
|
||||
addModule(new KineticGeneratorModule(LEGSONLY));
|
||||
addModule(new SolarGeneratorModule(HEADONLY));
|
||||
addModule(new AutoFeederModule(HEADONLY));
|
||||
addModule(new MagnetModule(TORSOONLY));
|
||||
addModule(new OreScannerModule(TOOLONLY));
|
||||
addModule(new LeafBlowerModule(TOOLONLY));
|
||||
addModule(new ThermalGeneratorModule(TORSOONLY));
|
||||
addModule(new MobRepulsorModule(TORSOONLY));
|
||||
addModule(new FlintAndSteelModule(TOOLONLY));
|
||||
addModule(new ClockModule(HEADONLY));
|
||||
addModule(new CompassModule(HEADONLY));
|
||||
addModule(new LightningModule(TOOLONLY));
|
||||
addModule(new WaterTankModule(TORSOONLY));
|
||||
addModule(new DimensionalRiftModule(TOOLONLY));
|
||||
addModule(new AdvancedSolarGenerator(HEADONLY));
|
||||
addModule(new NitrogenCoolingSystem(TORSOONLY));
|
||||
addModule(new MechanicalAssistance(TORSOONLY));
|
||||
// //addModule(new CoalGenerator(TORSOONLY)); //doesn't seem to be working
|
||||
}
|
||||
|
||||
public static Configuration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static boolean doAdditionalInfo() {
|
||||
return FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
|
||||
}
|
||||
|
||||
public static String additionalInfoInstructions() {
|
||||
String message = StatCollector.translateToLocal("tooltip.pressShift");
|
||||
return MuseStringUtils.wrapMultipleFormatTags(message, MuseStringUtils.FormatCodes.Grey, MuseStringUtils.FormatCodes.Italic);
|
||||
}
|
||||
|
||||
public static boolean useGraphicalMeters() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use Graphical Meters", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static double baseMaxHeat() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Base Heat Cap", 50.0).getDouble(50.0);
|
||||
}
|
||||
|
||||
public static boolean allowConflictingKeybinds() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Allow Conflicting Keybinds", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static boolean useCustomFonts() {
|
||||
return config.get("Font", "Use Custom Font Engine", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static double fontDetail() {
|
||||
return config.get("Font", "Font Detail Multiplier", 4).getDouble(4);
|
||||
}
|
||||
|
||||
public static String fontURI() {
|
||||
return config.get("Font", "Font URI", Config.RESOURCE_PREFIX + "fonts/cra.ttf").getString();
|
||||
}
|
||||
|
||||
public static String fontName() {
|
||||
return config.get("Font", "Native Font Name (Overrides URI)", "").getString();
|
||||
}
|
||||
|
||||
public static boolean fontAntiAliasing() {
|
||||
return config.get("Font", "Font Anti-Aliasing", false).getBoolean(false);
|
||||
}
|
||||
|
||||
public static int glowMultiplier() {
|
||||
return config.get("Graphics", "Bloom Multiplier", 3).getInt(3);
|
||||
}
|
||||
|
||||
public static boolean useShaders() {
|
||||
return config.get("Graphics", "Use Pixel/Vertex Shaders", true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static void setConfigFolderBase(File folder) {
|
||||
configFolder = new File(folder.getAbsolutePath() + "/machinemuse");
|
||||
}
|
||||
|
||||
public static void addCustomInstallCosts() {
|
||||
try {
|
||||
File installCostFile = new File(configFolder, "custominstallcosts.json");
|
||||
Gson gson = new Gson();
|
||||
if (installCostFile.exists()) {
|
||||
DataInputStream is = new DataInputStream(new FileInputStream(installCostFile));
|
||||
byte[] bytes = new byte[(int) installCostFile.length()];
|
||||
is.readFully(bytes);
|
||||
String string = Charset.defaultCharset().decode(ByteBuffer.wrap(bytes)).toString();
|
||||
is.close();
|
||||
|
||||
MuseLogger.logDebug(string);
|
||||
InstallCost[] costs = (InstallCost[])gson.fromJson(string, (Class)InstallCost[].class);
|
||||
for(InstallCost cost: costs) {
|
||||
String moduleName = cost.moduleName;
|
||||
Item item = GameRegistry.findItem(cost.modId, cost.itemName);
|
||||
if(item != null) {
|
||||
int metadata = (cost.itemMetadata == null) ? 0 : cost.itemMetadata.intValue();
|
||||
int quantity = (cost.itemQuantity == null) ? 1 : cost.itemQuantity.intValue();
|
||||
ItemStack stack = new ItemStack(item, quantity, metadata);
|
||||
if(stack != null) {
|
||||
ModuleManager.addCustomInstallCost(moduleName, stack);
|
||||
} else {
|
||||
MuseLogger.logError("Invalid Itemstack in custom install cost. Module [" + cost.moduleName + "], item [" + cost.itemName + "]");
|
||||
}
|
||||
} else {
|
||||
MuseLogger.logError("Invalid Item in custom install cost. Module [" + cost.moduleName + "], item [" + cost.itemName + "]");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
installCostFile.createNewFile();
|
||||
InstallCost examplecost = new InstallCost();
|
||||
examplecost.moduleName = "Shock Absorber";
|
||||
examplecost.itemName = "wool";
|
||||
examplecost.modId = "minecraft";
|
||||
examplecost.itemQuantity = 2;
|
||||
examplecost.itemMetadata = 0;
|
||||
InstallCost examplecost2 = new InstallCost();
|
||||
examplecost2.moduleName = "Shock Absorber";
|
||||
examplecost2.itemName = "powerArmorComponent";
|
||||
examplecost2.modId = "powersuits";
|
||||
examplecost2.itemQuantity = 2;
|
||||
examplecost2.itemMetadata = 2;
|
||||
InstallCost[] output = { examplecost, examplecost2 };
|
||||
String json = gson.toJson((Object)output);
|
||||
PrintWriter dest = new PrintWriter(installCostFile);
|
||||
dest.write(json);
|
||||
dest.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package net.machinemuse.powersuits.common;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import net.machinemuse.powersuits.common.proxy.CommonProxy;
|
||||
import net.machinemuse.powersuits.entity.EntityLuxCapacitor;
|
||||
import net.machinemuse.powersuits.entity.EntityPlasmaBolt;
|
||||
import net.machinemuse.powersuits.entity.EntitySpinningBlade;
|
||||
import net.machinemuse.powersuits.event.HarvestEventHandler;
|
||||
import net.machinemuse.powersuits.event.MovementManager;
|
||||
import net.machinemuse.powersuits.network.packets.MPSPacketList;
|
||||
import net.machinemuse.powersuits.powermodule.tool.TerminalHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
|
||||
import static net.machinemuse.powersuits.common.ModularPowersuits.MODID;
|
||||
import static net.machinemuse.powersuits.common.ModularPowersuits.VERSION;
|
||||
|
||||
/**
|
||||
* Main mod class. This is what Forge loads to get the mod up and running, both
|
||||
* server- and client-side.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
@Mod(modid = MODID, version = VERSION, dependencies = "required-after:numina@[@numina_version@,)")
|
||||
public final class ModularPowersuits {
|
||||
public static final String MODID = "powersuits";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
|
||||
@Nonnull
|
||||
private static ModularPowersuits INSTANCE;
|
||||
|
||||
@Nonnull
|
||||
@Mod.InstanceFactory
|
||||
public static ModularPowersuits getInstance() {
|
||||
if (INSTANCE == null)
|
||||
INSTANCE = new ModularPowersuits();
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@SidedProxy(clientSide = "net.machinemuse.powersuits.common.proxy.ClientProxy", serverSide = "net.machinemuse.powersuits.common.proxy.ServerProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
public static Configuration config = null;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
File newConfig = new File(event.getModConfigurationDirectory() + "/machinemuse/powersuits.cfg");
|
||||
Config.init(new Configuration(newConfig));
|
||||
Config.setConfigFolderBase(event.getModConfigurationDirectory());
|
||||
MinecraftForge.EVENT_BUS.register(new HarvestEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new MovementManager());
|
||||
proxy.registerEvents();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void load(FMLInitializationEvent event) {
|
||||
Config.loadPowerModules();
|
||||
Config.getMaximumArmorPerPiece();
|
||||
Config.getMaximumFlyingSpeedmps();
|
||||
Config.useMouseWheel();
|
||||
Config.useGraphicalMeters();
|
||||
Config.getSalvageChance();
|
||||
Config.baseMaxHeat();
|
||||
Config.allowConflictingKeybinds();
|
||||
Config.fontAntiAliasing();
|
||||
Config.useCustomFonts();
|
||||
Config.glowMultiplier();
|
||||
Config.useShaders();
|
||||
Config.getWeightCapacity();
|
||||
Config.keybindHUDon();
|
||||
Config.keybindHUDx();
|
||||
Config.toggleModuleSpam();
|
||||
EntityRegistry.registerModEntity(EntityPlasmaBolt.class, "entityPlasmaBolt", 2477, this, 64, 20, true);
|
||||
EntityRegistry.registerModEntity(EntitySpinningBlade.class, "entitySpinningBlade", 2478, this, 64, 20, true);
|
||||
EntityRegistry.registerModEntity(EntityLuxCapacitor.class, "entityLuxCapacitor", 2479, this, 64, 20, true);
|
||||
proxy.registerHandlers();
|
||||
proxy.registerRenderers();
|
||||
MPSPacketList.registerPackets();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, MPSGuiHandler.getInstance());
|
||||
TerminalHandler.registerHandler();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
proxy.postInit();
|
||||
ModCompatibility.registerModSpecificModules();
|
||||
Config.extractRecipes();
|
||||
Config.addCustomInstallCosts();
|
||||
Config.getConfig().save();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package net.machinemuse.powersuits.common.proxy;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.machinemuse.general.sound.SoundDictionary;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.numina.network.MusePacketModeChangeRequest;
|
||||
import net.machinemuse.numina.network.PacketSender;
|
||||
import net.machinemuse.numina.render.RenderGameOverlayEventHandler;
|
||||
import net.machinemuse.powersuits.block.BlockTinkerTable;
|
||||
import net.machinemuse.powersuits.block.TileEntityLuxCapacitor;
|
||||
import net.machinemuse.powersuits.block.TileEntityTinkerTable;
|
||||
import net.machinemuse.powersuits.client.render.block.RenderLuxCapacitorTESR;
|
||||
import net.machinemuse.powersuits.client.render.block.TinkerTableRenderer;
|
||||
import net.machinemuse.powersuits.client.render.entity.RenderLuxCapacitorEntity;
|
||||
import net.machinemuse.powersuits.client.render.entity.RenderPlasmaBolt;
|
||||
import net.machinemuse.powersuits.client.render.entity.RenderSpinningBlade;
|
||||
import net.machinemuse.powersuits.client.render.item.ToolRenderer;
|
||||
import net.machinemuse.powersuits.client.render.modelspec.ModelSpecXMLReader;
|
||||
import net.machinemuse.powersuits.common.MPSItems;
|
||||
import net.machinemuse.powersuits.control.KeybindKeyHandler;
|
||||
import net.machinemuse.powersuits.control.KeybindManager;
|
||||
import net.machinemuse.powersuits.entity.EntityLuxCapacitor;
|
||||
import net.machinemuse.powersuits.entity.EntityPlasmaBolt;
|
||||
import net.machinemuse.powersuits.entity.EntitySpinningBlade;
|
||||
import net.machinemuse.powersuits.event.ClientTickHandler;
|
||||
import net.machinemuse.powersuits.event.PlayerUpdateHandler;
|
||||
import net.machinemuse.powersuits.event.RenderEventHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Client side of the proxy.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class ClientProxy implements CommonProxy {
|
||||
@Override
|
||||
public void registerEvents() {
|
||||
MinecraftForge.EVENT_BUS.register(new SoundDictionary());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all the custom renderers for this mod.
|
||||
*/
|
||||
@Override
|
||||
public void registerRenderers() {
|
||||
MinecraftForgeClient.registerItemRenderer(MPSItems.INSTANCE.powerTool, new ToolRenderer());
|
||||
int tinkTableRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
TinkerTableRenderer tinkTableRenderer = new TinkerTableRenderer(tinkTableRenderID);
|
||||
BlockTinkerTable.setRenderType(tinkTableRenderID);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTinkerTable.class, tinkTableRenderer);
|
||||
RenderingRegistry.registerBlockHandler(tinkTableRenderer);
|
||||
int luxCapacitorRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderLuxCapacitorTESR luxCapacitorRenderer = new RenderLuxCapacitorTESR(luxCapacitorRenderID);
|
||||
MPSItems.INSTANCE.luxCapacitor.setRenderType(luxCapacitorRenderID);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLuxCapacitor.class, luxCapacitorRenderer);
|
||||
RenderingRegistry.registerBlockHandler(luxCapacitorRenderer);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityPlasmaBolt.class, new RenderPlasmaBolt());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySpinningBlade.class, new RenderSpinningBlade());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityLuxCapacitor.class, new RenderLuxCapacitorEntity());
|
||||
MinecraftForge.EVENT_BUS.register(new RenderEventHandler());
|
||||
URL resource = ClientProxy.class.getResource("/assets/powersuits/models/modelspec.xml");
|
||||
ModelSpecXMLReader.getINSTANCE().parseFile(resource);
|
||||
URL otherResource = ClientProxy.class.getResource("/assets/powersuits/models/armor2.xml");
|
||||
ModelSpecXMLReader.getINSTANCE().parseFile(otherResource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the tick handler (for on-tick behaviour) and packet handler (for
|
||||
* network synchronization and permission stuff).
|
||||
*/
|
||||
@Override
|
||||
public void registerHandlers() {
|
||||
FMLCommonHandler.instance().bus().register(new KeybindKeyHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerUpdateHandler());
|
||||
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
KeybindManager.readInKeybinds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendModeChange(int dMode, String newMode) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
RenderGameOverlayEventHandler.updateSwap((int) Math.signum(dMode));
|
||||
MusePacket modeChangePacket = new MusePacketModeChangeRequest(player, newMode, player.inventory.currentItem);
|
||||
PacketSender.sendToServer(modeChangePacket);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package net.machinemuse.powersuits.common.proxy;
|
||||
|
||||
/**
|
||||
* Common side of the proxy. Provides functions which
|
||||
* the ClientProxy and ServerProxy will override if the behaviour is different for client and
|
||||
* server, and keeps some common behaviour.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public interface CommonProxy {
|
||||
void registerEvents();
|
||||
|
||||
void registerRenderers();
|
||||
|
||||
void registerHandlers();
|
||||
|
||||
void postInit();
|
||||
|
||||
void sendModeChange(int dMode, String newMode);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package net.machinemuse.powersuits.common.proxy;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.machinemuse.powersuits.event.PlayerLoginHandlerThingy;
|
||||
import net.machinemuse.powersuits.event.PlayerUpdateHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* Server side of the proxy.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class ServerProxy implements CommonProxy{
|
||||
@Override
|
||||
public void registerEvents() {
|
||||
FMLCommonHandler.instance().bus().register(new PlayerLoginHandlerThingy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRenderers() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandlers() {
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerUpdateHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendModeChange(int dMode, String newMode) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.api.electricity.IModularItem;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketColourInfo extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int itemSlot;
|
||||
int[] tagData;
|
||||
|
||||
public MusePacketColourInfo(EntityPlayer player, int itemSlot, int[] tagData) {
|
||||
this.player = player;
|
||||
this.itemSlot = itemSlot;
|
||||
this.tagData = tagData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(itemSlot);
|
||||
writeIntArray(tagData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(itemSlot);
|
||||
if (stack != null && stack.getItem() instanceof IModularItem) {
|
||||
NBTTagCompound renderTag = MuseItemUtils.getMuseRenderTag(stack);
|
||||
renderTag.setIntArray("colours", tagData);
|
||||
}
|
||||
}
|
||||
|
||||
private static MusePacketColourInfoPackager PACKAGERINSTANCE;
|
||||
public static MusePacketColourInfoPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketColourInfoPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketColourInfoPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int itemSlot = readInt(datain);
|
||||
int[] tagData = readIntArray(datain);
|
||||
return new MusePacketColourInfo(player, itemSlot, tagData);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.api.electricity.IModularItem;
|
||||
import net.machinemuse.numina.general.MuseLogger;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 10:16 AM, 01/05/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketCosmeticInfo extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int itemSlot;
|
||||
String tagName;
|
||||
NBTTagCompound tagData;
|
||||
|
||||
public MusePacketCosmeticInfo(EntityPlayer player, int itemSlot, String tagName, NBTTagCompound tagData) {
|
||||
this.player = player;
|
||||
this.tagName = tagName;
|
||||
this.tagData = tagData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(itemSlot);
|
||||
writeString(tagName);
|
||||
writeNBTTagCompound(tagData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(itemSlot);
|
||||
if (tagName != null && stack != null && stack.getItem() instanceof IModularItem) {
|
||||
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
||||
NBTTagCompound renderTag = null;
|
||||
if (!itemTag.hasKey("render")) {
|
||||
renderTag = new NBTTagCompound();
|
||||
itemTag.setTag("render", renderTag);
|
||||
} else {
|
||||
renderTag = itemTag.getCompoundTag("render");
|
||||
}
|
||||
if (tagData.hasNoTags()) {
|
||||
MuseLogger.logDebug("Removing tag " + tagName);
|
||||
renderTag.removeTag(tagName);
|
||||
} else {
|
||||
MuseLogger.logDebug("Adding tag " + tagName + " : " + tagData);
|
||||
renderTag.setTag(tagName, tagData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static MusePacketCosmeticInfoPackager PACKAGERINSTANCE;
|
||||
public static MusePacketCosmeticInfoPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketCosmeticInfoPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketCosmeticInfoPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int itemSlot = readInt(datain);
|
||||
String tagName = readString(datain);
|
||||
NBTTagCompound tagData = readNBTTagCompound(datain);
|
||||
return new MusePacketCosmeticInfo(player, itemSlot, tagName, tagData);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.numina.network.PacketSender;
|
||||
import net.machinemuse.utils.ElectricItemUtils;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server decides whether it is a valid upgrade or not and replies with an associated
|
||||
* inventoryrefresh packet.
|
||||
*
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 10:16 AM, 01/05/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketInstallModuleRequest extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int itemSlot;
|
||||
String moduleName;
|
||||
|
||||
public MusePacketInstallModuleRequest(EntityPlayer player, int itemSlot, String moduleName) {
|
||||
this.player = player;
|
||||
this.itemSlot = itemSlot;
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(itemSlot);
|
||||
writeString(moduleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(itemSlot);
|
||||
if (moduleName != null) {
|
||||
InventoryPlayer inventory = player.inventory;
|
||||
IPowerModule moduleType = ModuleManager.getModule(moduleName);
|
||||
if (moduleType == null || !moduleType.isAllowed()) {
|
||||
player.addChatComponentMessage(new ChatComponentText("Server has disallowed this module. Sorry!"));
|
||||
return;
|
||||
}
|
||||
List<ItemStack> cost = moduleType.getInstallCost();
|
||||
if ((!ModuleManager.itemHasModule(stack, moduleName) && MuseItemUtils.hasInInventory(cost, player.inventory)) || player.capabilities.isCreativeMode) {
|
||||
ModuleManager.itemAddModule(stack, moduleType);
|
||||
for (ItemStack stackInCost : cost) {
|
||||
ElectricItemUtils.givePlayerEnergy(player, ElectricItemUtils.jouleValueOfComponent(stackInCost));
|
||||
}
|
||||
List<Integer> slotsToUpdate = new ArrayList<>();
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
slotsToUpdate = MuseItemUtils.deleteFromInventory(cost, inventory);
|
||||
}
|
||||
slotsToUpdate.add(itemSlot);
|
||||
for (Integer slotiter : slotsToUpdate) {
|
||||
MusePacket reply = new MusePacketInventoryRefresh(player, slotiter, inventory.getStackInSlot(slotiter));
|
||||
PacketSender.sendTo(reply, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static MusePacketInstallModuleRequestPackager PACKAGERINSTANCE;
|
||||
public static MusePacketInstallModuleRequestPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketInstallModuleRequestPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketInstallModuleRequestPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int itemSlot = readInt(datain);
|
||||
String moduleName = readString(datain);
|
||||
return new MusePacketInstallModuleRequest(player, itemSlot, moduleName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.general.gui.MuseGui;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketInventoryRefresh extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int slot;
|
||||
ItemStack stack;
|
||||
|
||||
public MusePacketInventoryRefresh(EntityPlayer player, int slot, ItemStack stack) {
|
||||
this.player = player;
|
||||
this.slot = slot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(slot);
|
||||
writeItemStack(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClient(EntityClientPlayerMP player) {
|
||||
IInventory inventory = player.inventory;
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
((MuseGui)(Minecraft.getMinecraft().currentScreen)).refresh();
|
||||
}
|
||||
|
||||
private static MusePacketInventoryRefreshPackager PACKAGERINSTANCE;
|
||||
public static MusePacketInventoryRefreshPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketInventoryRefreshPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketInventoryRefreshPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int itemSlot = readInt(datain);
|
||||
ItemStack stack = readItemStack(datain);
|
||||
return new MusePacketInventoryRefresh(player, itemSlot, stack);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.powersuits.entity.EntityPlasmaBolt;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketPlasmaBolt extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int entityID;
|
||||
double size;
|
||||
|
||||
|
||||
public MusePacketPlasmaBolt(EntityPlayer player, int entityID, double size) {
|
||||
this.player = player;
|
||||
this.entityID = entityID;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(entityID);
|
||||
writeDouble(size);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void handleClient(EntityClientPlayerMP player) {
|
||||
try {
|
||||
EntityPlasmaBolt entity = (EntityPlasmaBolt) Minecraft.getMinecraft().theWorld.getEntityByID(entityID);
|
||||
entity.size = this.size;
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static MusePacketPlasmaBoltPackager PACKAGERINSTANCE;
|
||||
public static MusePacketPlasmaBoltPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketPlasmaBoltPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketPlasmaBoltPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int entityID = readInt(datain);
|
||||
double size = readDouble(datain);
|
||||
return new MusePacketPlasmaBolt(player, entityID, size);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.numina.network.PacketSender;
|
||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketPlayerUpdate extends MusePacket {
|
||||
EntityPlayer player;
|
||||
PlayerInputMap inputMap;
|
||||
|
||||
public MusePacketPlayerUpdate(EntityPlayer player, PlayerInputMap inputMap) {
|
||||
this.player = player;
|
||||
this.inputMap = inputMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeString(player.getCommandSenderName());
|
||||
inputMap.writeToStream(dataout());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
MusePacketPlayerUpdate updatePacket = new MusePacketPlayerUpdate(player, inputMap);
|
||||
player.motionX = inputMap.motionX;
|
||||
player.motionY = inputMap.motionY;
|
||||
player.motionZ = inputMap.motionZ;
|
||||
PacketSender.sendToAllAround(updatePacket, player, 128);
|
||||
}
|
||||
|
||||
private static MusePacketPlayerUpdatePackager PACKAGERINSTANCE;
|
||||
public static MusePacketPlayerUpdatePackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketPlayerUpdatePackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketPlayerUpdatePackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
String username = readString(datain);
|
||||
PlayerInputMap inputMap = PlayerInputMap.getInputMapFor(username);
|
||||
inputMap.readFromStream(datain);
|
||||
return new MusePacketPlayerUpdate(player, inputMap);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.IPropertyModifier;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||
import net.machinemuse.powersuits.powermodule.PropertyModifierFlatAdditive;
|
||||
import net.machinemuse.powersuits.powermodule.PropertyModifierIntLinearAdditive;
|
||||
import net.machinemuse.powersuits.powermodule.PropertyModifierLinearAdditive;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 7:23 PM, 12/05/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketPropertyModifierConfig extends MusePacket {
|
||||
EntityPlayer player;
|
||||
DataInputStream data;
|
||||
|
||||
public MusePacketPropertyModifierConfig(EntityPlayer player, DataInputStream data) {
|
||||
this.player= player;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(ModuleManager.getAllModules().size());
|
||||
for (IPowerModule module : ModuleManager.getAllModules()) {
|
||||
writeString(module.getDataName());
|
||||
writeBoolean(module.isAllowed());
|
||||
writeInt(module.getPropertyModifiers().size());
|
||||
Map<String, List<IPropertyModifier>> propertyMap = module.getPropertyModifiers();
|
||||
|
||||
for (String propname : propertyMap.keySet()) {
|
||||
List<IPropertyModifier> propmodlist = propertyMap.get(propname);
|
||||
writeString(propname);
|
||||
writeInt(propmodlist.size());
|
||||
|
||||
for (IPropertyModifier propmod : propmodlist) {
|
||||
if (propmod instanceof PropertyModifierFlatAdditive)
|
||||
writeDouble(((PropertyModifierFlatAdditive) propmod).valueAdded);
|
||||
else if (propmod instanceof PropertyModifierIntLinearAdditive)
|
||||
writeDouble(((PropertyModifierIntLinearAdditive) propmod).multiplier);
|
||||
else
|
||||
writeDouble(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the network manager since it does all the packet mapping
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void handleClient(EntityClientPlayerMP player) {
|
||||
MusePackager d = MusePacketPropertyModifierConfigPackager.getInstance();
|
||||
int numModules = d.readInt(data);
|
||||
for (int i = 0; i < numModules; i++) {
|
||||
String moduleName = d.readString(data);
|
||||
boolean allowed = d.readBoolean(data);
|
||||
IPowerModule module = ModuleManager.getModule(moduleName);
|
||||
if (module instanceof PowerModuleBase)
|
||||
((PowerModuleBase) module).setIsAllowed(allowed);
|
||||
|
||||
int numProps = d.readInt(data);
|
||||
for (int j = 0; j < numProps; j++ ) {
|
||||
String propName = d.readString(data);
|
||||
int numModifiers = d.readInt(data);
|
||||
List<IPropertyModifier> proplist = module.getPropertyModifiers().get(propName);
|
||||
|
||||
for (int m = 0; m < numModifiers; m++) {
|
||||
IPropertyModifier propMod = proplist.get(m);
|
||||
if (propMod instanceof PropertyModifierFlatAdditive)
|
||||
((PropertyModifierFlatAdditive) propMod).valueAdded = d.readDouble(data);
|
||||
else if (propMod instanceof PropertyModifierLinearAdditive)
|
||||
((PropertyModifierLinearAdditive) propMod).multiplier = d.readDouble(data);
|
||||
else
|
||||
d.readDouble(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static MusePacketPropertyModifierConfigPackager PACKAGERINSTANCE;
|
||||
public static MusePacketPropertyModifierConfigPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketPropertyModifierConfigPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketPropertyModifierConfigPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
return new MusePacketPropertyModifierConfig(player, datain);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.numina.network.PacketSender;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server
|
||||
* decides whether it is a valid upgrade or not and replies with an associated
|
||||
* inventoryrefresh packet.
|
||||
*
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketSalvageModuleRequest extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int itemSlot;
|
||||
String moduleName;
|
||||
|
||||
public MusePacketSalvageModuleRequest(EntityPlayer player, int itemSlot, String moduleName) {
|
||||
this.player = player;
|
||||
this.itemSlot = itemSlot;
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(itemSlot);
|
||||
writeString(moduleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
if (moduleName != null) {
|
||||
InventoryPlayer inventory = player.inventory;
|
||||
ItemStack stack = player.inventory.getStackInSlot(itemSlot);
|
||||
IPowerModule moduleType = ModuleManager.getModule(moduleName);
|
||||
List<ItemStack> refund = moduleType.getInstallCost();
|
||||
if (ModuleManager.itemHasModule(stack, moduleName)) {
|
||||
Set<Integer> slots = new HashSet<>();
|
||||
ModuleManager.removeModule(stack, moduleName);
|
||||
for (ItemStack refundItem : refund) {
|
||||
slots.addAll(MuseItemUtils.giveOrDropItemWithChance(refundItem.copy(), player, Config.getSalvageChance()));
|
||||
}
|
||||
slots.add(itemSlot);
|
||||
|
||||
for (Integer slotiter : slots) {
|
||||
MusePacket reply = new MusePacketInventoryRefresh(player, slotiter, inventory.getStackInSlot(slotiter));
|
||||
PacketSender.sendTo(reply, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static MusePacketSalvageModuleRequestPackager PACKAGERINSTANCE;
|
||||
public static MusePacketSalvageModuleRequestPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketSalvageModuleRequestPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketSalvageModuleRequestPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int itemSlot = readInt(datain);
|
||||
String moduleName = readString(datain);
|
||||
return new MusePacketSalvageModuleRequest(player, itemSlot, moduleName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketToggleRequest extends MusePacket{
|
||||
EntityPlayer player;
|
||||
String module;
|
||||
Boolean active;
|
||||
public MusePacketToggleRequest(EntityPlayer player, String module, Boolean active) {
|
||||
this.player= player;
|
||||
this.module = module;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeString(module);
|
||||
writeBoolean(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
MuseItemUtils.toggleModuleForPlayer(player, module, active);
|
||||
}
|
||||
|
||||
private static MusePacketToggleRequestPackager PACKAGERINSTANCE;
|
||||
public static MusePacketToggleRequestPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketToggleRequestPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketToggleRequestPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
String module = readString(datain);
|
||||
boolean value = readBoolean(datain);
|
||||
return new MusePacketToggleRequest(player, module, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.machinemuse.powersuits.network.packets;
|
||||
|
||||
import net.machinemuse.numina.network.IMusePackager;
|
||||
import net.machinemuse.numina.network.MusePackager;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server
|
||||
* decides whether it is a valid upgrade or not and <strike>replies with an associated
|
||||
* inventoryrefresh packet</strike>.
|
||||
*
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 12:28 PM, 5/6/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/14/16.
|
||||
*/
|
||||
public class MusePacketTweakRequest extends MusePacket {
|
||||
EntityPlayer player;
|
||||
int itemSlot;
|
||||
String moduleName;
|
||||
String tweakName;
|
||||
double tweakValue;
|
||||
|
||||
public MusePacketTweakRequest(EntityPlayer player, int itemSlot, String moduleName, String tweakName, double tweakValue) {
|
||||
this.player = player;
|
||||
this.itemSlot = itemSlot;
|
||||
this.moduleName = moduleName;
|
||||
this.tweakValue = tweakValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMusePackager packager() {
|
||||
return getPackagerInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
writeInt(itemSlot);
|
||||
writeString(moduleName);
|
||||
writeString(tweakName);
|
||||
writeDouble(tweakValue);
|
||||
}
|
||||
|
||||
private static MusePacketTweakRequestPackager PACKAGERINSTANCE;
|
||||
public static MusePacketTweakRequestPackager getPackagerInstance() {
|
||||
if (PACKAGERINSTANCE == null)
|
||||
PACKAGERINSTANCE = new MusePacketTweakRequestPackager();
|
||||
return PACKAGERINSTANCE;
|
||||
}
|
||||
|
||||
public static class MusePacketTweakRequestPackager extends MusePackager {
|
||||
@Override
|
||||
public MusePacket read(DataInputStream datain, EntityPlayer player) {
|
||||
int itemSlot = readInt(datain);
|
||||
String moduleName = readString(datain);
|
||||
String tweakName = readString(datain);
|
||||
double tweakValue = readDouble(datain);
|
||||
return new MusePacketTweakRequest(player, itemSlot, moduleName, tweakName, tweakValue);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue