Compare commits

..

No commits in common. "3c69a887957b87ce006d6285f12b4bde596c530f" and "80961678c1a48a0226e32de5ccd90f5755c6fb8a" have entirely different histories.

85 changed files with 1242 additions and 5449 deletions

View File

@ -124,14 +124,6 @@ processResources {
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info' exclude 'mcmod.info'
} }
rename '(.+_at.cfg)', 'META-INF/$1'
}
jar {
manifest {
attributes 'FMLAT': 'nuclearcraft_at.cfg'
}
} }
task deobfJar(type: Jar) { task deobfJar(type: Jar) {

View File

@ -1,28 +1,6 @@
v2o.4.5
+ Added WIP OpenQASM code generation mode to quantum computers
* Fixed crash on placing Rock Crusher
+ Added French language file [thanks to Mravran and sanrom!]
* Updated Chinese language file [thanks to ghostbird03!]
+ Added configs for the volumes of various radiation-related sound effects
* Fixed Decay Hastener missing various recipes
* Hopefully fixed rare crash on forming multiblocks
- Removed many unused textures
+ Added totally ignorable stuff that's not worth worrying about to newly generated wasteland biomes
v2o.4.4
* Fixed crash on load with QMD installed
* Fixed crash on load without Patchouli installed
v2o.4.3 v2o.4.3
* Script addons no longer have to be manually unzipped + Script addons no longer have to be manually unzipped
+ Added logging of script addons being constructed + Added logging of script addons being constructed
* Modified turbine throughput leniency and power bonuses * Modified turbine throughput leniency and power bonuses

View File

@ -1,7 +1,7 @@
mc_version=1.12.2 mc_version=1.12.2
forge_version=14.23.5.2847 forge_version=14.23.5.2847
mapping_version=stable_39 mapping_version=stable_39
mod_version=2o.4.5 mod_version=2o.4.3
ic2_version=2.8.197-ex112 ic2_version=2.8.197-ex112
jei_version=4.15.0.293 jei_version=4.15.0.293

View File

@ -1,50 +0,0 @@
package nc.block;
import java.util.Random;
import nc.util.BlockHelper;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.math.*;
import net.minecraft.world.*;
import net.minecraftforge.common.util.ITeleporter;
public abstract class NCBlockPortal extends NCBlock {
protected final int targetDimension, returnDimension;
public NCBlockPortal(Material material, int targetDimension, int returnDimension) {
super(material);
setBlockUnbreakable();
setResistance(6000000F);
this.targetDimension = targetDimension;
this.returnDimension = returnDimension;
}
@Override
public int quantityDropped(Random random) {
return 0;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Items.AIR;
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return BlockHelper.REDUCED_BLOCK_AABB;
}
@Override
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
if (!worldIn.isRemote && !entityIn.isDead && !entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) {
entityIn.changeDimension(entityIn.dimension == targetDimension ? returnDimension : targetDimension, getTeleporter(worldIn, pos, state, entityIn));
}
}
protected abstract ITeleporter getTeleporter(World worldIn, BlockPos pos, IBlockState state, Entity entityIn);
}

View File

@ -1,56 +0,0 @@
package nc.block.tile;
import static nc.config.NCConfig.wasteland_dimension;
import java.util.Random;
import nc.block.NCBlockPortal;
import nc.init.NCBlocks;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ITeleporter;
import net.minecraftforge.fluids.IFluidBlock;
public class BlockPortalWasteland extends NCBlockPortal {
public BlockPortalWasteland() {
super(Material.ROCK, wasteland_dimension, 0);
}
@Override
protected ITeleporter getTeleporter(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
return new ITeleporter() {
@Override
public void placeEntity(World world, Entity entity, float yaw) {
Random rand = new Random();
BlockPos teleportPos = world.getTopSolidOrLiquidBlock(new BlockPos(entity.posX, entity.posY, entity.posZ));
int i = 0;
while (i < 10) {
int x = (2 + rand.nextInt(2)) * (rand.nextDouble() > 0.5D ? -1 : 1);
int y = (2 + rand.nextInt(2)) * (rand.nextDouble() > 0.5D ? -1 : 1);
int z = (2 + rand.nextInt(2)) * (rand.nextDouble() > 0.5D ? -1 : 1);
teleportPos = world.getTopSolidOrLiquidBlock(teleportPos.add(x, y, z));
Block block = world.getBlockState(teleportPos).getBlock();
if (block != NCBlocks.wasteland_portal && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock)) {
break;
}
i++;
}
if (i >= 10) {
world.setBlockState(teleportPos, NCBlocks.wasteland_earth.getDefaultState(), 3);
}
entity.setPositionAndUpdate(teleportPos.getX() + 0.5D, teleportPos.getY() + 1D, teleportPos.getZ() + 0.5D);
}
};
}
}

View File

