Compare commits
5 Commits
3e20bfa926
...
26b4844354
Author | SHA1 | Date | |
---|---|---|---|
![]() |
26b4844354 | ||
![]() |
36f86a0c9d | ||
![]() |
67d2e634b7 | ||
![]() |
99e694a7c7 | ||
![]() |
56bf8c1759 |
@ -397,10 +397,10 @@ mods.nuclearcraft.Condenser.removeRecipeWithInput(ILiquidStack fluidInput);
|
||||
mods.nuclearcraft.Condenser.removeRecipeWithOutput(ILiquidStack fluidOutput);
|
||||
|
||||
|
||||
Steam Turbine:
|
||||
--------------
|
||||
Turbine:
|
||||
--------
|
||||
|
||||
mods.nuclearcraft.Turbine.addRecipe(ILiquidStack fluidInput, ILiquidStack fluidOutput, double powerPerMB, double expansionLevel, {String particleEffect, double particleSpeedMultiplier});
|
||||
mods.nuclearcraft.Turbine.addRecipe(ILiquidStack fluidInput, ILiquidStack fluidOutput, double powerPerMB, double expansionLevel, double spinUpMultiplier, {String particleEffect, double particleSpeedMultiplier});
|
||||
|
||||
mods.nuclearcraft.Turbine.removeRecipeWithInput(ILiquidStack fluidInput);
|
||||
mods.nuclearcraft.Turbine.removeRecipeWithOutput(ILiquidStack fluidOutput);
|
||||
|
@ -1,7 +1,7 @@
|
||||
mc_version=1.12.2
|
||||
forge_version=14.23.5.2847
|
||||
mapping_version=stable_39
|
||||
mod_version=2o.5.0beta4
|
||||
mod_version=2o.5.0beta5
|
||||
|
||||
ic2_version=2.8.197-ex112
|
||||
jei_version=4.15.0.293
|
||||
|
@ -1,6 +1,6 @@
|
||||
#loader nc_preinit
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionSink("extreme", 210, "exactly one sic_sic_cmc sink");
|
||||
mods.nuclearcraft.Registration.registerFissionSink("extreme", 210, "exactly two axial conductors || one irradiator || one shield");
|
||||
mods.nuclearcraft.Registration.registerFissionSink("sic_sic_cmc", 215, "exactly one lead sink && at most two copper sinks");
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionHeater("extreme", "tritium", 1, "deuterium", 1, 210, "exactly one sic_sic_cmc heater");
|
||||
@ -8,7 +8,7 @@ mods.nuclearcraft.Registration.registerFissionHeater("sic_sic_cmc", "helium3", 1
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionSource("americium_beryllium", 0.975);
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionShield("cadmium", 10.0, 0.8);
|
||||
mods.nuclearcraft.Registration.registerFissionShield("cadmium", 10.0, 0.75);
|
||||
|
||||
mods.nuclearcraft.Registration.registerTurbineCoil("extreme", 1.14, "four of any coil");
|
||||
mods.nuclearcraft.Registration.registerTurbineCoil("sic_sic_cmc", 1.16, "exactly two axial connectors");
|
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1017 B After Width: | Height: | Size: 1017 B |
Before Width: | Height: | Size: 1018 B After Width: | Height: | Size: 1018 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 382 B |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 568 B After Width: | Height: | Size: 568 B |
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 461 B After Width: | Height: | Size: 461 B |
@ -1,6 +1,6 @@
|
||||
#loader nc_preinit
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionSink("extreme", 210, "exactly one sic_sic_cmc sink");
|
||||
mods.nuclearcraft.Registration.registerFissionSink("extreme", 210, "exactly two axial conductors || one irradiator || one shield");
|
||||
mods.nuclearcraft.Registration.registerFissionSink("sic_sic_cmc", 215, "exactly one lead sink && at most two copper sinks");
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionHeater("extreme", "tritium", 1, "deuterium", 1, 210, "exactly one sic_sic_cmc heater");
|
||||
@ -8,7 +8,7 @@ mods.nuclearcraft.Registration.registerFissionHeater("sic_sic_cmc", "helium3", 1
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionSource("americium_beryllium", 0.975);
|
||||
|
||||
mods.nuclearcraft.Registration.registerFissionShield("cadmium", 10.0, 0.8);
|
||||
mods.nuclearcraft.Registration.registerFissionShield("cadmium", 10.0, 0.75);
|
||||
|
||||
mods.nuclearcraft.Registration.registerTurbineCoil("extreme", 1.14, "four of any coil");
|
||||
mods.nuclearcraft.Registration.registerTurbineCoil("sic_sic_cmc", 1.16, "exactly two axial connectors");
|
||||
|
@ -4,7 +4,9 @@ import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import nc.capability.radiation.source.IRadiationSource;
|
||||
import nc.config.NCConfig;
|
||||
import nc.fluid.FluidCorium;
|
||||
import nc.init.NCBlocks;
|
||||
import nc.radiation.*;
|
||||
@ -18,6 +20,8 @@ import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class BlockFluidCorium extends BlockFluidFission {
|
||||
|
||||
protected static IntSet solidification_dim_set;
|
||||
|
||||
public BlockFluidCorium(FluidCorium fluid) {
|
||||
super(fluid);
|
||||
}
|
||||
@ -40,7 +44,11 @@ public class BlockFluidCorium extends BlockFluidFission {
|
||||
|
||||
super.updateTick(world, pos, state, rand);
|
||||
|
||||
if (state.getValue(LEVEL) == 0) {
|
||||
if (solidification_dim_set == null) {
|
||||
solidification_dim_set = new IntOpenHashSet(NCConfig.corium_solidification);
|
||||
}
|
||||
|
||||
if (state.getValue(LEVEL) == 0 && solidification_dim_set.contains(world.provider.getDimension()) != NCConfig.corium_solidification_list_type) {
|
||||
int count = 0;
|
||||
for (EnumFacing side : EnumFacing.VALUES) {
|
||||
if (isSourceBlock(world, pos.offset(side))) {
|
||||
@ -51,7 +59,7 @@ public class BlockFluidCorium extends BlockFluidFission {
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.nextInt(2 * (1 + count)) == 0) {
|
||||
if (rand.nextInt(2 + 4 * count) == 0) {
|
||||
world.setBlockState(pos, NCBlocks.solidified_corium.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ public class NCConfig {
|
||||
public static double[] speed_upgrade_multipliers;
|
||||
public static double[] energy_upgrade_power_laws;
|
||||
public static double[] energy_upgrade_multipliers;
|
||||
public static int[] upgrade_stack_sizes;
|
||||
public static int rf_per_eu;
|
||||
public static boolean enable_ic2_eu;
|
||||
public static boolean enable_gtce_eu;
|
||||
@ -221,6 +222,7 @@ public class NCConfig {
|
||||
public static String[] turbine_connector_rule;
|
||||
public static double[] turbine_power_per_mb;
|
||||
public static double[] turbine_expansion_level;
|
||||
public static double[] turbine_spin_up_multiplier;
|
||||
public static int turbine_mb_per_blade;
|
||||
public static double[] turbine_throughput_leniency_params;
|
||||
public static double turbine_tension_throughput_factor;
|
||||
@ -382,6 +384,9 @@ public class NCConfig {
|
||||
public static int mushroom_gen_size;
|
||||
public static int mushroom_gen_rate;
|
||||
|
||||
public static int[] corium_solidification;
|
||||
public static boolean corium_solidification_list_type;
|
||||
|
||||
public static boolean ore_dict_raw_material_recipes;
|
||||
public static boolean ore_dict_priority_bool;
|
||||
public static String[] ore_dict_priority;
|
||||
@ -463,6 +468,8 @@ public class NCConfig {
|
||||
propertyEnergyUpgradePowerLaws.setLanguageKey("gui.nc.config.energy_upgrade_power_laws_fp");
|
||||
Property propertyEnergyUpgradeMultipliers = config.get(CATEGORY_PROCESSOR, "energy_upgrade_multipliers_fp", new double[] {1D}, Lang.localise("gui.nc.config.energy_upgrade_multipliers_fp.comment"), 0D, 15D);
|
||||
propertyEnergyUpgradeMultipliers.setLanguageKey("gui.nc.config.energy_upgrade_multipliers_fp");
|
||||
Property propertyUpgradeStackSizes = config.get(CATEGORY_PROCESSOR, "upgrade_stack_sizes", new int[] {64, 64}, Lang.localise("gui.nc.config.upgrade_stack_sizes.comment"), 1, 64);
|
||||
propertyUpgradeStackSizes.setLanguageKey("gui.nc.config.upgrade_stack_sizes");
|
||||
Property propertyRFPerEU = config.get(CATEGORY_PROCESSOR, "rf_per_eu", 16, Lang.localise("gui.nc.config.rf_per_eu.comment"), 1, 2000);
|
||||
propertyRFPerEU.setLanguageKey("gui.nc.config.rf_per_eu");
|
||||
Property propertyEnableIC2EU = config.get(CATEGORY_PROCESSOR, "enable_ic2_eu", true, Lang.localise("gui.nc.config.enable_ic2_eu.comment"));
|
||||
@ -764,6 +771,8 @@ public class NCConfig {
|
||||
propertyTurbinePowerPerMB.setLanguageKey("gui.nc.config.turbine_power_per_mb");
|
||||
Property propertyTurbineExpansionLevel = config.get(CATEGORY_TURBINE, "turbine_expansion_level", new double[] {4D, 2D, 2D}, Lang.localise("gui.nc.config.turbine_expansion_level.comment"), 1D, 255D);
|
||||
propertyTurbineExpansionLevel.setLanguageKey("gui.nc.config.turbine_expansion_level");
|
||||
Property propertyTurbineSpinUpMultiplier = config.get(CATEGORY_TURBINE, "turbine_spin_up_multiplier", new double[] {1D, 1D, 1D}, Lang.localise("gui.nc.config.turbine_spin_up_multiplier.comment"), 0D, 255D);
|
||||
propertyTurbineSpinUpMultiplier.setLanguageKey("gui.nc.config.turbine_spin_up_multiplier");
|
||||
Property propertyTurbineMBPerBlade = config.get(CATEGORY_TURBINE, "turbine_mb_per_blade", 100, Lang.localise("gui.nc.config.turbine_mb_per_blade.comment"), 1, 32767);
|
||||
propertyTurbineMBPerBlade.setLanguageKey("gui.nc.config.turbine_mb_per_blade");
|
||||
Property propertyTurbineThroughputLeniencyParams = config.get(CATEGORY_TURBINE, "turbine_throughput_leniency_params", new double[] {0.5D, 0.75D}, Lang.localise("gui.nc.config.turbine_throughput_leniency_params.comment"), 0D, 1D);
|
||||
@ -1037,6 +1046,11 @@ public class NCConfig {
|
||||
Property propertyDungeonLoot = config.get(CATEGORY_MISC, "dungeon_loot", true, Lang.localise("gui.nc.config.dungeon_loot.comment"));
|
||||
propertyDungeonLoot.setLanguageKey("gui.nc.config.dungeon_loot");
|
||||
|
||||
Property propertyCoriumSolidification = config.get(CATEGORY_MISC, "corium_solidification", new int[] {0, 1, 2, -6, -100, 4598, -9999, -11325}, Lang.localise("gui.nc.config.corium_solidification.comment"), Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
propertyCoriumSolidification.setLanguageKey("gui.nc.config.corium_solidification");
|
||||
Property propertyCoriumSolidificationListType = config.get(CATEGORY_MISC, "corium_solidification_list_type", false, Lang.localise("gui.nc.config.corium_solidification_list_type.comment"));
|
||||
propertyCoriumSolidificationListType.setLanguageKey("gui.nc.config.corium_solidification_list_type");
|
||||
|
||||
Property propertyOreDictRawMaterialRecipes = config.get(CATEGORY_MISC, "ore_dict_raw_material_recipes", false, Lang.localise("gui.nc.config.ore_dict_raw_material_recipes.comment"));
|
||||
propertyOreDictRawMaterialRecipes.setLanguageKey("gui.nc.config.ore_dict_raw_material_recipes");
|
||||
Property propertyOreDictPriorityBool = config.get(CATEGORY_MISC, "ore_dict_priority_bool", true, Lang.localise("gui.nc.config.ore_dict_priority_bool.comment"));
|
||||
@ -1075,6 +1089,7 @@ public class NCConfig {
|
||||
propertyOrderProcessor.add(propertySpeedUpgradeMultipliers.getName());
|
||||
propertyOrderProcessor.add(propertyEnergyUpgradePowerLaws.getName());
|
||||
propertyOrderProcessor.add(propertyEnergyUpgradeMultipliers.getName());
|
||||
propertyOrderProcessor.add(propertyUpgradeStackSizes.getName());
|
||||
propertyOrderProcessor.add(propertyRFPerEU.getName());
|
||||
propertyOrderProcessor.add(propertyEnableIC2EU.getName());
|
||||
propertyOrderProcessor.add(propertyEnableGTCEEU.getName());
|
||||
@ -1245,6 +1260,7 @@ public class NCConfig {
|
||||
propertyOrderTurbine.add(propertyTurbineConnectorRule.getName());
|
||||
propertyOrderTurbine.add(propertyTurbinePowerPerMB.getName());
|
||||
propertyOrderTurbine.add(propertyTurbineExpansionLevel.getName());
|
||||
propertyOrderTurbine.add(propertyTurbineSpinUpMultiplier.getName());
|
||||
propertyOrderTurbine.add(propertyTurbineMBPerBlade.getName());
|
||||
propertyOrderTurbine.add(propertyTurbineThroughputLeniencyParams.getName());
|
||||
propertyOrderTurbine.add(propertyTurbineTensionThroughputFactor.getName());
|
||||
@ -1394,6 +1410,8 @@ public class NCConfig {
|
||||
propertyOrderMisc.add(propertyJEIChanceItemsIncludeNull.getName());
|
||||
propertyOrderMisc.add(propertyRareDrops.getName());
|
||||
propertyOrderMisc.add(propertyDungeonLoot.getName());
|
||||
propertyOrderMisc.add(propertyCoriumSolidification.getName());
|
||||
propertyOrderMisc.add(propertyCoriumSolidificationListType.getName());
|
||||
propertyOrderMisc.add(propertyOreDictRawMaterialRecipes.getName());
|
||||
propertyOrderMisc.add(propertyOreDictPriorityBool.getName());
|
||||
propertyOrderMisc.add(propertyOreDictPriority.getName());
|
||||
@ -1427,6 +1445,7 @@ public class NCConfig {
|
||||
speed_upgrade_multipliers = readDoubleArrayFromConfig(propertySpeedUpgradeMultipliers);
|
||||
energy_upgrade_power_laws = readDoubleArrayFromConfig(propertyEnergyUpgradePowerLaws);
|
||||
energy_upgrade_multipliers = readDoubleArrayFromConfig(propertyEnergyUpgradeMultipliers);
|
||||
upgrade_stack_sizes = readIntegerArrayFromConfig(propertyUpgradeStackSizes);
|
||||
rf_per_eu = propertyRFPerEU.getInt();
|
||||
enable_ic2_eu = propertyEnableIC2EU.getBoolean();
|
||||
enable_gtce_eu = propertyEnableGTCEEU.getBoolean();
|
||||
@ -1585,6 +1604,7 @@ public class NCConfig {
|
||||
turbine_connector_rule = propertyTurbineConnectorRule.getStringList();
|
||||
turbine_power_per_mb = readDoubleArrayFromConfig(propertyTurbinePowerPerMB);
|
||||
turbine_expansion_level = readDoubleArrayFromConfig(propertyTurbineExpansionLevel);
|
||||
turbine_spin_up_multiplier = readDoubleArrayFromConfig(propertyTurbineSpinUpMultiplier);
|
||||
turbine_mb_per_blade = propertyTurbineMBPerBlade.getInt();
|
||||
turbine_throughput_leniency_params = readDoubleArrayFromConfig(propertyTurbineThroughputLeniencyParams);
|
||||
turbine_tension_throughput_factor = propertyTurbineTensionThroughputFactor.getDouble();
|
||||
@ -1731,6 +1751,8 @@ public class NCConfig {
|
||||
jei_chance_items_include_null = propertyJEIChanceItemsIncludeNull.getBoolean();
|
||||
rare_drops = propertyRareDrops.getBoolean();
|
||||
dungeon_loot = propertyDungeonLoot.getBoolean();
|
||||
corium_solidification = propertyCoriumSolidification.getIntList();
|
||||
corium_solidification_list_type = propertyCoriumSolidificationListType.getBoolean();
|
||||
ore_dict_raw_material_recipes = propertyOreDictRawMaterialRecipes.getBoolean();
|
||||
ore_dict_priority_bool = propertyOreDictPriorityBool.getBoolean();
|
||||
ore_dict_priority = propertyOreDictPriority.getStringList();
|
||||
@ -1763,6 +1785,7 @@ public class NCConfig {
|
||||
propertySpeedUpgradeMultipliers.set(speed_upgrade_multipliers);
|
||||
propertyEnergyUpgradePowerLaws.set(energy_upgrade_power_laws);
|
||||
propertyEnergyUpgradeMultipliers.set(energy_upgrade_multipliers);
|
||||
propertyUpgradeStackSizes.set(upgrade_stack_sizes);
|
||||
propertyRFPerEU.set(rf_per_eu);
|
||||
propertyEnableIC2EU.set(enable_ic2_eu);
|
||||
propertyEnableGTCEEU.set(enable_gtce_eu);
|
||||
@ -1921,6 +1944,7 @@ public class NCConfig {
|
||||
propertyTurbineConnectorRule.set(turbine_connector_rule);
|
||||
propertyTurbinePowerPerMB.set(turbine_power_per_mb);
|
||||
propertyTurbineExpansionLevel.set(turbine_expansion_level);
|
||||
propertyTurbineSpinUpMultiplier.set(turbine_spin_up_multiplier);
|
||||
propertyTurbineMBPerBlade.set(turbine_mb_per_blade);
|
||||
propertyTurbineThroughputLeniencyParams.set(turbine_throughput_leniency_params);
|
||||
propertyTurbineTensionThroughputFactor.set(turbine_tension_throughput_factor);
|
||||
@ -2066,6 +2090,9 @@ public class NCConfig {
|
||||
propertyCtrlInfo.set(ctrl_info);
|
||||
propertyJEIChanceItemsIncludeNull.set(jei_chance_items_include_null);
|
||||
propertyRareDrops.set(rare_drops);
|
||||
propertyDungeonLoot.set(rare_drops);
|
||||
propertyCoriumSolidification.set(corium_solidification);
|
||||
propertyCoriumSolidificationListType.set(corium_solidification_list_type);
|
||||
propertyOreDictRawMaterialRecipes.set(ore_dict_raw_material_recipes);
|
||||
propertyOreDictPriorityBool.set(ore_dict_priority_bool);
|
||||
propertyOreDictPriority.set(ore_dict_priority);
|
||||
|
@ -1035,10 +1035,12 @@ public class MetaEnums {
|
||||
|
||||
private final String name;
|
||||
private final int id;
|
||||
private final int maxStackSize;
|
||||
|
||||
private UpgradeType(String name, int id) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.maxStackSize = upgrade_stack_sizes[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1055,6 +1057,10 @@ public class MetaEnums {
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getMaxStackSize() {
|
||||
return maxStackSize;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum FissionDustType implements IStringSerializable, IMetaEnum {
|
||||
|
@ -13,8 +13,8 @@ public class ScriptAddonHandler {
|
||||
public static final ObjectSet<File> SCRIPT_ADDON_DIRS = new ObjectOpenHashSet<>();
|
||||
|
||||
public static final String[] NC_ASSETS = {"advancements", "blockstates", "loot_tables", "models", "patchouli_books", "textures"};
|
||||
public static final String[] ADDON_ASSETS = {"advancements", "blockstates", "contenttweaker", "lang", "loot_tables", "models", "patchouli_books", "scripts", "textures"};
|
||||
public static final String[] IGNORE_SUFFIX = {".ignore", ".disabled"};
|
||||
public static final String[] ADDON_ASSETS = {"advancements", "blockstates", "contenttweaker", "lang", "loot_tables", "models", "modularmachinery", "patchouli_books", "scripts", "textures"};
|
||||
public static final String[] IGNORE_SUFFIX = {".ignore", ".ignored", ".disable", ".disabled"};
|
||||
|
||||
public static void init() throws IOException {
|
||||
NCUtil.getLogger().info("Constructing NuclearCraft Script Addons...");
|
||||
@ -48,7 +48,7 @@ public class ScriptAddonHandler {
|
||||
|
||||
public static void extractAddons(File dir) throws IOException {
|
||||
fileLoop: for (File f : dir.listFiles()) {
|
||||
if (!f.isDirectory() && IOHelper.isZip(f)) {
|
||||
if (f.isFile() && IOHelper.isZip(f)) {
|
||||
String fileName = f.getName();
|
||||
String fileNameLowerCase = fileName.toLowerCase(Locale.ROOT);
|
||||
for (String suffix : IGNORE_SUFFIX) {
|
||||
@ -107,6 +107,11 @@ public class ScriptAddonHandler {
|
||||
SCRIPT_ADDON_DIRS.add(dir);
|
||||
}
|
||||
|
||||
else if (f.getName().equals("modularmachinery")) {
|
||||
FileUtils.copyDirectory(f, new File("config/modularmachinery/machinery"));
|
||||
SCRIPT_ADDON_DIRS.add(dir);
|
||||
}
|
||||
|
||||
else {
|
||||
boolean a = false;
|
||||
for (File d : f.listFiles()) {
|
||||
@ -136,7 +141,7 @@ public class ScriptAddonHandler {
|
||||
public static void copyLangs(File addonDir, File langDir) throws IOException {
|
||||
for (File f : langDir.listFiles()) {
|
||||
String name = f.getName().toLowerCase();
|
||||
if (!f.isDirectory() && name.endsWith(".lang")) {
|
||||
if (f.isFile() && name.endsWith(".lang")) {
|
||||
String type = StringHelper.removeSuffix(name, 5);
|
||||
File lang = new File("resources/nuclearcraft/lang/" + type + ".lang");
|
||||
|
||||
|
40
src/main/java/nc/init/NCAdvancements.java
Normal file
@ -0,0 +1,40 @@
|
||||
package nc.init;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
||||
import nc.Global;
|
||||
import nc.multiblock.advancement.MultiblockTrigger;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class NCAdvancements {
|
||||
|
||||
|
||||
public static void init() {
|
||||
|
||||
Logger logger = LogManager.getLogger(Global.MOD_ID);
|
||||
|
||||
Method method = ReflectionHelper.findMethod(CriteriaTriggers.class, "register", "func_192118_a", ICriterionTrigger.class);
|
||||
method.setAccessible(true);
|
||||
|
||||
for (int i=0; i < MultiblockTrigger.TRIGGER_ARRAY.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
method.invoke(null, MultiblockTrigger.TRIGGER_ARRAY[i]);
|
||||
logger.log(Level.INFO, "Invoking: "+MultiblockTrigger.TRIGGER_ARRAY[i].getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.log(Level.ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -97,7 +97,7 @@ public class NCFluids {
|
||||
addFluidPair(FluidType.SALT_SOLUTION, "borax_solution", waterBlend(0xEEEEEE, 0.5F));
|
||||
addFluidPair(FluidType.SALT_SOLUTION, "irradiated_borax_solution", waterBlend(0xFFD0A3, 0.5F));
|
||||
|
||||
addFluidPair(FluidType.CORIUM, "corium", 0x7F8178);
|
||||
addFluidPair(FluidType.CORIUM, "corium", 0x7C7C6F);
|
||||
|
||||
addFluidPair(FluidType.LIQUID, "ice", false, 0xAFF1FF, 1000, 250, 2000, 0);
|
||||
addFluidPair(FluidType.LIQUID, "slurry_ice", false, 0x7EAEB7, 950, 270, 4000, 0);
|
||||
|
@ -124,7 +124,7 @@ public class NCItems {
|
||||
compound = withName(new NCItemMeta(MetaEnums.CompoundType.class), "compound");
|
||||
|
||||
part = withName(new NCItemMeta(MetaEnums.PartType.class), "part");
|
||||
upgrade = withName(new NCItemMeta(MetaEnums.UpgradeType.class, NCInfo.upgradeInfo()), "upgrade");
|
||||
upgrade = withName(new ItemUpgrade(MetaEnums.UpgradeType.class, NCInfo.upgradeInfo()), "upgrade");
|
||||
|
||||
fission_dust = withName(new NCItemMeta(MetaEnums.FissionDustType.class), "fission_dust");
|
||||
|
||||
|
@ -1168,6 +1168,13 @@ public class JEIRecipeWrapper {
|
||||
return recipe.getTurbineExpansionLevel();
|
||||
}
|
||||
|
||||
protected double getTurbineSpinUpMultiplier() {
|
||||
if (recipe == null) {
|
||||
return 1D;
|
||||
}
|
||||
return recipe.getTurbineSpinUpMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
@ -1175,6 +1182,7 @@ public class JEIRecipeWrapper {
|
||||
if (mouseX >= 73 - 47 && mouseY >= 34 - 30 && mouseX < 73 - 47 + 37 + 1 && mouseY < 34 - 30 + 18 + 1) {
|
||||
tooltip.add(TextFormatting.LIGHT_PURPLE + ENERGY_DENSITY + " " + TextFormatting.WHITE + NCMath.decimalPlaces(getTurbinePowerPerMB(), 2) + " RF/mB");
|
||||
tooltip.add(TextFormatting.GRAY + EXPANSION + " " + TextFormatting.WHITE + NCMath.pcDecimalPlaces(getTurbineExpansionLevel(), 1));
|
||||
tooltip.add(TextFormatting.GREEN + SPIN_UP + " " + TextFormatting.WHITE + NCMath.pcDecimalPlaces(getTurbineSpinUpMultiplier(), 1));
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
@ -1182,6 +1190,7 @@ public class JEIRecipeWrapper {
|
||||
|
||||
private static final String ENERGY_DENSITY = Lang.localise("jei.nuclearcraft.turbine_energy_density");
|
||||
private static final String EXPANSION = Lang.localise("jei.nuclearcraft.turbine_expansion");
|
||||
private static final String SPIN_UP = Lang.localise("jei.nuclearcraft.turbine_spin_up_multiplier");
|
||||
}
|
||||
|
||||
public static class RadiationScrubber extends JEIBasicRecipeWrapper {
|
||||
|
37
src/main/java/nc/item/ItemUpgrade.java
Normal file
@ -0,0 +1,37 @@
|
||||
package nc.item;
|
||||
|
||||
import nc.enumm.MetaEnums.UpgradeType;
|
||||
import nc.init.NCItems;
|
||||
import nc.util.StackHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class ItemUpgrade extends NCItemMeta<UpgradeType> {
|
||||
|
||||
public ItemUpgrade(Class<UpgradeType> enumm, TextFormatting infoColor, String[]... tooltips) {
|
||||
super(enumm, infoColor, tooltips);
|
||||
}
|
||||
|
||||
public ItemUpgrade(Class<UpgradeType> enumm, String[]... tooltips) {
|
||||
super(enumm, tooltips);
|
||||
}
|
||||
|
||||
// Allow upgrades to be right-clicked into machines
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) {
|
||||
return stack.getItem() == NCItems.upgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack) {
|
||||
if (stack.getItem() == NCItems.upgrade) {
|
||||
return values[StackHelper.getMetadata(stack)].getMaxStackSize();
|
||||
}
|
||||
else {
|
||||
return super.getItemStackLimit(stack);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,16 +5,13 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import nc.enumm.IMetaEnum;
|
||||
import nc.init.NCItems;
|
||||
import nc.util.*;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.*;
|
||||
|
||||
public class NCItemMeta<T extends Enum<T> & IStringSerializable & IMetaEnum> extends Item implements IInfoItem {
|
||||
@ -78,10 +75,4 @@ public class NCItemMeta<T extends Enum<T> & IStringSerializable & IMetaEnum> ext
|
||||
protected ActionResult<ItemStack> actionResult(boolean success, ItemStack stack) {
|
||||
return new ActionResult<>(success ? EnumActionResult.SUCCESS : EnumActionResult.FAIL, stack);
|
||||
}
|
||||
|
||||
// Allow upgrades to be right-clicked into machines
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) {
|
||||
return stack.getItem() == NCItems.upgrade;
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ import java.util.Map.Entry;
|
||||
import it.unimi.dsi.fastutil.longs.*;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import nc.Global;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.multiblock.tile.*;
|
||||
import nc.network.PacketHandler;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
import nc.tile.fluid.ITileFluid;
|
||||
import nc.tile.internal.energy.EnergyStorage;
|
||||
import nc.tile.internal.fluid.Tank;
|
||||
@ -37,8 +37,7 @@ public abstract class Multiblock<T extends ITileMultiblockPart, PACKET extends M
|
||||
// Multiblock stuff - do not mess with
|
||||
public final World WORLD;
|
||||
|
||||
// Disassembled -> Assembled; Assembled -> Disassembled OR Paused; Paused ->
|
||||
// Assembled
|
||||
// Disassembled -> Assembled; Assembled -> Disassembled OR Paused; Paused -> Assembled
|
||||
public enum AssemblyState {
|
||||
Disassembled,
|
||||
Assembled,
|
||||
@ -66,7 +65,7 @@ public abstract class Multiblock<T extends ITileMultiblockPart, PACKET extends M
|
||||
/** Set whenever we validate the multiblock */
|
||||
private MultiblockValidationError lastValidationError;
|
||||
|
||||
protected boolean debugMode;
|
||||
private boolean debugMode;
|
||||
|
||||
protected Set<EntityPlayer> playersToUpdate;
|
||||
|
||||
@ -1029,7 +1028,7 @@ public abstract class Multiblock<T extends ITileMultiblockPart, PACKET extends M
|
||||
* On the server, this will mark the for a data-update, so that nearby clients will receive an updated description packet from the server after a short time. The block's chunk will also be marked dirty and the block's chunk will be saved to disk the next time chunks are saved.
|
||||
*
|
||||
* On the client, this will mark the block for a rendering update. */
|
||||
protected void markReferenceCoordForUpdate() {
|
||||
public void markReferenceCoordForUpdate() {
|
||||
|
||||
BlockPos rc = this.getReferenceCoord();
|
||||
|
||||
@ -1046,7 +1045,7 @@ public abstract class Multiblock<T extends ITileMultiblockPart, PACKET extends M
|
||||
* On the client, does nothing.
|
||||
*
|
||||
* @see Multiblock#markReferenceCoordForUpdate() */
|
||||
protected void markReferenceCoordDirty() {
|
||||
public void markReferenceCoordDirty() {
|
||||
if (WORLD == null || WORLD.isRemote) {
|
||||
return;
|
||||
}
|
||||
@ -1086,7 +1085,7 @@ public abstract class Multiblock<T extends ITileMultiblockPart, PACKET extends M
|
||||
return;
|
||||
}
|
||||
for (EntityPlayer player : playersToUpdate) {
|
||||
PacketHandler.instance.sendTo(getUpdatePacket(), (EntityPlayerMP) player);
|
||||
PacketHandler.instance.sendTo(packet, (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1098,15 +1097,18 @@ public abstract class Multiblock<T extends ITileMultiblockPart, PACKET extends M
|
||||
if (packet == null) {
|
||||
return;
|
||||
}
|
||||
PacketHandler.instance.sendTo(getUpdatePacket(), (EntityPlayerMP) player);
|
||||
PacketHandler.instance.sendTo(packet, (EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
public void sendUpdateToAllPlayers() {
|
||||
if (WORLD.isRemote) {
|
||||
return;
|
||||
}
|
||||
PACKET packet = getUpdatePacket();
|
||||
if (packet == null) {
|
||||
return;
|
||||
}
|
||||
PacketHandler.instance.sendToAll(getUpdatePacket());
|
||||
PacketHandler.instance.sendToAll(packet);
|
||||
}
|
||||
|
||||
// Multiblock Parts
|
||||
|
@ -10,12 +10,12 @@ import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.salt.MoltenSaltFissionLogic;
|
||||
import nc.multiblock.fission.solid.SolidFuelFissionLogic;
|
||||
import nc.multiblock.heatExchanger.*;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.multiblock.tile.*;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.multiblock.tile.manager.*;
|
||||
import nc.multiblock.tile.port.*;
|
||||
import nc.multiblock.turbine.*;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
import nc.tile.ITileFiltered;
|
||||
import nc.tile.internal.energy.EnergyStorage;
|
||||
import nc.tile.internal.fluid.Tank;
|
||||
@ -249,8 +249,7 @@ public abstract class MultiblockLogic<MULTIBLOCK extends Multiblock<T, PACKET> &
|
||||
public static void init() {
|
||||
try {
|
||||
FissionReactor.LOGIC_MAP.put("", FissionReactorLogic.class.getConstructor(FissionReactorLogic.class));
|
||||
// FissionReactor.LOGIC_MAP.put("pebble_bed",
|
||||
// PebbleBedFissionLogic.class);
|
||||
// FissionReactor.LOGIC_MAP.put("pebble_bed", PebbleBedFissionLogic.class);
|
||||
FissionReactor.LOGIC_MAP.put("solid_fuel", SolidFuelFissionLogic.class.getConstructor(FissionReactorLogic.class));
|
||||
FissionReactor.LOGIC_MAP.put("molten_salt", MoltenSaltFissionLogic.class.getConstructor(FissionReactorLogic.class));
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package nc.multiblock;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.*;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
|
||||
public abstract class PartBunch<TYPE extends T, MULTIBLOCK extends Multiblock<T, PACKET>, T extends ITileMultiblockPart<MULTIBLOCK>, PACKET extends MultiblockUpdatePacket> {
|
||||
|
||||
|
165
src/main/java/nc/multiblock/advancement/CustomTrigger.java
Normal file
@ -0,0 +1,165 @@
|
||||
package nc.multiblock.advancement;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import nc.Global;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.AbstractCriterionInstance;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class CustomTrigger implements ICriterionTrigger<CustomTrigger.Instance> {
|
||||
private final ResourceLocation ID;
|
||||
private final Map<PlayerAdvancements, CustomTrigger.Listeners> listeners = Maps.<PlayerAdvancements, CustomTrigger.Listeners>newHashMap();
|
||||
|
||||
//entry for addons
|
||||
public CustomTrigger(String MOD_ID, String parString)
|
||||
{
|
||||
super();
|
||||
ID = new ResourceLocation(MOD_ID, parString);
|
||||
}
|
||||
|
||||
public CustomTrigger(String parString)
|
||||
{
|
||||
super();
|
||||
ID = new ResourceLocation(Global.MOD_ID, parString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener<CustomTrigger.Instance> listener)
|
||||
{
|
||||
CustomTrigger.Listeners customtrigger$listeners = this.listeners.get(playerAdvancementsIn);
|
||||
|
||||
if (customtrigger$listeners == null)
|
||||
{
|
||||
customtrigger$listeners = new CustomTrigger.Listeners(playerAdvancementsIn);
|
||||
this.listeners.put(playerAdvancementsIn, customtrigger$listeners);
|
||||
}
|
||||
|
||||
customtrigger$listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener<CustomTrigger.Instance> listener)
|
||||
{
|
||||
CustomTrigger.Listeners consumeitemtrigger$listeners = this.listeners.get(playerAdvancementsIn);
|
||||
|
||||
if (consumeitemtrigger$listeners != null)
|
||||
{
|
||||
consumeitemtrigger$listeners.remove(listener);
|
||||
|
||||
if (consumeitemtrigger$listeners.isEmpty())
|
||||
{
|
||||
this.listeners.remove(playerAdvancementsIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners(PlayerAdvancements playerAdvancementsIn)
|
||||
{
|
||||
this.listeners.remove(playerAdvancementsIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomTrigger.Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) {
|
||||
return new CustomTrigger.Instance(getId());
|
||||
}
|
||||
|
||||
public static class Instance extends AbstractCriterionInstance
|
||||
{
|
||||
|
||||
/**
|
||||
* Instantiates a new instance.
|
||||
*/
|
||||
public Instance(ResourceLocation parRL)
|
||||
{
|
||||
super(parRL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean test()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void trigger(EntityPlayerMP player) {
|
||||
CustomTrigger.Listeners enterblocktrigger$listeners = this.listeners.get(player.getAdvancements());
|
||||
|
||||
if (enterblocktrigger$listeners != null)
|
||||
{
|
||||
enterblocktrigger$listeners.trigger();
|
||||
}
|
||||
}
|
||||
|
||||
static class Listeners
|
||||
{
|
||||
private final PlayerAdvancements playerAdvancements;
|
||||
private final Set<ICriterionTrigger.Listener<CustomTrigger.Instance>> listeners = Sets.<ICriterionTrigger.Listener<CustomTrigger.Instance>>newHashSet();
|
||||
|
||||
public Listeners(PlayerAdvancements playerAdvancementsIn)
|
||||
{
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.listeners.isEmpty();
|
||||
}
|
||||
|
||||
public void add(ICriterionTrigger.Listener<CustomTrigger.Instance> listener)
|
||||
{
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
public void remove(ICriterionTrigger.Listener<CustomTrigger.Instance> listener)
|
||||
{
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void trigger()
|
||||
{
|
||||
List<ICriterionTrigger.Listener<CustomTrigger.Instance>> list = null;
|
||||
|
||||
for (ICriterionTrigger.Listener<CustomTrigger.Instance> listener : this.listeners)
|
||||
{
|
||||
if (((CustomTrigger.Instance)listener.getCriterionInstance()).test())
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists.<ICriterionTrigger.Listener<CustomTrigger.Instance>>newArrayList();
|
||||
}
|
||||
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (ICriterionTrigger.Listener<CustomTrigger.Instance> listener1 : list)
|
||||
{
|
||||
listener1.grantCriterion(this.playerAdvancements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package nc.multiblock.advancement;
|
||||
|
||||
import nc.Global;
|
||||
|
||||
public class MultiblockTrigger
|
||||
{
|
||||
public static final CustomTrigger FISSION_REACTOR_FORMED = new CustomTrigger("fission_reactor_complete");
|
||||
public static final CustomTrigger MOLTENSALT_REACTOR_FORMED = new CustomTrigger("moltensalt_reactor_complete");
|
||||
public static final CustomTrigger HEATEXCHANGER_FORMED = new CustomTrigger("heatexchanger_complete");
|
||||
public static final CustomTrigger TURBINE_FORMED = new CustomTrigger("turbine_complete");
|
||||
|
||||
public static final CustomTrigger[] TRIGGER_ARRAY = new CustomTrigger[] {
|
||||
FISSION_REACTOR_FORMED,
|
||||
MOLTENSALT_REACTOR_FORMED,
|
||||
HEATEXCHANGER_FORMED,
|
||||
TURBINE_FORMED
|
||||
};
|
||||
}
|
@ -5,9 +5,9 @@ import javax.annotation.Nonnull;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import nc.multiblock.Multiblock;
|
||||
import nc.multiblock.battery.tile.TileBattery;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
import nc.tile.internal.energy.EnergyStorage;
|
||||
import nc.util.NCMath;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -4,7 +4,10 @@ import javax.annotation.Nullable;
|
||||
|
||||
import nc.Global;
|
||||
import nc.block.NCBlock;
|
||||
import nc.block.tile.INBTDrop;
|
||||
import nc.multiblock.*;
|
||||
import nc.multiblock.advancement.MultiblockTrigger;
|
||||
import nc.multiblock.fission.solid.tile.TileSolidFissionController;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.render.BlockHighlightTracker;
|
||||
import nc.tile.fluid.ITileFluid;
|
||||
@ -12,6 +15,7 @@ import nc.util.*;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.*;
|
||||
@ -66,13 +70,20 @@ public abstract class BlockMultiblockPart extends NCBlock implements ITileEntity
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(new TextComponentString(Lang.localise(Global.MOD_ID + ".multiblock_validation.no_controller")));
|
||||
return true;
|
||||
}
|
||||
//Not the best place. But leaving this as an example
|
||||
controller.checkIfMachineIsWhole();
|
||||
if (!world.isRemote && controller.isAssembled()) {
|
||||
MultiblockTrigger.FISSION_REACTOR_FORMED.trigger((EntityPlayerMP)player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prioritiseGui;
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ package nc.multiblock.cuboidal;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import nc.multiblock.*;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
import nc.util.NCMath;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -2,7 +2,7 @@ package nc.multiblock.fission;
|
||||
|
||||
import nc.multiblock.PartBunch;
|
||||
import nc.multiblock.fission.tile.IFissionPart;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
|
||||
public abstract class FissionPartBunch<T extends IFissionPart> extends PartBunch<T, FissionReactor, IFissionPart, FissionUpdatePacket> {
|
||||
|
||||
|
@ -180,12 +180,21 @@ public abstract class FissionPlacement {
|
||||
if (split[i].contains("wall") || split[i].contains("casing")) {
|
||||
rule = "casing";
|
||||
}
|
||||
else if (split[i].contains("conductor")) {
|
||||
rule = "conductor";
|
||||
}
|
||||
else if (split[i].contains("moderator")) {
|
||||
rule = "moderator";
|
||||
}
|
||||
else if (split[i].contains("reflector")) {
|
||||
rule = "reflector";
|
||||
}
|
||||
else if (split[i].contains("irradiator")) {
|
||||
rule = "irradiator";
|
||||
}
|
||||
else if (split[i].contains("shield")) {
|
||||
rule = "shield";
|
||||
}
|
||||
else if (split[i].contains("cell")) {
|
||||
rule = "cell";
|
||||
}
|
||||
@ -218,12 +227,21 @@ public abstract class FissionPlacement {
|
||||
if (rule.equals("casing")) {
|
||||
return new AdjacentCasing(amount, countType, adjType);
|
||||
}
|
||||
else if (rule.equals("conductor")) {
|
||||
return new AdjacentConductor(amount, countType, adjType);
|
||||
}
|
||||
else if (rule.equals("moderator")) {
|
||||
return new AdjacentModerator(amount, countType, adjType);
|
||||
}
|
||||
else if (rule.equals("reflector")) {
|
||||
return new AdjacentReflector(amount, countType, adjType);
|
||||
}
|
||||
else if (rule.equals("irradiator")) {
|
||||
return new AdjacentIrradiator(amount, countType, adjType);
|
||||
}
|
||||
else if (rule.equals("shield")) {
|
||||
return new AdjacentShield(amount, countType, adjType);
|
||||
}
|
||||
else if (rule.equals("cell")) {
|
||||
return new AdjacentCell(amount, countType, adjType);
|
||||
}
|
||||
@ -262,6 +280,18 @@ public abstract class FissionPlacement {
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdjacentConductor extends Adjacent {
|
||||
|
||||
public AdjacentConductor(int amount, CountType countType, AdjacencyType adjType) {
|
||||
super("conductor", amount, countType, adjType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean satisfied(IFissionPart part, EnumFacing dir) {
|
||||
return isConductor(part.getMultiblock(), part.getTilePos().offset(dir));
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdjacentModerator extends Adjacent {
|
||||
|
||||
public AdjacentModerator(int amount, CountType countType, AdjacencyType adjType) {
|
||||
@ -286,6 +316,30 @@ public abstract class FissionPlacement {
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdjacentIrradiator extends Adjacent {
|
||||
|
||||
public AdjacentIrradiator(int amount, CountType countType, AdjacencyType adjType) {
|
||||
super("irradiator", amount, countType, adjType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean satisfied(IFissionPart part, EnumFacing dir) {
|
||||
return isFunctionalIrradiator(part.getMultiblock(), part.getTilePos().offset(dir));
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdjacentShield extends Adjacent {
|
||||
|
||||
public AdjacentShield(int amount, CountType countType, AdjacencyType adjType) {
|
||||
super("shield", amount, countType, adjType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean satisfied(IFissionPart part, EnumFacing dir) {
|
||||
return isFunctionalShield(part.getMultiblock(), part.getTilePos().offset(dir));
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdjacentCell extends Adjacent {
|
||||
|
||||
public AdjacentCell(int amount, CountType countType, AdjacencyType adjType) {
|
||||
@ -363,6 +417,10 @@ public abstract class FissionPlacement {
|
||||
return tile instanceof TileFissionPart && ((TileFissionPart) tile).getPartPositionType().isGoodForWall();
|
||||
}
|
||||
|
||||
public static boolean isConductor(FissionReactor reactor, BlockPos pos) {
|
||||
return reactor.getPartMap(TileFissionConductor.class).get(pos.toLong()) != null;
|
||||
}
|
||||
|
||||
public static boolean isActiveModerator(FissionReactor reactor, BlockPos pos) {
|
||||
IFissionComponent component = reactor.getPartMap(IFissionComponent.class).get(pos.toLong());
|
||||
return (component != null && component.isActiveModerator()) || (reactor.activeModeratorCache.contains(pos.toLong()) && RecipeHelper.blockRecipe(NCRecipes.fission_moderator, reactor.WORLD, pos) != null);
|
||||
@ -372,24 +430,34 @@ public abstract class FissionPlacement {
|
||||
return reactor.activeReflectorCache.contains(pos.toLong()) && RecipeHelper.blockRecipe(NCRecipes.fission_reflector, reactor.WORLD, pos) != null;
|
||||
}
|
||||
|
||||
public static boolean isFunctionalIrradiator(FissionReactor reactor, BlockPos pos) {
|
||||
TileFissionIrradiator irradiator = reactor.getPartMap(TileFissionIrradiator.class).get(pos.toLong());
|
||||
return irradiator != null && irradiator.isFunctional();
|
||||
}
|
||||
|
||||
public static boolean isFunctionalShield(FissionReactor reactor, BlockPos pos) {
|
||||
TileFissionShield shield = reactor.getPartMap(TileFissionShield.class).get(pos.toLong());
|
||||
return shield != null && shield.isFunctional();
|
||||
}
|
||||
|
||||
public static boolean isFunctionalCell(FissionReactor reactor, BlockPos pos) {
|
||||
TileSolidFissionCell cell = reactor.getPartMap(TileSolidFissionCell.class).get(pos.toLong());
|
||||
return cell == null ? false : cell.isFunctional();
|
||||
return cell != null && cell.isFunctional();
|
||||
}
|
||||
|
||||
public static boolean isValidSink(FissionReactor reactor, BlockPos pos, String sinkType) {
|
||||
TileSolidFissionSink sink = reactor.getPartMap(TileSolidFissionSink.class).get(pos.toLong());
|
||||
return sink == null ? false : sink.isFunctional() && (sinkType.equals("any") || sink.sinkType.equals(sinkType));
|
||||
return sink != null && sink.isFunctional() && (sinkType.equals("any") || sink.sinkType.equals(sinkType));
|
||||
}
|
||||
|
||||
public static boolean isFunctionalVessel(FissionReactor reactor, BlockPos pos) {
|
||||
TileSaltFissionVessel vessel = reactor.getPartMap(TileSaltFissionVessel.class).get(pos.toLong());
|
||||
return vessel == null ? false : vessel.isFunctional();
|
||||
return vessel != null && vessel.isFunctional();
|
||||
}
|
||||
|
||||
public static boolean isValidHeater(FissionReactor reactor, BlockPos pos, String heaterType) {
|
||||
TileSaltFissionHeater heater = reactor.getPartMap(TileSaltFissionHeater.class).get(pos.toLong());
|
||||
return heater == null ? false : heater.isFunctional() && (heaterType.equals("any") || heater.heaterType.equals(heaterType));
|
||||
return heater != null && heater.isFunctional() && (heaterType.equals("any") || heater.heaterType.equals(heaterType));
|
||||
}
|
||||
|
||||
// Default Tooltip Builder
|
||||
|
@ -11,9 +11,9 @@ import nc.Global;
|
||||
import nc.multiblock.*;
|
||||
import nc.multiblock.cuboidal.CuboidalMultiblock;
|
||||
import nc.multiblock.fission.tile.*;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -19,8 +19,8 @@ import nc.multiblock.fission.tile.IFissionFuelComponent.ModeratorBlockInfo;
|
||||
import nc.multiblock.fission.tile.TileFissionSource.PrimingTargetInfo;
|
||||
import nc.multiblock.fission.tile.manager.TileFissionShieldManager;
|
||||
import nc.multiblock.fission.tile.port.TileFissionIrradiatorPort;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
import nc.tile.internal.energy.EnergyStorage;
|
||||
import nc.tile.internal.fluid.Tank;
|
||||
import nc.tile.internal.heat.HeatBuffer;
|
||||
|
@ -18,8 +18,8 @@ import nc.multiblock.fission.salt.tile.*;
|
||||
import nc.multiblock.fission.solid.tile.*;
|
||||
import nc.multiblock.fission.tile.*;
|
||||
import nc.multiblock.fission.tile.port.*;
|
||||
import nc.multiblock.network.*;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.*;
|
||||
import nc.recipe.*;
|
||||
import nc.recipe.ingredient.IFluidIngredient;
|
||||
import nc.tile.internal.fluid.Tank;
|
||||
|
@ -21,7 +21,7 @@ import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.*;
|
||||
import nc.multiblock.fission.tile.IFissionFuelComponent.ModeratorBlockInfo;
|
||||
import nc.multiblock.fission.tile.port.*;
|
||||
import nc.multiblock.network.SaltFissionHeaterUpdatePacket;
|
||||
import nc.network.multiblock.SaltFissionHeaterUpdatePacket;
|
||||
import nc.recipe.*;
|
||||
import nc.recipe.ingredient.IFluidIngredient;
|
||||
import nc.tile.ITileGui;
|
||||
|
@ -20,7 +20,7 @@ import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.salt.SaltFissionVesselBunch;
|
||||
import nc.multiblock.fission.tile.*;
|
||||
import nc.multiblock.fission.tile.port.*;
|
||||
import nc.multiblock.network.SaltFissionVesselUpdatePacket;
|
||||
import nc.network.multiblock.SaltFissionVesselUpdatePacket;
|
||||
import nc.radiation.RadiationHelper;
|
||||
import nc.recipe.*;
|
||||
import nc.recipe.ingredient.IFluidIngredient;
|
||||
|
@ -18,8 +18,8 @@ import nc.multiblock.fission.salt.tile.*;
|
||||
import nc.multiblock.fission.solid.tile.TileSolidFissionCell;
|
||||
import nc.multiblock.fission.tile.*;
|
||||
import nc.multiblock.fission.tile.port.TileFissionCellPort;
|
||||
import nc.multiblock.network.*;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.*;
|
||||
import nc.recipe.*;
|
||||
import nc.recipe.ingredient.IFluidIngredient;
|
||||
import nc.tile.internal.fluid.Tank;
|
||||
|
@ -18,7 +18,7 @@ import nc.multiblock.cuboidal.CuboidalPartPositionType;
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.*;
|
||||
import nc.multiblock.fission.tile.port.*;
|
||||
import nc.multiblock.network.SolidFissionCellUpdatePacket;
|
||||
import nc.network.multiblock.SolidFissionCellUpdatePacket;
|
||||
import nc.radiation.RadiationHelper;
|
||||
import nc.recipe.*;
|
||||
import nc.recipe.ingredient.IItemIngredient;
|
||||
@ -867,13 +867,13 @@ public class TileSolidFissionCell extends TileFissionPart implements ITileFilter
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeInventory(NBTTagCompound nbt) {
|
||||
NBTHelper.saveAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
NBTHelper.writeAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInventory(NBTTagCompound nbt) {
|
||||
NBTHelper.loadAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
NBTHelper.readAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
}
|
||||
|
||||
// Capability
|
||||
|
@ -1,8 +1,8 @@
|
||||
package nc.multiblock.fission.tile;
|
||||
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.ITileLogicMultiblockPart;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
|
||||
public interface IFissionPart extends ITileLogicMultiblockPart<FissionReactor, FissionReactorLogic, IFissionPart, FissionUpdatePacket> {
|
||||
|
||||
|
@ -135,6 +135,124 @@ public class TileFissionComputerPort extends TileFissionPart implements SimpleCo
|
||||
/* @Callback
|
||||
*
|
||||
* @Optional.Method(modid = "opencomputers") public Object[] deactivate(Context context, Arguments args) { if (isMultiblockAssembled()) { getMultiblock().computerActivated = false; getMultiblock().setIsReactorOn(); } return new Object[] {}; } */
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getNumberOfFuelCells(Context context, Arguments args) {
|
||||
return new Object[] {isMultiblockAssembled() ? getMultiblock().getPartMap(TileSolidFissionCell.class).size() : 0};
|
||||
}
|
||||
|
||||
|
||||
//TODO review OC fission cell method
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getFuelCellStats(Context context, Arguments args) {
|
||||
List<Map> fuelCellData = new ArrayList<Map>();
|
||||
if(isMultiblockAssembled()) {
|
||||
Collection<TileSolidFissionCell> fuelCells = getMultiblock().getPartMap(TileSolidFissionCell.class).values();
|
||||
for(TileSolidFissionCell fuelCell: fuelCells) {
|
||||
Map<String, Object> entry = new HashMap<String, Object>();
|
||||
entry.put("fuel", new Object[] {fuelCell.getInventoryStacks().get(0).getCount(),fuelCell.getInventoryStacks().get(0).getDisplayName()});
|
||||
entry.put("heating", fuelCell.getEffectiveHeating());
|
||||
entry.put("heat_mult", fuelCell.getHeatMultiplier());
|
||||
entry.put("is_processing", fuelCell.isProcessing);
|
||||
entry.put("time", fuelCell.time);
|
||||
entry.put("base_process_time", fuelCell.baseProcessTime);
|
||||
entry.put("claster_heat_capacity", fuelCell.getCluster().heatBuffer.getHeatCapacity());
|
||||
entry.put("claster_heat_stored", fuelCell.getCluster().heatBuffer.getHeatStored());
|
||||
entry.put("cooling", fuelCell.getCluster().cooling);
|
||||
entry.put("base_process_criticality", fuelCell.baseProcessCriticality);
|
||||
entry.put("base_process_efficiency", fuelCell.baseProcessEfficiency);
|
||||
entry.put("is_primed", fuelCell.isPrimed());
|
||||
entry.put("flux_efficiency", fuelCell.getEfficiency());
|
||||
fuelCellData.add(entry);
|
||||
}
|
||||
}
|
||||
return new Object[] {fuelCellData.toArray()};
|
||||
}
|
||||
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getNumberOfShields(Context context, Arguments args) {
|
||||
return new Object[] {isMultiblockAssembled() ? getMultiblock().getPartMap(TileFissionShield.class).size() : 0};
|
||||
}
|
||||
|
||||
|
||||
//TODO review updateShieldState method
|
||||
@Callback(doc = "function(int shield_id, bool state) Activate/Deactivate shield")
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] updateShieldState(Context context, Arguments args) {
|
||||
boolean activated = false;
|
||||
if(isMultiblockAssembled()) {
|
||||
if(getMultiblock().getPartMap(TileFissionShield.class).size() == 0) {
|
||||
return new Object[] {"No shields found."};
|
||||
}
|
||||
int shieldId = args.checkInteger(0)-1;
|
||||
boolean shieldState = (boolean) args.checkBoolean(1);
|
||||
if(shieldId > getMultiblock().getPartMap(TileFissionShield.class).size()) {
|
||||
return new Object[] {"Wrong shield ID."};
|
||||
}
|
||||
//for some reasons getMultiblock().getPartMap(TileFissionShield.class).get(shieldId) is not giving us a shield instance, so using this workaround
|
||||
Collection<TileFissionShield> shields = getMultiblock().getPartMap(TileFissionShield.class).values();
|
||||
int i = 0;
|
||||
for(TileFissionShield shield : shields) {
|
||||
if(shieldId == i) {
|
||||
shield.isShielding = shieldState;
|
||||
shield.setActivity(shield.isShielding);
|
||||
shield.resetStats();
|
||||
getLogic().onShieldUpdated(shield);
|
||||
markDirty();
|
||||
getMultiblock().refreshFlag = true;
|
||||
activated = shield.isShielding;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new Object[] {activated};
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getNumberOfClusters(Context context, Arguments args) {
|
||||
int clusters = 0;
|
||||
if(isMultiblockAssembled()) {
|
||||
clusters = getMultiblock().clusterCount;
|
||||
}
|
||||
return new Object[] {clusters};
|
||||
}
|
||||
|
||||
|
||||
//TODO review method getClusterComponents
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getClusterComponents(Context context, Arguments args) {
|
||||
List<Map> componentsData = new ArrayList<Map>();
|
||||
if(isMultiblockAssembled()) {
|
||||
if(getMultiblock().clusterCount == 0) {
|
||||
return new Object[] {"No clusters found."};
|
||||
}
|
||||
int clusterId = args.checkInteger(0)-1;
|
||||
if(clusterId > getMultiblock().clusterCount) {
|
||||
return new Object[] {"Wrong cluster ID."};
|
||||
}
|
||||
FissionCluster cluster = getMultiblock().getClusterMap().get(clusterId);
|
||||
for (Object comp : cluster.getComponentMap().values()) {
|
||||
Map<String, Object> component = new HashMap<String, Object>();
|
||||
if (comp instanceof TileSolidFissionSink) {
|
||||
TileSolidFissionSink sink = (TileSolidFissionSink) comp;
|
||||
component.put(sink.ruleID, new Object[]{sink.getHeatStored(), sink.coolingRate});
|
||||
}
|
||||
if (comp instanceof TileFissionShield) {
|
||||
TileFissionShield shield = (TileFissionShield) comp;
|
||||
component.put(shield.getClass().getName().toString(), new Object[]{shield.flux, shield.heatPerFlux, shield.isShielding, shield.heat, shield.efficiency});
|
||||
}
|
||||
componentsData.add(component);
|
||||
}
|
||||
}
|
||||
return new Object[] {componentsData.toArray()};
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
|
@ -16,7 +16,7 @@ import nc.Global;
|
||||
import nc.multiblock.cuboidal.CuboidalPartPositionType;
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.port.*;
|
||||
import nc.multiblock.network.FissionIrradiatorUpdatePacket;
|
||||
import nc.network.multiblock.FissionIrradiatorUpdatePacket;
|
||||
import nc.recipe.*;
|
||||
import nc.recipe.ingredient.IItemIngredient;
|
||||
import nc.tile.ITileGui;
|
||||
@ -684,13 +684,13 @@ public class TileFissionIrradiator extends TileFissionPart implements ITileFilte
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeInventory(NBTTagCompound nbt) {
|
||||
NBTHelper.saveAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
NBTHelper.writeAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInventory(NBTTagCompound nbt) {
|
||||
NBTHelper.loadAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
NBTHelper.readAllItems(nbt, inventoryStacks, filterStacks, consumedStacks);
|
||||
}
|
||||
|
||||
// Capability
|
||||
|
@ -2,8 +2,8 @@ package nc.multiblock.fission.tile.manager;
|
||||
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.IFissionPart;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.manager.ITileManager;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
|
||||
public interface IFissionManager<MANAGER extends IFissionManager<MANAGER, LISTENER>, LISTENER extends IFissionManagerListener<MANAGER, LISTENER>> extends ITileManager<FissionReactor, FissionReactorLogic, IFissionPart, MANAGER, LISTENER, FissionUpdatePacket> {
|
||||
|
||||
|
@ -2,8 +2,8 @@ package nc.multiblock.fission.tile.manager;
|
||||
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.IFissionPart;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.manager.ITileManagerListener;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
|
||||
public interface IFissionManagerListener<MANAGER extends IFissionManager<MANAGER, LISTENER>, LISTENER extends IFissionManagerListener<MANAGER, LISTENER>> extends ITileManagerListener<FissionReactor, FissionReactorLogic, IFissionPart, MANAGER, LISTENER, FissionUpdatePacket> {
|
||||
|
||||
|
@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.longs.*;
|
||||
import nc.multiblock.cuboidal.CuboidalPartPositionType;
|
||||
import nc.multiblock.fission.FissionReactor;
|
||||
import nc.multiblock.fission.tile.TileFissionPart;
|
||||
import nc.util.NBTHelper;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@ -64,25 +65,14 @@ public abstract class TileFissionManager<MANAGER extends TileFissionManager<MANA
|
||||
@Override
|
||||
public NBTTagCompound writeAll(NBTTagCompound nbt) {
|
||||
super.writeAll(nbt);
|
||||
|
||||
int count = 0;
|
||||
for (long posLong : listenerPosSet) {
|
||||
nbt.setLong("listenerPos" + count, posLong);
|
||||
count++;
|
||||
}
|
||||
|
||||
NBTHelper.writeLongCollection(nbt, listenerPosSet, "listenerPosSet");
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAll(NBTTagCompound nbt) {
|
||||
super.readAll(nbt);
|
||||
|
||||
for (String key : nbt.getKeySet()) {
|
||||
if (key.startsWith("listenerPos")) {
|
||||
listenerPosSet.add(nbt.getLong(key));
|
||||
}
|
||||
}
|
||||
NBTHelper.readLongCollection(nbt, listenerPosSet, "listenerPosSet");
|
||||
}
|
||||
|
||||
// Capability
|
||||
|
@ -2,8 +2,8 @@ package nc.multiblock.fission.tile.port;
|
||||
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.IFissionPart;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.port.ITilePort;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
|
||||
public interface IFissionPort<PORT extends IFissionPort<PORT, TARGET>, TARGET extends IFissionPortTarget<PORT, TARGET>> extends ITilePort<FissionReactor, FissionReactorLogic, IFissionPart, PORT, TARGET, FissionUpdatePacket> {
|
||||
|
||||
|
@ -2,8 +2,8 @@ package nc.multiblock.fission.tile.port;
|
||||
|
||||
import nc.multiblock.fission.*;
|
||||
import nc.multiblock.fission.tile.IFissionPart;
|
||||
import nc.multiblock.network.FissionUpdatePacket;
|
||||
import nc.multiblock.tile.port.ITilePortTarget;
|
||||
import nc.network.multiblock.FissionUpdatePacket;
|
||||
|
||||
public interface IFissionPortTarget<PORT extends IFissionPort<PORT, TARGET>, TARGET extends IFissionPortTarget<PORT, TARGET>> extends ITilePortTarget<FissionReactor, FissionReactorLogic, IFissionPart, PORT, TARGET, FissionUpdatePacket> {
|
||||
|
||||
|
@ -6,7 +6,7 @@ import java.util.Set;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import nc.multiblock.fission.solid.tile.TileSolidFissionCell;
|
||||
import nc.multiblock.network.FissionCellPortUpdatePacket;
|
||||
import nc.network.multiblock.FissionCellPortUpdatePacket;
|
||||
import nc.recipe.NCRecipes;
|
||||
import nc.tile.ITileGui;
|
||||
import net.minecraft.client.util.RecipeItemHelper;
|
||||
|
@ -10,7 +10,7 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import nc.multiblock.fission.salt.tile.TileSaltFissionHeater;
|
||||
import nc.multiblock.network.FissionHeaterPortUpdatePacket;
|
||||
import nc.network.multiblock.FissionHeaterPortUpdatePacket;
|
||||
import nc.recipe.NCRecipes;
|
||||
import nc.tile.ITileGui;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -6,7 +6,7 @@ import java.util.Set;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import nc.multiblock.fission.tile.TileFissionIrradiator;
|
||||
import nc.multiblock.network.FissionIrradiatorPortUpdatePacket;
|
||||
import nc.network.multiblock.FissionIrradiatorPortUpdatePacket;
|
||||
import nc.recipe.NCRecipes;
|
||||
import nc.tile.ITileGui;
|
||||
import net.minecraft.client.util.RecipeItemHelper;
|
||||
|
@ -257,7 +257,7 @@ public abstract class TileFissionItemPort<PORT extends TileFissionItemPort<PORT,
|
||||
}
|
||||
}
|
||||
|
||||
NBTHelper.saveAllItems(nbt, inventoryStacks, filterStacks);
|
||||
NBTHelper.writeAllItems(nbt, inventoryStacks, filterStacks);
|
||||
|
||||
for (int i = 0; i < inventoryStacks.size(); i++) {
|
||||
if (!inventoryStacks.get(i).isEmpty()) {
|
||||
@ -270,7 +270,7 @@ public abstract class TileFissionItemPort<PORT extends TileFissionItemPort<PORT,
|
||||
|
||||
@Override
|
||||
public void readInventory(NBTTagCompound nbt) {
|
||||
NBTHelper.loadAllItems(nbt, inventoryStacks, filterStacks);
|
||||
NBTHelper.readAllItems(nbt, inventoryStacks, filterStacks);
|
||||
|
||||
for (int i = 0; i < inventoryStacks.size(); i++) {
|
||||
if (!inventoryStacks.get(i).isEmpty()) {
|
||||
|
@ -7,7 +7,7 @@ import java.util.Set;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import nc.multiblock.fission.salt.tile.TileSaltFissionVessel;
|
||||
import nc.multiblock.network.FissionVesselPortUpdatePacket;
|
||||
import nc.network.multiblock.FissionVesselPortUpdatePacket;
|
||||
import nc.recipe.NCRecipes;
|
||||
import nc.tile.ITileGui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -6,8 +6,8 @@ import nc.Global;
|
||||
import nc.multiblock.gui.element.MultiblockButton;
|
||||
import nc.multiblock.heatExchanger.HeatExchanger;
|
||||
import nc.multiblock.heatExchanger.tile.IHeatExchangerController;
|
||||
import nc.multiblock.network.ClearAllMaterialPacket;
|
||||
import nc.network.PacketHandler;
|
||||
import nc.network.multiblock.ClearAllMaterialPacket;
|
||||
import nc.util.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -7,8 +7,8 @@ import nc.multiblock.fission.FissionReactor;
|
||||
import nc.multiblock.fission.salt.MoltenSaltFissionLogic;
|
||||
import nc.multiblock.fission.tile.IFissionController;
|
||||
import nc.multiblock.gui.element.MultiblockButton;
|
||||
import nc.multiblock.network.ClearAllMaterialPacket;
|
||||
import nc.network.PacketHandler;
|
||||
import nc.network.multiblock.ClearAllMaterialPacket;
|
||||
import nc.util.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -73,7 +73,7 @@ public class GuiSaltFissionController extends GuiLogicMultiblock<FissionReactor,
|
||||
String speedMult = Lang.localise("gui.nc.container.salt_fission_controller.heating_speed_multiplier") + " " + NCMath.pcDecimalPlaces(logic.meanHeatingSpeedMultiplier, 1);
|
||||
fontRenderer.drawString(speedMult, xSize / 2 - width(speedMult) / 2, 46, fontColor);
|
||||
|
||||
String sparsity = NCUtil.isModifierKeyDown() ? Lang.localise("gui.nc.container.fission_controller.useful_parts") + " " + multiblock.usefulPartCount + "/" + multiblock.getInteriorVolume() : Lang.localise("gui.nc.container.fission_controller.sparsity") + " " + NCMath.decimalPlaces(multiblock.sparsityEfficiencyMult, 1);
|
||||
String sparsity = NCUtil.isModifierKeyDown() ? Lang.localise("gui.nc.container.fission_controller.useful_parts") + " " + multiblock.usefulPartCount + "/" + multiblock.getInteriorVolume() : Lang.localise("gui.nc.container.fission_controller.sparsity") + " " + NCMath.pcDecimalPlaces(multiblock.sparsityEfficiencyMult, 1);
|
||||
fontRenderer.drawString(sparsity, xSize / 2 - width(sparsity) / 2, 58, fontColor);
|
||||
|
||||
String temperature = Lang.localise("gui.nc.container.fission_controller.temperature") + " " + (NCUtil.isModifierKeyDown() ? logic.getTemperature() - 273 + " C" : logic.getTemperature() + " K");
|
||||
|
@ -7,8 +7,8 @@ import nc.multiblock.fission.FissionReactor;
|
||||
import nc.multiblock.fission.solid.SolidFuelFissionLogic;
|
||||
import nc.multiblock.fission.tile.IFissionController;
|
||||
import nc.multiblock.gui.element.MultiblockButton;
|
||||
import nc.multiblock.network.ClearAllMaterialPacket;
|
||||
import nc.network.PacketHandler;
|
||||
import nc.network.multiblock.ClearAllMaterialPacket;
|
||||
import nc.util.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -2,10 +2,10 @@ package nc.multiblock.gui;
|
||||
|
||||
import nc.Global;
|
||||
import nc.multiblock.gui.element.MultiblockButton;
|
||||
import nc.multiblock.network.ClearAllMaterialPacket;
|
||||
import nc.multiblock.turbine.Turbine;
|
||||
import nc.multiblock.turbine.tile.*;
|
||||
import nc.network.PacketHandler;
|
||||
import nc.network.multiblock.ClearAllMaterialPacket;
|
||||
import nc.util.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -11,9 +11,9 @@ import nc.Global;
|
||||
import nc.multiblock.*;
|
||||
import nc.multiblock.cuboidal.CuboidalMultiblock;
|
||||
import nc.multiblock.heatExchanger.tile.*;
|
||||
import nc.multiblock.network.HeatExchangerUpdatePacket;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.HeatExchangerUpdatePacket;
|
||||
import nc.util.NCMath;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -9,8 +9,8 @@ import com.google.common.collect.Lists;
|
||||
import nc.Global;
|
||||
import nc.multiblock.*;
|
||||
import nc.multiblock.heatExchanger.tile.*;
|
||||
import nc.multiblock.network.HeatExchangerUpdatePacket;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.HeatExchangerUpdatePacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class HeatExchangerLogic extends MultiblockLogic<HeatExchanger, HeatExchangerLogic, IHeatExchangerPart, HeatExchangerUpdatePacket> {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package nc.multiblock.heatExchanger.tile;
|
||||
|
||||
import nc.multiblock.heatExchanger.*;
|
||||
import nc.multiblock.network.HeatExchangerUpdatePacket;
|
||||
import nc.multiblock.tile.ITileLogicMultiblockPart;
|
||||
import nc.network.multiblock.HeatExchangerUpdatePacket;
|
||||
|
||||
public interface IHeatExchangerPart extends ITileLogicMultiblockPart<HeatExchanger, HeatExchangerLogic, IHeatExchangerPart, HeatExchangerUpdatePacket> {
|
||||
|
||||
|
@ -1,111 +0,0 @@
|
||||
package nc.multiblock.network;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import nc.multiblock.Multiblock.AssemblyState;
|
||||
import nc.multiblock.turbine.Turbine;
|
||||
import nc.multiblock.turbine.tile.TileTurbineController;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class TurbineFormPacket extends MultiblockUpdatePacket {
|
||||
|
||||
public AssemblyState assemblyState;
|
||||
public EnumFacing flowDir;
|
||||
public boolean nullData;
|
||||
public BlockPos[] bladePosArray;
|
||||
public Vector3f[] renderPosArray;
|
||||
public float[] bladeAngleArray;
|
||||
|
||||
public TurbineFormPacket() {
|
||||
messageValid = false;
|
||||
}
|
||||
|
||||
public TurbineFormPacket(BlockPos pos, AssemblyState assemblyState, EnumFacing flowDir, BlockPos[] bladePosArray, Vector3f[] renderPosArray, float[] bladeAngleArray) {
|
||||
this.pos = pos;
|
||||
this.assemblyState = assemblyState;
|
||||
this.flowDir = flowDir;
|
||||
|
||||
nullData = flowDir == null || bladePosArray == null || renderPosArray == null || bladeAngleArray == null;
|
||||
if (!nullData && ArrayUtils.contains(bladePosArray, null)) {
|
||||
nullData = true;
|
||||
}
|
||||
if (!nullData && ArrayUtils.contains(renderPosArray, null)) {
|
||||
nullData = true;
|
||||
}
|
||||
|
||||
this.bladePosArray = bladePosArray;
|
||||
this.renderPosArray = renderPosArray;
|
||||
this.bladeAngleArray = bladeAngleArray;
|
||||
|
||||
messageValid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readMessage(ByteBuf buf) {
|
||||
pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
byte b = buf.readByte();
|
||||
assemblyState = b == 0 ? AssemblyState.Assembled : (b == 1 ? AssemblyState.Disassembled : AssemblyState.Paused);
|
||||
|
||||
nullData = buf.readBoolean();
|
||||
if (!nullData) {
|
||||
flowDir = EnumFacing.byIndex(buf.readInt());
|
||||
bladePosArray = new BlockPos[buf.readInt()];
|
||||
for (int i = 0; i < bladePosArray.length; i++) {
|
||||
bladePosArray[i] = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
}
|
||||
renderPosArray = new Vector3f[buf.readInt()];
|
||||
for (int i = 0; i < renderPosArray.length; i++) {
|
||||
renderPosArray[i] = new Vector3f(buf.readFloat(), buf.readFloat(), buf.readFloat());
|
||||
}
|
||||
bladeAngleArray = new float[buf.readInt()];
|
||||
for (int i = 0; i < bladeAngleArray.length; i++) {
|
||||
bladeAngleArray[i] = buf.readFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMessage(ByteBuf buf) {
|
||||
buf.writeInt(pos.getX());
|
||||
buf.writeInt(pos.getY());
|
||||
buf.writeInt(pos.getZ());
|
||||
buf.writeByte(assemblyState == AssemblyState.Assembled ? 0 : (assemblyState == AssemblyState.Disassembled ? 1 : 2));
|
||||
|
||||
buf.writeBoolean(nullData);
|
||||
if (!nullData) {
|
||||
buf.writeInt(flowDir.getIndex());
|
||||
buf.writeInt(bladePosArray.length);
|
||||
for (BlockPos rotorPos : bladePosArray) {
|
||||
buf.writeInt(rotorPos.getX());
|
||||
buf.writeInt(rotorPos.getY());
|
||||
buf.writeInt(rotorPos.getZ());
|
||||
}
|
||||
buf.writeInt(renderPosArray.length);
|
||||
for (Vector3f planePos : renderPosArray) {
|
||||
buf.writeFloat(planePos.x);
|
||||
buf.writeFloat(planePos.y);
|
||||
buf.writeFloat(planePos.z);
|
||||
}
|
||||
buf.writeInt(bladeAngleArray.length);
|
||||
for (float bladeAngle : bladeAngleArray) {
|
||||
buf.writeFloat(bladeAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler extends MultiblockUpdatePacket.Handler<TurbineFormPacket, Turbine, TileTurbineController> {
|
||||
|
||||
public Handler() {
|
||||
super(TileTurbineController.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPacket(TurbineFormPacket message, Turbine multiblock) {
|
||||
multiblock.onFormPacket(message);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package nc.multiblock.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import nc.multiblock.turbine.Turbine;
|
||||
import nc.multiblock.turbine.tile.ITurbinePart;
|
||||
import nc.network.PacketHandler;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.*;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class TurbineResendFormPacket implements IMessage {
|
||||
|
||||
boolean messageValid;
|
||||
|
||||
BlockPos pos;
|
||||
|
||||
public TurbineResendFormPacket() {
|
||||
messageValid = false;
|
||||
}
|
||||
|
||||
public TurbineResendFormPacket(BlockPos pos) {
|
||||
this.pos = pos;
|
||||
messageValid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
try {
|
||||
pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
messageValid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
if (!messageValid) {
|
||||
return;
|
||||
}
|
||||
buf.writeInt(pos.getX());
|
||||
buf.writeInt(pos.getY());
|
||||
buf.writeInt(pos.getZ());
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TurbineResendFormPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TurbineResendFormPacket message, MessageContext ctx) {
|
||||
if (!message.messageValid && ctx.side != Side.SERVER) {
|
||||
return null;
|
||||
}
|
||||
FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> processMessage(message, ctx));
|
||||
return null;
|
||||
}
|
||||
|
||||
void processMessage(TurbineResendFormPacket message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
TileEntity tile = player.getServerWorld().getTileEntity(message.pos);
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
if (tile instanceof ITurbinePart) {
|
||||
Turbine turbine = ((ITurbinePart) tile).getMultiblock();
|
||||
if (turbine != null) {
|
||||
PacketHandler.instance.sendTo(turbine.getFormPacket(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,13 +13,12 @@ import it.unimi.dsi.fastutil.ints.*;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import nc.Global;
|
||||
import nc.multiblock.Multiblock;
|
||||
import nc.multiblock.network.*;
|
||||
import nc.multiblock.qComputer.tile.*;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.PacketHandler;
|
||||
import nc.network.multiblock.*;
|
||||
import nc.util.*;
|
||||
import nc.util.Vector;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -35,7 +34,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
|
||||
protected TileQuantumComputerController controller;
|
||||
|
||||
protected Vector state, cache = null;
|
||||
protected ComplexVector state, cache = null;
|
||||
|
||||
protected Queue<QuantumGate> queue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@ -47,7 +46,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
for (Class<? extends IQuantumComputerPart> clazz : PART_CLASSES) {
|
||||
partSuperMap.equip(clazz);
|
||||
}
|
||||
state = new Vector(1);
|
||||
state = new ComplexVector(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,7 +239,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
|
||||
@Override
|
||||
public void syncDataFrom(NBTTagCompound data, SyncReason syncReason) {
|
||||
cache = Vector.readFromNBT(data, "state");
|
||||
cache = ComplexVector.readFromNBT(data, "state");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -301,7 +300,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
|
||||
protected void checkStateDim(int dim) {
|
||||
if (state.dim != dim && qubitCount() <= quantum_max_qubits_live) {
|
||||
state = new Vector(dim);
|
||||
state = new ComplexVector(dim);
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,16 +403,16 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Matrix fallback() {
|
||||
protected ComplexMatrix fallback() {
|
||||
return id(qubitCount());
|
||||
}
|
||||
|
||||
protected void gate(Matrix m) {
|
||||
protected void gate(ComplexMatrix m) {
|
||||
checkStateDim(dim(qubitCount()));
|
||||
state.map(m);
|
||||
}
|
||||
|
||||
protected Matrix single(Matrix m, IntList n) {
|
||||
protected ComplexMatrix single(ComplexMatrix m, IntList n) {
|
||||
int q = qubitCount();
|
||||
if (n.isEmpty()) {
|
||||
return id(q);
|
||||
@ -423,12 +422,12 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
return fallback();
|
||||
}
|
||||
|
||||
Matrix[] t = new Matrix[q];
|
||||
ComplexMatrix[] t = new ComplexMatrix[q];
|
||||
for (int j = 0; j < q; j++) {
|
||||
t[j] = n.contains(j) ? m : I;
|
||||
}
|
||||
|
||||
return Matrix.tensorProduct(t);
|
||||
return ComplexMatrix.tensorProduct(t);
|
||||
}
|
||||
|
||||
public void x(IntSet n) {
|
||||
@ -520,7 +519,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
}
|
||||
}
|
||||
|
||||
public Matrix control(Matrix g, IntList c, IntList t) {
|
||||
public ComplexMatrix control(ComplexMatrix g, IntList c, IntList t) {
|
||||
int q = qubitCount();
|
||||
if (t.isEmpty()) {
|
||||
return id(q);
|
||||
@ -541,8 +540,8 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
}
|
||||
|
||||
int s = dim(c.size()), k;
|
||||
Matrix m = new Matrix(dim(q));
|
||||
Matrix[] e = new Matrix[q];
|
||||
ComplexMatrix m = new ComplexMatrix(dim(q));
|
||||
ComplexMatrix[] e = new ComplexMatrix[q];
|
||||
boolean b;
|
||||
for (int i = 0; i < s; i++) {
|
||||
k = 0;
|
||||
@ -553,7 +552,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
++k;
|
||||
}
|
||||
}
|
||||
m.add(Matrix.tensorProduct(e));
|
||||
m.add(ComplexMatrix.tensorProduct(e));
|
||||
}
|
||||
|
||||
return m;
|
||||
@ -636,8 +635,8 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
int s = dim(c.size()), q = qubitCount(), dim = dim(q), k, i, j, w;
|
||||
checkStateDim(dim);
|
||||
|
||||
Matrix m = new Matrix(dim), p;
|
||||
Matrix[] e = new Matrix[q];
|
||||
ComplexMatrix m = new ComplexMatrix(dim), p;
|
||||
ComplexMatrix[] e = new ComplexMatrix[q];
|
||||
boolean b;
|
||||
for (int u = 0; u < s; u++) {
|
||||
k = 0;
|
||||
@ -648,7 +647,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
|
||||
++k;
|
||||
}
|
||||
}
|
||||
p = Matrix.tensorProduct(e);
|
||||
p = ComplexMatrix.tensorProduct(e);
|
||||
if (u == s - 1) {
|
||||
for (int l = 0; l < dim; l++) {
|
||||
for (int a = 0; a < i_.size(); a++) {
|
||||
|
@ -2,8 +2,6 @@ package nc.multiblock.qComputer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import nc.util.*;
|
||||
@ -40,15 +38,22 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract QuantumGate withoutControl();
|
||||
|
||||
public abstract Matrix singleQubitOperation();
|
||||
public abstract ComplexMatrix singleQubitOperation();
|
||||
|
||||
/** Adds the required decomposition of this gate to the list. */
|
||||
public abstract void addRequiredDecomposition(List<QuantumGate> decomposition);
|
||||
|
||||
public abstract List<String> getCode(int type);
|
||||
|
||||
public static interface IControl {
|
||||
|
||||
public IntSet c();
|
||||
|
||||
public IntSet t();
|
||||
|
||||
public QuantumGate withoutControl();
|
||||
}
|
||||
|
||||
public static class Measurement extends QuantumGate<Measurement> {
|
||||
|
||||
private static final String[] ID = new String[] {"measure"};
|
||||
@ -88,12 +93,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuantumGate withoutControl() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -160,12 +160,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuantumGate withoutControl() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -224,11 +219,6 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
|
||||
public abstract Basic newMerged(IntSet c, IntSet t);
|
||||
|
||||
@Override
|
||||
public QuantumGate withoutControl() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequiredDecomposition(List<QuantumGate> decomposition) {
|
||||
if (!n.isEmpty()) {
|
||||
@ -289,7 +279,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return X;
|
||||
}
|
||||
|
||||
@ -333,7 +323,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Y;
|
||||
}
|
||||
|
||||
@ -377,7 +367,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Z;
|
||||
}
|
||||
|
||||
@ -421,7 +411,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return H;
|
||||
}
|
||||
|
||||
@ -465,7 +455,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return S;
|
||||
}
|
||||
|
||||
@ -509,7 +499,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Sdg;
|
||||
}
|
||||
|
||||
@ -553,7 +543,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return T;
|
||||
}
|
||||
|
||||
@ -597,7 +587,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Tdg;
|
||||
}
|
||||
|
||||
@ -665,11 +655,6 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuantumGate withoutControl() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequiredDecomposition(List<QuantumGate> decomposition) {
|
||||
if (!n.isEmpty()) {
|
||||
@ -711,7 +696,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return p(angle);
|
||||
}
|
||||
|
||||
@ -755,7 +740,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return rx(angle);
|
||||
}
|
||||
|
||||
@ -799,7 +784,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return ry(angle);
|
||||
}
|
||||
|
||||
@ -843,7 +828,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return rz(angle);
|
||||
}
|
||||
|
||||
@ -858,7 +843,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class Control extends Basic {
|
||||
public static abstract class Control extends Basic implements IControl {
|
||||
|
||||
protected final IntSet c;
|
||||
|
||||
@ -867,6 +852,16 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSet c() {
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSet t() {
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Basic mergeInernal(Basic next) {
|
||||
if (!matchingControl(c, next instanceof Control ? ((Control) next).c : S0)) {
|
||||
@ -884,9 +879,6 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return newMerged(c, n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract QuantumGate withoutControl();
|
||||
|
||||
@Override
|
||||
public void addRequiredDecomposition(List<QuantumGate> decomposition) {
|
||||
if (c.size() == 1) {
|
||||
@ -895,7 +887,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
}
|
||||
else {
|
||||
addZYZDecomposition(this, c, n, decomposition);
|
||||
addZYZDecomposition(this, decomposition);
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,7 +979,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return X;
|
||||
}
|
||||
|
||||
@ -1070,7 +1062,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
}
|
||||
else {
|
||||
addZYZDecomposition(this, c, n, decomposition);
|
||||
addZYZDecomposition(this, decomposition);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1172,7 +1164,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Y;
|
||||
}
|
||||
|
||||
@ -1221,7 +1213,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Z;
|
||||
}
|
||||
|
||||
@ -1270,7 +1262,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return H;
|
||||
}
|
||||
|
||||
@ -1319,7 +1311,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return S;
|
||||
}
|
||||
|
||||
@ -1368,7 +1360,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Sdg;
|
||||
}
|
||||
|
||||
@ -1417,7 +1409,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return T;
|
||||
}
|
||||
|
||||
@ -1466,7 +1458,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return Tdg;
|
||||
}
|
||||
|
||||
@ -1481,7 +1473,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class ControlAngle extends BasicAngle {
|
||||
public static abstract class ControlAngle extends BasicAngle implements IControl {
|
||||
|
||||
protected final IntSet c;
|
||||
|
||||
@ -1490,6 +1482,16 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSet c() {
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSet t() {
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicAngle mergeInernal(BasicAngle next) {
|
||||
if (angle != next.angle) {
|
||||
@ -1511,9 +1513,6 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return newMerged(angle, c, n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract QuantumGate withoutControl();
|
||||
|
||||
@Override
|
||||
public void addRequiredDecomposition(List<QuantumGate> decomposition) {
|
||||
if (c.size() == 1) {
|
||||
@ -1522,7 +1521,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
}
|
||||
else {
|
||||
addZYZDecomposition(this, c, n, decomposition);
|
||||
addZYZDecomposition(this, decomposition);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1614,7 +1613,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return p(angle);
|
||||
}
|
||||
|
||||
@ -1663,7 +1662,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return rx(angle);
|
||||
}
|
||||
|
||||
@ -1712,7 +1711,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return ry(angle);
|
||||
}
|
||||
|
||||
@ -1761,7 +1760,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return rz(angle);
|
||||
}
|
||||
|
||||
@ -1818,12 +1817,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuantumGate withoutControl() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix singleQubitOperation() {
|
||||
public ComplexMatrix singleQubitOperation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1855,7 +1849,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ControlSwap extends Swap {
|
||||
public static class ControlSwap extends Swap implements IControl {
|
||||
|
||||
private static final String[] ID = new String[] {"cswap", "swap"};
|
||||
|
||||
@ -1866,6 +1860,16 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSet c() {
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSet t() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ID[0];
|
||||
@ -1894,58 +1898,62 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO
|
||||
public void addRequiredDecomposition(List<QuantumGate> decomposition) {
|
||||
if (!i.isEmpty() && i.size() == j.size()) {
|
||||
decomposition.add(this);
|
||||
if (c.isEmpty()) {
|
||||
decomposition.add(withoutControl());
|
||||
}
|
||||
else if (c.size() == 1) {
|
||||
decomposition.add(this);
|
||||
}
|
||||
else {
|
||||
for (int k = 0; k < i.size(); k++) {
|
||||
IntSet c_1 = set(i.getInt(k));
|
||||
c_1.addAll(c);
|
||||
CX cx_1 = new CX(qc, c_1, set(j.getInt(k)));
|
||||
|
||||
IntSet c_2 = set(j.getInt(k));
|
||||
c_2.addAll(c);
|
||||
CX cx_2 = new CX(qc, c_2, set(i.getInt(k)));
|
||||
|
||||
addZYZDecomposition(cx_1, decomposition);
|
||||
addZYZDecomposition(cx_2, decomposition);
|
||||
addZYZDecomposition(cx_1, decomposition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO
|
||||
public List<String> getCode(int type) {
|
||||
if (c.isEmpty()) {
|
||||
return super.getCode(type);
|
||||
return withoutControl().getCode(type);
|
||||
}
|
||||
|
||||
List<String> out = new ArrayList<>();
|
||||
|
||||
if (i.size() == j.size() && !i.isEmpty()) {
|
||||
IntList l = list(c);
|
||||
if (type == 0) {
|
||||
if (l.size() == 1) {
|
||||
if (!i.isEmpty() && i.size() == j.size()) {
|
||||
if (c.size() == 1) {
|
||||
IntList l = list(c);
|
||||
if (type == 0) {
|
||||
String s = "cswap q[" + l.getInt(0) + "], ";
|
||||
for (int k = 0; k < i.size(); k++) {
|
||||
out.add(s + "q[" + i.getInt(k) + "], q[" + j.getInt(k) + "];");
|
||||
}
|
||||
}
|
||||
else {
|
||||
out.add("// multi-controlled swap decomposition not yet implemented!");
|
||||
String s = Strings.repeat("c", l.size()) + "swap ";
|
||||
for (int k = 0; k < l.size(); k++) {
|
||||
s += ("q[" + l.getInt(k) + "], ");
|
||||
}
|
||||
for (int k = 0; k < i.size(); k++) {
|
||||
out.add(s + "q[" + i.getInt(k) + "], q[" + j.getInt(k) + "];");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == 1) {
|
||||
if (l.size() == 1) {
|
||||
else if (type == 1) {
|
||||
String s = "qc.cswap(" + l.getInt(0) + ", ";
|
||||
for (int k = 0; k < i.size(); k++) {
|
||||
out.add(s + i.getInt(k) + ", " + j.getInt(k) + ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
out.add("# multi-controlled swap decomposition not yet implemented!");
|
||||
String s = "qc." + Strings.repeat("c", l.size()) + "swap(";
|
||||
for (int k = 0; k < l.size(); k++) {
|
||||
s += (l.getInt(k) + ", ");
|
||||
}
|
||||
for (int k = 0; k < i.size(); k++) {
|
||||
out.add(s + i.getInt(k) + ", " + j.getInt(k) + ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<QuantumGate> decomposition = new ArrayList<>();
|
||||
addRequiredDecomposition(decomposition);
|
||||
|
||||
for (QuantumGate gate : decomposition) {
|
||||
out.addAll(gate.getCode(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1962,8 +1970,8 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return 1 << n;
|
||||
}
|
||||
|
||||
public static Matrix id(int n) {
|
||||
return new Matrix(dim(n)).id();
|
||||
public static ComplexMatrix id(int n) {
|
||||
return new ComplexMatrix(dim(n)).id();
|
||||
}
|
||||
|
||||
public static IntSet set(int... n) {
|
||||
@ -1988,49 +1996,49 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return Arrays.toString(list.toIntArray());
|
||||
}
|
||||
|
||||
public static final Matrix I = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 1D, 0D}});
|
||||
public static final ComplexMatrix I = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 1D, 0D}});
|
||||
|
||||
public static final Matrix X = new Matrix(new double[][] {new double[] {0D, 0D, 1D, 0D}, new double[] {1D, 0D, 0D, 0D}});
|
||||
public static final ComplexMatrix X = new ComplexMatrix(new double[][] {new double[] {0D, 0D, 1D, 0D}, new double[] {1D, 0D, 0D, 0D}});
|
||||
|
||||
public static final Matrix Y = new Matrix(new double[][] {new double[] {0D, 0D, 0D, -1D}, new double[] {0D, 1D, 0D, 0D}});
|
||||
public static final ComplexMatrix Y = new ComplexMatrix(new double[][] {new double[] {0D, 0D, 0D, -1D}, new double[] {0D, 1D, 0D, 0D}});
|
||||
|
||||
public static final Matrix Z = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, -1D, 0D}});
|
||||
public static final ComplexMatrix Z = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, -1D, 0D}});
|
||||
|
||||
public static final Matrix H = new Matrix(new double[][] {new double[] {1D, 0D, 1D, 0D}, new double[] {1D, 0D, -1D, 0D}}).multiply(NCMath.INV_SQRT2);
|
||||
public static final ComplexMatrix H = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 1D, 0D}, new double[] {1D, 0D, -1D, 0D}}).multiply(NCMath.INV_SQRT2);
|
||||
|
||||
public static final Matrix S = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, 1D}});
|
||||
public static final ComplexMatrix S = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, 1D}});
|
||||
|
||||
public static final Matrix Sdg = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, -1D}});
|
||||
public static final ComplexMatrix Sdg = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, -1D}});
|
||||
|
||||
public static final Matrix T = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, NCMath.INV_SQRT2, NCMath.INV_SQRT2}});
|
||||
public static final ComplexMatrix T = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, NCMath.INV_SQRT2, NCMath.INV_SQRT2}});
|
||||
|
||||
public static final Matrix Tdg = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, NCMath.INV_SQRT2, -NCMath.INV_SQRT2}});
|
||||
public static final ComplexMatrix Tdg = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, NCMath.INV_SQRT2, -NCMath.INV_SQRT2}});
|
||||
|
||||
/** Angle in degrees! */
|
||||
public static Matrix p(double angle) {
|
||||
public static ComplexMatrix p(double angle) {
|
||||
double[] p = Complex.phase_d(angle);
|
||||
return new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, p[0], p[1]}});
|
||||
return new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, p[0], p[1]}});
|
||||
}
|
||||
|
||||
/** Angle in degrees! */
|
||||
public static Matrix rx(double angle) {
|
||||
return new Matrix(new double[][] {new double[] {NCMath.cos_d(angle / 2D), 0D, 0D, -NCMath.sin_d(angle / 2D)}, new double[] {0D, -NCMath.sin_d(angle / 2D), NCMath.cos_d(angle / 2D), 0D}});
|
||||
public static ComplexMatrix rx(double angle) {
|
||||
return new ComplexMatrix(new double[][] {new double[] {NCMath.cos_d(angle / 2D), 0D, 0D, -NCMath.sin_d(angle / 2D)}, new double[] {0D, -NCMath.sin_d(angle / 2D), NCMath.cos_d(angle / 2D), 0D}});
|
||||
}
|
||||
|
||||
/** Angle in degrees! */
|
||||
public static Matrix ry(double angle) {
|
||||
return new Matrix(new double[][] {new double[] {NCMath.cos_d(angle / 2D), 0D, -NCMath.sin_d(angle / 2D), 0D}, new double[] {NCMath.sin_d(angle / 2D), 0D, NCMath.cos_d(angle / 2D), 0D}});
|
||||
public static ComplexMatrix ry(double angle) {
|
||||
return new ComplexMatrix(new double[][] {new double[] {NCMath.cos_d(angle / 2D), 0D, -NCMath.sin_d(angle / 2D), 0D}, new double[] {NCMath.sin_d(angle / 2D), 0D, NCMath.cos_d(angle / 2D), 0D}});
|
||||
}
|
||||
|
||||
/** Angle in degrees! */
|
||||
public static Matrix rz(double angle) {
|
||||
public static ComplexMatrix rz(double angle) {
|
||||
double[] a = Complex.phase_d(-angle / 2D), b = Complex.phase_d(angle / 2D);
|
||||
return new Matrix(new double[][] {new double[] {a[0], a[1], 0D, 0D}, new double[] {0D, 0D, b[0], b[1]}});
|
||||
return new ComplexMatrix(new double[][] {new double[] {a[0], a[1], 0D, 0D}, new double[] {0D, 0D, b[0], b[1]}});
|
||||
}
|
||||
|
||||
public static final Matrix P_0 = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, 0D}});
|
||||
public static final ComplexMatrix P_0 = new ComplexMatrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, 0D}});
|
||||
|
||||
public static final Matrix P_1 = new Matrix(new double[][] {new double[] {0D, 0D, 0D, 0D}, new double[] {0D, 0D, 1D, 0D}});
|
||||
public static final ComplexMatrix P_1 = new ComplexMatrix(new double[][] {new double[] {0D, 0D, 0D, 0D}, new double[] {0D, 0D, 1D, 0D}});
|
||||
|
||||
// Helper Methods
|
||||
|
||||
@ -2055,7 +2063,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final Object2ObjectMap<Matrix, double[]> ZYZ_DECOMPOSITION_ANGLES_CACHE = new Object2ObjectOpenHashMap<>();
|
||||
public static final Object2ObjectMap<ComplexMatrix, double[]> ZYZ_DECOMPOSITION_ANGLES_CACHE = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
ZYZ_DECOMPOSITION_ANGLES_CACHE.put(I, new double[] {0D, 0D, 0D, 0D});
|
||||
@ -2071,7 +2079,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
|
||||
/** Returns the phase and Euler angles for the gate in the ZYZ basis in degrees.
|
||||
* Translated from https://qiskit.org/documentation/_modules/qiskit/quantum_info/synthesis/one_qubit_decompose.html#OneQubitEulerDecomposer */
|
||||
public static double[] getZYZDecompositionAngles(Matrix matrix) {
|
||||
public static double[] getZYZDecompositionAngles(ComplexMatrix matrix) {
|
||||
if (ZYZ_DECOMPOSITION_ANGLES_CACHE.containsKey(matrix)) {
|
||||
return ZYZ_DECOMPOSITION_ANGLES_CACHE.get(matrix);
|
||||
}
|
||||
@ -2079,7 +2087,7 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
double[] det = matrix.det();
|
||||
double[] phase = Complex.invSqrt(det[0], det[1]);
|
||||
|
||||
Matrix m = matrix.copy();
|
||||
ComplexMatrix m = matrix.copy();
|
||||
m.multiply(phase[0], phase[1]);
|
||||
|
||||
double ppl = 2D * Complex.arg(m.re[1][1], m.im[1][1]);
|
||||
@ -2092,10 +2100,12 @@ public abstract class QuantumGate<GATE extends QuantumGate> {
|
||||
* Combines results from:
|
||||
* https://arxiv.org/abs/quant-ph/9503016,
|
||||
* Nielsen, Michael A.; Chuang, Isaac L. Quantum Computation and Quantum Information */
|
||||
public static void addZYZDecomposition(QuantumGate gate, IntSet c, IntSet t, List<QuantumGate> decomposition) {
|
||||
public static <GATE extends QuantumGate<?> & IControl> void addZYZDecomposition(GATE gate, List<QuantumGate> decomposition) {
|
||||
IntSet t = gate.t();
|
||||
if (t.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
IntSet c = gate.c();
|
||||
|
||||
double[] azyz = getZYZDecompositionAngles(gate.singleQubitOperation());
|
||||
double alpha = azyz[0], beta = azyz[1], hgam = azyz[2] / 2D, hbpd = (azyz[1] + azyz[3]) / 2D, hdmb = (azyz[3] - azyz[1]) / 2D;
|
||||
|
@ -49,7 +49,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setTarget") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, n, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, n, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(n))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -64,14 +64,14 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
@Override
|
||||
public NBTTagCompound writeAll(NBTTagCompound nbt) {
|
||||
super.writeAll(nbt);
|
||||
NBTHelper.saveIntCollection(nbt, n, "nQubits");
|
||||
NBTHelper.writeIntCollection(nbt, n, "nQubits");
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAll(NBTTagCompound nbt) {
|
||||
super.readAll(nbt);
|
||||
NBTHelper.loadIntCollection(nbt, n, "nQubits");
|
||||
NBTHelper.readIntCollection(nbt, n, "nQubits");
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setTarget") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, n, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, n, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(n))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -323,7 +323,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setControl") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, c, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, c, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", intSetToString(c))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -343,7 +343,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setTarget") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, t, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, t, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(t))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -358,16 +358,16 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
@Override
|
||||
public NBTTagCompound writeAll(NBTTagCompound nbt) {
|
||||
super.writeAll(nbt);
|
||||
NBTHelper.saveIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.saveIntCollection(nbt, t, "tQubits");
|
||||
NBTHelper.writeIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.writeIntCollection(nbt, t, "tQubits");
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAll(NBTTagCompound nbt) {
|
||||
super.readAll(nbt);
|
||||
NBTHelper.loadIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.loadIntCollection(nbt, t, "tQubits");
|
||||
NBTHelper.readIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.readIntCollection(nbt, t, "tQubits");
|
||||
}
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setControl") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, c, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, c, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", intSetToString(c))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -535,7 +535,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setTarget") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, t, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, t, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(t))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -644,7 +644,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setFirst") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, i, "qubitIDList");
|
||||
NBTHelper.readIntCollection(nbt, i, "qubitIDList");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_first_swap_list", intListToString(i))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -664,7 +664,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setSecond") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, j, "qubitIDList");
|
||||
NBTHelper.readIntCollection(nbt, j, "qubitIDList");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list", intListToString(j))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -679,16 +679,16 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
@Override
|
||||
public NBTTagCompound writeAll(NBTTagCompound nbt) {
|
||||
super.writeAll(nbt);
|
||||
NBTHelper.saveIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.saveIntCollection(nbt, j, "jQubits");
|
||||
NBTHelper.writeIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.writeIntCollection(nbt, j, "jQubits");
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAll(NBTTagCompound nbt) {
|
||||
super.readAll(nbt);
|
||||
NBTHelper.loadIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.loadIntCollection(nbt, j, "jQubits");
|
||||
NBTHelper.readIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.readIntCollection(nbt, j, "jQubits");
|
||||
}
|
||||
}
|
||||
|
||||
@ -729,7 +729,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setControl") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, c, "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, c, "qubitIDSet");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", intSetToString(c))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -749,7 +749,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setFirst") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, i, "qubitIDList");
|
||||
NBTHelper.readIntCollection(nbt, i, "qubitIDList");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_first_swap_list", intListToString(i))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -769,7 +769,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
return true;
|
||||
}
|
||||
else if (toolMode.equals("setSecond") && !player.isSneaking()) {
|
||||
NBTHelper.loadIntCollection(nbt, j, "qubitIDList");
|
||||
NBTHelper.readIntCollection(nbt, j, "qubitIDList");
|
||||
player.sendMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list", intListToString(j))));
|
||||
nbt.setString("qubitMode", "");
|
||||
nbt.setString("gateMode", "");
|
||||
@ -784,18 +784,18 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
@Override
|
||||
public NBTTagCompound writeAll(NBTTagCompound nbt) {
|
||||
super.writeAll(nbt);
|
||||
NBTHelper.saveIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.saveIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.saveIntCollection(nbt, j, "jQubits");
|
||||
NBTHelper.writeIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.writeIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.writeIntCollection(nbt, j, "jQubits");
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAll(NBTTagCompound nbt) {
|
||||
super.readAll(nbt);
|
||||
NBTHelper.loadIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.loadIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.loadIntCollection(nbt, j, "jQubits");
|
||||
NBTHelper.readIntCollection(nbt, c, "cQubits");
|
||||
NBTHelper.readIntCollection(nbt, i, "iQubits");
|
||||
NBTHelper.readIntCollection(nbt, j, "jQubits");
|
||||
}
|
||||
}
|
||||
|
||||
@ -841,8 +841,8 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
|
||||
|
||||
public static void clearMultitoolGateInfo(NBTTagCompound nbt) {
|
||||
nbt.setDouble("gateAngle", 0D);
|
||||
NBTHelper.saveIntCollection(nbt, new IntOpenHashSet(), "qubitIDSet");
|
||||
NBTHelper.saveIntCollection(nbt, new IntArrayList(), "qubitIDList");
|
||||
NBTHelper.writeIntCollection(nbt, new IntOpenHashSet(), "qubitIDSet");
|
||||
NBTHelper.writeIntCollection(nbt, new IntArrayList(), "qubitIDList");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,8 +1,8 @@
|
||||
package nc.multiblock.qComputer.tile;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import nc.multiblock.network.QuantumComputerQubitRenderPacket;
|
||||
import nc.multiblock.qComputer.*;
|
||||
import nc.network.multiblock.QuantumComputerQubitRenderPacket;
|
||||
import nc.util.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -58,12 +58,12 @@ public class TileQuantumComputerQubit extends TileQuantumComputerPart implements
|
||||
if (s || l) {
|
||||
IntCollection idColl = s ? new IntOpenHashSet() : new IntArrayList();
|
||||
if (s) {
|
||||
NBTHelper.loadIntCollection(nbt, idColl, "qubitIDSet");
|
||||
NBTHelper.saveIntCollection(nbt, new IntArrayList(), "qubitIDList");
|
||||
NBTHelper.readIntCollection(nbt, idColl, "qubitIDSet");
|
||||
NBTHelper.writeIntCollection(nbt, new IntArrayList(), "qubitIDList");
|
||||
}
|
||||
else {
|
||||
NBTHelper.loadIntCollection(nbt, idColl, "qubitIDList");
|
||||
NBTHelper.saveIntCollection(nbt, new IntOpenHashSet(), "qubitIDSet");
|
||||
NBTHelper.readIntCollection(nbt, idColl, "qubitIDList");
|
||||
NBTHelper.writeIntCollection(nbt, new IntOpenHashSet(), "qubitIDSet");
|
||||
}
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
@ -79,10 +79,10 @@ public class TileQuantumComputerQubit extends TileQuantumComputerPart implements
|
||||
}
|
||||
|
||||
if (s) {
|
||||
NBTHelper.saveIntCollection(nbt, idColl, "qubitIDSet");
|
||||
NBTHelper.writeIntCollection(nbt, idColl, "qubitIDSet");
|
||||
}
|
||||
else {
|
||||
NBTHelper.saveIntCollection(nbt, idColl, "qubitIDList");
|
||||
NBTHelper.writeIntCollection(nbt, idColl, "qubitIDList");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import nc.multiblock.Multiblock;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.multiblock.rtg.tile.TileRTG;
|
||||
import nc.multiblock.tile.ITileMultiblockPart;
|
||||
import nc.multiblock.tile.TileBeefAbstract.SyncReason;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
import nc.tile.internal.energy.EnergyStorage;
|
||||
import nc.util.NCMath;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nc.multiblock.tile;
|
||||
|
||||
import nc.multiblock.*;
|
||||
import nc.multiblock.network.MultiblockUpdatePacket;
|
||||
import nc.network.multiblock.MultiblockUpdatePacket;
|
||||
|
||||
public interface ITileLogicMultiblockPart<MULTIBLOCK extends Multiblock<T, PACKET> & ILogicMultiblock<LOGIC, T>, LOGIC extends MultiblockLogic<MULTIBLOCK, LOGIC, T, PACKET>, T extends ITileLogicMultiblockPart<MULTIBLOCK, LOGIC, T, PACKET>, PACKET extends MultiblockUpdatePacket> extends ITileMultiblockPart<MULTIBLOCK> {
|
||||
|
||||
|
@ -254,23 +254,34 @@ public abstract class TileBeefAbstract extends TileEntity implements ITile {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
return writeToNBT(new NBTTagCompound());
|
||||
NBTTagCompound data = super.writeToNBT(new NBTTagCompound());
|
||||
writeAll(data);
|
||||
syncDataTo(data, SyncReason.NetworkUpdate);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag(NBTTagCompound data) {
|
||||
super.handleUpdateTag(data);
|
||||
super.readFromNBT(data);
|
||||
readAll(data);
|
||||
syncDataFrom(data, SyncReason.NetworkUpdate);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
return new SPacketUpdateTileEntity(pos, getBlockMetadata(), writeToNBT(new NBTTagCompound()));
|
||||
NBTTagCompound data = super.writeToNBT(new NBTTagCompound());
|
||||
writeAll(data);
|
||||
syncDataTo(data, SyncReason.NetworkUpdate);
|
||||
return new SPacketUpdateTileEntity(pos, getBlockMetadata(), data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
NBTTagCompound data = packet.getNbtCompound();
|
||||
super.readFromNBT(data);
|
||||
readAll(data);
|
||||
syncDataFrom(data, SyncReason.NetworkUpdate);
|
||||
if (getBlockType() instanceof IDynamicState) {
|
||||
notifyBlockUpdate();
|
||||
}
|
||||
|