@ -223,8 +223,7 @@ public class NCConfig {
public static double accelerator_electromagnet_power; public static double accelerator_electromagnet_power;
public static double accelerator_supercooler_coolant; public static double accelerator_supercooler_coolant;
public static int quantum_max_qubits_live; public static int quantum_max_qubits;
public static int quantum_max_qubits_qasm;
public static int quantum_angle_precision; public static int quantum_angle_precision;
public static int[] tool_mining_level; public static int[] tool_mining_level;
@ -280,7 +279,6 @@ public class NCConfig {
public static double radiation_lowest_rate; public static double radiation_lowest_rate;
public static double radiation_chunk_limit; public static double radiation_chunk_limit;
public static double[] radiation_sound_volumes;
public static boolean radiation_check_blocks; public static boolean radiation_check_blocks;
public static int radiation_block_effect_max_rate; public static int radiation_block_effect_max_rate;
public static double radiation_rain_mult; public static double radiation_rain_mult;
@ -756,10 +754,8 @@ public class NCConfig {
Property propertyAcceleratorSupercoolerCoolant = config.get(CATEGORY_ACCELERATOR, "accelerator_supercooler_coolant", 0.125D, Lang.localise("gui.nc.config.accelerator_supercooler_coolant.comment"), 0D, Integer.MAX_VALUE); Property propertyAcceleratorSupercoolerCoolant = config.get(CATEGORY_ACCELERATOR, "accelerator_supercooler_coolant", 0.125D, Lang.localise("gui.nc.config.accelerator_supercooler_coolant.comment"), 0D, Integer.MAX_VALUE);
propertyAcceleratorSupercoolerCoolant.setLanguageKey("gui.nc.config.accelerator_supercooler_coolant"); propertyAcceleratorSupercoolerCoolant.setLanguageKey("gui.nc.config.accelerator_supercooler_coolant");
Property propertyQuantumMaxQubitsLive = config.get(CATEGORY_QUANTUM, "quantum_max_qubits_live", 7, Lang.localise("gui.nc.config.quantum_max_qubits_live.comment"), 1, 14); Property propertyQuantumMaxQubits = config.get(CATEGORY_QUANTUM, "quantum_max_qubits", 7, Lang.localise("gui.nc.config.quantum_max_qubits.comment"), 1, 14);
propertyQuantumMaxQubitsLive.setLanguageKey("gui.nc.config.quantum_max_qubits_live"); propertyQuantumMaxQubits.setLanguageKey("gui.nc.config.quantum_max_qubits");
Property propertyQuantumMaxQubitsQasm = config.get(CATEGORY_QUANTUM, "quantum_max_qubits_qasm", 16, Lang.localise("gui.nc.config.quantum_max_qubits_qasm.comment"), 1, 32);
propertyQuantumMaxQubitsQasm.setLanguageKey("gui.nc.config.quantum_max_qubits_qasm");
Property propertyQuantumAnglePrecision = config.get(CATEGORY_QUANTUM, "quantum_angle_precision", 16, Lang.localise("gui.nc.config.quantum_angle_precision.comment"), 2, 5760); Property propertyQuantumAnglePrecision = config.get(CATEGORY_QUANTUM, "quantum_angle_precision", 16, Lang.localise("gui.nc.config.quantum_angle_precision.comment"), 2, 5760);
propertyQuantumAnglePrecision.setLanguageKey("gui.nc.config.quantum_angle_precision"); propertyQuantumAnglePrecision.setLanguageKey("gui.nc.config.quantum_angle_precision");
@ -858,8 +854,6 @@ public class NCConfig {
Property propertyRadiationChunkLimit = config.get(CATEGORY_RADIATION, "radiation_chunk_limit", -1D, Lang.localise("gui.nc.config.radiation_chunk_limit.comment"), -1D, Double.MAX_VALUE); Property propertyRadiationChunkLimit = config.get(CATEGORY_RADIATION, "radiation_chunk_limit", -1D, Lang.localise("gui.nc.config.radiation_chunk_limit.comment"), -1D, Double.MAX_VALUE);
propertyRadiationChunkLimit.setLanguageKey("gui.nc.config.radiation_chunk_limit"); propertyRadiationChunkLimit.setLanguageKey("gui.nc.config.radiation_chunk_limit");
Property propertyRadiationSoundVolumes = config.get(CATEGORY_RADIATION, "radiation_sound_volumes", new double[] {1D, 1D, 1D, 1D, 1D, 1D, 1D, 1D}, Lang.localise("gui.nc.config.radiation_sound_volumes.comment"), 0D, 15D);
propertyRadiationSoundVolumes.setLanguageKey("gui.nc.config.radiation_sound_volumes");
Property propertyRadiationCheckBlocks = config.get(CATEGORY_RADIATION, "radiation_check_blocks", true, Lang.localise("gui.config.radiation.radiation_check_blocks.comment")); Property propertyRadiationCheckBlocks = config.get(CATEGORY_RADIATION, "radiation_check_blocks", true, Lang.localise("gui.config.radiation.radiation_check_blocks.comment"));
propertyRadiationCheckBlocks.setLanguageKey("gui.config.radiation.radiation_check_blocks"); propertyRadiationCheckBlocks.setLanguageKey("gui.config.radiation.radiation_check_blocks");
Property propertyRadiationBlockEffectMaxRate = config.get(CATEGORY_RADIATION, "radiation_block_effect_max_rate", 0, Lang.localise("gui.nc.config.radiation_block_effect_max_rate.comment"), 0, 15); Property propertyRadiationBlockEffectMaxRate = config.get(CATEGORY_RADIATION, "radiation_block_effect_max_rate", 0, Lang.localise("gui.nc.config.radiation_block_effect_max_rate.comment"), 0, 15);
@ -1215,8 +1209,7 @@ public class NCConfig {
config.setCategoryPropertyOrder(CATEGORY_ACCELERATOR, propertyOrderAccelerator); config.setCategoryPropertyOrder(CATEGORY_ACCELERATOR, propertyOrderAccelerator);
List<String> propertyOrderQuantum = new ArrayList<>(); List<String> propertyOrderQuantum = new ArrayList<>();
propertyOrderQuantum.add(propertyQuantumMaxQubitsLive.getName()); propertyOrderQuantum.add(propertyQuantumMaxQubits.getName());
propertyOrderQuantum.add(propertyQuantumMaxQubitsQasm.getName());
propertyOrderQuantum.add(propertyQuantumAnglePrecision.getName()); propertyOrderQuantum.add(propertyQuantumAnglePrecision.getName());
config.setCategoryPropertyOrder(CATEGORY_QUANTUM, propertyOrderQuantum); config.setCategoryPropertyOrder(CATEGORY_QUANTUM, propertyOrderQuantum);
@ -1273,7 +1266,6 @@ public class NCConfig {
propertyOrderRadiation.add(propertyRadiationDecayRate.getName()); propertyOrderRadiation.add(propertyRadiationDecayRate.getName());
propertyOrderRadiation.add(propertyRadiationLowestRate.getName()); propertyOrderRadiation.add(propertyRadiationLowestRate.getName());
propertyOrderRadiation.add(propertyRadiationChunkLimit.getName()); propertyOrderRadiation.add(propertyRadiationChunkLimit.getName());
propertyOrderRadiation.add(propertyRadiationSoundVolumes.getName());
propertyOrderRadiation.add(propertyRadiationCheckBlocks.getName()); propertyOrderRadiation.add(propertyRadiationCheckBlocks.getName());
propertyOrderRadiation.add(propertyRadiationBlockEffectMaxRate.getName()); propertyOrderRadiation.add(propertyRadiationBlockEffectMaxRate.getName());
propertyOrderRadiation.add(propertyRadiationRainMult.getName()); propertyOrderRadiation.add(propertyRadiationRainMult.getName());
@ -1539,8 +1531,7 @@ public class NCConfig {
accelerator_electromagnet_power = propertyAcceleratorElectromagnetPower.getDouble(); accelerator_electromagnet_power = propertyAcceleratorElectromagnetPower.getDouble();
accelerator_supercooler_coolant = propertyAcceleratorSupercoolerCoolant.getDouble(); accelerator_supercooler_coolant = propertyAcceleratorSupercoolerCoolant.getDouble();
quantum_max_qubits_live = propertyQuantumMaxQubitsLive.getInt(); quantum_max_qubits = propertyQuantumMaxQubits.getInt();
quantum_max_qubits_qasm = propertyQuantumMaxQubitsQasm.getInt();
quantum_angle_precision = propertyQuantumAnglePrecision.getInt(); quantum_angle_precision = propertyQuantumAnglePrecision.getInt();
tool_mining_level = readIntegerArrayFromConfig(propertyToolMiningLevel); tool_mining_level = readIntegerArrayFromConfig(propertyToolMiningLevel);
@ -1595,7 +1586,6 @@ public class NCConfig {
radiation_lowest_rate = propertyRadiationLowestRate.getDouble(); radiation_lowest_rate = propertyRadiationLowestRate.getDouble();
radiation_chunk_limit = propertyRadiationChunkLimit.getDouble(); radiation_chunk_limit = propertyRadiationChunkLimit.getDouble();
radiation_sound_volumes = readDoubleArrayFromConfig(propertyRadiationSoundVolumes);
radiation_check_blocks = propertyRadiationCheckBlocks.getBoolean(); radiation_check_blocks = propertyRadiationCheckBlocks.getBoolean();
radiation_block_effect_max_rate = propertyRadiationBlockEffectMaxRate.getInt(); radiation_block_effect_max_rate = propertyRadiationBlockEffectMaxRate.getInt();
radiation_rain_mult = propertyRadiationRainMult.getDouble(); radiation_rain_mult = propertyRadiationRainMult.getDouble();
@ -1863,8 +1853,7 @@ public class NCConfig {
propertyAcceleratorElectromagnetPower.set(accelerator_electromagnet_power); propertyAcceleratorElectromagnetPower.set(accelerator_electromagnet_power);
propertyAcceleratorSupercoolerCoolant.set(accelerator_supercooler_coolant); propertyAcceleratorSupercoolerCoolant.set(accelerator_supercooler_coolant);
propertyQuantumMaxQubitsLive.set(quantum_max_qubits_live); propertyQuantumMaxQubits.set(quantum_max_qubits);
propertyQuantumMaxQubitsQasm.set(quantum_max_qubits_qasm);
propertyQuantumAnglePrecision.set(quantum_angle_precision); propertyQuantumAnglePrecision.set(quantum_angle_precision);
propertyToolMiningLevel.set(tool_mining_level); propertyToolMiningLevel.set(tool_mining_level);
@ -1919,7 +1908,6 @@ public class NCConfig {
propertyRadiationLowestRate.set(radiation_lowest_rate); propertyRadiationLowestRate.set(radiation_lowest_rate);
propertyRadiationChunkLimit.set(radiation_chunk_limit); propertyRadiationChunkLimit.set(radiation_chunk_limit);
propertyRadiationSoundVolumes.set(radiation_sound_volumes);
propertyRadiationCheckBlocks.set(radiation_check_blocks); propertyRadiationCheckBlocks.set(radiation_check_blocks);
propertyRadiationBlockEffectMaxRate.set(radiation_block_effect_max_rate); propertyRadiationBlockEffectMaxRate.set(radiation_block_effect_max_rate);
propertyRadiationRainMult.set(radiation_rain_mult); propertyRadiationRainMult.set(radiation_rain_mult);

View File

@ -1,6 +1,6 @@
package nc.entity; package nc.entity;
import static nc.config.NCConfig.*; import static nc.config.NCConfig.register_entity;
import java.util.Calendar; import java.util.Calendar;
@ -86,34 +86,27 @@ public class EntityFeralGhoul extends EntityZombie {
} }
@Override @Override
protected SoundEvent getHurtSound(DamageSource damageSource) { protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
// return SoundHandler.feral_ghoul_hurt; // return SoundHandler.feral_ghoul_hurt;
return NCSounds.feral_ghoul_charge; return NCSounds.feral_ghoul_charge;
} }
@Override
protected void playHurtSound(DamageSource source) {
playSound(getHurtSound(source), getSoundVolume(), getSoundPitch() - 0.3F);
}
@Override @Override
protected SoundEvent getDeathSound() { protected SoundEvent getDeathSound() {
return NCSounds.feral_ghoul_death; return NCSounds.feral_ghoul_death;
} }
@Override
protected SoundEvent getFallSound(int height) {
// return SoundHandler.feral_ghoul_fall;
return height > 4 ? SoundEvents.ENTITY_HOSTILE_BIG_FALL : SoundEvents.ENTITY_HOSTILE_SMALL_FALL;
}
@Override @Override
protected SoundEvent getStepSound() { protected SoundEvent getStepSound() {
// return SoundHandler.feral_ghoul_step; // return SoundHandler.feral_ghoul_step;
return SoundEvents.ENTITY_HUSK_STEP; return SoundEvents.ENTITY_HUSK_STEP;
} }
@Override
protected void playHurtSound(DamageSource source) {
applyEntityAI();
playSound(getHurtSound(source), getSoundVolume(), getSoundPitch() - 0.3F);
}
@Nullable @Nullable
@Override @Override
protected ResourceLocation getLootTable() { protected ResourceLocation getLootTable() {
@ -157,7 +150,7 @@ public class EntityFeralGhoul extends EntityZombie {
if (entityRads != null) { if (entityRads != null) {
entityRads.setPoisonBuffer(entityRads.getPoisonBuffer() + RadSources.CAESIUM_137 * mult); entityRads.setPoisonBuffer(entityRads.getPoisonBuffer() + RadSources.CAESIUM_137 * mult);
entityRads.setRecentPoisonAddition(RadSources.CAESIUM_137 * mult); entityRads.setRecentPoisonAddition(RadSources.CAESIUM_137 * mult);
playSound(NCSounds.rad_poisoning, (float) (1.35D * radiation_sound_volumes[7]), 1F + 0.2F * (rand.nextFloat() - rand.nextFloat())); playSound(NCSounds.rad_poisoning, 1.35F, 1F + 0.2F * (rand.nextFloat() - rand.nextFloat()));
} }
} }
@ -252,6 +245,7 @@ public class EntityFeralGhoul extends EntityZombie {
int i = MathHelper.ceil((distance - 3F) * damageMultiplier); int i = MathHelper.ceil((distance - 3F) * damageMultiplier);
if (i > 0) { if (i > 0) {
playSound(getFallSound(i), 1F, 1F); playSound(getFallSound(i), 1F, 1F);
// playSound(SoundHandler.feral_ghoul_fall, 1F, 1F);
playSound(SoundEvents.ENTITY_HUSK_AMBIENT, 1F, 1F); playSound(SoundEvents.ENTITY_HUSK_AMBIENT, 1F, 1F);
int j = MathHelper.floor(posX); int j = MathHelper.floor(posX);
int k = MathHelper.floor(posY - 0.20000000298023224D); int k = MathHelper.floor(posY - 0.20000000298023224D);
@ -352,7 +346,7 @@ public class EntityFeralGhoul extends EntityZombie {
} }
else { else {
float f6 = 0.91F; float f6 = 0.91F;
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(posX, posY - 1D, posZ); BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(posX, getEntityBoundingBox().minY - 1D, posZ);
if (onGround) { if (onGround) {
IBlockState underState = world.getBlockState(blockpos$pooledmutableblockpos); IBlockState underState = world.getBlockState(blockpos$pooledmutableblockpos);
@ -373,7 +367,7 @@ public class EntityFeralGhoul extends EntityZombie {
f6 = 0.91F; f6 = 0.91F;
if (onGround) { if (onGround) {
IBlockState underState = world.getBlockState(blockpos$pooledmutableblockpos.setPos(posX, posY - 1D, posZ)); IBlockState underState = world.getBlockState(blockpos$pooledmutableblockpos.setPos(posX, getEntityBoundingBox().minY - 1D, posZ));
f6 = underState.getBlock().getSlipperiness(underState, world, blockpos$pooledmutableblockpos, this) * 0.91F; f6 = underState.getBlock().getSlipperiness(underState, world, blockpos$pooledmutableblockpos, this) * 0.91F;
} }

View File

@ -11,31 +11,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class EntityHandler { public class EntityHandler {
@SubscribeEvent @SubscribeEvent
public void onEntityLivingSpawn(LivingSpawnEvent.CheckSpawn event) { public void onLootTableLoad(LivingSpawnEvent.CheckSpawn event) {
EntityLivingBase entity = event.getEntityLiving(); EntityLivingBase entity = event.getEntityLiving();
if (entity instanceof EntityFeralGhoul) { if (entity instanceof EntityFeralGhoul) {
if (!event.isSpawner()) {
World world = entity.world; World world = entity.world;
BlockPos pos = new BlockPos(entity.posX, entity.posY, entity.posZ); if (!event.isSpawner() && (!world.canSeeSky(new BlockPos(entity.posX, entity.getEntityBoundingBox().minY, entity.posZ)) || world.countEntities(EntityFeralGhoul.class) > 20)) {
boolean canSeeSky = world.canSeeSky(pos);
if (!canSeeSky) {
event.setResult(Result.DENY); event.setResult(Result.DENY);
return;
}
boolean tooManyGhouls = false;
Iterable<EntityFeralGhoul> iterable = world.getChunk(pos).getEntityLists()[(int) Math.floor(entity.posY / 16D)].getByClass(EntityFeralGhoul.class);
while (iterable.iterator().hasNext()) {
tooManyGhouls = true;
break;
}
if (tooManyGhouls) {
event.setResult(Result.DENY);
return;
}
} }
} }
} }

View File

@ -42,22 +42,22 @@ public class ItemUseHandler {
if (rads > 0D) { if (rads > 0D) {
entityRads.setPoisonBuffer(entityRads.getPoisonBuffer() + rads); entityRads.setPoisonBuffer(entityRads.getPoisonBuffer() + rads);
entityRads.setRecentPoisonAddition(rads); entityRads.setRecentPoisonAddition(rads);
entity.playSound(NCSounds.rad_poisoning, (float) ((1D - Math.pow(10D, -Math.sqrt(rads) / 10D)) * radiation_sound_volumes[3]), 1F); entity.playSound(NCSounds.rad_poisoning, 1F - (float) Math.pow(10D, -Math.sqrt(rads) / 10D), 1F);
} }
else { else {
entityRads.setRadawayBuffer(false, entityRads.getRadawayBuffer(false) - rads); entityRads.setRadawayBuffer(false, entityRads.getRadawayBuffer(false) - rads);
entityRads.setRecentRadawayAddition(-rads); entityRads.setRecentRadawayAddition(-rads);
entity.playSound(NCSounds.radaway, (float) ((1D - Math.pow(10D, -Math.sqrt(-rads) / 10D)) * radiation_sound_volumes[3]), 1F); entity.playSound(NCSounds.radaway, 1F - (float) Math.pow(10D, -Math.sqrt(-rads) / 10D), 1F);
} }
if (entityRads.getRadXCooldown() <= 0D) { if (entityRads.getRadXCooldown() <= 0D) {
entityRads.setInternalRadiationResistance(entityRads.getInternalRadiationResistance() + resistance); entityRads.setInternalRadiationResistance(entityRads.getInternalRadiationResistance() + resistance);
entityRads.setRecentRadXAddition(Math.abs(resistance)); entityRads.setRecentRadXAddition(Math.abs(resistance));
if (resistance > 0D) { if (resistance > 0D) {
entity.playSound(NCSounds.rad_x, (float) ((1D - Math.pow(10D, -5D * Math.sqrt(resistance) / radiation_rad_x_amount)) * radiation_sound_volumes[3]), 1F); entity.playSound(NCSounds.rad_x, 1F - (float) Math.pow(10D, -5D * Math.sqrt(resistance) / radiation_rad_x_amount), 1F);
} }
else { else {
entity.playSound(NCSounds.chems_wear_off, (float) ((1D - Math.pow(10D, -5D * Math.sqrt(-resistance) / radiation_rad_x_amount)) * radiation_sound_volumes[3]), 1F); entity.playSound(NCSounds.chems_wear_off, 1F - (float) Math.pow(10D, -5D * Math.sqrt(-resistance) / radiation_rad_x_amount), 1F);
} }
} }
} }

View File

@ -14,6 +14,8 @@ public class ScriptAddonHandler {
public static void init() throws IOException { public static void init() throws IOException {
NCUtil.getLogger().info("Constructing NuclearCraft Script Addons..."); NCUtil.getLogger().info("Constructing NuclearCraft Script Addons...");
new File("resources/nuclearcraft").mkdirs();
for (String s : new String[] {"addons", "advancements", "blockstates", "lang", "loot_tables", "models/block", "models/item", "patchouli_books/guide", "textures/blocks", "textures/items"}) { for (String s : new String[] {"addons", "advancements", "blockstates", "lang", "loot_tables", "models/block", "models/item", "patchouli_books/guide", "textures/blocks", "textures/items"}) {
new File("resources/nuclearcraft/" + s).mkdirs(); new File("resources/nuclearcraft/" + s).mkdirs();
} }
@ -61,11 +63,8 @@ public class ScriptAddonHandler {
public static void copyAddons(File dir) throws IOException { public static void copyAddons(File dir) throws IOException {
String dirName = dir.getName(); String dirName = dir.getName();
if (dirName.equals("__MACOSX")) {
return;
}
String dirNameLowerCase = dirName.toLowerCase(); String dirNameLowerCase = dirName.toLowerCase();
for (String suffix : IGNORE_SUFFIX) { for (String suffix : IGNORE_SUFFIX) {
if (dirNameLowerCase.endsWith(suffix)) { if (dirNameLowerCase.endsWith(suffix)) {
return; return;
@ -153,7 +152,7 @@ public class ScriptAddonHandler {
} }
if (lang.exists()) { if (lang.exists()) {
String s = IOHelper.NEW_LINE; String s = System.lineSeparator();
IOHelper.appendFile(lang, f, (lang.length() == 0 ? "" : (s + s)) + "# " + addonDir.getName() + s + s); IOHelper.appendFile(lang, f, (lang.length() == 0 ? "" : (s + s)) + "# " + addonDir.getName() + s + s);
} }
} }

View File

@ -178,9 +178,8 @@ public class NCBlocks {
public static Block glowing_mushroom; public static Block glowing_mushroom;
public static Block wasteland_earth; public static Block wasteland_earth;
public static Block wasteland_portal;
public static Block tritium_lamp; public static Block tritium_lamp;
public static Block tritium_lantern;
public static Block quantum_computer_controller; public static Block quantum_computer_controller;
public static Block quantum_computer_qubit; public static Block quantum_computer_qubit;
@ -190,6 +189,7 @@ public class NCBlocks {
public static Block quantum_computer_gate_swap; public static Block quantum_computer_gate_swap;
public static Block quantum_computer_connector; public static Block quantum_computer_connector;
// public static Block quantum_computer_port;
public static void init() { public static void init() {
ore = withName(new BlockMeta.BlockOre(), "ore"); ore = withName(new BlockMeta.BlockOre(), "ore");
@ -378,8 +378,6 @@ public class NCBlocks {
glowing_mushroom = withName(new NCBlockMushroom().setCreativeTab(NCTabs.RADIATION).setLightLevel(1F), "glowing_mushroom"); glowing_mushroom = withName(new NCBlockMushroom().setCreativeTab(NCTabs.RADIATION).setLightLevel(1F), "glowing_mushroom");
wasteland_earth = withName(new NCBlock(Material.ROCK).setCreativeTab(NCTabs.RADIATION), "wasteland_earth"); wasteland_earth = withName(new NCBlock(Material.ROCK).setCreativeTab(NCTabs.RADIATION), "wasteland_earth");
wasteland_portal = withName(new BlockPortalWasteland().setCreativeTab(NCTabs.RADIATION), "wasteland_portal");
tritium_lamp = withName(new NCBlock(Material.GLASS).setCreativeTab(NCTabs.MISC).setLightLevel(1F), "tritium_lamp"); tritium_lamp = withName(new NCBlock(Material.GLASS).setCreativeTab(NCTabs.MISC).setLightLevel(1F), "tritium_lamp");
if (register_quantum) { if (register_quantum) {
@ -391,6 +389,7 @@ public class NCBlocks {
quantum_computer_gate_swap = withName(new BlockQuantumComputerGate.Swap(), "quantum_computer_gate_swap"); quantum_computer_gate_swap = withName(new BlockQuantumComputerGate.Swap(), "quantum_computer_gate_swap");
quantum_computer_connector = withName(new BlockQuantumComputerConnector(), "quantum_computer_connector"); quantum_computer_connector = withName(new BlockQuantumComputerConnector(), "quantum_computer_connector");
// quantum_computer_port = withName(new BlockQuantumComputerPort(), "quantum_computer_port");
} }
} }
@ -582,8 +581,6 @@ public class NCBlocks {
registerBlock(glowing_mushroom); registerBlock(glowing_mushroom);
registerBlock(wasteland_earth); registerBlock(wasteland_earth);
registerBlock(wasteland_portal);
registerBlock(tritium_lamp); registerBlock(tritium_lamp);
if (register_quantum) { if (register_quantum) {
@ -595,6 +592,7 @@ public class NCBlocks {
registerBlock(quantum_computer_gate_swap, new ItemBlockMeta(quantum_computer_gate_swap, QuantumGateEnums.SwapType.class, TextFormatting.AQUA)); registerBlock(quantum_computer_gate_swap, new ItemBlockMeta(quantum_computer_gate_swap, QuantumGateEnums.SwapType.class, TextFormatting.AQUA));
registerBlock(quantum_computer_connector); registerBlock(quantum_computer_connector);
// registerBlock(quantum_computer_port);
} }
} }
@ -811,8 +809,6 @@ public class NCBlocks {
registerRender(glowing_mushroom); registerRender(glowing_mushroom);
registerRender(wasteland_earth); registerRender(wasteland_earth);
registerRender(wasteland_portal);
registerRender(tritium_lamp); registerRender(tritium_lamp);
if (register_quantum) { if (register_quantum) {
@ -830,6 +826,7 @@ public class NCBlocks {
} }
registerRender(quantum_computer_connector); registerRender(quantum_computer_connector);
// registerRender(quantum_computer_port);
} }
} }

View File

@ -21,8 +21,8 @@ public class NCSounds {
// public static SoundEvent feral_ghoul_ambient; // public static SoundEvent feral_ghoul_ambient;
// public static SoundEvent feral_ghoul_hurt; // public static SoundEvent feral_ghoul_hurt;
public static SoundEvent feral_ghoul_death; public static SoundEvent feral_ghoul_death;
// public static SoundEvent feral_ghoul_fall;
// public static SoundEvent feral_ghoul_step; // public static SoundEvent feral_ghoul_step;
// public static SoundEvent feral_ghoul_fall;
public static SoundEvent feral_ghoul_charge; public static SoundEvent feral_ghoul_charge;
public static SoundEvent wanderer; public static SoundEvent wanderer;

View File

@ -490,7 +490,7 @@ public class JEIRecipeWrapper {
@Override @Override
protected int getProgressArrowTime() { protected int getProgressArrowTime() {
return (int) (getDecayGeneratorLifetime() / 20D); return (int) (getDecayGeneratorLifetime() / 4D);
} }
protected double getDecayGeneratorLifetime() { protected double getDecayGeneratorLifetime() {
@ -831,7 +831,7 @@ public class JEIRecipeWrapper {
@Override @Override
protected int getProgressArrowTime() { protected int getProgressArrowTime() {
return (int) (144D * getSaltFissionFuelTime() / 80D); return (int) (getSaltFissionFuelTime() / 80D);
} }
protected double getSaltFissionFuelTime() { protected double getSaltFissionFuelTime() {

View File

@ -68,7 +68,7 @@ public abstract class JEIRecipeWrapperAbstract<T extends JEIRecipeWrapperAbstrac
} }
private boolean staticArrow() { private boolean staticArrow() {
return getProgressArrowTime() < 2 /* || (factor_recipes && itemInputs.isEmpty() && itemOutputs.isEmpty() && getProgressArrowTime() < 4) */; return getProgressArrowTime() < 4 /* || (factor_recipes && itemInputs.isEmpty() && itemOutputs.isEmpty() && getProgressArrowTime() < 8) */;
} }
@Override @Override

View File

@ -34,7 +34,7 @@ public class ItemRadX extends NCItem {
return stack; return stack;
} }
if (playerRads.canConsumeRadX()) { if (playerRads.canConsumeRadX()) {
world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, NCSounds.rad_x, SoundCategory.PLAYERS, (float) (0.5D * radiation_sound_volumes[2]), 1F); world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, NCSounds.rad_x, SoundCategory.PLAYERS, 0.5F, 1F);
onRadXConsumed(stack, world, player); onRadXConsumed(stack, world, player);
player.addStat(StatList.getObjectUseStats(this)); player.addStat(StatList.getObjectUseStats(this));
if (player instanceof EntityPlayerMP) { if (player instanceof EntityPlayerMP) {
@ -59,7 +59,7 @@ public class ItemRadX extends NCItem {
private static void sendCooldownMessage(World world, EntityPlayer player, IEntityRads playerRads, boolean playSound) { private static void sendCooldownMessage(World world, EntityPlayer player, IEntityRads playerRads, boolean playSound) {
if (playerRads.getRadXCooldown() > 0D && playerRads.getMessageCooldownTime() <= 0) { if (playerRads.getRadXCooldown() > 0D && playerRads.getMessageCooldownTime() <= 0) {
if (playSound && world.isRemote) { if (playSound && world.isRemote) {
player.playSound(NCSounds.chems_wear_off, (float) (0.5D * radiation_sound_volumes[4]), 1F); player.playSound(NCSounds.chems_wear_off, 0.5F, 1F);
} }
if (!world.isRemote) { if (!world.isRemote) {
playerRads.setMessageCooldownTime(20); playerRads.setMessageCooldownTime(20);

View File

@ -37,7 +37,7 @@ public class ItemRadaway extends NCItem {
return stack; return stack;
} }
if (playerRads.canConsumeRadaway()) { if (playerRads.canConsumeRadaway()) {
world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, NCSounds.radaway, SoundCategory.PLAYERS, (float) (0.5D * radiation_sound_volumes[1]), 1F); world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, NCSounds.radaway, SoundCategory.PLAYERS, 0.5F, 1F);
onRadawayConsumed(stack, world, player); onRadawayConsumed(stack, world, player);
player.addStat(StatList.getObjectUseStats(this)); player.addStat(StatList.getObjectUseStats(this));
if (player instanceof EntityPlayerMP) { if (player instanceof EntityPlayerMP) {
@ -62,7 +62,7 @@ public class ItemRadaway extends NCItem {
private static void sendCooldownMessage(World world, EntityPlayer player, IEntityRads playerRads, boolean playSound) { private static void sendCooldownMessage(World world, EntityPlayer player, IEntityRads playerRads, boolean playSound) {
if (playerRads.getRadawayCooldown() > 0D && playerRads.getMessageCooldownTime() <= 0) { if (playerRads.getRadawayCooldown() > 0D && playerRads.getMessageCooldownTime() <= 0) {
if (playSound && world.isRemote) { if (playSound && world.isRemote) {
player.playSound(NCSounds.chems_wear_off, (float) (0.5D * radiation_sound_volumes[4]), 1F); player.playSound(NCSounds.chems_wear_off, 0.5F, 1F);
} }
if (!world.isRemote) { if (!world.isRemote) {
playerRads.setMessageCooldownTime(20); playerRads.setMessageCooldownTime(20);

View File

@ -92,7 +92,7 @@ public class ItemRadiationBadge extends NCItem implements IBauble {
player.sendMessage(new TextComponentString(TextFormatting.ITALIC + BADGE_BROKEN)); player.sendMessage(new TextComponentString(TextFormatting.ITALIC + BADGE_BROKEN));
} }
else { else {
player.playSound(NCSounds.chems_wear_off, (float) (0.65D * radiation_sound_volumes[5]), 1F); player.playSound(NCSounds.chems_wear_off, 0.65F, 1F);
} }
stack.shrink(1); stack.shrink(1);
} }

View File

@ -63,6 +63,7 @@ public final class BlockFacing {
} }
public IBlockState toBlockState(IBlockState state) { public IBlockState toBlockState(IBlockState state) {
return state.withProperty(FACING_DOWN, isSet(EnumFacing.DOWN)).withProperty(FACING_UP, isSet(EnumFacing.UP)).withProperty(FACING_WEST, isSet(EnumFacing.WEST)).withProperty(FACING_EAST, isSet(EnumFacing.EAST)).withProperty(FACING_NORTH, isSet(EnumFacing.NORTH)).withProperty(FACING_SOUTH, isSet(EnumFacing.SOUTH)); return state.withProperty(FACING_DOWN, isSet(EnumFacing.DOWN)).withProperty(FACING_UP, isSet(EnumFacing.UP)).withProperty(FACING_WEST, isSet(EnumFacing.WEST)).withProperty(FACING_EAST, isSet(EnumFacing.EAST)).withProperty(FACING_NORTH, isSet(EnumFacing.NORTH)).withProperty(FACING_SOUTH, isSet(EnumFacing.SOUTH));
} }
@ -74,6 +75,7 @@ public final class BlockFacing {
* the new value for the state of the face * the new value for the state of the face
* @return a BlockFacing object */ * @return a BlockFacing object */
public BlockFacing set(EnumFacing facing, boolean value) { public BlockFacing set(EnumFacing facing, boolean value) {
byte newHash = _value; byte newHash = _value;
if (value) { if (value) {
@ -83,7 +85,7 @@ public final class BlockFacing {
newHash &= ~(1 << facing.getIndex()); newHash &= ~(1 << facing.getIndex());
} }
return BlockFacing.from(newHash); return BlockFacing.from(Byte.valueOf(newHash));
} }
/** Count the number of faces that are in the required state /** Count the number of faces that are in the required state
@ -92,6 +94,7 @@ public final class BlockFacing {
* specify if you are looking for "set" faces (true) or not (false) * specify if you are looking for "set" faces (true) or not (false)
* @return the number of faces found in the required state */ * @return the number of faces found in the required state */
public int countFacesIf(boolean areSet) { public int countFacesIf(boolean areSet) {
int checkFor = areSet ? 1 : 0; int checkFor = areSet ? 1 : 0;
int mask = _value; int mask = _value;
int faces = 0; int faces = 0;
@ -110,6 +113,7 @@ public final class BlockFacing {
* *
* @return a PropertyBlockFacings value */ * @return a PropertyBlockFacings value */
public PropertyBlockFacing toProperty() { public PropertyBlockFacing toProperty() {
PropertyBlockFacing[] values = PropertyBlockFacing.values(); PropertyBlockFacing[] values = PropertyBlockFacing.values();
for (PropertyBlockFacing value : values) { for (PropertyBlockFacing value : values) {
@ -127,6 +131,7 @@ public final class BlockFacing {
* the original position * the original position
* @return the new position */ * @return the new position */
public BlockPos offsetBlockPos(BlockPos originalPosition) { public BlockPos offsetBlockPos(BlockPos originalPosition) {
int x = 0, y = 0, z = 0; int x = 0, y = 0, z = 0;
for (EnumFacing facing : EnumFacing.VALUES) { for (EnumFacing facing : EnumFacing.VALUES) {
@ -147,6 +152,7 @@ public final class BlockFacing {
* specify if you are looking for "set" faces (true) or not (false) * specify if you are looking for "set" faces (true) or not (false)
* @return the first face that match the required state or null if no face is found */ * @return the first face that match the required state or null if no face is found */
public EnumFacing firstIf(boolean isSet) { public EnumFacing firstIf(boolean isSet) {
for (EnumFacing facing : EnumFacing.VALUES) { for (EnumFacing facing : EnumFacing.VALUES) {
if (isSet == isSet(facing)) { if (isSet == isSet(facing)) {
return facing; return facing;
@ -172,6 +178,7 @@ public final class BlockFacing {
* the state of the "east" face * the state of the "east" face
* @return a BlockFacing object */ * @return a BlockFacing object */
public static BlockFacing from(boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) { public static BlockFacing from(boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) {
return BlockFacing.from(BlockFacing.computeHash(down, up, north, south, west, east)); return BlockFacing.from(BlockFacing.computeHash(down, up, north, south, west, east));
} }
@ -181,6 +188,7 @@ public final class BlockFacing {
* an array describing the state. the elements of the array must be filled in following the order in EnumFacing.VALUES * an array describing the state. the elements of the array must be filled in following the order in EnumFacing.VALUES
* @return a BlockFacing object */ * @return a BlockFacing object */
public static BlockFacing from(boolean[] facings) { public static BlockFacing from(boolean[] facings) {
return BlockFacing.from(BlockFacing.computeHash(facings)); return BlockFacing.from(BlockFacing.computeHash(facings));
} }
@ -190,25 +198,26 @@ public final class BlockFacing {
return String.format("Facings: %s%s%s%s%s%s", isSet(EnumFacing.DOWN) ? "DOWN " : "", isSet(EnumFacing.UP) ? "UP " : "", isSet(EnumFacing.NORTH) ? "NORTH " : "", isSet(EnumFacing.SOUTH) ? "SOUTH " : "", isSet(EnumFacing.WEST) ? "WEST " : "", isSet(EnumFacing.EAST) ? "EAST " : ""); return String.format("Facings: %s%s%s%s%s%s", isSet(EnumFacing.DOWN) ? "DOWN " : "", isSet(EnumFacing.UP) ? "UP " : "", isSet(EnumFacing.NORTH) ? "NORTH " : "", isSet(EnumFacing.SOUTH) ? "SOUTH " : "", isSet(EnumFacing.WEST) ? "WEST " : "", isSet(EnumFacing.EAST) ? "EAST " : "");
} }
static BlockFacing from(byte hash) { static BlockFacing from(Byte hash) {
BlockFacing facings = CACHE.get(hash);
BlockFacing facings = BlockFacing.s_cache.get(hash);
if (null == facings) { if (null == facings) {
facings = new BlockFacing(hash); facings = new BlockFacing(hash.byteValue());
CACHE.put(hash, facings); BlockFacing.s_cache.put(hash, facings);
} }
return facings; return facings;
} }
private final byte _value;
private BlockFacing(byte value) { private BlockFacing(byte value) {
_value = value; _value = value;
} }
static byte computeHash(boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) { static Byte computeHash(boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) {
byte hash = 0; byte hash = 0;
if (down) { if (down) {
@ -235,10 +244,11 @@ public final class BlockFacing {
hash |= 1 << EnumFacing.EAST.getIndex(); hash |= 1 << EnumFacing.EAST.getIndex();
} }
return hash; return Byte.valueOf(hash);
} }
static byte computeHash(boolean[] facings) { static Byte computeHash(boolean[] facings) {
byte hash = 0; byte hash = 0;
int len = null == facings ? -1 : facings.length; int len = null == facings ? -1 : facings.length;
@ -253,34 +263,40 @@ public final class BlockFacing {
} }
} }
return hash; return Byte.valueOf(hash);
} }
private static final Byte2ObjectMap<BlockFacing> CACHE = new Byte2ObjectOpenHashMap<>(); private final byte _value;
private static Byte2ObjectMap<BlockFacing> s_cache;
static { static {
byte hash = BlockFacing.computeHash(false, false, false, false, false, false); Byte hash;
CACHE.put(hash, NONE = new BlockFacing(hash));
s_cache = new Byte2ObjectOpenHashMap<>(8);
hash = BlockFacing.computeHash(false, false, false, false, false, false);
s_cache.put(hash, NONE = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(true, true, true, true, true, true); hash = BlockFacing.computeHash(true, true, true, true, true, true);
CACHE.put(hash, ALL = new BlockFacing(hash)); s_cache.put(hash, ALL = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(true, false, false, false, false, false); hash = BlockFacing.computeHash(true, false, false, false, false, false);
CACHE.put(hash, DOWN = new BlockFacing(hash)); s_cache.put(hash, DOWN = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, true, false, false, false, false); hash = BlockFacing.computeHash(false, true, false, false, false, false);
CACHE.put(hash, UP = new BlockFacing(hash)); s_cache.put(hash, UP = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, true, false, false, false); hash = BlockFacing.computeHash(false, false, true, false, false, false);
CACHE.put(hash, NORTH = new BlockFacing(hash)); s_cache.put(hash, NORTH = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, false, true, false, false); hash = BlockFacing.computeHash(false, false, false, true, false, false);
CACHE.put(hash, SOUTH = new BlockFacing(hash)); s_cache.put(hash, SOUTH = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, false, false, true, false); hash = BlockFacing.computeHash(false, false, false, false, true, false);
CACHE.put(hash, WEST = new BlockFacing(hash)); s_cache.put(hash, WEST = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, false, false, false, true); hash = BlockFacing.computeHash(false, false, false, false, false, true);
CACHE.put(hash, EAST = new BlockFacing(hash)); s_cache.put(hash, EAST = new BlockFacing(hash.byteValue()));
} }
} }

View File

@ -18,10 +18,14 @@ final class MultiblockWorldRegistry {
private World worldObj; private World worldObj;
private final ObjectSet<Multiblock> multiblocks; // Active multiblocks private final ObjectSet<Multiblock> multiblocks; // Active multiblocks
private final ObjectSet<Multiblock> dirtyMultiblocks; // Multiblocks whose parts lists have changed private final ObjectSet<Multiblock> dirtyMultiblocks; // Multiblocks whose
private final ObjectSet<Multiblock> deadMultiblocks; // Multiblocks which are empty // parts lists have
// changed
private final ObjectSet<Multiblock> deadMultiblocks; // Multiblocks which
// are empty
// A list of orphan parts - parts which currently have no master, but should seek one this tick // A list of orphan parts - parts which currently have no master, but should
// seek one this tick
// Indexed by the hashed chunk coordinate // Indexed by the hashed chunk coordinate
// This can be added-to asynchronously via chunk loads! // This can be added-to asynchronously via chunk loads!
private ObjectSet<ITileMultiblockPart> orphanedParts; private ObjectSet<ITileMultiblockPart> orphanedParts;
@ -61,7 +65,8 @@ final class MultiblockWorldRegistry {
for (Multiblock multiblock : multiblocks) { for (Multiblock multiblock : multiblocks) {
if (multiblock.WORLD == worldObj && multiblock.WORLD.isRemote == worldObj.isRemote) { if (multiblock.WORLD == worldObj && multiblock.WORLD.isRemote == worldObj.isRemote) {
if (multiblock.isEmpty()) { if (multiblock.isEmpty()) {
// This happens on the server when the user breaks the last block. It's fine. // This happens on the server when the user breaks the
// last block. It's fine.
// Mark 'er dead and move on. // Mark 'er dead and move on.
deadMultiblocks.add(multiblock); deadMultiblocks.add(multiblock);
} }
@ -78,16 +83,19 @@ final class MultiblockWorldRegistry {
public void processMultiblockChanges() { public void processMultiblockChanges() {
BlockPos coord; BlockPos coord;
// Merge pools - sets of adjacent machines which should be merged later on in processing // Merge pools - sets of adjacent machines which should be merged later
// on in processing
List<Set<Multiblock>> mergePools = null; List<Set<Multiblock>> mergePools = null;
if (orphanedParts.size() > 0) { if (orphanedParts.size() > 0) {
Set<ITileMultiblockPart> orphansToProcess = null; Set<ITileMultiblockPart> orphansToProcess = null;
// Keep the synchronized block small. // Keep the synchronized block small. We can't iterate over
// We can't iterate over orphanedParts directly because the client // orphanedParts directly
// does not know which chunks are actually loaded, so attachToNeighbors() // because the client does not know which chunks are actually
// loaded, so attachToNeighbors()
// is not chunk-safe on the client, because Minecraft is stupid. // is not chunk-safe on the client, because Minecraft is stupid.
// It's possible to polyfill this, but the polyfill is too slow for comfort. // It's possible to polyfill this, but the polyfill is too slow for
// comfort.
synchronized (orphanedPartsMutex) { synchronized (orphanedPartsMutex) {
if (orphanedParts.size() > 0) { if (orphanedParts.size() > 0) {
orphansToProcess = orphanedParts; orphansToProcess = orphanedParts;
@ -96,11 +104,13 @@ final class MultiblockWorldRegistry {
} }
if (orphansToProcess != null && orphansToProcess.size() > 0) { if (orphansToProcess != null && orphansToProcess.size() > 0) {
// IChunkProvider chunkProvider = this.worldObj.getChunkProvider(); // IChunkProvider chunkProvider =
// this.worldObj.getChunkProvider();
Set<Multiblock> compatibleMultiblocks; Set<Multiblock> compatibleMultiblocks;
// Process orphaned blocks // Process orphaned blocks
// These are blocks that exist in a valid chunk and require a multiblock // These are blocks that exist in a valid chunk and require a
// multiblock
for (ITileMultiblockPart orphan : orphansToProcess) { for (ITileMultiblockPart orphan : orphansToProcess) {
coord = orphan.getTilePos(); coord = orphan.getTilePos();
if (!worldObj.isBlockLoaded(coord)) { if (!worldObj.isBlockLoaded(coord)) {
@ -122,7 +132,8 @@ final class MultiblockWorldRegistry {
compatibleMultiblocks = orphan.attachToNeighbors(); compatibleMultiblocks = orphan.attachToNeighbors();
if (compatibleMultiblocks == null) { if (compatibleMultiblocks == null) {
// FOREVER ALONE! Create and register a new multiblock. // FOREVER ALONE! Create and register a new multiblock.
// THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE CREATED. // THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE
// CREATED.
Multiblock newMultiblock = orphan.createNewMultiblock(); Multiblock newMultiblock = orphan.createNewMultiblock();
newMultiblock.attachBlock(orphan); newMultiblock.attachBlock(orphan);
multiblocks.add(newMultiblock); multiblocks.add(newMultiblock);
@ -133,13 +144,15 @@ final class MultiblockWorldRegistry {
} }
// THIS IS THE ONLY PLACE WHERE MERGES ARE DETECTED // THIS IS THE ONLY PLACE WHERE MERGES ARE DETECTED
// Multiple compatible multiblocks indicates an impending merge. // Multiple compatible multiblocks indicates an
// impending merge.
// Locate the appropriate merge pool(s) // Locate the appropriate merge pool(s)
// boolean hasAddedToPool = false; // boolean hasAddedToPool = false;
List<Set<Multiblock>> candidatePools = new ArrayList<>(); List<Set<Multiblock>> candidatePools = new ArrayList<>();
for (Set<Multiblock> candidatePool : mergePools) { for (Set<Multiblock> candidatePool : mergePools) {
if (!Collections.disjoint(candidatePool, compatibleMultiblocks)) { if (!Collections.disjoint(candidatePool, compatibleMultiblocks)) {
// They share at least one element, so that means they will all touch after the merge // They share at least one element, so that
// means they will all touch after the merge
candidatePools.add(candidatePool); candidatePools.add(candidatePool);
} }
} }
@ -153,7 +166,8 @@ final class MultiblockWorldRegistry {
candidatePools.get(0).addAll(compatibleMultiblocks); candidatePools.get(0).addAll(compatibleMultiblocks);
} }
else { else {
// Multiple pools- merge into one, then add the compatible multiblocks // Multiple pools- merge into one, then add the
// compatible multiblocks
Set<Multiblock> masterPool = candidatePools.get(0); Set<Multiblock> masterPool = candidatePools.get(0);
Set<Multiblock> consumedPool; Set<Multiblock> consumedPool;
for (int i = 1; i < candidatePools.size(); i++) { for (int i = 1; i < candidatePools.size(); i++) {
@ -169,10 +183,15 @@ final class MultiblockWorldRegistry {
} }
if (mergePools != null && mergePools.size() > 0) { if (mergePools != null && mergePools.size() > 0) {
// Process merges - any machines that have been marked for merge should be merged into the "master" machine. // Process merges - any machines that have been marked for merge
// To do this, we combine lists of machines that are touching one another and therefore should voltron the fuck up. // should be merged
// into the "master" machine.
// To do this, we combine lists of machines that are touching one
// another and therefore
// should voltron the fuck up.
for (Set<Multiblock> mergePool : mergePools) { for (Set<Multiblock> mergePool : mergePools) {
// Search for the new master machine, which will take over all the blocks contained in the other machines // Search for the new master machine, which will take over all
// the blocks contained in the other machines
Multiblock newMaster = null; Multiblock newMaster = null;
for (Multiblock multiblock : mergePool) { for (Multiblock multiblock : mergePool) {
if (newMaster == null || multiblock.shouldConsume(newMaster)) { if (newMaster == null || multiblock.shouldConsume(newMaster)) {
@ -184,7 +203,8 @@ final class MultiblockWorldRegistry {
FMLLog.severe("Multiblock system checked a merge pool of size %d, found no master candidates. This should never happen.", mergePool.size()); FMLLog.severe("Multiblock system checked a merge pool of size %d, found no master candidates. This should never happen.", mergePool.size());
} }
else { else {
// Merge all the other machines into the master machine, then unregister them // Merge all the other machines into the master machine,
// then unregister them
addDirtyMultiblock(newMaster); addDirtyMultiblock(newMaster);
for (Multiblock multiblock : mergePool) { for (Multiblock multiblock : mergePool) {
if (multiblock != newMaster) { if (multiblock != newMaster) {
@ -198,14 +218,18 @@ final class MultiblockWorldRegistry {
} }
// Process splits and assembly // Process splits and assembly
// Any multiblocks which have had parts removed must be checked to see if some parts are no longer physically connected to their master. // Any multiblocks which have had parts removed must be checked to see
// if some parts are no longer
// physically connected to their master.
if (dirtyMultiblocks.size() > 0) { if (dirtyMultiblocks.size() > 0) {
Set<ITileMultiblockPart> newlyDetachedParts = null; Set<ITileMultiblockPart> newlyDetachedParts = null;
for (Multiblock multiblock : dirtyMultiblocks) { for (Multiblock multiblock : dirtyMultiblocks) {
// Tell the machine to check if any parts are disconnected. // Tell the machine to check if any parts are disconnected.
// It should return a set of parts which are no longer connected. // It should return a set of parts which are no longer
// connected.
// POSTCONDITION: The multiblock must have informed those parts // POSTCONDITION: The multiblock must have informed those parts
// that they are no longer connected to this machine. // that
// they are no longer connected to this machine.
newlyDetachedParts = multiblock.checkForDisconnections(); newlyDetachedParts = multiblock.checkForDisconnections();
if (!multiblock.isEmpty()) { if (!multiblock.isEmpty()) {
@ -217,7 +241,8 @@ final class MultiblockWorldRegistry {
} }
if (newlyDetachedParts != null && newlyDetachedParts.size() > 0) { if (newlyDetachedParts != null && newlyDetachedParts.size() > 0) {
// Multiblock has shed some parts - add them to the detached list for delayed processing // Multiblock has shed some parts - add them to the detached
// list for delayed processing
detachedParts.addAll(newlyDetachedParts); detachedParts.addAll(newlyDetachedParts);
} }
} }
@ -228,7 +253,8 @@ final class MultiblockWorldRegistry {
// Unregister dead multiblocks // Unregister dead multiblocks
if (deadMultiblocks.size() > 0) { if (deadMultiblocks.size() > 0) {
for (Multiblock multiblock : deadMultiblocks) { for (Multiblock multiblock : deadMultiblocks) {
// Go through any multiblocks which have marked themselves as potentially dead. // Go through any multiblocks which have marked themselves as
// potentially dead.
// Validate that they are empty/dead, then unregister them. // Validate that they are empty/dead, then unregister them.
if (!multiblock.isEmpty()) { if (!multiblock.isEmpty()) {
FMLLog.severe("Found a non-empty multiblock. Forcing it to shed its blocks and die. This should never happen!"); FMLLog.severe("Found a non-empty multiblock. Forcing it to shed its blocks and die. This should never happen!");
@ -243,8 +269,10 @@ final class MultiblockWorldRegistry {
} }
// Process detached blocks // Process detached blocks
// Any blocks which have been detached this tick should be moved to the orphaned // Any blocks which have been detached this tick should be moved to the
// list, and will be checked next tick to see if their chunk is still loaded. // orphaned
// list, and will be checked next tick to see if their chunk is still
// loaded.
for (ITileMultiblockPart part : detachedParts) { for (ITileMultiblockPart part : detachedParts) {
// Ensure parts know they're detached // Ensure parts know they're detached
part.assertDetached(); part.assertDetached();

View File

@ -2,15 +2,16 @@ package nc.multiblock.fission.salt.tile;
import static nc.block.property.BlockProperties.FACING_ALL; import static nc.block.property.BlockProperties.FACING_ALL;
import nc.Global;
import nc.multiblock.container.*; import nc.multiblock.container.*;
import nc.multiblock.cuboidal.CuboidalPartPositionType; import nc.multiblock.cuboidal.CuboidalPartPositionType;
import nc.multiblock.fission.FissionReactor; import nc.multiblock.fission.FissionReactor;
import nc.multiblock.fission.tile.*; import nc.multiblock.fission.tile.*;
import nc.util.RegistryHelper;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry;
public class TileSaltFissionController extends TileFissionPart implements IFissionController { public class TileSaltFissionController extends TileFissionPart implements IFissionController {
@ -57,7 +58,7 @@ public class TileSaltFissionController extends TileFissionPart implements IFissi
@Override @Override
public void doMeltdown() { public void doMeltdown() {
IBlockState corium = FluidRegistry.getFluid("corium").getBlock().getDefaultState(); IBlockState corium = RegistryHelper.getBlock(Global.MOD_ID + ":fluid_corium").getDefaultState();
world.removeTileEntity(pos); world.removeTileEntity(pos);
world.setBlockState(pos, corium); world.setBlockState(pos, corium);
} }

View File

@ -13,7 +13,7 @@ import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.longs.*; import it.unimi.dsi.fastutil.longs.*;
import it.unimi.dsi.fastutil.objects.*; import it.unimi.dsi.fastutil.objects.*;
import nc.ModCheck; import nc.*;
import nc.capability.radiation.source.IRadiationSource; import nc.capability.radiation.source.IRadiationSource;
import nc.multiblock.cuboidal.CuboidalPartPositionType; import nc.multiblock.cuboidal.CuboidalPartPositionType;
import nc.multiblock.fission.*; import nc.multiblock.fission.*;
@ -28,7 +28,7 @@ import nc.tile.ITileGui;
import nc.tile.fluid.*; import nc.tile.fluid.*;
import nc.tile.generator.IFluidGenerator; import nc.tile.generator.IFluidGenerator;
import nc.tile.internal.fluid.*; import nc.tile.internal.fluid.*;
import nc.util.CapabilityHelper; import nc.util.*;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -36,7 +36,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.*; import net.minecraft.util.math.*;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
public class TileSaltFissionVessel extends TileFissionPart implements ITileFilteredFluid, ITileGui<SaltFissionVesselUpdatePacket>, IFluidGenerator, IFissionFuelComponent, IFissionPortTarget<TileFissionVesselPort, TileSaltFissionVessel> { public class TileSaltFissionVessel extends TileFissionPart implements ITileFilteredFluid, ITileGui<SaltFissionVesselUpdatePacket>, IFluidGenerator, IFissionFuelComponent, IFissionPortTarget<TileFissionVesselPort, TileSaltFissionVessel> {
@ -327,7 +327,7 @@ public class TileSaltFissionVessel extends TileFissionPart implements ITileFilte
RadiationHelper.addToSourceRadiation(chunkSource, 8D * baseProcessRadiation * getSpeedMultiplier() * fission_meltdown_radiation_multiplier); RadiationHelper.addToSourceRadiation(chunkSource, 8D * baseProcessRadiation * getSpeedMultiplier() * fission_meltdown_radiation_multiplier);
} }
IBlockState corium = FluidRegistry.getFluid("corium").getBlock().getDefaultState(); IBlockState corium = RegistryHelper.getBlock(Global.MOD_ID + ":fluid_corium").getDefaultState();
world.removeTileEntity(pos); world.removeTileEntity(pos);
world.setBlockState(pos, corium); world.setBlockState(pos, corium);

View File

@ -36,7 +36,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*; import net.minecraft.util.*;
import net.minecraft.util.math.*; import net.minecraft.util.math.*;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.items.*; import net.minecraftforge.items.*;
public class TileSolidFissionCell extends TileFissionPart implements ITileFilteredInventory, ITileGui<SolidFissionCellUpdatePacket>, IItemGenerator, IFissionFuelComponent, IFissionPortTarget<TileFissionCellPort, TileSolidFissionCell> { public class TileSolidFissionCell extends TileFissionPart implements ITileFilteredInventory, ITileGui<SolidFissionCellUpdatePacket>, IItemGenerator, IFissionFuelComponent, IFissionPortTarget<TileFissionCellPort, TileSolidFissionCell> {
@ -313,7 +312,7 @@ public class TileSolidFissionCell extends TileFissionPart implements ITileFilter
RadiationHelper.addToSourceRadiation(chunkSource, 8D * baseProcessRadiation * getSpeedMultiplier() * fission_meltdown_radiation_multiplier); RadiationHelper.addToSourceRadiation(chunkSource, 8D * baseProcessRadiation * getSpeedMultiplier() * fission_meltdown_radiation_multiplier);
} }
IBlockState corium = FluidRegistry.getFluid("corium").getBlock().getDefaultState(); IBlockState corium = RegistryHelper.getBlock(Global.MOD_ID + ":fluid_corium").getDefaultState();
world.removeTileEntity(pos); world.removeTileEntity(pos);
world.setBlockState(pos, corium); world.setBlockState(pos, corium);

View File

@ -2,15 +2,16 @@ package nc.multiblock.fission.solid.tile;
import static nc.block.property.BlockProperties.FACING_ALL; import static nc.block.property.BlockProperties.FACING_ALL;
import nc.Global;
import nc.multiblock.container.*; import nc.multiblock.container.*;
import nc.multiblock.cuboidal.CuboidalPartPositionType; import nc.multiblock.cuboidal.CuboidalPartPositionType;
import nc.multiblock.fission.FissionReactor; import nc.multiblock.fission.FissionReactor;
import nc.multiblock.fission.tile.*; import nc.multiblock.fission.tile.*;
import nc.util.RegistryHelper;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry;
public class TileSolidFissionController extends TileFissionPart implements IFissionController { public class TileSolidFissionController extends TileFissionPart implements IFissionController {
@ -57,7 +58,7 @@ public class TileSolidFissionController extends TileFissionPart implements IFiss
@Override @Override
public void doMeltdown() { public void doMeltdown() {
IBlockState corium = FluidRegistry.getFluid("corium").getBlock().getDefaultState(); IBlockState corium = RegistryHelper.getBlock(Global.MOD_ID + ":fluid_corium").getDefaultState();
world.removeTileEntity(pos); world.removeTileEntity(pos);
world.setBlockState(pos, corium); world.setBlockState(pos, corium);
} }

View File

@ -1,14 +1,10 @@
package nc.multiblock.qComputer; package nc.multiblock.qComputer;
import static nc.config.NCConfig.*; import static nc.config.NCConfig.quantum_max_qubits;
import static nc.multiblock.qComputer.QuantumGate.*;
import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.commons.io.FileUtils;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import it.unimi.dsi.fastutil.objects.*; import it.unimi.dsi.fastutil.objects.*;
import nc.Global; import nc.Global;
@ -20,10 +16,7 @@ import nc.multiblock.tile.TileBeefAbstract.SyncReason;
import nc.network.PacketHandler; import nc.network.PacketHandler;
import nc.util.*; import nc.util.*;
import nc.util.Vector; import nc.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.*;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
public class QuantumComputer extends Multiblock<IQuantumComputerPart, MultiblockUpdatePacket> { public class QuantumComputer extends Multiblock<IQuantumComputerPart, MultiblockUpdatePacket> {
@ -38,9 +31,6 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
protected Queue<QuantumGate> queue = new ConcurrentLinkedQueue<>(); protected Queue<QuantumGate> queue = new ConcurrentLinkedQueue<>();
public boolean qasmStart = false, qasmWrite = false;
protected StringBuilder qasmStringBuilder = new StringBuilder();
public QuantumComputer(World world) { public QuantumComputer(World world) {
super(world); super(world);
for (Class<? extends IQuantumComputerPart> clazz : PART_CLASSES) { for (Class<? extends IQuantumComputerPart> clazz : PART_CLASSES) {
@ -81,13 +71,9 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
onQuantumComputerFormed(); onQuantumComputerFormed();
} }
public static int getMaxQubits() {
return Math.max(quantum_max_qubits_live, quantum_max_qubits_qasm);
}
protected void onQuantumComputerFormed() { protected void onQuantumComputerFormed() {
if (!WORLD.isRemote) { if (!WORLD.isRemote) {
IntSet set = new IntOpenHashSet(); IntSet set = new IntOpenHashSet(quantum_max_qubits);
for (TileQuantumComputerQubit qubit : getQubits()) { for (TileQuantumComputerQubit qubit : getQubits()) {
if (set.contains(qubit.id)) { if (set.contains(qubit.id)) {
qubit.id = -1; qubit.id = -1;
@ -146,8 +132,8 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
return false; return false;
} }
int q = qubitCount(); int q = qubitCount();
if (q > getMaxQubits()) { if (q > quantum_max_qubits) {
multiblock.setLastError(Global.MOD_ID + ".multiblock_validation.quantum_computer.too_many_qubits", null, q, getMaxQubits()); multiblock.setLastError(Global.MOD_ID + ".multiblock_validation.quantum_computer.too_many_qubits", null, q, quantum_max_qubits);
return false; return false;
} }
@ -171,18 +157,10 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
@Override @Override
protected boolean updateServer() { protected boolean updateServer() {
boolean refresh = false; boolean refresh = false;
int q = qubitCount();
if (qasmStart) {
qasmStart = false;
qasmWrite = true;
qasmStringBuilder = new StringBuilder();
}
QuantumGate gate = queue.poll(); QuantumGate gate = queue.poll();
if (gate != null) { if (gate != null) {
try { try {
tryLoadStateCache(dim(q)); tryLoadStateCache(dim(qubitCount()));
QuantumGate merger = gate, next; QuantumGate merger = gate, next;
while (merger != null) { while (merger != null) {
next = queue.peek(); next = queue.peek();
@ -197,30 +175,15 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
gate = merger; gate = merger;
} }
} }
if (qasmWrite) {
if (q <= quantum_max_qubits_qasm) {
List<String> qasmCode = gate.qasmCode();
if (!qasmCode.isEmpty()) {
qasmStringBuilder.append(IOHelper.NEW_LINE);
}
for (String line : qasmCode) {
qasmStringBuilder.append(line);
qasmStringBuilder.append(IOHelper.NEW_LINE);
}
}
}
else if (q <= quantum_max_qubits_live) {
gate.run(); gate.run();
refresh = gate.shouldMarkDirty(); refresh = gate.shouldMarkDirty();
} }
}
catch (OutOfMemoryError e) { catch (OutOfMemoryError e) {
if (controller != null) { if (controller != null) {
WORLD.removeTileEntity(controller.getPos()); WORLD.removeTileEntity(controller.getPos());
WORLD.setBlockToAir(controller.getPos()); WORLD.setBlockToAir(controller.getPos());
} }
NCUtil.getLogger().fatal("The quantum computer with " + q + " qubits at " + getMiddleCoord().toString() + " has caused the game to run out of heap memory! The controller has been destroyed and so the multiblock has been disabled. It is HIGHLY recommended that the maximum qubit limits are lowered in the configs!"); NCUtil.getLogger().fatal("The quantum computer at " + getMiddleCoord().toString() + " has caused the game to run out of heap memory! The controller has been destroyed and so the multiblock has been disabled. It is HIGHLY recommended that the maximum qubit limit is lowered in the configs!");
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
@ -240,13 +203,13 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
@Override @Override
public void syncDataFrom(NBTTagCompound data, SyncReason syncReason) { public void syncDataFrom(NBTTagCompound data, SyncReason syncReason) {
cache = Vector.readFromNBT(data, "state"); cache = Vector.readFromNBT(data, "state");
} }
@Override @Override
public void syncDataTo(NBTTagCompound data, SyncReason syncReason) { public void syncDataTo(NBTTagCompound data, SyncReason syncReason) {
if (qubitCount() <= quantum_max_qubits_live) {
state.writeToNBT(data, "state"); state.writeToNBT(data, "state");
}
} }
protected boolean tryLoadStateCache(int dim) { protected boolean tryLoadStateCache(int dim) {
@ -270,11 +233,11 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
// Quantum Logic // Quantum Logic
public Collection<TileQuantumComputerQubit> getQubits() { protected Collection<TileQuantumComputerQubit> getQubits() {
return getParts(TileQuantumComputerQubit.class); return getParts(TileQuantumComputerQubit.class);
} }
public int qubitCount() { protected int qubitCount() {
return getPartCount(TileQuantumComputerQubit.class); return getPartCount(TileQuantumComputerQubit.class);
} }
@ -299,7 +262,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
} }
protected void checkStateDim(int dim) { protected void checkStateDim(int dim) {
if (state.dim != dim && qubitCount() <= quantum_max_qubits_live) { if (state.dim != dim) {
state = new Vector(dim); state = new Vector(dim);
} }
} }
@ -329,7 +292,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
protected void refreshState(boolean collapse) { protected void refreshState(boolean collapse) {
int q = qubitCount(); int q = qubitCount();
if (q > getMaxQubits()) { if (q > quantum_max_qubits) {
return; return;
} }
@ -464,22 +427,22 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
/** Angle in degrees! */ /** Angle in degrees! */
public void p(double angle, IntSet n) { public void p(double angle, IntSet n) {
gate(single(QuantumGate.p(angle), list(n))); gate(single(p(angle), list(n)));
} }
/** Angle in degrees! */ /** Angle in degrees! */
public void rx(double angle, IntSet n) { public void rx(double angle, IntSet n) {
gate(single(QuantumGate.rx(angle), list(n))); gate(single(rx(angle), list(n)));
} }
/** Angle in degrees! */ /** Angle in degrees! */
public void ry(double angle, IntSet n) { public void ry(double angle, IntSet n) {
gate(single(QuantumGate.ry(angle), list(n))); gate(single(ry(angle), list(n)));
} }
/** Angle in degrees! */ /** Angle in degrees! */
public void rz(double angle, IntSet n) { public void rz(double angle, IntSet n) {
gate(single(QuantumGate.rz(angle), list(n))); gate(single(rz(angle), list(n)));
} }
public void swap(IntList i_, IntList j_) { public void swap(IntList i_, IntList j_) {
@ -592,22 +555,22 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
/** Angle in degrees! */ /** Angle in degrees! */
public void cp(double angle, IntSet c, IntSet t) { public void cp(double angle, IntSet c, IntSet t) {
gate(control(QuantumGate.p(angle), list(c), list(t))); gate(control(p(angle), list(c), list(t)));
} }
/** Angle in degrees! */ /** Angle in degrees! */
public void crx(double angle, IntSet c, IntSet t) { public void crx(double angle, IntSet c, IntSet t) {
gate(control(QuantumGate.rx(angle), list(c), list(t))); gate(control(rx(angle), list(c), list(t)));
} }
/** Angle in degrees! */ /** Angle in degrees! */
public void cry(double angle, IntSet c, IntSet t) { public void cry(double angle, IntSet c, IntSet t) {
gate(control(QuantumGate.ry(angle), list(c), list(t))); gate(control(ry(angle), list(c), list(t)));
} }
/** Angle in degrees! */ /** Angle in degrees! */
public void crz(double angle, IntSet c, IntSet t) { public void crz(double angle, IntSet c, IntSet t) {
gate(control(QuantumGate.rz(angle), list(c), list(t))); gate(control(rz(angle), list(c), list(t)));
} }
// Don't know how to optimise this! // Don't know how to optimise this!
@ -638,6 +601,7 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
Matrix m = new Matrix(dim), p; Matrix m = new Matrix(dim), p;
Matrix[] e = new Matrix[q]; Matrix[] e = new Matrix[q];
boolean b; boolean b;
double re, im;
for (int u = 0; u < s; u++) { for (int u = 0; u < s; u++) {
k = 0; k = 0;
for (int v = 0; v < q; v++) { for (int v = 0; v < q; v++) {
@ -661,8 +625,19 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
j = q - j - 1; j = q - j - 1;
if (NCMath.getBit(l, i) == 0 && NCMath.getBit(l, j) == 1) { if (NCMath.getBit(l, i) == 0 && NCMath.getBit(l, j) == 1) {
w = NCMath.swap(l, i, j); w = NCMath.swap(l, i, j);
p.swap(l, l, w, l); re = p.re[l][l];
p.swap(w, w, l, w); im = p.im[l][l];
p.re[l][l] = p.re[w][l];
p.im[l][l] = p.im[w][l];
p.re[w][l] = re;
p.im[w][l] = im;
re = p.re[w][w];
im = p.im[w][w];
p.re[w][w] = p.re[l][w];
p.im[w][w] = p.im[l][w];
p.re[l][w] = re;
p.im[l][w] = im;
} }
} }
} }
@ -673,44 +648,79 @@ public class QuantumComputer extends Multiblock<IQuantumComputerPart, Multiblock
gate(m); gate(m);
} }
public void qasmPrint(EntityPlayer player) { // Static
if (!qasmWrite) {
return; protected static int dim(int n) {
return 1 << n;
} }
qasmWrite = false; protected static Matrix id(int n) {
return new Matrix(dim(n)).id();
int q = qubitCount();
if (q > quantum_max_qubits_qasm) {
player.sendMessage(new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.controller.qasm_exit_too_many_qubits")));
return;
} }
String qasmString = qasmStringBuilder.toString(); public static IntSet set(int... n) {
qasmStringBuilder = new StringBuilder(); return new IntOpenHashSet(n);
if (qasmString.isEmpty()) {
player.sendMessage(new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.controller.qasm_exit")));
return;
} }
File out = new File("nuclearcraft/quantum/" + q + "_qubit_" + System.currentTimeMillis() + ".qasm"); public static IntList list(IntSet n) {
IntList l = new IntArrayList(n.size());
String s = IOHelper.NEW_LINE; for (int i = 0; i < quantum_max_qubits; i++) {
qasmString = "OPENQASM 2.0;" + s + "include \"qelib1.inc\";" + s + s + "qreg q[" + q + "];" + s + "creg c[" + q + "];" + s + qasmString; if (n.contains(i)) {
l.add(i);
ITextComponent link = new TextComponentString(out.getName());
link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, out.getAbsolutePath())).setBold(true).setUnderlined(true);
try {
FileUtils.writeStringToFile(out, qasmString);
player.sendMessage(new TextComponentTranslation("info.nuclearcraft.multitool.quantum_computer.controller.qasm_print", new Object[] {link}));
} }
catch (IOException e) { }
NCUtil.getLogger().catching(e); return l;
player.sendMessage(new TextComponentTranslation("info.nuclearcraft.multitool.quantum_computer.controller.qasm_error", new Object[] {link}));
} }
qasmString = ""; public static String intSetToString(IntSet set) {
return Arrays.toString(list(set).toIntArray());
} }
public static String intListToString(IntList list) {
return Arrays.toString(list.toIntArray());
}
protected static final Matrix I = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 1D, 0D}});
protected static final Matrix X = new Matrix(new double[][] {new double[] {0D, 0D, 1D, 0D}, new double[] {1D, 0D, 0D, 0D}});
protected static final Matrix Y = new Matrix(new double[][] {new double[] {0D, 0D, 0D, -1D}, new double[] {0D, 1D, 0D, 0D}});
protected static final Matrix Z = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, -1D, 0D}});
protected static final Matrix H = new Matrix(new double[][] {new double[] {1D, 0D, 1D, 0D}, new double[] {1D, 0D, -1D, 0D}}).multiply(NCMath.INV_SQRT2);
protected static final Matrix S = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, 1D}});
protected static final Matrix Sdg = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, -1D}});
protected static final Matrix T = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, NCMath.INV_SQRT2, NCMath.INV_SQRT2}});
protected static final Matrix Tdg = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, NCMath.INV_SQRT2, -NCMath.INV_SQRT2}});
/** Angle in degrees! */
protected static Matrix 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]}});
}
/** Angle in degrees! */
protected 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}});
}
/** Angle in degrees! */
protected 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}});
}
/** Angle in degrees! */
protected static Matrix 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]}});
}
protected static final Matrix P_0 = new Matrix(new double[][] {new double[] {1D, 0D, 0D, 0D}, new double[] {0D, 0D, 0D, 0D}});
protected static final Matrix P_1 = new Matrix(new double[][] {new double[] {0D, 0D, 0D, 0D}, new double[] {0D, 0D, 1D, 0D}});
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,9 @@
package nc.multiblock.qComputer.tile; package nc.multiblock.qComputer.tile;
import nc.config.NCConfig;
import nc.multiblock.qComputer.*; import nc.multiblock.qComputer.*;
import nc.util.Lang;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*; import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World; import net.minecraft.world.World;
public class TileQuantumComputerController extends TileQuantumComputerPart implements ITickable { public class TileQuantumComputerController extends TileQuantumComputerPart implements ITickable {
@ -49,27 +44,6 @@ public class TileQuantumComputerController extends TileQuantumComputerPart imple
} }
} }
@Override
public boolean onUseMultitool(ItemStack multitoolStack, EntityPlayer player, World world, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
QuantumComputer qc = getMultiblock();
if (qc != null) {
if (qc.qasmWrite) {
qc.qasmPrint(player);
}
else if (qc.qubitCount() <= NCConfig.quantum_max_qubits_qasm) {
qc.qasmStart = true;
player.sendMessage(new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.controller.qasm_start")));
}
else {
player.sendMessage(new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.controller.qasm_too_many_qubits")));
}
return true;
}
}
return super.onUseMultitool(multitoolStack, player, world, facing, hitX, hitY, hitZ);
}
@Override @Override
public NBTTagCompound writeAll(NBTTagCompound nbt) { public NBTTagCompound writeAll(NBTTagCompound nbt) {
super.writeAll(nbt); super.writeAll(nbt);

View File

@ -1,7 +1,5 @@
package nc.multiblock.qComputer.tile; package nc.multiblock.qComputer.tile;
import static nc.multiblock.qComputer.QuantumGate.*;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import nc.multiblock.qComputer.*; import nc.multiblock.qComputer.*;
import nc.util.*; import nc.util.*;
@ -31,7 +29,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
@Override @Override
public TextComponentString gateInfo() { public TextComponentString gateInfo() {
return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.single_gate_info", intSetToString(n))); return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.single_gate_info", QuantumComputer.intSetToString(n)));
} }
@Override @Override
@ -49,7 +47,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setTarget") && !player.isSneaking()) { else if (toolMode.equals("setTarget") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, n, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, n, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(n)))); player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", QuantumComputer.intSetToString(n))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getTarget"; toolMode = "getTarget";
@ -181,7 +179,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
@Override @Override
public TextComponentString gateInfo() { public TextComponentString gateInfo() {
return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.single_angle_gate_info", intSetToString(n), NCMath.decimalPlaces(angle, 5))); return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.single_angle_gate_info", QuantumComputer.intSetToString(n), NCMath.decimalPlaces(angle, 5)));
} }
@Override @Override
@ -219,7 +217,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setTarget") && !player.isSneaking()) { else if (toolMode.equals("setTarget") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, n, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, n, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(n)))); player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", QuantumComputer.intSetToString(n))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getAngle"; toolMode = "getAngle";
@ -305,7 +303,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
@Override @Override
public TextComponentString gateInfo() { public TextComponentString gateInfo() {
return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.control_gate_info", intSetToString(t), intSetToString(c))); return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.control_gate_info", QuantumComputer.intSetToString(t), QuantumComputer.intSetToString(c)));
} }
@Override @Override
@ -323,7 +321,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setControl") && !player.isSneaking()) { else if (toolMode.equals("setControl") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, c, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, c, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", intSetToString(c)))); player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", QuantumComputer.intSetToString(c))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getTarget"; toolMode = "getTarget";
@ -343,7 +341,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setTarget") && !player.isSneaking()) { else if (toolMode.equals("setTarget") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, t, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, t, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(t)))); player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", QuantumComputer.intSetToString(t))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getControl"; toolMode = "getControl";
@ -477,7 +475,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
@Override @Override
public TextComponentString gateInfo() { public TextComponentString gateInfo() {
return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.control_angle_gate_info", intSetToString(t), NCMath.decimalPlaces(angle, 5), intSetToString(c))); return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.control_angle_gate_info", QuantumComputer.intSetToString(t), NCMath.decimalPlaces(angle, 5), QuantumComputer.intSetToString(c)));
} }
@Override @Override
@ -515,7 +513,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setControl") && !player.isSneaking()) { else if (toolMode.equals("setControl") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, c, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, c, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", intSetToString(c)))); player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", QuantumComputer.intSetToString(c))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getTarget"; toolMode = "getTarget";
@ -535,7 +533,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setTarget") && !player.isSneaking()) { else if (toolMode.equals("setTarget") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, t, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, t, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", intSetToString(t)))); player.sendMessage(new TextComponentString(TextFormatting.BLUE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_target_set", QuantumComputer.intSetToString(t))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getAngle"; toolMode = "getAngle";
@ -626,7 +624,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
@Override @Override
public TextComponentString gateInfo() { public TextComponentString gateInfo() {
return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.swap_gate_info", intListToString(i), intListToString(j))); return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.swap_gate_info", QuantumComputer.intListToString(i), QuantumComputer.intListToString(j)));
} }
@Override @Override
@ -644,7 +642,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setFirst") && !player.isSneaking()) { else if (toolMode.equals("setFirst") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, i, "qubitIDList"); NBTHelper.loadIntCollection(nbt, i, "qubitIDList");
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_first_swap_list", intListToString(i)))); player.sendMessage(new TextComponentString(TextFormatting.GOLD + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_first_swap_list", QuantumComputer.intListToString(i))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getSecond"; toolMode = "getSecond";
@ -664,7 +662,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setSecond") && !player.isSneaking()) { else if (toolMode.equals("setSecond") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, j, "qubitIDList"); NBTHelper.loadIntCollection(nbt, j, "qubitIDList");
player.sendMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list", intListToString(j)))); player.sendMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list", QuantumComputer.intListToString(j))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getFirst"; toolMode = "getFirst";
@ -711,7 +709,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
@Override @Override
public TextComponentString gateInfo() { public TextComponentString gateInfo() {
return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.control_swap_gate_info", intListToString(i), intListToString(j), intSetToString(c))); return new TextComponentString(Lang.localise("info.nuclearcraft.multitool.quantum_computer.control_swap_gate_info", QuantumComputer.intListToString(i), QuantumComputer.intListToString(j), QuantumComputer.intSetToString(c)));
} }
@Override @Override
@ -729,7 +727,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setControl") && !player.isSneaking()) { else if (toolMode.equals("setControl") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, c, "qubitIDSet"); NBTHelper.loadIntCollection(nbt, c, "qubitIDSet");
player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", intSetToString(c)))); player.sendMessage(new TextComponentString(TextFormatting.RED + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_control_set", QuantumComputer.intSetToString(c))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getFirst"; toolMode = "getFirst";
@ -749,7 +747,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setFirst") && !player.isSneaking()) { else if (toolMode.equals("setFirst") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, i, "qubitIDList"); NBTHelper.loadIntCollection(nbt, i, "qubitIDList");
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_first_swap_list", intListToString(i)))); player.sendMessage(new TextComponentString(TextFormatting.GOLD + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_first_swap_list", QuantumComputer.intListToString(i))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getSecond"; toolMode = "getSecond";
@ -769,7 +767,7 @@ public abstract class TileQuantumComputerGate extends TileQuantumComputerPart im
} }
else if (toolMode.equals("setSecond") && !player.isSneaking()) { else if (toolMode.equals("setSecond") && !player.isSneaking()) {
NBTHelper.loadIntCollection(nbt, j, "qubitIDList"); NBTHelper.loadIntCollection(nbt, j, "qubitIDList");
player.sendMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list", intListToString(j)))); player.sendMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + Lang.localise("info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list", QuantumComputer.intListToString(j))));
nbt.setString("qubitMode", ""); nbt.setString("qubitMode", "");
nbt.setString("gateMode", ""); nbt.setString("gateMode", "");
toolMode = "getControl"; toolMode = "getControl";

View File

@ -2,14 +2,13 @@ package nc.proxy;
import static nc.config.NCConfig.register_projecte_emc; import static nc.config.NCConfig.register_projecte_emc;
import java.io.*; import java.io.IOException;
import java.util.Locale; import java.util.Locale;
import crafttweaker.CraftTweakerAPI; import crafttweaker.CraftTweakerAPI;
import nc.*; import nc.*;
import nc.capability.radiation.RadiationCapabilityHandler; import nc.capability.radiation.RadiationCapabilityHandler;
import nc.command.CommandHandler; import nc.command.CommandHandler;
import nc.config.NCConfig;
import nc.handler.*; import nc.handler.*;
import nc.init.*; import nc.init.*;
import nc.integration.crafttweaker.CTRegistration; import nc.integration.crafttweaker.CTRegistration;
@ -27,7 +26,7 @@ import nc.recipe.*;
import nc.recipe.vanilla.CraftingRecipeHandler; import nc.recipe.vanilla.CraftingRecipeHandler;
import nc.util.*; import nc.util.*;
import nc.worldgen.biome.NCBiomes; import nc.worldgen.biome.NCBiomes;
import nc.worldgen.decoration.MushroomGenerator; import nc.worldgen.decoration.BushGenerator;
import nc.worldgen.dimension.NCWorlds; import nc.worldgen.dimension.NCWorlds;
import nc.worldgen.ore.OreGenerator; import nc.worldgen.ore.OreGenerator;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -104,10 +103,6 @@ public class CommonProxy {
for (RegistrationInfo info : CTRegistration.INFO_LIST) { for (RegistrationInfo info : CTRegistration.INFO_LIST) {
info.preInit(); info.preInit();
} }
if (NCConfig.register_quantum) {
new File("nuclearcraft/quantum").mkdirs();
}
} }
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
@ -127,7 +122,7 @@ public class CommonProxy {
NCWorlds.registerDimensions(); NCWorlds.registerDimensions();
GameRegistry.registerWorldGenerator(new OreGenerator(), 0); GameRegistry.registerWorldGenerator(new OreGenerator(), 0);
GameRegistry.registerWorldGenerator(new MushroomGenerator(NCBlocks.glowing_mushroom.getDefaultState()), 100); GameRegistry.registerWorldGenerator(new BushGenerator(), 100);
// GameRegistry.registerWorldGenerator(new WastelandPortalGenerator(), 10); // GameRegistry.registerWorldGenerator(new WastelandPortalGenerator(), 10);
NCEntities.register(); NCEntities.register();

View File

@ -508,11 +508,6 @@ public class RadSources {
return (rad1 * amount1 + rad2 * amount2) * INGOT / 9D; return (rad1 * amount1 + rad2 * amount2) * INGOT / 9D;
} }
@Deprecated
public static double getDepletedFuelRadiation(double rad1, int amount1, double rad2, int amount2, double rad3, int amount3, double rad4, int amount4) {
return (rad1 * amount1 + rad2 * amount2 + rad3 * amount3 + rad4 * amount4) * INGOT / 9D;
}
public static double getDepletedFuelRadiation(double rad1, int amount1, double rad2, int amount2, double rad3, int amount3, double rad4, int amount4, double waste1, double waste2, double m, double r) { public static double getDepletedFuelRadiation(double rad1, int amount1, double rad2, int amount2, double rad3, int amount3, double rad4, int amount4, double waste1, double waste2, double m, double r) {
return (rad1 * amount1 + rad2 * amount2 + rad3 * amount3 + rad4 * amount4 + waste1 * m * r + waste2 * m * (1D - r)) * INGOT / 9D; return (rad1 * amount1 + rad2 * amount2 + rad3 * amount3 + rad4 * amount4 + waste1 * m * r + waste2 * m * (1D - r)) * INGOT / 9D;
} }

View File

@ -211,11 +211,11 @@ public class RadiationHandler {
return; return;
} }
if (playerRads.getRadXWoreOff() && playerRads.getRadXUsed()) { if (playerRads.getRadXWoreOff() && playerRads.getRadXUsed()) {
player.playSound(NCSounds.chems_wear_off, (float) (0.65D * radiation_sound_volumes[4]), 1F); player.playSound(NCSounds.chems_wear_off, 0.65F, 1F);
player.sendMessage(new TextComponentString(TextFormatting.ITALIC + RAD_X_WORE_OFF)); player.sendMessage(new TextComponentString(TextFormatting.ITALIC + RAD_X_WORE_OFF));
} }
if (playerRads.getShouldWarn()) { if (playerRads.getShouldWarn()) {
player.playSound(NCSounds.chems_wear_off, (float) (0.8D * radiation_sound_volumes[6]), 0.7F); player.playSound(NCSounds.chems_wear_off, 0.8F, 0.7F);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + RAD_WARNING)); player.sendMessage(new TextComponentString(TextFormatting.GOLD + RAD_WARNING));
} }
} }
@ -483,10 +483,10 @@ public class RadiationHandler {
} }
double soundChance = Math.cbrt(entityRads.getRawRadiationLevel() / 200D); double soundChance = Math.cbrt(entityRads.getRawRadiationLevel() / 200D);
double soundVolume = MathHelper.clamp(8D * soundChance, 0.55D, 1.1D); float soundVolume = MathHelper.clamp((float) (8F * soundChance), 0.55F, 1.1F);
for (int i = 0; i < loops; i++) { for (int i = 0; i < loops; i++) {
if (RAND.nextDouble() < soundChance) { if (RAND.nextDouble() < soundChance) {
player.playSound(NCSounds.geiger_tick, (float) ((soundVolume + RAND.nextDouble() * 0.12D) * radiation_sound_volumes[0]), 0.92F + RAND.nextFloat() * 0.16F); player.playSound(NCSounds.geiger_tick, soundVolume + RAND.nextFloat() * 0.12F, 0.92F + RAND.nextFloat() * 0.16F);
} }
} }
} }

View File

@ -24,12 +24,12 @@ public class RecipeStats {
setBlockPurificationThreshold(); setBlockPurificationThreshold();
} }
public static double getProcessorMaxBaseProcessTime(int processorID) { public static double getProcessorMaxBaseProcessTime(int i) {
return processor_max_base_process_time[processorID - 1]; return processor_max_base_process_time[i];
} }
public static double getProcessorMaxBaseProcessPower(int processorID) { public static double getProcessorMaxBaseProcessPower(int i) {
return processor_max_base_process_power[processorID - 1]; return processor_max_base_process_power[i];
} }
private static void setProcessorMaxStats() { private static void setProcessorMaxStats() {

View File

@ -4,7 +4,7 @@ import static nc.config.NCConfig.*;
import java.util.*; import java.util.*;
import com.google.common.collect.*; import com.google.common.collect.Lists;
import nc.radiation.RadSources; import nc.radiation.RadSources;
import nc.recipe.ProcessorRecipeHandler; import nc.recipe.ProcessorRecipeHandler;
@ -30,7 +30,7 @@ public class DecayGeneratorRecipes extends ProcessorRecipeHandler {
addDecayRecipes("Californium252", "Lead", decay_lifetime[8], decay_power[8], RadSources.CALIFORNIUM_252); addDecayRecipes("Californium252", "Lead", decay_lifetime[8], decay_power[8], RadSources.CALIFORNIUM_252);
} }
private static final Set<String> NON_FISSION = Sets.newHashSet("Lead", "Bismuth", "Thorium"); private static final List<String> NON_FISSION = Lists.newArrayList("Lead", "Bismuth", "Thorium");
public void addDecayRecipes(String input, String output, double lifetime, double power, double radiation) { public void addDecayRecipes(String input, String output, double lifetime, double power, double radiation) {
String inputName = "block" + input; String inputName = "block" + input;

View File

@ -4,7 +4,7 @@ import static nc.config.NCConfig.processor_time;
import java.util.*; import java.util.*;
import com.google.common.collect.*; import com.google.common.collect.Lists;
import nc.radiation.RadSources; import nc.radiation.RadSources;
import nc.recipe.*; import nc.recipe.*;
@ -63,7 +63,7 @@ public class DecayHastenerRecipes extends ProcessorRecipeHandler {
addDecayRecipes("Californium252", "Thorium", RadSources.CALIFORNIUM_252); addDecayRecipes("Californium252", "Thorium", RadSources.CALIFORNIUM_252);
} }
private static final Set<String> NON_FISSION = Sets.newHashSet("Thorium", "Lead", "Bismuth", "Thallium", "Radium", "Polonium", "TBP", "Zirconium", "Palladium", "Barium", "Neodymium", "Gadolinium"); private static final List<String> NON_FISSION = Lists.newArrayList("Lead", "Bismuth", "Radium", "Polonium", "Thorium", "TBP");
public void addDecayRecipes(String input, String output, double radiation) { public void addDecayRecipes(String input, String output, double radiation) {
String inputName = (OreDictHelper.oreExists("ingot" + input) ? "ingot" : "dust") + input; String inputName = (OreDictHelper.oreExists("ingot" + input) ? "ingot" : "dust") + input;

View File

@ -5,7 +5,7 @@ import static nc.util.FluidStackHelper.*;
import java.util.*; import java.util.*;
import com.google.common.collect.Sets; import com.google.common.collect.Lists;
import nc.init.NCItems; import nc.init.NCItems;
import nc.recipe.ProcessorRecipeHandler; import nc.recipe.ProcessorRecipeHandler;
@ -107,7 +107,7 @@ public class IngotFormerRecipes extends ProcessorRecipeHandler {
} }
} }
private static final Set<String> CASTING_BLACKLIST = Sets.newHashSet("glass", "coal", "redstone", "glowstone", "prismarine", "obsidian", "silicon", "marshmallow"); private static final List<String> CASTING_BLACKLIST = Lists.newArrayList("glass", "coal", "redstone", "glowstone", "prismarine", "obsidian", "silicon", "marshmallow");
public void addIngotFormingRecipes() { public void addIngotFormingRecipes() {
ArrayList<String> fluidList = new ArrayList(FluidRegistry.getRegisteredFluids().keySet()); ArrayList<String> fluidList = new ArrayList(FluidRegistry.getRegisteredFluids().keySet());

View File

@ -4,7 +4,7 @@ import static nc.config.NCConfig.*;
import java.util.*; import java.util.*;
import com.google.common.collect.*; import com.google.common.collect.Lists;
import nc.init.NCItems; import nc.init.NCItems;
import nc.recipe.*; import nc.recipe.*;
@ -98,7 +98,7 @@ public class ManufactoryRecipes extends ProcessorRecipeHandler {
addLogRecipes(); addLogRecipes();
} }
private static final Set<String> BLACKLIST = Sets.newHashSet("silicon"); private static final List<String> BLACKLIST = Lists.newArrayList("silicon");
public void addMetalProcessingRecipes() { public void addMetalProcessingRecipes() {
for (String ingot : OreDictionary.getOreNames()) { for (String ingot : OreDictionary.getOreNames()) {

View File

@ -5,7 +5,7 @@ import static nc.util.FluidStackHelper.*;
import java.util.*; import java.util.*;
import com.google.common.collect.*; import com.google.common.collect.Lists;
import nc.init.NCItems; import nc.init.NCItems;
import nc.recipe.ProcessorRecipeHandler; import nc.recipe.ProcessorRecipeHandler;
@ -195,7 +195,7 @@ public class MelterRecipes extends ProcessorRecipeHandler {
} }
} }
private static final Set<String> MELTING_BLACKLIST = Sets.newHashSet("coal", "redstone", "glowstone", "prismarine", "obsidian", "silicon", "marshmallow"); private static final List<String> MELTING_BLACKLIST = Lists.newArrayList("coal", "redstone", "glowstone", "prismarine", "obsidian", "silicon", "marshmallow");
public void addOreMeltingRecipes() { public void addOreMeltingRecipes() {
ArrayList<String> fluidList = new ArrayList(FluidRegistry.getRegisteredFluids().keySet()); ArrayList<String> fluidList = new ArrayList(FluidRegistry.getRegisteredFluids().keySet());

View File

@ -2,7 +2,7 @@ package nc.recipe.processor;
import java.util.*; import java.util.*;
import com.google.common.collect.*; import com.google.common.collect.Lists;
import nc.init.NCItems; import nc.init.NCItems;
import nc.recipe.ProcessorRecipeHandler; import nc.recipe.ProcessorRecipeHandler;
@ -42,7 +42,7 @@ public class PressurizerRecipes extends ProcessorRecipeHandler {
addPlatePressingRecipes(); addPlatePressingRecipes();
} }
private static final Set<String> PLATE_BLACKLIST = Sets.newHashSet("Graphite"); private static final List<String> PLATE_BLACKLIST = Lists.newArrayList("Graphite");
public void addPlatePressingRecipes() { public void addPlatePressingRecipes() {
for (String ore : OreDictionary.getOreNames()) { for (String ore : OreDictionary.getOreNames()) {

View File

@ -27,10 +27,8 @@ import vazkii.patchouli.common.item.ItemModBook;
public class CraftingRecipeHandler { public class CraftingRecipeHandler {
public static void registerCraftingRecipes() { public static void registerCraftingRecipes() {
if (ModCheck.patchouliLoaded()) {
addShapelessOreRecipe(ItemModBook.forBook("nuclearcraft:guide"), new Object[] {Items.BOOK, "ingotUranium"}); addShapelessOreRecipe(ItemModBook.forBook("nuclearcraft:guide"), new Object[] {Items.BOOK, "ingotUranium"});
addShapelessOreRecipe(Items.BOOK, new Object[] {ItemModBook.forBook("nuclearcraft:guide")}); addShapelessOreRecipe(Items.BOOK, new Object[] {ItemModBook.forBook("nuclearcraft:guide")});
}
for (int i = 0; i < IngotType.values().length; i++) { for (int i = 0; i < IngotType.values().length; i++) {
String type = StringHelper.capitalize(IngotType.values()[i].getName()); String type = StringHelper.capitalize(IngotType.values()[i].getName());

View File

@ -13,7 +13,6 @@ public class RenderQuantumComputerQubit extends TileEntitySpecialRenderer<TileQu
@Override @Override
public void render(TileQuantumComputerQubit qubit, double posX, double posY, double posZ, float partialTicks, int destroyStage, float alpha) { public void render(TileQuantumComputerQubit qubit, double posX, double posY, double posZ, float partialTicks, int destroyStage, float alpha) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
boolean up = qubit.measureColor > 0F, down = qubit.measureColor < 0F; boolean up = qubit.measureColor > 0F, down = qubit.measureColor < 0F;
float r = (float) NCMath.trapezoidalWave(time * 0.12D, 0D) + 6F * (down ? -qubit.measureColor : 0F); float r = (float) NCMath.trapezoidalWave(time * 0.12D, 0D) + 6F * (down ? -qubit.measureColor : 0F);
float g = (float) NCMath.trapezoidalWave(time * 0.12D, 120D); float g = (float) NCMath.trapezoidalWave(time * 0.12D, 120D);

View File

@ -204,7 +204,8 @@ public class TileNuclearFurnace extends TileEntity implements ITickable, ITileIn
if (cookTime == totalCookTime) { if (cookTime == totalCookTime) {
cookTime = 0; cookTime = 0;
// totalCookTime = getCookTime(furnaceItemStacks.get(0)); // totalCookTime =
// getCookTime(furnaceItemStacks.get(0));
totalCookTime = getCookTime(); totalCookTime = getCookTime();
smeltItem(); smeltItem();
flag1 = true; flag1 = true;

View File

@ -25,24 +25,6 @@ public class Complex {
return new double[] {re / scale, -im / scale}; return new double[] {re / scale, -im / scale};
} }
public static double[] sqrt(double re, double im) {
if (im == 0D) {
if (re >= 0D) {
return new double[] {Math.sqrt(re), 0D};
}
else {
return new double[] {0D, Math.sqrt(-re)};
}
}
double a = Math.sqrt((re + abs(re, im)) / 2D);
return new double[] {a, im / (2D * a)};
}
public static double[] invSqrt(double re, double im) {
double sq = absSq(re, im);
return sqrt(re / sq, -im / sq);
}
public static double[] divide(double re1, double im1, double re2, double im2) { public static double[] divide(double re1, double im1, double re2, double im2) {
double scale = absSq(re2, im2); double scale = absSq(re2, im2);
return new double[] {(re1 * re2 + im1 * im2) / scale, (im1 * re2 - re1 * im2) / scale}; return new double[] {(re1 * re2 + im1 * im2) / scale, (im1 * re2 - re1 * im2) / scale};

View File

@ -5,8 +5,6 @@ import java.util.zip.*;
public class IOHelper { public class IOHelper {
public static final String NEW_LINE = System.lineSeparator();
/** Modified from Srikanth A's answer at https://stackoverflow.com/a/45951007 */ /** Modified from Srikanth A's answer at https://stackoverflow.com/a/45951007 */
public static void appendFile(File target, File source, String separator) throws IOException { public static void appendFile(File target, File source, String separator) throws IOException {
FileWriter writer = new FileWriter(target, true); FileWriter writer = new FileWriter(target, true);
@ -31,7 +29,7 @@ public class IOHelper {
signature = raf.readInt(); signature = raf.readInt();
} }
catch (IOException e) { catch (IOException e) {
NCUtil.getLogger().catching(e);
} }
return signature == 0x504B0304 || signature == 0x504B0506 || signature == 0x504B0708; return signature == 0x504B0304 || signature == 0x504B0506 || signature == 0x504B0708;
} }

View File

@ -2,7 +2,6 @@ package nc.util;
import java.util.Arrays; import java.util.Arrays;
import it.unimi.dsi.fastutil.HashCommon;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
/** Only handles square matrices! */ /** Only handles square matrices! */
@ -141,88 +140,17 @@ public class Matrix {
return new double[] {re, im}; return new double[] {re, im};
} }
public void swap(int i1, int j1, int i2, int j2) {
double re = this.re[i1][j1];
double im = this.im[i1][j1];
this.re[i1][j1] = this.re[i2][j2];
this.im[i1][j1] = this.im[i2][j2];
this.re[i2][j2] = re;
this.im[i2][j2] = im;
}
/** Modified from Srikanth A's answer at https://stackoverflow.com/a/45951007 */
public double[] det() {
if (dim == 0) {
return new double[] {1D, 0D};
}
else if (dim == 1) {
return new double[] {re[0][0], im[0][0]};
}
else if (dim == 2) {
double[] ad = Complex.multiply(re[0][0], im[0][0], re[1][1], im[1][1]);
double[] bc = Complex.multiply(re[0][1], im[0][1], re[1][0], im[1][0]);
return new double[] {ad[0] - bc[0], ad[1] - bc[1]};
}
double re1, im1, re2, im2;
int index;
double[] det = new double[] {1D, 0D}, total = new double[] {1D, 0D};
double[] tempRe = new double[dim + 1], tempIm = new double[dim + 1];
Matrix m = copy();
for (int i = 0; i < dim; i++) {
index = i;
while (index < dim && m.re[index][i] == 0D && m.im[index][i] == 0D) {
index++;
}
if (index == dim) {
continue;
}
if (index != i) {
for (int j = 0; j < dim; j++) {
m.swap(index, j, i, j);
}
det = Complex.multiply(det[0], det[1], -1D, 0D);
}
for (int j = 0; j < dim; j++) {
tempRe[j] = m.re[i][j];
tempIm[j] = m.im[i][j];
}
for (int j = i + 1; j < dim; j++) {
re1 = tempRe[i];
im1 = tempIm[i];
re2 = m.re[j][i];
im2 = m.im[j][i];
for (int k = 0; k < dim; k++) {
double[] ad = Complex.multiply(re1, im1, m.re[j][k], m.im[j][k]);
double[] bc = Complex.multiply(re2, im2, tempRe[k], tempIm[k]);
m.re[j][k] = ad[0] - bc[0];
m.im[j][k] = ad[1] - bc[1];
}
total = Complex.multiply(total[0], total[1], re1, im1);
}
}
for (int i = 0; i < dim; i++) {
det = Complex.multiply(det[0], det[1], m.re[i][i], m.im[i][i]);
}
return Complex.divide(det[0], det[1], total[0], total[1]);
}
public Matrix transpose() { public Matrix transpose() {
double re, im;
for (int i = 0; i < dim; i++) { for (int i = 0; i < dim; i++) {
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
if (i != j) { if (i != j) {
swap(i, j, j, i); re = this.re[i][j];
im = this.im[i][j];
this.re[i][j] = this.re[j][i];
this.im[i][j] = this.im[j][i];
this.re[j][i] = re;
this.im[j][i] = im;
} }
} }
} }
@ -309,58 +237,22 @@ public class Matrix {
} }
public Matrix hermitian() { public Matrix hermitian() {
double re, im;
for (int i = 0; i < dim; i++) { for (int i = 0; i < dim; i++) {
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
if (i != j) { if (i != j) {
swap(i, j, j, i); re = this.re[i][j];
im = this.im[i][j];
this.re[i][j] = this.re[j][i];
this.im[i][j] = -this.im[j][i];
this.re[j][i] = re;
this.im[j][i] = -im;
} }
} }
} }
return this; return this;
} }
@Override
public int hashCode() {
int h = 1;
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
h = 31 * h + HashCommon.double2int(re[i][j]);
h = 31 * h + HashCommon.double2int(im[i][j]);
}
}
return h;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Matrix)) {
return false;
}
Matrix other = (Matrix) obj;
if (dim != other.dim) {
return false;
}
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
if (re[i][j] != other.re[i][j]) {
return false;
}
if (im[i][j] != other.im[i][j]) {
return false;
}
}
}
return true;
}
@Override @Override
public String toString() { public String toString() {
String s = "", v; String s = "", v;

View File

@ -0,0 +1,237 @@
package nc.worldgen.biome;
import java.util.Random;
import nc.init.NCBlocks;
import nc.worldgen.decoration.WorldGenBush;
import nc.worldgen.ore.UniversalOrePredicate;
import net.minecraft.block.BlockStone;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.*;
import net.minecraft.world.gen.feature.*;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType;
public class BiomeDecoratorNuclearWasteland extends BiomeDecorator {
private final int dirtSize = 4;
private final int gravelSize = 26;
private final int graniteSize = 20;
private final int dioriteSize = 20;
private final int andesiteSize = 20;
private final int coalSize = 10;
private final int ironSize = 9;
private final int goldSize = 9;
private final int redstoneSize = 9;
private final int diamondSize = 8;
private final int lapisSize = 8;
private final int dirtCount = 5;
private final int gravelCount = 10;
private final int dioriteCount = 7;
private final int graniteCount = 7;
private final int andesiteCount = 7;
private final int coalCount = 10;
private final int ironCount = 10;
private final int goldCount = 4;
private final int redstoneCount = 8;
private final int diamondCount = 1;
private final int lapisCount = 1;
private final int lapisCenterHeight = 6;
private final int lapisSpread = 16;
private final int oreGenMinHeight = 0;
private final int dirtMaxHeight = 30;
private final int gravelMaxHeight = 90;
private final int dioriteMaxHeight = 50;
private final int graniteMaxHeight = 50;
private final int andesiteMaxHeight = 50;
private final int coalMaxHeight = 64;
private final int ironMaxHeight = 64;
private final int goldMaxHeight = 48;
private final int redstoneMaxHeight = 16;
private final int diamondMaxHeight = 16;
protected WorldGenBush bushGen;
public BiomeDecoratorNuclearWasteland() {
dirtGen = new WorldGenMinable(Blocks.DIRT.getDefaultState(), dirtSize, new UniversalOrePredicate());
gravelOreGen = new WorldGenMinable(Blocks.GRAVEL.getDefaultState(), gravelSize, new UniversalOrePredicate());
graniteGen = new WorldGenMinable(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE), graniteSize, new UniversalOrePredicate());
dioriteGen = new WorldGenMinable(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE), dioriteSize, new UniversalOrePredicate());
andesiteGen = new WorldGenMinable(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE), andesiteSize, new UniversalOrePredicate());
coalGen = new WorldGenMinable(Blocks.COAL_ORE.getDefaultState(), coalSize, new UniversalOrePredicate());
ironGen = new WorldGenMinable(Blocks.IRON_ORE.getDefaultState(), ironSize, new UniversalOrePredicate());
goldGen = new WorldGenMinable(Blocks.GOLD_ORE.getDefaultState(), goldSize, new UniversalOrePredicate());
redstoneGen = new WorldGenMinable(Blocks.REDSTONE_ORE.getDefaultState(), redstoneSize, new UniversalOrePredicate());
diamondGen = new WorldGenMinable(Blocks.DIAMOND_ORE.getDefaultState(), diamondSize, new UniversalOrePredicate());
lapisGen = new WorldGenMinable(Blocks.LAPIS_ORE.getDefaultState(), lapisSize, new UniversalOrePredicate());
}
/** This is the function where ore generation and things like flowers are generated. */
@Override
public void decorate(World worldIn, Random random, Biome biome, BlockPos pos) {
if (decorating) {
throw new RuntimeException("Already decorating");
}
else {
chunkPos = pos;
genDecorations(biome, worldIn, random);
decorating = false;
}
}
/** This is where things like trees are generated. */
@Override
protected void genDecorations(Biome biomeIn, World worldIn, Random random) {
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(worldIn, random, chunkPos));
generateOres(worldIn, random);
generate(worldIn, random, chunkPos, DecorateBiomeEvent.Decorate.EventType.SAND_PASS2, gravelGen, gravelPatchesPerChunk);
generateTrees(worldIn, biomeIn, random, chunkPos);
generateFlowers(worldIn, biomeIn, random, chunkPos);
generateGrass(worldIn, biomeIn, random, chunkPos);
if (generateFalls) {
// generateFalls(worldIn, random, chunkPos); Disabling due to weird crash.
}
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(worldIn, random, chunkPos));
}
private void generateTrees(World worldIn, Biome biomeIn, Random random, BlockPos chunkPos) {
int treesToGen = treesPerChunk;
if (random.nextFloat() < extraTreeChance) {
++treesToGen;
}
if (TerrainGen.decorate(worldIn, random, chunkPos, DecorateBiomeEvent.Decorate.EventType.TREE)) {
for (int numTreesGenerated = 0; numTreesGenerated < treesToGen; ++numTreesGenerated) {
int treeX = random.nextInt(16) + 8;
int treeZ = random.nextInt(16) + 8;
WorldGenAbstractTree treeGen = biomeIn.getRandomTreeFeature(random);
treeGen.setDecorationDefaults();
BlockPos blockpos = worldIn.getHeight(chunkPos.add(treeX, 0, treeZ));
if (treeGen.generate(worldIn, random, blockpos)) {
treeGen.generateSaplings(worldIn, random, blockpos);
}
}
}
}
private void generateFlowers(World worldIn, Biome biomeIn, Random random, BlockPos chunkPos) {
if (TerrainGen.decorate(worldIn, random, chunkPos, DecorateBiomeEvent.Decorate.EventType.FLOWERS)) {
for (int numFlowersGenerated = 0; numFlowersGenerated < flowersPerChunk; ++numFlowersGenerated) {
int flowerX = random.nextInt(16) + 8;
int flowerZ = random.nextInt(16) + 8;
int yRange = worldIn.getHeight(chunkPos.add(flowerX, 0, flowerZ)).getY() + 32;
bushGen = new WorldGenBush(NCBlocks.glowing_mushroom.getDefaultState());
if (yRange > 0) {
int flowerY = random.nextInt(yRange);
BlockPos flowerBlockPos = chunkPos.add(flowerX, flowerY, flowerZ);
bushGen.generateBush(random, worldIn, flowerBlockPos);
}
}
}
}
private void generateGrass(World worldIn, Biome biomeIn, Random random, BlockPos chunkPos) {
if (TerrainGen.decorate(worldIn, random, chunkPos, DecorateBiomeEvent.Decorate.EventType.GRASS)) {
for (int numGrassPerChunk = 0; numGrassPerChunk < grassPerChunk; ++numGrassPerChunk) {
int grassX = random.nextInt(16) + 8;
int grassZ = random.nextInt(16) + 8;
int yRange = worldIn.getHeight(chunkPos.add(grassX, 0, grassZ)).getY() * 2;
if (yRange > 0) {
int grassY = random.nextInt(yRange);
biomeIn.getRandomWorldGenForGrass(random).generate(worldIn, random, chunkPos.add(grassX, grassY, grassZ));
}
}
}
}
/*private static void generateFalls(World worldIn, Random random, BlockPos chunkPos) {
if (TerrainGen.decorate(worldIn, random, chunkPos, DecorateBiomeEvent.Decorate.EventType.LAKE_WATER)) {
for (int k5 = 0; k5 < 50; ++k5) {
int i10 = random.nextInt(16) + 8;
int l13 = random.nextInt(16) + 8;
int i17 = random.nextInt(248) + 8;
if (i17 > 0) {
int k19 = random.nextInt(i17);
BlockPos blockpos6 = chunkPos.add(i10, k19, l13);
new WorldGenLiquids(Blocks.FLOWING_WATER).generate(worldIn, random, blockpos6);
}
}
}
if (TerrainGen.decorate(worldIn, random, chunkPos, DecorateBiomeEvent.Decorate.EventType.LAKE_LAVA)) {
for (int l5 = 0; l5 < 20; ++l5) {
int j10 = random.nextInt(16) + 8;
int i14 = random.nextInt(16) + 8;
int j17 = random.nextInt(random.nextInt(random.nextInt(240) + 8) + 8);
BlockPos blockpos3 = chunkPos.add(j10, j17, i14);
new WorldGenLiquids(Blocks.FLOWING_LAVA).generate(worldIn, random, blockpos3);
}
}
}*/
private static void generate(World worldIn, Random random, BlockPos chunkPos, EventType eventType, WorldGenerator generator, int countPerChunk) {
if (TerrainGen.decorate(worldIn, random, chunkPos, eventType)) {
for (int count = 0; count < countPerChunk; ++count) {
int randX = random.nextInt(16) + 8;
int randZ = random.nextInt(16) + 8;
generator.generate(worldIn, random, worldIn.getTopSolidOrLiquidBlock(chunkPos.add(randX, 0, randZ)));
}
}
}
/** Generates ores in the current chunk */
@Override
protected void generateOres(World worldIn, Random random) {
MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(worldIn, random, chunkPos));
if (TerrainGen.generateOre(worldIn, random, dirtGen, chunkPos, OreGenEvent.GenerateMinable.EventType.DIRT)) {
genStandardOre1(worldIn, random, dirtCount, dirtGen, oreGenMinHeight, dirtMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, gravelOreGen, chunkPos, OreGenEvent.GenerateMinable.EventType.GRAVEL)) {
genStandardOre1(worldIn, random, gravelCount, gravelOreGen, oreGenMinHeight, gravelMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, dioriteGen, chunkPos, OreGenEvent.GenerateMinable.EventType.DIORITE)) {
genStandardOre1(worldIn, random, dioriteCount, dioriteGen, oreGenMinHeight, dioriteMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, graniteGen, chunkPos, OreGenEvent.GenerateMinable.EventType.GRANITE)) {
genStandardOre1(worldIn, random, graniteCount, graniteGen, oreGenMinHeight, graniteMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, andesiteGen, chunkPos, OreGenEvent.GenerateMinable.EventType.ANDESITE)) {
genStandardOre1(worldIn, random, andesiteCount, andesiteGen, oreGenMinHeight, andesiteMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, coalGen, chunkPos, OreGenEvent.GenerateMinable.EventType.COAL)) {
genStandardOre1(worldIn, random, coalCount, coalGen, oreGenMinHeight, coalMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, ironGen, chunkPos, OreGenEvent.GenerateMinable.EventType.IRON)) {
genStandardOre1(worldIn, random, ironCount, ironGen, oreGenMinHeight, ironMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, goldGen, chunkPos, OreGenEvent.GenerateMinable.EventType.GOLD)) {
genStandardOre1(worldIn, random, goldCount, goldGen, oreGenMinHeight, goldMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, redstoneGen, chunkPos, OreGenEvent.GenerateMinable.EventType.REDSTONE)) {
genStandardOre1(worldIn, random, redstoneCount, redstoneGen, oreGenMinHeight, redstoneMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, diamondGen, chunkPos, OreGenEvent.GenerateMinable.EventType.DIAMOND)) {
genStandardOre1(worldIn, random, diamondCount, diamondGen, oreGenMinHeight, diamondMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, lapisGen, chunkPos, OreGenEvent.GenerateMinable.EventType.LAPIS)) {
genStandardOre2(worldIn, random, lapisCount, lapisGen, lapisCenterHeight, lapisSpread);
}
MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(worldIn, random, chunkPos));
}
}

View File

@ -1,60 +1,32 @@
package nc.worldgen.biome; package nc.worldgen.biome;
import java.util.Random; import java.util.*;
import nc.entity.EntityFeralGhoul; import nc.entity.EntityFeralGhoul;
import nc.init.NCBlocks; import nc.init.NCBlocks;
import net.minecraft.block.BlockTallGrass; import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.*; import net.minecraft.world.biome.*;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.gen.feature.*; import net.minecraft.world.gen.feature.*;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.relauncher.*; import net.minecraftforge.fml.relauncher.*;
public class BiomeNuclearWasteland extends NCBiome { public class BiomeNuclearWasteland extends Biome {
public BiomeNuclearWasteland() { public BiomeNuclearWasteland() {
super(new BiomeProperties("Nuclear Wasteland").setBaseHeight(0.12F).setHeightVariation(0.02F).setTemperature(2F).setWaterColor(0x994C00).setRainDisabled()); super(new BiomeProperties("Nuclear Wasteland").setBaseHeight(0.12F).setHeightVariation(0.02F).setTemperature(2F).setWaterColor(0x994C00).setRainDisabled());
topBlock = NCBlocks.wasteland_earth.getDefaultState(); topBlock = NCBlocks.wasteland_earth.getDefaultState();
fillerBlock = Blocks.SAND.getDefaultState(); fillerBlock = Blocks.SAND.getDefaultState();
waterBlock = FluidRegistry.getFluid("corium").getBlock().getDefaultState();
frozenBlock = Blocks.MAGMA.getDefaultState(); decorator = createBiomeDecorator();
setSpawnables(); setSpawnables();
setFlowers(); addFlowers();
}
protected void setSpawnables() {
spawnableMonsterList.clear();
spawnableCreatureList.clear();
spawnableWaterCreatureList.clear();
spawnableCaveCreatureList.clear();
spawnableMonsterList.add(new Biome.SpawnListEntry(EntityFeralGhoul.class, Short.MAX_VALUE, 1, 1));
spawnableCreatureList.add(new Biome.SpawnListEntry(EntityFeralGhoul.class, Short.MAX_VALUE, 1, 1));
}
protected void setFlowers() {
flowers.clear();
addFlower(NCBlocks.glowing_mushroom.getDefaultState(), 10);
}
@Override
public BiomeDecorator createBiomeDecorator() {
return getModdedBiomeDecorator(new Decorator());
}
@Override
public WorldGenAbstractTree getRandomTreeFeature(Random rand) {
return TREE_FEATURE;
}
@Override
public WorldGenerator getRandomWorldGenForGrass(Random rand) {
return new WorldGenTallGrass(BlockTallGrass.EnumType.DEAD_BUSH);
} }
@Override @Override
@ -75,27 +47,132 @@ public class BiomeNuclearWasteland extends NCBiome {
return getModdedBiomeFoliageColor(0x994C00); return getModdedBiomeFoliageColor(0x994C00);
} }
protected int portalGenChance = 256; /** Allocate a new BiomeDecorator for this BiomeGenBase */
@Override
public BiomeDecorator createBiomeDecorator() {
BiomeDecorator biomeDecorator = new BiomeDecoratorNuclearWasteland();
public static class Decorator extends BiomeDecorator { biomeDecorator.waterlilyPerChunk = 0;
biomeDecorator.treesPerChunk = 0;
biomeDecorator.extraTreeChance = 0F;
biomeDecorator.flowersPerChunk = 20;
biomeDecorator.grassPerChunk = 3;
biomeDecorator.deadBushPerChunk = 2;
biomeDecorator.mushroomsPerChunk = 0;
biomeDecorator.reedsPerChunk = 0;
biomeDecorator.cactiPerChunk = 0;
biomeDecorator.gravelPatchesPerChunk = 2;
biomeDecorator.sandPatchesPerChunk = 2;
biomeDecorator.clayPerChunk = 0;
biomeDecorator.bigMushroomsPerChunk = 0;
biomeDecorator.generateFalls = false;
return getModdedBiomeDecorator(biomeDecorator);
}
@Override @Override
protected void genDecorations(Biome biomeIn, World worldIn, Random random) { public WorldGenAbstractTree getRandomTreeFeature(Random rand) {
super.genDecorations(biomeIn, worldIn, random); return TREE_FEATURE;
if (biomeIn instanceof BiomeNuclearWasteland) {
BiomeNuclearWasteland wasteland = (BiomeNuclearWasteland) biomeIn;
if (random.nextInt(wasteland.portalGenChance) == 0) {
int x = random.nextInt(16) + 8;
int y = random.nextInt(worldIn.getHeight());
int z = random.nextInt(16) + 8;
if (new WorldGenLakes(NCBlocks.wasteland_portal).generate(worldIn, random, chunkPos.add(x, y, z))) {
wasteland.portalGenChance = 256;
} }
@Override
public WorldGenerator getRandomWorldGenForGrass(Random rand) {
return new WorldGenTallGrass(BlockTallGrass.EnumType.DEAD_BUSH);
}
@Override
public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) {
return BlockFlower.EnumFlowerType.DANDELION;
}
public List<FlowerEntry> getFlowerList() {
return flowers;
}
private void addFlowers() {
flowers.clear();
addFlower(NCBlocks.glowing_mushroom.getDefaultState(), 10);
}
private void setSpawnables() {
spawnableCreatureList.clear();
spawnableMonsterList.clear();
spawnableWaterCreatureList.clear();
spawnableCaveCreatureList.clear();
spawnableCreatureList.add(new Biome.SpawnListEntry(EntityFeralGhoul.class, Short.MAX_VALUE, 1, 2));
spawnableMonsterList.add(new Biome.SpawnListEntry(EntityFeralGhoul.class, Short.MAX_VALUE, 1, 2));
}
@Override
public void decorate(World worldIn, Random rand, BlockPos pos) {
decorator.decorate(worldIn, rand, this, pos);
}
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
int seaLevel = worldIn.getSeaLevel();
IBlockState topBlockState = topBlock;
IBlockState fillerBlockState = fillerBlock;
int heightCount = -1;
int noise = (int) (noiseVal / 3D + 3D + rand.nextDouble() * 0.25D);
int chunkPosX = x & 15;
int chunkPosZ = z & 15;
BlockPos.MutableBlockPos mutableblockpos = new BlockPos.MutableBlockPos();
for (int posY = 255; posY >= 0; --posY) {
if (posY <= rand.nextInt(5)) {
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, BEDROCK);
} }
else { else {
wasteland.portalGenChance--; IBlockState currentBlockState = chunkPrimerIn.getBlockState(chunkPosX, posY, chunkPosZ);
if (currentBlockState.getMaterial() == Material.AIR) {
heightCount = -1;
}
else if (currentBlockState.getBlock() == Blocks.STONE) {
if (heightCount == -1) {
if (noise <= 0) {
topBlockState = AIR;
fillerBlockState = STONE;
}
else if (posY >= seaLevel - 4 && posY <= seaLevel + 1) {
topBlockState = topBlock;
fillerBlockState = fillerBlock;
}
if (posY < seaLevel && (topBlockState == null || topBlockState.getMaterial() == Material.AIR)) {
if (getTemperature(mutableblockpos.setPos(x, posY, z)) < 0.15F) {
topBlockState = ICE;
}
else {
topBlockState = WATER;
}
}
heightCount = noise;
if (posY >= seaLevel - 1) {
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, topBlockState);
}
else if (posY < seaLevel - 7 - noise) {
topBlockState = AIR;
fillerBlockState = STONE;
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, GRAVEL);
}
else {
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, fillerBlockState);
}
}
else if (heightCount > 0) {
--heightCount;
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, fillerBlockState);
if (heightCount == 0 && fillerBlockState == fillerBlock && noise > 1) {
heightCount = rand.nextInt(4) + Math.max(0, posY - 63);
fillerBlockState = topBlock;
}
}
} }
} }
} }

View File

@ -1,103 +0,0 @@
package nc.worldgen.biome;
import java.util.Random;
import net.minecraft.block.BlockSand;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkPrimer;
public class NCBiome extends Biome {
public IBlockState airBlock = AIR;
public IBlockState bedrockBlock = BEDROCK;
public IBlockState stoneBlock = STONE;
public IBlockState gravelBlock = GRAVEL;
public IBlockState waterBlock = WATER;
public IBlockState frozenBlock = ICE;
public NCBiome(BiomeProperties properties) {
super(properties);
}
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
generateTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
public void generateTerrain(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
int seaLevel = worldIn.getSeaLevel();
IBlockState topBlockState = topBlock;
IBlockState fillerBlockState = fillerBlock;
int heightCount = -1;
int noise = (int) (noiseVal / 3D + 3D + rand.nextDouble() * 0.25D);
int chunkPosX = x & 15;
int chunkPosZ = z & 15;
BlockPos.MutableBlockPos mutableblockpos = new BlockPos.MutableBlockPos();
for (int posY = 255; posY >= 0; --posY) {
if (posY <= rand.nextInt(5)) {
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, bedrockBlock);
}
else {
IBlockState currentBlockState = chunkPrimerIn.getBlockState(chunkPosX, posY, chunkPosZ);
if (currentBlockState.getMaterial() == Material.AIR) {
heightCount = -1;
}
else if (currentBlockState.getBlock() == stoneBlock.getBlock()) {
if (heightCount == -1) {
if (noise <= 0) {
topBlockState = airBlock;
fillerBlockState = stoneBlock;
}
else if (posY >= seaLevel - 4 && posY <= seaLevel + 1) {
topBlockState = topBlock;
fillerBlockState = fillerBlock;
}
if (posY < seaLevel && (topBlockState == null || topBlockState.getMaterial() == Material.AIR)) {
if (getTemperature(mutableblockpos.setPos(x, posY, z)) < 0.15F) {
topBlockState = frozenBlock;
}
else {
topBlockState = waterBlock;
}
}
heightCount = noise;
if (posY >= seaLevel - 1) {
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, topBlockState);
}
else if (posY < seaLevel - 7 - noise) {
topBlockState = airBlock;
fillerBlockState = stoneBlock;
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, gravelBlock);
}
else {
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, fillerBlockState);
}
}
else if (heightCount > 0) {
--heightCount;
chunkPrimerIn.setBlockState(chunkPosX, posY, chunkPosZ, fillerBlockState);
if (heightCount == 0 && fillerBlockState == Blocks.SAND && noise > 1) {
heightCount = rand.nextInt(4) + Math.max(0, posY - 63);
fillerBlockState = getSandstoneTerrainBlock(chunkPosX, posY, chunkPosZ, fillerBlockState);
}
}
}
}
}
}
public IBlockState getSandstoneTerrainBlock(int chunkPosX, int posY, int chunkPosZ, IBlockState sandState) {
return sandState.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
}
}

View File

@ -1,10 +1,12 @@
package nc.worldgen.decoration; package nc.worldgen.decoration;
import static nc.config.NCConfig.*;
import java.util.Random; import java.util.Random;
import net.minecraft.block.*; import nc.init.NCBlocks;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.*; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
@ -15,30 +17,30 @@ import net.minecraftforge.fml.common.IWorldGenerator;
public class BushGenerator implements IWorldGenerator { public class BushGenerator implements IWorldGenerator {
protected final IBlockState bush; private final WorldGenBush glowing_mushroom;
protected final int genSize, genRate;
public BushGenerator(IBlockState bush, int genSize, int genRate) { public BushGenerator() {
this.bush = bush; glowing_mushroom = new WorldGenBush(NCBlocks.glowing_mushroom.getDefaultState());
this.genSize = genSize;
this.genRate = genRate;
}
public boolean shouldGenerate() {
return genSize > 0 && genRate > 0;
} }
@Override @Override
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (!shouldGenerate()) { generateNether(random, chunkX, chunkZ, world, NCBlocks.glowing_mushroom.getDefaultState());
}
public void generateNether(Random random, int chunkX, int chunkZ, World world, IBlockState mushroom) {
if (!mushroom_gen || mushroom_gen_size <= 0 || mushroom_gen_rate <= 0) {
return; return;
} }
int genRarity = Math.max(1, 400 / genRate); int genRarity = Math.max(400 / mushroom_gen_rate, 1);
int xSpawn, ySpawn, zSpawn;
int xPos = chunkX * 16 + 8; int xPos = chunkX * 16 + 8;
int zPos = chunkZ * 16 + 8; int zPos = chunkZ * 16 + 8;
BlockPos chunkPos = new BlockPos(xPos, rand.nextInt(world.getHeight()), zPos); BlockPos chunkPos = new BlockPos(xPos, 0, zPos);
BlockPos position;
Biome biome = world.getChunk(chunkPos).getBiome(chunkPos, world.getBiomeProvider()); Biome biome = world.getChunk(chunkPos).getBiome(chunkPos, world.getBiomeProvider());
if (biome == null) { if (biome == null) {
@ -46,22 +48,13 @@ public class BushGenerator implements IWorldGenerator {
} }
if (BiomeDictionary.hasType(biome, Type.NETHER)) { if (BiomeDictionary.hasType(biome, Type.NETHER)) {
if (rand.nextInt(genRarity) == 0) { if (random.nextInt(genRarity) == 0) {
generateBush(rand, world, chunkPos.add(rand.nextInt(16), 0, rand.nextInt(16))); xSpawn = xPos + random.nextInt(16);
} ySpawn = random.nextInt(128);
} zSpawn = zPos + random.nextInt(16);
} position = new BlockPos(xSpawn, ySpawn, zSpawn);
public void generateBush(Random rand, World world, BlockPos sourcePos) { glowing_mushroom.generateBush(random, world, position);
Block block = bush.getBlock();
for (int i = 0; i < genSize; ++i) {
int height = MathHelper.clamp(sourcePos.getY() + rand.nextInt(4) - rand.nextInt(4), 1, world.getHeight() - 1);
BlockPos genPos = new BlockPos(sourcePos.getX() + rand.nextInt(8) - rand.nextInt(8), height, sourcePos.getZ() + rand.nextInt(8) - rand.nextInt(8));
boolean canBlockStay = block instanceof BlockBush ? ((BlockBush) block).canBlockStay(world, genPos, bush) : true;
if (world.isAirBlock(genPos) && (!world.provider.hasSkyLight() || genPos.getY() < world.getHeight() - 1) && canBlockStay) {
world.setBlockState(genPos, bush, 2);
} }
} }
} }

View File

@ -1,17 +0,0 @@
package nc.worldgen.decoration;
import static nc.config.NCConfig.*;
import net.minecraft.block.state.IBlockState;
public class MushroomGenerator extends BushGenerator {
public MushroomGenerator(IBlockState bush) {
super(bush, mushroom_gen_size, mushroom_gen_rate);
}
@Override
public boolean shouldGenerate() {
return mushroom_gen && super.shouldGenerate();
}
}

View File

@ -0,0 +1,37 @@
package nc.worldgen.decoration;
import static nc.config.NCConfig.mushroom_gen_size;
import java.util.Random;
import net.minecraft.block.BlockBush;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
public class WorldGenBush implements IWorldGenerator {
private final IBlockState bush;
public WorldGenBush(IBlockState bush) {
this.bush = bush;
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {}
public void generateBush(Random random, World world, BlockPos pos) {
BlockBush block = (BlockBush) bush.getBlock();
for (int i = 0; i < mushroom_gen_size; ++i) {
BlockPos blockpos = pos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
if (world.isAirBlock(blockpos) && (!world.provider.hasSkyLight() || blockpos.getY() < world.getHeight() - 1) && block.canBlockStay(world, blockpos, bush)) {
world.setBlockState(blockpos, bush, 2);
}
}
}
}

View File

@ -0,0 +1,11 @@
package nc.worldgen.dimension;
import nc.worldgen.biome.NCBiomes;
import net.minecraft.world.biome.BiomeProviderSingle;
public class BiomeProviderWasteland extends BiomeProviderSingle {
public BiomeProviderWasteland() {
super(NCBiomes.NUCLEAR_WASTELAND);
}
}

View File

@ -1,18 +1,375 @@
package nc.worldgen.dimension; package nc.worldgen.dimension;
import net.minecraft.world.World; import java.util.*;
import net.minecraft.world.gen.ChunkGeneratorOverworld;
import javax.annotation.Nullable;
import nc.worldgen.biome.NCBiomes;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.*;
import net.minecraft.world.*;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.*;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.WorldGenDungeons;
import net.minecraft.world.gen.structure.*;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
public class ChunkGeneratorWasteland extends ChunkGeneratorOverworld { public class ChunkGeneratorWasteland implements IChunkGenerator {
public ChunkGeneratorWasteland(World world) { protected static final IBlockState STONE = Blocks.STONE.getDefaultState();
super(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), getGeneratorOptions()); protected Biome biome = NCBiomes.NUCLEAR_WASTELAND;
oceanBlock = FluidRegistry.getFluid("corium").getBlock().getDefaultState(); private final Random rand;
private NoiseGeneratorOctaves minLimitPerlinNoise;
private NoiseGeneratorOctaves maxLimitPerlinNoise;
private NoiseGeneratorOctaves mainPerlinNoise;
private NoiseGeneratorPerlin surfaceNoise;
public NoiseGeneratorOctaves scaleNoise;
public NoiseGeneratorOctaves depthNoise;
public NoiseGeneratorOctaves forestNoise;
private final World world;
private final boolean mapFeaturesEnabled;
private final WorldType terrainType;
private final double[] heightMap;
private final float[] biomeWeights;
private ChunkGeneratorSettings settings;
private final IBlockState oceanBlock = FluidRegistry.getFluid("corium").getBlock().getDefaultState();
private double[] depthBuffer = new double[256];
private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();
double[] mainNoiseRegion;
double[] minLimitRegion;
double[] maxLimitRegion;
double[] depthRegion;
public ChunkGeneratorWasteland(World worldIn) {
{
mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, InitMapGenEvent.EventType.MINESHAFT);
scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, InitMapGenEvent.EventType.SCATTERED_FEATURE);
}
world = worldIn;
mapFeaturesEnabled = world.getWorldInfo().isMapFeaturesEnabled();
terrainType = worldIn.getWorldInfo().getTerrainType();
rand = new Random(world.getSeed());
String generatorOptions = world.getWorldInfo().getGeneratorOptions();
minLimitPerlinNoise = new NoiseGeneratorOctaves(rand, 16);
maxLimitPerlinNoise = new NoiseGeneratorOctaves(rand, 16);
mainPerlinNoise = new NoiseGeneratorOctaves(rand, 8);
surfaceNoise = new NoiseGeneratorPerlin(rand, 4);
scaleNoise = new NoiseGeneratorOctaves(rand, 10);
depthNoise = new NoiseGeneratorOctaves(rand, 16);
forestNoise = new NoiseGeneratorOctaves(rand, 8);
heightMap = new double[825];
biomeWeights = new float[25];
for (int i = -2; i <= 2; ++i) {
for (int j = -2; j <= 2; ++j) {
float f = 10F / MathHelper.sqrt(i * i + j * j + 0.2F);
biomeWeights[i + 2 + (j + 2) * 5] = f;
}
} }
// net.minecraft.client.gui.GuiScreenCustomizePresets if (generatorOptions != null) {
public static String getGeneratorOptions() { settings = ChunkGeneratorSettings.Factory.jsonToFactory(generatorOptions).build();
return "{ \"useCaves\":false, \"useDungeons\":false, \"dungeonChance\":8, \"useStrongholds\":false, \"useVillages\":false, \"useMineShafts\":false, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":false, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":true, \"seaLevel\":63 }"; worldIn.setSeaLevel(settings.seaLevel);
}
InitNoiseGensEvent.ContextOverworld ctx = new InitNoiseGensEvent.ContextOverworld(minLimitPerlinNoise, maxLimitPerlinNoise, mainPerlinNoise, surfaceNoise, scaleNoise, depthNoise, forestNoise);
ctx = TerrainGen.getModdedNoiseGenerators(worldIn, rand, ctx);
minLimitPerlinNoise = ctx.getLPerlin1();
maxLimitPerlinNoise = ctx.getLPerlin2();
mainPerlinNoise = ctx.getPerlin();
surfaceNoise = ctx.getHeight();
scaleNoise = ctx.getScale();
depthNoise = ctx.getDepth();
forestNoise = ctx.getForest();
}
public void setBlocksInChunk(int x, int z, ChunkPrimer primer) {
generateHeightmap(x * 4, 0, z * 4);
for (int i = 0; i < 4; ++i) {
int j = i * 5;
int k = (i + 1) * 5;
for (int l = 0; l < 4; ++l) {
int i1 = (j + l) * 33;
int j1 = (j + l + 1) * 33;
int k1 = (k + l) * 33;
int l1 = (k + l + 1) * 33;
for (int i2 = 0; i2 < 32; ++i2) {
double d1 = heightMap[i1 + i2];
double d2 = heightMap[j1 + i2];
double d3 = heightMap[k1 + i2];
double d4 = heightMap[l1 + i2];
double d5 = (heightMap[i1 + i2 + 1] - d1) * 0.125D;
double d6 = (heightMap[j1 + i2 + 1] - d2) * 0.125D;
double d7 = (heightMap[k1 + i2 + 1] - d3) * 0.125D;
double d8 = (heightMap[l1 + i2 + 1] - d4) * 0.125D;
for (int j2 = 0; j2 < 8; ++j2) {
double d10 = d1;
double d11 = d2;
double d12 = (d3 - d1) * 0.25D;
double d13 = (d4 - d2) * 0.25D;
for (int k2 = 0; k2 < 4; ++k2) {
double d16 = (d11 - d10) * 0.25D;
double lvt_45_1_ = d10 - d16;
for (int l2 = 0; l2 < 4; ++l2) {
if ((lvt_45_1_ += d16) > 0D) {
primer.setBlockState(i * 4 + k2, i2 * 8 + j2, l * 4 + l2, STONE);
}
else if (i2 * 8 + j2 < settings.seaLevel) {
primer.setBlockState(i * 4 + k2, i2 * 8 + j2, l * 4 + l2, oceanBlock);
}
}
d10 += d12;
d11 += d13;
}
d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}
public void replaceBiomeBlocks(int x, int z, ChunkPrimer primer) {
if (!ForgeEventFactory.onReplaceBiomeBlocks(this, x, z, primer, world)) {
return;
}
depthBuffer = surfaceNoise.getRegion(depthBuffer, x * 16, z * 16, 16, 16, 0.0625D, 0.0625D, 1D);
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
biome.genTerrainBlocks(world, rand, primer, x * 16 + i, z * 16 + j, depthBuffer[j + i * 16]);
}
}
}
/** Generates the chunk at the specified position, from scratch */
@Override
public Chunk generateChunk(int x, int z) {
rand.setSeed(x * 341873128712L + z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
setBlocksInChunk(x, z, chunkprimer);
replaceBiomeBlocks(x, z, chunkprimer);
if (mapFeaturesEnabled) {
if (settings.useMineShafts) {
mineshaftGenerator.generate(world, x, z, chunkprimer);
}
}
Chunk chunk = new Chunk(world, chunkprimer, x, z);
byte[] abyte = chunk.getBiomeArray();
for (int i = 0; i < abyte.length; ++i) {
abyte[i] = (byte) Biome.getIdForBiome(biome);
}
chunk.generateSkylightMap();
return chunk;
}
private void generateHeightmap(int p_185978_1_, int p_185978_2_, int p_185978_3_) {
depthRegion = depthNoise.generateNoiseOctaves(depthRegion, p_185978_1_, p_185978_3_, 5, 5, settings.depthNoiseScaleX, settings.depthNoiseScaleZ, settings.depthNoiseScaleExponent);
float f = settings.coordinateScale;
float f1 = settings.heightScale;
mainNoiseRegion = mainPerlinNoise.generateNoiseOctaves(mainNoiseRegion, p_185978_1_, p_185978_2_, p_185978_3_, 5, 33, 5, f / settings.mainNoiseScaleX, f1 / settings.mainNoiseScaleY, f / settings.mainNoiseScaleZ);
minLimitRegion = minLimitPerlinNoise.generateNoiseOctaves(minLimitRegion, p_185978_1_, p_185978_2_, p_185978_3_, 5, 33, 5, f, f1, f);
maxLimitRegion = maxLimitPerlinNoise.generateNoiseOctaves(maxLimitRegion, p_185978_1_, p_185978_2_, p_185978_3_, 5, 33, 5, f, f1, f);
int i = 0;
int j = 0;
for (int k = 0; k < 5; ++k) {
for (int l = 0; l < 5; ++l) {
float f2 = 0F;
float f3 = 0F;
float f4 = 0F;
for (int j1 = -2; j1 <= 2; ++j1) {
for (int k1 = -2; k1 <= 2; ++k1) {
float f5 = settings.biomeDepthOffSet + biome.getBaseHeight() * settings.biomeDepthWeight;
float f6 = settings.biomeScaleOffset + biome.getHeightVariation() * settings.biomeScaleWeight;
if (terrainType == WorldType.AMPLIFIED && f5 > 0F) {
f5 = 1F + f5 * 2F;
f6 = 1F + f6 * 4F;
}
float f7 = biomeWeights[j1 + 2 + (k1 + 2) * 5] / (f5 + 2F);
f2 += f6 * f7;
f3 += f5 * f7;
f4 += f7;
}
}
f2 = f2 / f4;
f3 = f3 / f4;
f2 = f2 * 0.9F + 0.1F;
f3 = (f3 * 4F - 1F) / 8F;
double d7 = depthRegion[j] / 8000D;
if (d7 < 0D) {
d7 = -d7 * 0.3D;
}
d7 = d7 * 3D - 2D;
if (d7 < 0D) {
d7 = d7 / 2D;
if (d7 < -1D) {
d7 = -1D;
}
d7 = d7 / 1.4D;
d7 = d7 / 2D;
}
else {
if (d7 > 1D) {
d7 = 1D;
}
d7 = d7 / 8D;
}
++j;
double d8 = f3;
double d9 = f2;
d8 = d8 + d7 * 0.2D;
d8 = d8 * settings.baseSize / 8D;
double d0 = settings.baseSize + d8 * 4D;
for (int l1 = 0; l1 < 33; ++l1) {
double d1 = (l1 - d0) * settings.stretchY * 128D / 256D / d9;
if (d1 < 0D) {
d1 *= 4D;
}
double d2 = minLimitRegion[i] / settings.lowerLimitScale;
double d3 = maxLimitRegion[i] / settings.upperLimitScale;
double d4 = (mainNoiseRegion[i] / 10D + 1D) / 2D;
double d5 = MathHelper.clampedLerp(d2, d3, d4) - d1;
if (l1 > 29) {
double d6 = (l1 - 29) / 3F;
d5 = d5 * (1D - d6) + -10D * d6;
}
heightMap[i] = d5;
++i;
}
}
}
}
@Override
public void populate(int x, int z) {
BlockFalling.fallInstantly = true;
int i = x * 16;
int j = z * 16;
BlockPos blockpos = new BlockPos(i, 0, j);
Biome biome = world.getBiome(blockpos.add(16, 0, 16));
rand.setSeed(world.getSeed());
long k = rand.nextLong() / 2L * 2L + 1L;
long l = rand.nextLong() / 2L * 2L + 1L;
rand.setSeed(x * k + z * l ^ world.getSeed());
boolean flag = false;
ChunkPos chunkpos = new ChunkPos(x, z);
ForgeEventFactory.onChunkPopulate(true, this, world, rand, x, z, flag);
if (mapFeaturesEnabled) {
if (settings.useMineShafts) {
mineshaftGenerator.generateStructure(world, rand, chunkpos);
}
}
if (settings.useDungeons) {
if (TerrainGen.populate(this, world, rand, x, z, flag, PopulateChunkEvent.Populate.EventType.DUNGEON)) {
for (int j2 = 0; j2 < settings.dungeonChance; ++j2) {
int i3 = rand.nextInt(16) + 8;
int l3 = rand.nextInt(256);
int l1 = rand.nextInt(16) + 8;
new WorldGenDungeons().generate(world, rand, blockpos.add(i3, l3, l1));
}
}
}
biome.decorate(world, rand, new BlockPos(i, 0, j));
if (TerrainGen.populate(this, world, rand, x, z, flag, PopulateChunkEvent.Populate.EventType.ANIMALS)) {
WorldEntitySpawner.performWorldGenSpawning(world, biome, i + 8, j + 8, 16, 16, rand);
}
blockpos = blockpos.add(8, 0, 8);
ForgeEventFactory.onChunkPopulate(false, this, world, rand, x, z, flag);
BlockFalling.fallInstantly = false;
}
/** Called to generate additional structures after initial worldgen, used by ocean monuments */
@Override
public boolean generateStructures(Chunk chunkIn, int x, int z) {
return false;
}
@Override
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
Biome biome = world.getBiome(pos);
if (mapFeaturesEnabled) {
if (creatureType == EnumCreatureType.MONSTER && scatteredFeatureGenerator.isSwampHut(pos)) {
return scatteredFeatureGenerator.getMonsters();
}
}
return biome.getSpawnableList(creatureType);
}
@Override
public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos) {
if (!mapFeaturesEnabled) {
return false;
}
else {
return mineshaftGenerator.isInsideStructure(pos) && "Mineshaft".equals(structureName) && mineshaftGenerator != null;
}
}
@Override
@Nullable
public BlockPos getNearestStructurePos(World worldIn, String structureName, BlockPos position, boolean findUnexplored) {
if (!mapFeaturesEnabled) {
return null;
}
else {
return "Mineshaft".equals(structureName) && mineshaftGenerator != null ? mineshaftGenerator.getNearestStructurePos(worldIn, position, findUnexplored) : null;
}
}
/** Recreates data about structures intersecting given chunk (used for example by getPossibleCreatures), without placing any blocks. When called for the first time before any chunk is generated - also initializes the internal state needed by getPossibleCreatures. */
@Override
public void recreateStructures(Chunk chunkIn, int x, int z) {
if (mapFeaturesEnabled) {
if (settings.useMineShafts) {
mineshaftGenerator.generate(world, x, z, (ChunkPrimer) null);
}
}
} }
} }

View File

@ -2,17 +2,19 @@ package nc.worldgen.dimension;
import static nc.config.NCConfig.*; import static nc.config.NCConfig.*;
import net.minecraft.world.DimensionType; import net.minecraft.world.*;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
public class NCWorlds { public class NCWorlds {
public static DimensionType wastelandDimType; public static final String WASTELAND_DIM_NAME = "nc_wasteland";
public static final int WASTELAND_DIM_ID = wasteland_dimension;
public static final DimensionType WASTELAND_DIM_TYPE = DimensionType.register(WASTELAND_DIM_NAME, "_" + WASTELAND_DIM_NAME, WASTELAND_DIM_ID, WorldProviderWasteland.class, false);
public static final WorldProvider WASTELAND_WORLD_PROVIDER = new WorldProviderWasteland();
public static final void registerDimensions() { public static final void registerDimensions() {
if (wasteland_dimension_gen) { if (wasteland_dimension_gen) {
wastelandDimType = DimensionType.register("nc_wasteland", "_nc_wasteland", wasteland_dimension, WorldProviderWasteland.class, false); DimensionManager.registerDimension(WASTELAND_DIM_ID, WASTELAND_DIM_TYPE);
DimensionManager.registerDimension(wasteland_dimension, wastelandDimType);
} }
} }
} }

View File

@ -1,9 +1,7 @@
package nc.worldgen.dimension; package nc.worldgen.dimension;
import nc.worldgen.biome.NCBiomes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.*; import net.minecraft.world.*;
import net.minecraft.world.biome.BiomeProviderSingle;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.gen.IChunkGenerator;
@ -12,12 +10,12 @@ public class WorldProviderWasteland extends WorldProvider {
@Override @Override
protected void init() { protected void init() {
hasSkyLight = true; hasSkyLight = true;
biomeProvider = new BiomeProviderSingle(NCBiomes.NUCLEAR_WASTELAND); biomeProvider = new BiomeProviderWasteland();
} }
@Override @Override
public DimensionType getDimensionType() { public DimensionType getDimensionType() {
return NCWorlds.wastelandDimType; return NCWorlds.WASTELAND_DIM_TYPE;
} }
@Override @Override
@ -25,11 +23,6 @@ public class WorldProviderWasteland extends WorldProvider {
return false; return false;
} }
@Override
public boolean isNether() {
return false;
}
@Override @Override
public boolean canRespawnHere() { public boolean canRespawnHere() {
return false; return false;

View File

@ -12,14 +12,14 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.*;
import net.minecraftforge.fml.common.IWorldGenerator; import net.minecraftforge.fml.common.IWorldGenerator;
public class OreGenerator implements IWorldGenerator { public class OreGenerator implements IWorldGenerator {
protected final WorldGenOre[] ores; private final WorldGenerator[] ores;
protected static class WorldGenOre extends WorldGenMinable { private static class WorldGenOre extends WorldGenMinable {
public WorldGenOre(int meta) { public WorldGenOre(int meta) {
super(((BlockMeta) NCBlocks.ore).getStateFromMeta(meta), ore_size[meta] + 2, new UniversalOrePredicate()); super(((BlockMeta) NCBlocks.ore).getStateFromMeta(meta), ore_size[meta] + 2, new UniversalOrePredicate());
@ -27,7 +27,7 @@ public class OreGenerator implements IWorldGenerator {
} }
public OreGenerator() { public OreGenerator() {
ores = new WorldGenOre[8]; ores = new WorldGenerator[8];
for (int i = 0; i < MetaEnums.OreType.values().length; i++) { for (int i = 0; i < MetaEnums.OreType.values().length; i++) {
ores[i] = new WorldGenOre(i); ores[i] = new WorldGenOre(i);
} }
@ -44,16 +44,8 @@ public class OreGenerator implements IWorldGenerator {
} }
} }
protected void generateOres(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { private static void generateOre(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
for (int i = 0; i < MetaEnums.OreType.values().length; i++) { if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight) {
if (ore_gen[i]) {
generateOre(ores[i], world, random, chunkX, chunkZ, ore_rate[i], ore_min_height[i], ore_max_height[i]);
}
}
}
public static void generateOre(WorldGenOre generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
if (minHeight < 0 || maxHeight >= world.getHeight() || minHeight > maxHeight) {
throw new IllegalArgumentException("Illegal height arguments for WorldGenerator!"); throw new IllegalArgumentException("Illegal height arguments for WorldGenerator!");
} }
@ -65,4 +57,12 @@ public class OreGenerator implements IWorldGenerator {
generator.generate(world, rand, new BlockPos(x, y, z)); generator.generate(world, rand, new BlockPos(x, y, z));
} }
} }
private void generateOres(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
for (int i = 0; i < MetaEnums.OreType.values().length; i++) {
if (ore_gen[i]) {
generateOre(ores[i], world, random, chunkX, chunkZ, ore_rate[i], ore_min_height[i], ore_max_height[i]);
}
}
}
} }

View File

@ -1,25 +0,0 @@
{
"forge_marker": 1,
"defaults": {
"model":"cube_all",
"textures": {
"all": "nuclearcraft:blocks/wasteland_portal"
}
},
"variants": {
"inventory": [{}],
"normal":
[{
"y": 0
},
{
"y": 90
},
{
"y": 180
},
{
"y": 270
}]
}
}

View File

@ -359,8 +359,6 @@ tile.nuclearcraft.geiger_block.desc=Reads the radiation level of the chunk it is
tile.nuclearcraft.glowing_mushroom.name=Glowing Mushroom tile.nuclearcraft.glowing_mushroom.name=Glowing Mushroom
tile.nuclearcraft.wasteland_earth.name=Wasteland Earth tile.nuclearcraft.wasteland_earth.name=Wasteland Earth
tile.nuclearcraft.wasteland_portal.name=Wasteland Portal
tile.nuclearcraft.tritium_lamp.name=Tritium Lamp tile.nuclearcraft.tritium_lamp.name=Tritium Lamp
tile.nuclearcraft.tritium_lantern.name=Tritium Lantern tile.nuclearcraft.tritium_lantern.name=Tritium Lantern
@ -418,9 +416,9 @@ tile.nuclearcraft.quantum_computer_gate_control.crz.name=Quantum Computer Contro
tile.nuclearcraft.quantum_computer_gate_control.crz.desc=Performs a controlled rotation on the target qubits about the spatial Z-axis. tile.nuclearcraft.quantum_computer_gate_control.crz.desc=Performs a controlled rotation on the target qubits about the spatial Z-axis.
tile.nuclearcraft.quantum_computer_gate_swap.swap.name=Quantum Computer Swap Gate tile.nuclearcraft.quantum_computer_gate_swap.swap.name=Quantum Computer Swap Gate
tile.nuclearcraft.quantum_computer_gate_swap.swap.desc=Swaps two lists of qubits. tile.nuclearcraft.quantum_computer_gate_swap.swap.desc=Swaps two collections of qubits.
tile.nuclearcraft.quantum_computer_gate_swap.cswap.name=Quantum Computer Controlled Swap Gate tile.nuclearcraft.quantum_computer_gate_swap.cswap.name=Quantum Computer Controlled Swap Gate
tile.nuclearcraft.quantum_computer_gate_swap.cswap.desc=Performs a controlled swap on two lists of qubits. tile.nuclearcraft.quantum_computer_gate_swap.cswap.desc=Performs a controlled swap on two collections of qubits.
tile.nuclearcraft.quantum_computer_connector.name=Quantum Computer Connector tile.nuclearcraft.quantum_computer_connector.name=Quantum Computer Connector
tile.nuclearcraft.quantum_computer_port.name=Quantum Computer Port (WIP) tile.nuclearcraft.quantum_computer_port.name=Quantum Computer Port (WIP)
@ -2172,13 +2170,6 @@ info.nuclearcraft.multitool.quantum_computer.finish_second_swap_list=Gate now se
info.nuclearcraft.multitool.quantum_computer.control_swap_gate_info=Gate currently swapping qubits %s with qubits %s, controlled by qubits %s info.nuclearcraft.multitool.quantum_computer.control_swap_gate_info=Gate currently swapping qubits %s with qubits %s, controlled by qubits %s
info.nuclearcraft.multitool.quantum_computer.controller.qasm_start=Quantum Computer entering QASM mode! Gate operations will be recorded but not carried out in the game.
info.nuclearcraft.multitool.quantum_computer.controller.qasm_too_many_qubits=Quantum Computer can not enter QASM mode, too many qubits installed.
info.nuclearcraft.multitool.quantum_computer.controller.qasm_print=Quantum Computer exiting QASM mode, saved generated code to %s
info.nuclearcraft.multitool.quantum_computer.controller.qasm_error=Quantum Computer exiting QASM mode, an error occurred attempting save generated code to %s
info.nuclearcraft.multitool.quantum_computer.controller.qasm_exit_too_many_qubits=Quantum Computer exiting QASM mode, too many qubits installed to generate code.
info.nuclearcraft.multitool.quantum_computer.controller.qasm_exit=Quantum Computer exiting QASM mode.
item.nuclearcraft.geiger_counter.name=Geiger Counter item.nuclearcraft.geiger_counter.name=Geiger Counter
item.nuclearcraft.geiger_counter.desc=Detects radiation and informs the player of their rad count. Can be used to read the irradiation of entities. Will be muted if off the hotbar. item.nuclearcraft.geiger_counter.desc=Detects radiation and informs the player of their rad count. Can be used to read the irradiation of entities. Will be muted if off the hotbar.
item.nuclearcraft.geiger_counter.rads=Radiation: item.nuclearcraft.geiger_counter.rads=Radiation:
@ -2356,13 +2347,13 @@ gui.nc.config.wasteland_dimension=Wasteland Dimension ID
gui.nc.config.wasteland_dimension.comment=Set the dimension ID for the Wasteland Dimension. gui.nc.config.wasteland_dimension.comment=Set the dimension ID for the Wasteland Dimension.
gui.nc.config.mushroom_spread_rate=Mushroom Spread Rate gui.nc.config.mushroom_spread_rate=Mushroom Spread Rate
gui.nc.config.mushroom_spread_rate.comment=The rate at which mushrooms added by NC will spread. gui.nc.config.mushroom_spread_rate.comment=Glowing Mushroom spread rate.
gui.nc.config.mushroom_gen=Generate Mushrooms gui.nc.config.mushroom_gen=Generate Mushrooms
gui.nc.config.mushroom_gen.comment=Will mushrooms added by NC generate in the nether? gui.nc.config.mushroom_gen.comment=Will glowing mushrooms generate in the nether?
gui.nc.config.mushroom_gen_size=Mushroom Gen Size gui.nc.config.mushroom_gen_size=Mushroom Gen Size
gui.nc.config.mushroom_gen_size.comment=Determines how many mushrooms added by NC will spawn at a time. gui.nc.config.mushroom_gen_size.comment=Determines how many glowing mushrooms will spawn at a time.
gui.nc.config.mushroom_gen_rate=Mushroom Gen Rate gui.nc.config.mushroom_gen_rate=Mushroom Gen Rate
gui.nc.config.mushroom_gen_rate.comment=Determines how often mushrooms added by NC will spawn. gui.nc.config.mushroom_gen_rate.comment=Determines how often glowing mushrooms will spawn.
gui.nc.config.category.processor=Processor Configs gui.nc.config.category.processor=Processor Configs
gui.nc.config.category.processor.tooltip=Configure processors. gui.nc.config.category.processor.tooltip=Configure processors.
@ -2656,10 +2647,8 @@ gui.nc.config.accelerator_supercooler_coolant.comment=mB/t of liquid helium requ
gui.nc.config.category.quantum=Quantum Configs gui.nc.config.category.quantum=Quantum Configs
gui.nc.config.category.quantum.tooltip=Configure quantum mechanical systems. gui.nc.config.category.quantum.tooltip=Configure quantum mechanical systems.
gui.nc.config.quantum_max_qubits_live=Max Live Qubits gui.nc.config.quantum_max_qubits=Max Qubits
gui.nc.config.quantum_max_qubits_live.comment=The maximum number of actively calculating qubits a single quantum computer multiblock can have. !!!WARNING!!! Allowing for complex circuits of more than seven qubits will begin to seriously impact performance and use up a huge amount of memory. Increase this limit with EXTREME caution! gui.nc.config.quantum_max_qubits.comment=The maximum number of qubits a single quantum computer multiblock can have. !!!WARNING!!! Allowing for complex circuits of more than seven qubits will begin to seriously impact performance and use up a huge amount of memory. Increase this limit with EXTREME caution!
gui.nc.config.quantum_max_qubits_qasm=Max QASM Qubits
gui.nc.config.quantum_max_qubits_qasm.comment=The maximum number of qubits a single quantum computer multiblock can have for generating QASM code. !!!WARNING!!! Gates with more control qubits will take increasingly more work and memory to decompile into basic operations, thus will generate increasingly mode code. IBMQ Experience's circuit composer will begin to struggle to deal with more than a few hundreds of lines of code. Increase this limit with EXTREME caution!
gui.nc.config.quantum_angle_precision=Gate Angle Precision gui.nc.config.quantum_angle_precision=Gate Angle Precision
gui.nc.config.quantum_angle_precision.comment=Controls the precision allowed for setting the working angle of gates by defining the number of available angles, uniformly distributed from 0 to 360 degrees. gui.nc.config.quantum_angle_precision.comment=Controls the precision allowed for setting the working angle of gates by defining the number of available angles, uniformly distributed from 0 to 360 degrees.
@ -2770,9 +2759,6 @@ gui.nc.config.radiation_lowest_rate=Lowest Radiation Rate
gui.nc.config.radiation_lowest_rate.comment=The lowest rate of player and chunk irradiation possible in Rad/t - amounts below this are ignored. gui.nc.config.radiation_lowest_rate.comment=The lowest rate of player and chunk irradiation possible in Rad/t - amounts below this are ignored.
gui.nc.config.radiation_chunk_limit=Chunk Radiation Limit gui.nc.config.radiation_chunk_limit=Chunk Radiation Limit
gui.nc.config.radiation_chunk_limit.comment=The maximum chunk radiation level possible in Rad/t. A negative value means there is no limit. gui.nc.config.radiation_chunk_limit.comment=The maximum chunk radiation level possible in Rad/t. A negative value means there is no limit.
gui.nc.config.radiation_sound_volumes=Radiation Sound Volumes
gui.nc.config.radiation_sound_volumes.comment=Modifiers for the volumes of radiation sound effects. Order: Geiger counter ticking, RadAway use, Rad-X use, food effects, chems wearing off, radiation badge breaking, radiation level warning, feral ghoul attack.
gui.nc.config.radiation_check_blocks=Block Radiation Contribution gui.nc.config.radiation_check_blocks=Block Radiation Contribution
gui.nc.config.radiation_check_blocks.comment=Should non-tile entity blocks contribute to chunk radiation? gui.nc.config.radiation_check_blocks.comment=Should non-tile entity blocks contribute to chunk radiation?
gui.nc.config.radiation_block_effect_max_rate=Radiation Block Mutation Max Rate gui.nc.config.radiation_block_effect_max_rate=Radiation Block Mutation Max Rate
@ -2842,9 +2828,9 @@ gui.nc.config.radiation_hud_text_outline=HUD Text Outline
gui.nc.config.radiation_hud_text_outline.comment=If enabled, a black outline will surround the radiation counter text underneath the rad bar. gui.nc.config.radiation_hud_text_outline.comment=If enabled, a black outline will surround the radiation counter text underneath the rad bar.
gui.nc.config.radiation_require_counter=Counter Required For Info gui.nc.config.radiation_require_counter=Counter Required For Info
gui.nc.config.radiation_require_counter.comment=If disabled, the rads overlay will show and the ticking will be heard even when a Geiger counter is not being held. gui.nc.config.radiation_require_counter.comment=If disabled, the rads overlay will show and the ticking will be heard even when a Geiger Counter is not being held.
gui.nc.config.radiation_chunk_boundaries=Counter/Scrubber Chunk Boundaries gui.nc.config.radiation_chunk_boundaries=Counter/Scrubber Chunk Boundaries
gui.nc.config.radiation_chunk_boundaries.comment=If enabled, chunk boundaries will be shown while holding or looking at a Geiger counter block or radiation scrubber. gui.nc.config.radiation_chunk_boundaries.comment=If enabled, chunk boundaries will be shown while holding or looking at a geiger counter block or radiation scrubber.
gui.nc.config.radiation_unit_prefixes=Radiation Unit Prefixes gui.nc.config.radiation_unit_prefixes=Radiation Unit Prefixes
gui.nc.config.radiation_unit_prefixes.comment=If set to a positive integer, radiation levels will be shown without unit prefixes to this number of significant figures. gui.nc.config.radiation_unit_prefixes.comment=If set to a positive integer, radiation levels will be shown without unit prefixes to this number of significant figures.
@ -3129,8 +3115,8 @@ nuclearcraft.multiblock_validation.too_many_controllers=There must only be one c
nuclearcraft.multiblock_validation.fission_reactor.prohibit_cells=This is not a solid fuel reactor - there must be no cells for it to form! nuclearcraft.multiblock_validation.fission_reactor.prohibit_cells=This is not a solid fuel reactor - there must be no cells for it to form!
nuclearcraft.multiblock_validation.fission_reactor.prohibit_sinks=This is not a solid fuel reactor - there must be no sinks for it to form! nuclearcraft.multiblock_validation.fission_reactor.prohibit_sinks=This is not a solid fuel reactor - there must be no sinks for it to form!
nuclearcraft.multiblock_validation.fission_reactor.prohibit_vessels=This is not a molten salt reactor - there must be no vessels for it to form! nuclearcraft.multiblock_validation.fission_reactor.prohibit_vessels=This is not a molten salt reactor - there must be no vessels it to form!
nuclearcraft.multiblock_validation.fission_reactor.prohibit_heaters=This is not a molten salt reactor - there must be no heaters for it to form! nuclearcraft.multiblock_validation.fission_reactor.prohibit_heaters=This is not a molten salt reactor - there must be no heaters it to form!
nuclearcraft.multiblock.fission_reactor_source.no_target=Has no target! nuclearcraft.multiblock.fission_reactor_source.no_target=Has no target!
nuclearcraft.multiblock.fission_reactor_source.target=Targeting %4$s at [%1$d, %2$d, %3$d] nuclearcraft.multiblock.fission_reactor_source.target=Targeting %4$s at [%1$d, %2$d, %3$d]

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"SOLID",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_side_off_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"SOLID",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_side_on_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"SOLID",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_top_off_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"SOLID",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_top_on_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"CUTOUT",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_transparent_side_off_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"CUTOUT",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_transparent_side_on_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"CUTOUT",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_transparent_top_off_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

View File

@ -0,0 +1,10 @@
{
"ctm": {
"ctm_version": 1,
"type":"ctm",
"layer":"CUTOUT",
"textures":[
"nuclearcraft:blocks/fusion_electromagnet_transparent_top_on_ctm"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1017 B

View File

@ -1,5 +0,0 @@
{
"animation": {
"frametime": 1
}
}

View File

@ -1,2 +0,0 @@
#ChunkGeneratorOverworld
public net.minecraft.world.gen.ChunkGeneratorOverworld field_186001_t #oceanBlock

View File

@ -1,8 +1,3 @@
Work out why 4->1 NOT works (only two Toffoli decomps) but 5->1 NOT doesn't (two 4CX and six Toffoli decomps)
(Currently logging Toffi and 4CX decomps)
Config to disable food rad effect sound effects
Adjacent MSR vessels with same filter form bundle to share flux, shared criticality factor is sum of single vessel criticality factors Adjacent MSR vessels with same filter form bundle to share flux, shared criticality factor is sum of single vessel criticality factors
Take number of available open faces of vessel bundle into account when calculating the heat multiplier (and efficiency) Take number of available open faces of vessel bundle into account when calculating the heat multiplier (and efficiency)