diff --git a/.gitignore b/.gitignore index fe12f1e41..5836788f8 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ output # other eclipse run +run-server refresh.bat AdvancedRocketry.txt changelog.html diff --git a/build.gradle.kts b/build.gradle.kts index e4daa9b23..9e50df44f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -63,7 +63,7 @@ tasks.compileJava { minecraft { - mappings("snapshot", "20170624-1.12") + mappings("snapshot", "20171003-1.12") accessTransformer(file("src/main/resources/META-INF/accessTransformer.cfg")) @@ -131,10 +131,10 @@ repositories { name = "ModMaven" url = uri("https://modmaven.k-4u.nl") } - maven { - name = "Galacticraft" - url = uri("https://maven.galacticraft.dev/repository/legacy-releases/") - } + //maven { + // name = "Galacticraft" + // url = uri("https://maven.galacticraft.dev/repository/legacy-releases/") + //} // maven { // name = "LibVulpes" // url = uri("http://maven.dmodoomsirius.me/") @@ -152,15 +152,15 @@ dependencies { //compileOnly("net.industrial-craft:industrialcraft-2:$icVersion:dev") //implementation("zmaster587.libVulpes:LibVulpes:$mcVersion-$libVulpesVersion-$libVulpesBuildNum-deobf") - compileOnly(fg.deobf("dev.galacticraft:galacticraft-legacy:$gcVersion")) - + //compileOnly(fg.deobf("dev.galacticraft:galacticraft-legacy:$gcVersion")) + compileOnly(fg.deobf("curse.maven:galacticraft-legacy-564236:4671122")) compileOnly(fg.deobf("mezz.jei:jei_${mcVersion}:${jeiVersion}:api")) - runtimeOnly(fg.deobf("mezz.jei:jei_${mcVersion}:${jeiVersion}")) + implementation(fg.deobf("mezz.jei:jei_${mcVersion}:${jeiVersion}")) // Sorry but it won't start wihout jei... + //runtimeOnly(fg.deobf("mezz.jei:jei_${mcVersion}:${jeiVersion}")) // I think this crashes the game for me when running from IntelliJ implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) implementation ("net.minecraftforge:mergetool:0.2.3.3") - // implementation ("zmaster587.libVulpes:libVulpes:1.12.2-0.4.2+:deobf") } tasks.processResources { diff --git a/gradle.properties b/gradle.properties index 9135f44e4..26a04fab4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,10 @@ org.gradle.daemon=false # Project mcVersion=1.12.2 forgeVersion=14.23.5.2860 -modVersion=2.0.11 +modVersion=2.1.3 archiveBase=AdvancedRocketry startGitRev=8e676bd # Dependencies -libVulpesVersion=0.4.3 +libVulpesVersion=0.5.0 jeiVersion=4.16.1.301 -icVersion=2.7.39-ex111 -gcVersion=4.0.6 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fc6f9a390..8c25905ce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ +#Sun Jul 07 14:46:24 CEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/libs/LibVulpes-deobf.jar b/libs/LibVulpes-deobf.jar index e47687576..01b31d883 100644 Binary files a/libs/LibVulpes-deobf.jar and b/libs/LibVulpes-deobf.jar differ diff --git a/settings.gradle.kts b/settings.gradle.kts index fe5385aca..8c3d444bb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { gradlePluginPortal() + mavenCentral() maven { name = "MinecraftForge" url = uri("https://maven.minecraftforge.net/") @@ -9,6 +10,10 @@ pluginManagement { name = "FancyGradle" url = uri("https://maven.gofancy.wtf/releases") } + maven { url = uri("https://plugins.gradle.org/m2/") } + maven { + url = uri("https://oss.sonatype.org/content/repositories/snapshots/") + } } } diff --git a/src/main/java/zmaster587/advancedRocketry/AdvancedRocketry.java b/src/main/java/zmaster587/advancedRocketry/AdvancedRocketry.java index cbe6b6827..07de6be2b 100644 --- a/src/main/java/zmaster587/advancedRocketry/AdvancedRocketry.java +++ b/src/main/java/zmaster587/advancedRocketry/AdvancedRocketry.java @@ -351,6 +351,7 @@ public void preInit(FMLPreInitializationEvent event) { //TileEntity Registration --------------------------------------------------------------------------------------------- GameRegistry.registerTileEntity(TileBrokenPart.class, "ARbrokenPart"); + GameRegistry.registerTileEntity(TileRocketServiceStation.class, "ARserviceStation"); GameRegistry.registerTileEntity(TileRocketAssemblingMachine.class, "ARrocketBuilder"); GameRegistry.registerTileEntity(TileWarpCore.class, "ARwarpCore"); //GameRegistry.registerTileEntity(TileModelRender.class, "ARmodelRenderer"); @@ -590,6 +591,12 @@ public void registerItems(RegistryEvent.Register evt) { OreDictionary.registerOre("slab", new ItemStack(Blocks.STONE_SLAB)); OreDictionary.registerOre("blockWarpCoreCore", new ItemStack(Blocks.GOLD_BLOCK)); OreDictionary.registerOre("blockWarpCoreRim", MaterialRegistry.getMaterialFromName("Titanium").getProduct(AllowedProducts.getProductByName("BLOCK"))); + + Item.getItemFromBlock(AdvancedRocketryBlocks.blockEngine).setMaxDamage(10); + Item.getItemFromBlock(AdvancedRocketryBlocks.blockAdvEngine).setMaxDamage(10); + Item.getItemFromBlock(AdvancedRocketryBlocks.blockBipropellantEngine).setMaxDamage(10); + Item.getItemFromBlock(AdvancedRocketryBlocks.blockAdvBipropellantEngine).setMaxDamage(10); + Item.getItemFromBlock(AdvancedRocketryBlocks.blockNuclearEngine).setMaxDamage(10); } @SubscribeEvent(priority = EventPriority.HIGH) @@ -668,6 +675,7 @@ public void registerBlocks(RegistryEvent.Register evt) { AdvancedRocketryBlocks.blockIntake = new BlockIntake(Material.IRON).setUnlocalizedName("gasIntake").setCreativeTab(tabAdvRocketry).setHardness(3f); AdvancedRocketryBlocks.blockDrill = new BlockMiningDrill().setUnlocalizedName("drill").setCreativeTab(tabAdvRocketry).setHardness(3f); AdvancedRocketryBlocks.blockLandingFloat = new Block(Material.IRON).setUnlocalizedName("landingfloat").setCreativeTab(tabAdvRocketry).setHardness(1).setResistance(1f); + AdvancedRocketryBlocks.blockServiceMonitor = new Block(Material.IRON).setUnlocalizedName("servicemonitor").setCreativeTab(tabAdvRocketry).setHardness(1).setResistance(1f); //Assembly machines AdvancedRocketryBlocks.blockRocketBuilder = new BlockTileWithMultitooltip(TileRocketAssemblingMachine.class, GuiHandler.guiId.MODULARNOINV.ordinal()).setUnlocalizedName("rocketAssembler").setCreativeTab(tabAdvRocketry).setHardness(3f); AdvancedRocketryBlocks.blockStationBuilder = new BlockTileWithMultitooltip(TileStationAssembler.class, GuiHandler.guiId.MODULAR.ordinal()).setUnlocalizedName("stationAssembler").setCreativeTab(tabAdvRocketry).setHardness(3f); @@ -678,6 +686,7 @@ public void registerBlocks(RegistryEvent.Register evt) { AdvancedRocketryBlocks.blockMonitoringStation = new BlockTileNeighborUpdate(TileRocketMonitoringStation.class, GuiHandler.guiId.MODULARNOINV.ordinal()).setCreativeTab(tabAdvRocketry).setHardness(3f).setUnlocalizedName("monitoringstation"); AdvancedRocketryBlocks.blockSatelliteControlCenter = new BlockTile(TileSatelliteTerminal.class, GuiHandler.guiId.MODULAR.ordinal()).setCreativeTab(tabAdvRocketry).setHardness(3f).setUnlocalizedName("satelliteMonitor"); AdvancedRocketryBlocks.blockTerraformingTerminal = new BlockTileTerraformer(TileTerraformingTerminal.class, GuiHandler.guiId.MODULAR.ordinal()).setCreativeTab(tabAdvRocketry).setHardness(3f).setUnlocalizedName("terraformingTerminal"); + AdvancedRocketryBlocks.blockServiceStation = new BlockTile(TileRocketServiceStation.class, GuiHandler.guiId.MODULARNOINV.ordinal()).setCreativeTab(tabAdvRocketry).setHardness(3f).setUnlocalizedName("serviceStation"); //Station machines AdvancedRocketryBlocks.blockWarpShipMonitor = new BlockWarpController(TileWarpController.class, GuiHandler.guiId.MODULARNOINV.ordinal()).setCreativeTab(tabAdvRocketry).setHardness(3f).setUnlocalizedName("stationmonitor"); @@ -838,12 +847,14 @@ public void registerBlocks(RegistryEvent.Register evt) { LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockIntake.setRegistryName("intake")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockDrill.setRegistryName("drill")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockLandingFloat.setRegistryName("landingfloat")); + LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockServiceMonitor.setRegistryName("servicemonitor")); //Assembly machines LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockRocketBuilder.setRegistryName("rocketBuilder")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockStationBuilder.setRegistryName("stationBuilder")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockDeployableRocketBuilder.setRegistryName("deployableRocketBuilder")); //Infrastructure machines LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockLoader.setRegistryName("loader"), ItemBlockMeta.class, false); + LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockServiceStation.setRegistryName("serviceStation")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockFuelingStation.setRegistryName("fuelingStation")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockMonitoringStation.setRegistryName("monitoringStation")); LibVulpesBlocks.registerBlock(AdvancedRocketryBlocks.blockSatelliteControlCenter.setRegistryName("satelliteControlCenter")); diff --git a/src/main/java/zmaster587/advancedRocketry/api/ARConfiguration.java b/src/main/java/zmaster587/advancedRocketry/api/ARConfiguration.java index 0c1601918..2f7529e38 100644 --- a/src/main/java/zmaster587/advancedRocketry/api/ARConfiguration.java +++ b/src/main/java/zmaster587/advancedRocketry/api/ARConfiguration.java @@ -236,6 +236,8 @@ public class ARConfiguration { @ConfigProperty public int planetDiscoveryChance; @ConfigProperty + public boolean allowNonArBiomesInTerraforming; + @ConfigProperty public double oxygenVentPowerMultiplier; @ConfigProperty public boolean skyOverride; @@ -272,15 +274,21 @@ public class ARConfiguration { @ConfigProperty(needsSync = true) public boolean experimentalSpaceFlight; - public ARConfiguration() { + @ConfigProperty + public boolean advancedWeightSystem; - } + @ConfigProperty + public boolean partsWearSystem; + + @ConfigProperty + public double increaseWearIntensityProb; + + public ARConfiguration() {} public ARConfiguration(ARConfiguration config) { Field[] fields = ARConfiguration.class.getDeclaredFields(); List fieldList = new ArrayList<>(fields.length); - // getDeclaredFields returns an unordered list, so we need to sort them for (Field field : fields) { if (field.isAnnotationPresent(ConfigProperty.class)) @@ -355,7 +363,7 @@ public static void loadPreInit() { arConfig.crystalliserMaximumGravity = (float) config.get(Configuration.CATEGORY_GENERAL, "crystalliserMaximumGravity", 0f, "Maximum gravity the crystalliser will function at. Use 0.0 to disable!").getDouble(); arConfig.enableLaserDrill = config.get(Configuration.CATEGORY_GENERAL, "EnableLaserDrill", true, "Enables the laser drill machine").getBoolean(); arConfig.spaceLaserPowerMult = (float) config.get(Configuration.CATEGORY_GENERAL, "LaserDrillPowerMultiplier", 1d, "Power multiplier for the laser drill machine").getDouble(); - arConfig.laserDrillPlanet = config.get(Configuration.CATEGORY_GENERAL, "laserDrillPlanet", false, "If true the orbital laser will actually mine blocks on the planet below (currently not working)").getBoolean(); + arConfig.laserDrillPlanet = config.get(Configuration.CATEGORY_GENERAL, "laserDrillPlanet", false, "If true the orbital laser will actually mine blocks on the planet below").getBoolean(); String[] str = config.getStringList("spaceLaserDimIdBlackList", Configuration.CATEGORY_GENERAL, new String[]{}, "Laser drill will not mine these dimension"); arConfig.enableTerraforming = config.get(Configuration.CATEGORY_GENERAL, "EnableTerraforming", true, "Enables terraforming items and blocks").getBoolean(); arConfig.terraformSpeed = config.get(Configuration.CATEGORY_GENERAL, "terraformMult", 1f, "Multplier for atmosphere change speed").getDouble(); @@ -364,6 +372,7 @@ public static void loadPreInit() { arConfig.terraformliquidRate = config.get(Configuration.CATEGORY_GENERAL, "TerraformerFluidConsumeRate", 40, "how many millibuckets/t are required to keep the terraformer running").getInt(); arConfig.allowTerraformNonAR = config.get(Configuration.CATEGORY_GENERAL, "allowTerraformingNonARWorlds", false, "If true dimensions not added by AR can be terraformed, including the overworld").getBoolean(); arConfig.enableGravityController = config.get(Configuration.CATEGORY_GENERAL, "enableGravityMachine", true, "If false the gravity controller cannot be built or used").getBoolean(); + arConfig.allowNonArBiomesInTerraforming = config.get(Configuration.CATEGORY_GENERAL, "allowNonArBiomesInTerraforming", false, "non-ar biomes from mods with custom world gen can not be decorated in terraforming. If you want fully decorated terraforming with only default biomes, set this to false").getBoolean(); //Oxygen arConfig.enableOxygen = config.get(OXYGEN, "EnableAtmosphericEffects", true, "If true, allows players being hurt due to lack of oxygen and allows effects from non-standard atmosphere types").getBoolean(); @@ -446,6 +455,9 @@ public static void loadPreInit() { arConfig.gravityAffectsFuel = config.get(ROCKET, "gravityAffectsFuels", true, "If true planets with higher gravity require more fuel and lower gravity would require less").getBoolean(); arConfig.launchingDestroysBlocks = config.get(ROCKET, "launchBlockDestruction", false, "If true rocket launches will kill plants, glass soil, turn rock into lava, and more").getBoolean(); blackListRocketBlocksStr = config.getStringList("rocketBlockBlackList", ROCKET, new String[]{"minecraft:portal", "minecraft:bedrock", "minecraft:snow_layer", "minecraft:water", "minecraft:flowing_water", "minecraft:lava", "minecraft:flowing_lava", "minecraft:fire", "advancedrocketry:rocketfire"}, "Mod:Blockname for example \"minecraft:chest\""); + arConfig.advancedWeightSystem = config.get(ROCKET, "advancedWeightSystem", true, "Enables advanced weight system which computes rocket weight, including the handled inventories. Block weights are stores in weights.json").getBoolean(); + arConfig.partsWearSystem = config.get(ROCKET, "partsWearSystem", true, "Enables rocket parts wear subsystem. Every rocket start it has probability to explode based on parts' wear intensities").getBoolean(); + arConfig.increaseWearIntensityProb = config.get(ROCKET, "increaseWearIntensityProb", 0.025, "Every rocket usage every part has this probability to increase wear intensity").getDouble(); //Ore and worldgen configuration //Ore configuration diff --git a/src/main/java/zmaster587/advancedRocketry/api/AdvancedRocketryBlocks.java b/src/main/java/zmaster587/advancedRocketry/api/AdvancedRocketryBlocks.java index 72e54a4b6..9bcd3d05d 100644 --- a/src/main/java/zmaster587/advancedRocketry/api/AdvancedRocketryBlocks.java +++ b/src/main/java/zmaster587/advancedRocketry/api/AdvancedRocketryBlocks.java @@ -28,6 +28,7 @@ public class AdvancedRocketryBlocks { public static Block blockBipropellantFuelTank; public static Block blockOxidizerFuelTank; public static Block blockFuelingStation; + public static Block blockServiceStation; public static Block blockMonitoringStation, blockSatelliteBuilder, blockSatelliteControlCenter; public static Block blockNuclearFuelTank; public static Block blockMoonTurf, blockHotTurf; @@ -106,4 +107,5 @@ public class AdvancedRocketryBlocks { public static Block blockSolarArray; public static Block blockSolarArrayPanel; public static Block blockRocketFire; + public static Block blockServiceMonitor; } diff --git a/src/main/java/zmaster587/advancedRocketry/api/SatelliteRegistry.java b/src/main/java/zmaster587/advancedRocketry/api/SatelliteRegistry.java index 2c9921bd2..6504b9379 100644 --- a/src/main/java/zmaster587/advancedRocketry/api/SatelliteRegistry.java +++ b/src/main/java/zmaster587/advancedRocketry/api/SatelliteRegistry.java @@ -137,7 +137,7 @@ public static SatelliteProperties getSatelliteProperties(@Nonnull ItemStack stac if (nbt != null) { if (stack.getItem() instanceof ItemSatellite) { - SatelliteProperties properties = new SatelliteProperties(nbt.getInteger("powerGeneration"), nbt.getInteger("powerStorage"), nbt.getString("dataType"), nbt.getInteger("maxData")); + SatelliteProperties properties = new SatelliteProperties(nbt.getInteger("powerGeneration"), nbt.getInteger("powerStorage"), nbt.getString("dataType"), nbt.getInteger("maxData"), nbt.getFloat("weight")); properties.setId(SatelliteRegistry.getSatelliteId(stack)); return properties; } diff --git a/src/main/java/zmaster587/advancedRocketry/api/satellite/SatelliteProperties.java b/src/main/java/zmaster587/advancedRocketry/api/satellite/SatelliteProperties.java index 9772ee9e2..ee3bfbec4 100644 --- a/src/main/java/zmaster587/advancedRocketry/api/satellite/SatelliteProperties.java +++ b/src/main/java/zmaster587/advancedRocketry/api/satellite/SatelliteProperties.java @@ -9,17 +9,20 @@ public class SatelliteProperties implements IWeighted { private int powerGeneration, powerStorage, maxData; private long id; private String satType; + private float weight; + public SatelliteProperties() { satType = null; id = -1; } - public SatelliteProperties(int powerGeneration, int powerStorage, String satType, int maxData) { + public SatelliteProperties(int powerGeneration, int powerStorage, String satType, int maxData, float weight) { this(); this.powerGeneration = powerGeneration; this.powerStorage = powerStorage; this.satType = satType; this.maxData = maxData; + this.weight = weight; } /** @@ -79,7 +82,7 @@ public SatelliteProperties setPowerGeneration(int powerGeneration) { } public float getWeight() { - return 50 + getPowerStorage() * 0.1F + getPowerGeneration() * 0.2F + getMaxDataStorage() * 0.01F; + return this.weight; } /** @@ -136,6 +139,7 @@ public void writeToNBT(NBTTagCompound nbt) { nbt.setString("dataType", satType); nbt.setLong("satId", id); nbt.setInteger("maxData", maxData); + nbt.setFloat("weight", weight); } public void readFromNBT(NBTTagCompound nbt) { @@ -144,6 +148,7 @@ public void readFromNBT(NBTTagCompound nbt) { satType = nbt.getString("dataType"); id = nbt.getLong("satId"); maxData = nbt.getInteger("maxData"); + weight = nbt.getFloat("weight"); } public enum Property { diff --git a/src/main/java/zmaster587/advancedRocketry/atmosphere/AtmosphereHandler.java b/src/main/java/zmaster587/advancedRocketry/atmosphere/AtmosphereHandler.java index 6dc2b9c12..b3711e857 100644 --- a/src/main/java/zmaster587/advancedRocketry/atmosphere/AtmosphereHandler.java +++ b/src/main/java/zmaster587/advancedRocketry/atmosphere/AtmosphereHandler.java @@ -135,6 +135,8 @@ public static void onBlockChange(@Nonnull World world, @Nonnull BlockPos bpos) { } + // sure.. causes stackoverflow left right center + /* else if (!handler.getAtmosphereType(bpos).allowsCombustion()) { if (world.getBlockState(bpos).getBlock().isLeaves(world.getBlockState(bpos), world, bpos)) { if (!(Boolean)world.getBlockState(bpos).getValue(BlockLeaves.CHECK_DECAY)) { @@ -152,6 +154,7 @@ else if (!handler.getAtmosphereType(bpos).allowsCombustion()) { world.setBlockState(bpos, Blocks.DIRT.getDefaultState()); } } + */ //Gasses should automatically vaporize and dissipate if (handler.getAtmosphereType(bpos) == AtmosphereType.VACUUM) { diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedBipropellantRocketMotor.java b/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedBipropellantRocketMotor.java index 6abd08a75..43dde33f6 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedBipropellantRocketMotor.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedBipropellantRocketMotor.java @@ -1,8 +1,14 @@ package zmaster587.advancedRocketry.block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import zmaster587.advancedRocketry.api.ARConfiguration; +import zmaster587.advancedRocketry.tile.TileBrokenPart; + +import javax.annotation.Nullable; public class BlockAdvancedBipropellantRocketMotor extends BlockBipropellantRocketMotor { @@ -19,4 +25,10 @@ public int getThrust(World world, BlockPos pos) { public int getFuelConsumptionRate(World world, int x, int y, int z) { return 3; } + + @Nullable + @Override + public TileEntity createTileEntity(final World worldIn, final IBlockState state) { + return new TileBrokenPart(10, (float) ARConfiguration.getCurrentConfig().increaseWearIntensityProb); + } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedRocketMotor.java b/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedRocketMotor.java index 84b8e8ee6..546a9e845 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedRocketMotor.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockAdvancedRocketMotor.java @@ -1,8 +1,14 @@ package zmaster587.advancedRocketry.block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import zmaster587.advancedRocketry.api.ARConfiguration; +import zmaster587.advancedRocketry.tile.TileBrokenPart; + +import javax.annotation.Nullable; public class BlockAdvancedRocketMotor extends BlockRocketMotor { @@ -19,4 +25,10 @@ public int getThrust(World world, BlockPos pos) { public int getFuelConsumptionRate(World world, int x, int y, int z) { return 3; } + + @Nullable + @Override + public TileEntity createTileEntity(final World worldIn, final IBlockState state) { + return new TileBrokenPart(10, (float) ARConfiguration.getCurrentConfig().increaseWearIntensityProb); + } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantFuelTank.java b/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantFuelTank.java index 890e33532..dbac33ace 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantFuelTank.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantFuelTank.java @@ -13,54 +13,9 @@ import java.util.Locale; -public class BlockBipropellantFuelTank extends Block implements IFuelTank { - - public final static PropertyEnum TANKSTATES = PropertyEnum.create("tankstates", TankStates.class); - +public class BlockBipropellantFuelTank extends BlockFuelTank implements IFuelTank { public BlockBipropellantFuelTank(Material mat) { super(mat); - this.setDefaultState(this.getDefaultState().withProperty(TANKSTATES, TankStates.MIDDLE)); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(TANKSTATES, TankStates.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TANKSTATES).ordinal(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TANKSTATES); - } - - @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, - BlockPos pos) { - int i = world.getBlockState(pos.add(0, 1, 0)).getBlock() == this ? 1 : 0; - i += world.getBlockState(pos.add(0, -1, 0)).getBlock() == this ? 2 : 0; - - //If there is no tank below this one - if (i == 1) { - return state.withProperty(TANKSTATES, TankStates.BOTTOM); - } - //If there is no tank above this one - else if (i == 2) { - return state.withProperty(TANKSTATES, TankStates.TOP); - } - //If there is a tank above and below this one - else { - return state.withProperty(TANKSTATES, TankStates.MIDDLE); - } - } - - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; } @Override @@ -68,15 +23,5 @@ public int getMaxFill(World world, BlockPos pos, IBlockState state) { return 1000; } - public enum TankStates implements IStringSerializable { - TOP, - BOTTOM, - MIDDLE; - @Override - public String getName() { - return name().toLowerCase(Locale.ENGLISH); - } - - } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantRocketMotor.java b/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantRocketMotor.java index a375c2313..74d3d4a6b 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantRocketMotor.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockBipropellantRocketMotor.java @@ -3,16 +3,26 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import zmaster587.advancedRocketry.api.ARConfiguration; import zmaster587.advancedRocketry.api.IRocketEngine; +import zmaster587.advancedRocketry.tile.TileBrokenPart; +import zmaster587.advancedRocketry.util.IBrokenPartBlock; import zmaster587.libVulpes.block.BlockFullyRotatable; import javax.annotation.Nonnull; +import javax.annotation.Nullable; -public class BlockBipropellantRocketMotor extends BlockFullyRotatable implements IRocketEngine { +public class BlockBipropellantRocketMotor extends BlockFullyRotatable implements IRocketEngine, IBrokenPartBlock { public BlockBipropellantRocketMotor(Material mat) { super(mat); @@ -35,8 +45,69 @@ public int getFuelConsumptionRate(World world, int x, int y, int z) { } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) { + public EnumBlockRenderType getRenderType(final IBlockState state) { + return EnumBlockRenderType.INVISIBLE; + } + @Override + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) { world.setBlockState(pos, state.withProperty(FACING, EnumFacing.DOWN)); + + TileEntity te = world.getTileEntity(pos); + ((TileBrokenPart) te).setStage(stack.getItemDamage()); + } + +// @Override +// public boolean onBlockActivated(final World worldIn, final BlockPos pos, final IBlockState state, final EntityPlayer playerIn, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { +// if (!worldIn.isRemote) { +// TileEntity te = worldIn.getTileEntity(pos); +// ((TileBrokenPart) te).transition(); +// } +// return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); +// } + + @Override + public void harvestBlock(final World world, final EntityPlayer player, final BlockPos pos, final IBlockState state, @Nullable final TileEntity te, final ItemStack stack) { + if (!world.isRemote && !player.isCreative()) { + TileBrokenPart tile = (TileBrokenPart) te; + + ItemStack drop = getDropItem(state, world, tile); + + world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), drop)); + } + + super.harvestBlock(world, player, pos, state, te, stack); + } + + public IBlockState getStateFromMeta(int meta) { + if (meta > 5) { + return this.getDefaultState(); + } + return super.getStateFromMeta(meta); + } + + @Override + public void getDrops(final NonNullList drops, final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + // no drops here + } + + @Override + public boolean hasTileEntity(IBlockState state) { + return true; + } + + @Nullable + @Override + public TileEntity createTileEntity(final World worldIn, final IBlockState state) { + return new TileBrokenPart(10, (float) ARConfiguration.getCurrentConfig().increaseWearIntensityProb); + } + + @Override + public ItemStack getDropItem(final IBlockState state, final World world, final @Nullable TileBrokenPart te) { + ItemStack drop = new ItemStack(this.getItemDropped(state, world.rand, 0)); + if (te != null) { + drop.setItemDamage(te.getStage()); + } + return drop; } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockFuelTank.java b/src/main/java/zmaster587/advancedRocketry/block/BlockFuelTank.java index 37ce75e34..1a0b5ae46 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockFuelTank.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockFuelTank.java @@ -13,6 +13,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import zmaster587.advancedRocketry.api.IFuelTank; +import zmaster587.advancedRocketry.api.IRocketEngine; import zmaster587.libVulpes.block.BlockFullyRotatable; import javax.annotation.Nonnull; @@ -84,7 +85,7 @@ public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world if (world.getBlockState(pos).getValue(FACING) == EnumFacing.DOWN || world.getBlockState(pos).getValue(FACING) == EnumFacing.UP) { int i = (world.getBlockState(pos.add(0, 1, 0)).getBlock() == this && world.getBlockState(pos.add(0, 1, 0)).getValue(FACING) == EnumFacing.UP) ? 1 : 0; - i += (world.getBlockState(pos.add(0, -1, 0)).getBlock() == this && world.getBlockState(pos.add(0, -1, 0)).getValue(FACING) == EnumFacing.UP) || world.getBlockState(pos.add(0, -1, 0)).getBlock() instanceof BlockRocketMotor ? 2 : 0; + i += (world.getBlockState(pos.add(0, -1, 0)).getBlock() == this && world.getBlockState(pos.add(0, -1, 0)).getValue(FACING) == EnumFacing.UP) || world.getBlockState(pos.add(0, -1, 0)).getBlock() instanceof IRocketEngine ? 2 : 0; //If there is no tank below this one and no engine below if (i == 1) { @@ -101,8 +102,8 @@ else if (i == 2) { } if (world.getBlockState(pos).getValue(FACING) == EnumFacing.EAST || world.getBlockState(pos).getValue(FACING) == EnumFacing.WEST) { - int i = (world.getBlockState(pos.add(1, 0, 0)).getBlock() == this && world.getBlockState(pos.add(1, 0, 0)).getValue(FACING) == EnumFacing.EAST) || world.getBlockState(pos.add(1, 0, 0)).getBlock() instanceof BlockRocketMotor ? 1 : 0; - i += (world.getBlockState(pos.add(-1, 0, 0)).getBlock() == this && world.getBlockState(pos.add(-1, 0, 0)).getValue(FACING) == EnumFacing.EAST) || world.getBlockState(pos.add(-1, 0, 0)).getBlock() instanceof BlockRocketMotor ? 2 : 0; + int i = (world.getBlockState(pos.add(1, 0, 0)).getBlock() == this && world.getBlockState(pos.add(1, 0, 0)).getValue(FACING) == EnumFacing.EAST) || world.getBlockState(pos.add(1, 0, 0)).getBlock() instanceof IRocketEngine ? 1 : 0; + i += (world.getBlockState(pos.add(-1, 0, 0)).getBlock() == this && world.getBlockState(pos.add(-1, 0, 0)).getValue(FACING) == EnumFacing.EAST) || world.getBlockState(pos.add(-1, 0, 0)).getBlock() instanceof IRocketEngine ? 2 : 0; //If there is no tank below this one and no engine below if (i == 1) { @@ -119,8 +120,8 @@ else if (i == 2) { } if (world.getBlockState(pos).getValue(FACING) == EnumFacing.NORTH || world.getBlockState(pos).getValue(FACING) == EnumFacing.SOUTH) { - int i = (world.getBlockState(pos.add(0, 0, 1)).getBlock() == this && world.getBlockState(pos.add(0, 0, 1)).getValue(FACING) == EnumFacing.SOUTH) || world.getBlockState(pos.add(0, 0, 1)).getBlock() instanceof BlockRocketMotor ? 1 : 0; - i += (world.getBlockState(pos.add(0, 0, -1)).getBlock() == this && world.getBlockState(pos.add(0, 0, -1)).getValue(FACING) == EnumFacing.SOUTH) || world.getBlockState(pos.add(0, 0, -1)).getBlock() instanceof BlockRocketMotor ? 2 : 0; + int i = (world.getBlockState(pos.add(0, 0, 1)).getBlock() == this && world.getBlockState(pos.add(0, 0, 1)).getValue(FACING) == EnumFacing.SOUTH) || world.getBlockState(pos.add(0, 0, 1)).getBlock() instanceof IRocketEngine ? 1 : 0; + i += (world.getBlockState(pos.add(0, 0, -1)).getBlock() == this && world.getBlockState(pos.add(0, 0, -1)).getValue(FACING) == EnumFacing.SOUTH) || world.getBlockState(pos.add(0, 0, -1)).getBlock() instanceof IRocketEngine ? 2 : 0; //If there is no tank below this one and no engine below if (i == 1) { diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearFuelTank.java b/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearFuelTank.java index 7afd5e4eb..4e8b21c1e 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearFuelTank.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearFuelTank.java @@ -13,70 +13,14 @@ import java.util.Locale; -public class BlockNuclearFuelTank extends Block implements IFuelTank { - - public final static PropertyEnum TANKSTATES = PropertyEnum.create("tankstates", TankStates.class); +public class BlockNuclearFuelTank extends BlockFuelTank implements IFuelTank { public BlockNuclearFuelTank(Material mat) { super(mat); - this.setDefaultState(this.getDefaultState().withProperty(TANKSTATES, TankStates.MIDDLE)); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(TANKSTATES, TankStates.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TANKSTATES).ordinal(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TANKSTATES); - } - - @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, - BlockPos pos) { - int i = world.getBlockState(pos.add(0, 1, 0)).getBlock() == this ? 1 : 0; - i += world.getBlockState(pos.add(0, -1, 0)).getBlock() == this ? 2 : 0; - - //If there is no tank below this one - if (i == 1) { - return state.withProperty(TANKSTATES, TankStates.BOTTOM); - } - //If there is no tank above this one - else if (i == 2) { - return state.withProperty(TANKSTATES, TankStates.TOP); - } - //If there is a tank above and below this one - else { - return state.withProperty(TANKSTATES, TankStates.MIDDLE); - } - } - - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; } @Override public int getMaxFill(World world, BlockPos pos, IBlockState state) { return 1000; } - - public enum TankStates implements IStringSerializable { - TOP, - BOTTOM, - MIDDLE; - - @Override - public String getName() { - return name().toLowerCase(Locale.ENGLISH); - } - - } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearRocketMotor.java b/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearRocketMotor.java index 23327bf87..ed84d34d5 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearRocketMotor.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockNuclearRocketMotor.java @@ -1,8 +1,14 @@ package zmaster587.advancedRocketry.block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import zmaster587.advancedRocketry.api.ARConfiguration; +import zmaster587.advancedRocketry.tile.TileBrokenPart; + +import javax.annotation.Nullable; public class BlockNuclearRocketMotor extends BlockRocketMotor { @@ -19,4 +25,10 @@ public int getThrust(World world, BlockPos pos) { public int getFuelConsumptionRate(World world, int x, int y, int z) { return 1; } + + @Nullable + @Override + public TileEntity createTileEntity(final World worldIn, final IBlockState state) { + return new TileBrokenPart(10, 4 * (float) ARConfiguration.getCurrentConfig().increaseWearIntensityProb); + } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockOxidizerFuelTank.java b/src/main/java/zmaster587/advancedRocketry/block/BlockOxidizerFuelTank.java index cb8f3cd72..cbdc850c2 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockOxidizerFuelTank.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockOxidizerFuelTank.java @@ -14,57 +14,11 @@ import javax.annotation.Nonnull; import java.util.Locale; -public class BlockOxidizerFuelTank extends Block implements IFuelTank { +public class BlockOxidizerFuelTank extends BlockFuelTank implements IFuelTank { - public final static PropertyEnum TANKSTATES = PropertyEnum.create("tankstates", TankStates.class); public BlockOxidizerFuelTank(Material mat) { super(mat); - this.setDefaultState(this.getDefaultState().withProperty(TANKSTATES, TankStates.MIDDLE)); - } - - @Override - @Nonnull - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(TANKSTATES, TankStates.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TANKSTATES).ordinal(); - } - - @Override - @Nonnull - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TANKSTATES); - } - - @Override - @Nonnull - public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world, - BlockPos pos) { - int i = world.getBlockState(pos.add(0, 1, 0)).getBlock() == this ? 1 : 0; - i += world.getBlockState(pos.add(0, -1, 0)).getBlock() == this ? 2 : 0; - - //If there is no tank below this one - if (i == 1) { - return state.withProperty(TANKSTATES, TankStates.BOTTOM); - } - //If there is no tank above this one - else if (i == 2) { - return state.withProperty(TANKSTATES, TankStates.TOP); - } - //If there is a tank above and below this one - else { - return state.withProperty(TANKSTATES, TankStates.MIDDLE); - } - } - - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; } @Override @@ -72,15 +26,4 @@ public int getMaxFill(World world, BlockPos pos, IBlockState state) { return 1000; } - public enum TankStates implements IStringSerializable { - TOP, - BOTTOM, - MIDDLE; - - @Override - public String getName() { - return name().toLowerCase(Locale.ENGLISH); - } - - } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockPressurizedFluidTank.java b/src/main/java/zmaster587/advancedRocketry/block/BlockPressurizedFluidTank.java index b6ef309cf..cd6dffcfa 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockPressurizedFluidTank.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockPressurizedFluidTank.java @@ -39,7 +39,7 @@ public class BlockPressurizedFluidTank extends Block { public BlockPressurizedFluidTank(Material material) { super(material); - isBlockContainer = true; + hasTileEntity = true; } @Override diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockRocketMotor.java b/src/main/java/zmaster587/advancedRocketry/block/BlockRocketMotor.java index 86aa18612..088ac702e 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockRocketMotor.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockRocketMotor.java @@ -4,22 +4,25 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import zmaster587.advancedRocketry.api.ARConfiguration; import zmaster587.advancedRocketry.api.IRocketEngine; import zmaster587.advancedRocketry.tile.TileBrokenPart; +import zmaster587.advancedRocketry.util.IBrokenPartBlock; import zmaster587.libVulpes.block.BlockFullyRotatable; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class BlockRocketMotor extends BlockFullyRotatable implements IRocketEngine { +public class BlockRocketMotor extends BlockFullyRotatable implements IRocketEngine, IBrokenPartBlock { public BlockRocketMotor(Material mat) { super(mat); @@ -45,7 +48,17 @@ public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world if (world.getBlockState(pos.add(0, 0, -1)).getBlock() instanceof BlockFuelTank) { return state.withProperty(FACING, EnumFacing.NORTH); } - return state; + return super.getActualState(state, world, pos); + } + + @Override + public int getThrust(World world, BlockPos pos) { + return 10; + } + + @Override + public int getFuelConsumptionRate(World world, int x, int y, int z) { + return 1; } @Override @@ -54,26 +67,21 @@ public boolean isOpaqueCube(@Nonnull IBlockState state) { } @Override - public int getThrust(World world, BlockPos pos) { - return 10; + public boolean isBlockNormalCube(@Nonnull final IBlockState state) { + return false; } @Override - public int getFuelConsumptionRate(World world, int x, int y, int z) { - return 1; + public EnumBlockRenderType getRenderType(final IBlockState state) { + return EnumBlockRenderType.INVISIBLE; } @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) { - NBTTagCompound compound = stack.getTagCompound(); - int stage = 0; - if (compound != null && compound.hasKey("destruction_stage")) { - stage = compound.getInteger("destruction_stage"); - } world.setBlockState(pos, state.withProperty(FACING, EnumFacing.DOWN)); TileEntity te = world.getTileEntity(pos); - ((TileBrokenPart) te).setStage(stage); + ((TileBrokenPart) te).setStage(stack.getItemDamage()); } // @Override @@ -86,19 +94,23 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity // } @Override - public void breakBlock(final World world, final BlockPos pos, final IBlockState state) { - if (!world.isRemote) { - ItemStack drop = new ItemStack(this.getItemDropped(state, world.rand, 0)); + public void harvestBlock(final World world, final EntityPlayer player, final BlockPos pos, final IBlockState state, @Nullable final TileEntity te, final ItemStack stack) { + if (!world.isRemote && !player.isCreative()) { + TileBrokenPart tile = (TileBrokenPart) te; - TileBrokenPart te = (TileBrokenPart) world.getTileEntity(pos); - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("destruction_stage", te.getStage()); - drop.setTagCompound(compound); + ItemStack drop = getDropItem(state, world, tile); world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), drop)); } - super.breakBlock(world, pos, state); + super.harvestBlock(world, player, pos, state, te, stack); + } + + public IBlockState getStateFromMeta(int meta) { + if (meta > 5) { + return this.getDefaultState(); + } + return super.getStateFromMeta(meta); } @Override @@ -114,6 +126,15 @@ public boolean hasTileEntity(IBlockState state) { @Nullable @Override public TileEntity createTileEntity(final World worldIn, final IBlockState state) { - return new TileBrokenPart(10, 0.1F); + return new TileBrokenPart(10, 2 * (float) ARConfiguration.getCurrentConfig().increaseWearIntensityProb); + } + + @Override + public ItemStack getDropItem(final IBlockState state, final World world, final @Nullable TileBrokenPart te) { + ItemStack drop = new ItemStack(this.getItemDropped(state, world.rand, 0)); + if (te != null) { + drop.setItemDamage(te.getStage()); + } + return drop; } } diff --git a/src/main/java/zmaster587/advancedRocketry/block/BlockTileTerraformer.java b/src/main/java/zmaster587/advancedRocketry/block/BlockTileTerraformer.java index 7ac0de83a..2ebf763ca 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/BlockTileTerraformer.java +++ b/src/main/java/zmaster587/advancedRocketry/block/BlockTileTerraformer.java @@ -8,6 +8,7 @@ import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -20,12 +21,16 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import org.lwjgl.Sys; +import scala.tools.nsc.doc.base.comment.EntityLink; import zmaster587.advancedRocketry.dimension.DimensionManager; import zmaster587.advancedRocketry.tile.satellite.TileTerraformingTerminal; import zmaster587.libVulpes.LibVulpes; import zmaster587.libVulpes.block.RotatableBlock; import zmaster587.libVulpes.util.IAdjBlockUpdate; +import javax.annotation.Nonnull; + public class BlockTileTerraformer extends RotatableBlock { protected Class tileClass; protected int guiId; @@ -100,7 +105,18 @@ public boolean isOpaqueCube(IBlockState state) { return false; } + @Override + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, @Nonnull ItemStack itemstack) { + super.onBlockPlacedBy(world, pos, state, player, itemstack); + if (!world.isRemote) { + DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).registerProtectingBlock(pos); + System.out.println("terminal placed"); + } + } public void breakBlock(World world, BlockPos pos, IBlockState state) { + if (!world.isRemote) + DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).unregisterProtectingBlock(pos); + TileEntity tile = world.getTileEntity(pos); @@ -133,6 +149,7 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) { entityitem.getItem().setTagCompound(tag == null ? null : tag.copy()); } + // why double calling this?? world.spawnEntity(entityitem); world.spawnEntity(entityitem); } diff --git a/src/main/java/zmaster587/advancedRocketry/block/CrystalColorizer.java b/src/main/java/zmaster587/advancedRocketry/block/CrystalColorizer.java index 25c6df5b7..7139bf40d 100644 --- a/src/main/java/zmaster587/advancedRocketry/block/CrystalColorizer.java +++ b/src/main/java/zmaster587/advancedRocketry/block/CrystalColorizer.java @@ -12,7 +12,7 @@ public class CrystalColorizer implements IBlockColor, IItemColor { @Override - public int getColorFromItemstack(@Nonnull ItemStack stack, int tintIndex) { + public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) { return BlockCrystal.EnumCrystal.values()[stack.getItemDamage()].getColor(); } diff --git a/src/main/java/zmaster587/advancedRocketry/client/ClientProxy.java b/src/main/java/zmaster587/advancedRocketry/client/ClientProxy.java index 8a6f186f3..d618b0402 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/ClientProxy.java +++ b/src/main/java/zmaster587/advancedRocketry/client/ClientProxy.java @@ -30,11 +30,15 @@ import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; import zmaster587.advancedRocketry.AdvancedRocketry; import zmaster587.advancedRocketry.api.AdvancedRocketryBlocks; import zmaster587.advancedRocketry.api.AdvancedRocketryItems; import zmaster587.advancedRocketry.api.stations.ISpaceObject; +import zmaster587.advancedRocketry.backwardCompat.ModelFormatException; +import zmaster587.advancedRocketry.backwardCompat.WavefrontObject; import zmaster587.advancedRocketry.block.BlockCrystal; import zmaster587.advancedRocketry.block.CrystalColorizer; import zmaster587.advancedRocketry.client.model.ModelRocket; @@ -47,6 +51,7 @@ import zmaster587.advancedRocketry.event.PlanetEventHandler; import zmaster587.advancedRocketry.event.RocketEventHandler; import zmaster587.advancedRocketry.stations.SpaceObjectManager; +import zmaster587.advancedRocketry.tile.TileBrokenPart; import zmaster587.advancedRocketry.tile.TileFluidTank; import zmaster587.advancedRocketry.tile.TileRocketAssemblingMachine; import zmaster587.advancedRocketry.tile.cables.TileDataPipe; @@ -64,16 +69,31 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; +@Mod.EventBusSubscriber(value = Side.CLIENT) public class ClientProxy extends CommonProxy { private static final zmaster587.advancedRocketry.dimension.DimensionManager dimensionManagerClient = new zmaster587.advancedRocketry.dimension.DimensionManager(); + private static final Map models = new HashMap<>(); + + public static WavefrontObject getModel(ResourceLocation location) { + WavefrontObject model = models.getOrDefault(location, null); + if (model == null) { + try { + model = new WavefrontObject(location); + models.put(location, model); + } catch (ModelFormatException e) { + e.printStackTrace(); + } + } + return model; + } @Override public void registerRenderers() { - - ClientRegistry.bindTileEntitySpecialRenderer(TileRocketAssemblingMachine.class, new RendererRocketAssemblingMachine()); ClientRegistry.bindTileEntitySpecialRenderer(TilePrecisionAssembler.class, new RendererPrecisionAssembler()); ClientRegistry.bindTileEntitySpecialRenderer(TileCuttingMachine.class, new RendererCuttingMachine()); @@ -104,6 +124,7 @@ public void registerRenderers() { ClientRegistry.bindTileEntitySpecialRenderer(zmaster587.advancedRocketry.tile.multiblock.machine.TileCentrifuge.class, new zmaster587.advancedRocketry.client.render.multiblocks.RenderCentrifuge()); ClientRegistry.bindTileEntitySpecialRenderer(TilePrecisionLaserEtcher.class, new RendererPrecisionLaserEtcher()); ClientRegistry.bindTileEntitySpecialRenderer(TileSolarArray.class, new RendererSolarArray()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBrokenPart.class, new RendererBrokenPart()); //ClientRegistry.bindTileEntitySpecialRenderer(TileModelRenderRotatable.class, modelBlock); @@ -128,7 +149,7 @@ public void init() { Minecraft.getMinecraft().getItemColors().registerItemColorHandler(colorizer, Item.getItemFromBlock(AdvancedRocketryBlocks.blockCrystal)); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() { - public int getColorFromItemstack(@Nonnull ItemStack stack, int tintIndex) { + public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) { return tintIndex > 0 ? -1 : ((ItemArmor) stack.getItem()).getColor(stack); } }, AdvancedRocketryItems.itemSpaceSuit_Boots, AdvancedRocketryItems.itemSpaceSuit_Chest, AdvancedRocketryItems.itemSpaceSuit_Helmet, AdvancedRocketryItems.itemSpaceSuit_Leggings); @@ -240,8 +261,6 @@ public void preInitItems() { public void preinit() { OBJLoader.INSTANCE.addDomain("advancedrocketry"); registerRenderers(); - - } private void registerFluidModel(IFluidBlock fluidBlock) { diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/RenderLaser.java b/src/main/java/zmaster587/advancedRocketry/client/render/RenderLaser.java index c2591aae0..42daa9a9b 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/RenderLaser.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/RenderLaser.java @@ -115,7 +115,7 @@ public void doRender(Particle entity, double x, double y, double z, GlStateManager.color(flareColor[0], flareColor[1], flareColor[2], flareColor[3]); for (int i = 0; i < 4; i++) { - RenderHelper.renderBottomFaceWithUV(buffer, -y + 200, -(i * 6) - x, -(i * 6) - z, (i * 6) - x, (i * 6) - z, 0, 1, 0, 1); + RenderHelper.renderBottomFaceWithUV(buffer, -y, -(i * 6) - x, -(i * 6) - z, (i * 6) - x, (i * 6) - z, 0, 1, 0, 1); } Tessellator.getInstance().draw(); diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/RendererBrokenPart.java b/src/main/java/zmaster587/advancedRocketry/client/render/RendererBrokenPart.java new file mode 100644 index 000000000..ce415f2b6 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/client/render/RendererBrokenPart.java @@ -0,0 +1,66 @@ +package zmaster587.advancedRocketry.client.render; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.Vec3i; +import zmaster587.advancedRocketry.backwardCompat.WavefrontObject; +import zmaster587.advancedRocketry.client.ClientProxy; +import zmaster587.advancedRocketry.tile.TileBrokenPart; +import zmaster587.libVulpes.block.BlockFullyRotatable; + +public class RendererBrokenPart extends TileEntitySpecialRenderer { + + @Override + public void render(TileBrokenPart tile, double x, double y, double z, float t, int destroyStage, float a) { + ResourceLocation res = tile.getBlockType().getRegistryName(); + String name = tile.getBlockType().getUnlocalizedName().split("\\.")[1].toLowerCase(); + String pathToTexture = "textures/models/" + name + "_" + tile.getStage() / 3 + ".png"; + + if (!name.equals("air")) { + GlStateManager.pushMatrix(); + GlStateManager.translate((float) x, (float) y, (float) z); + + if (tile.getBlockType() instanceof BlockFullyRotatable) { + IBlockState state = tile.getWorld().getBlockState(tile.getPos()); + EnumFacing facing = state.getBlock().getActualState(state, tile.getWorld(), tile.getPos()).getValue(BlockFullyRotatable.FACING); + Vec3i dir = facing.getDirectionVec(); + GlStateManager.translate(0.5F, 0.5F, 0.5F); + if (dir.getY() > 0) { + GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); + } + if (dir.getX() != 0) { + GlStateManager.rotate(90.0F, 0.0F, 0.0F, -dir.getX()); + } + if (dir.getZ() != 0) { + GlStateManager.rotate(90.0F, dir.getZ(), 0.0F, 0.0F); + } + GlStateManager.translate(-0.5F, -0.5F, -0.5F); + } + + if (destroyStage >= 0) { + this.bindTexture(DESTROY_STAGES[destroyStage]); + GlStateManager.matrixMode(5890); + GlStateManager.pushMatrix(); + GlStateManager.scale(4.0F, 4.0F, 1.0F); + GlStateManager.translate(0.0625F, 0.0625F, 0.0625F); + GlStateManager.matrixMode(5888); + } else { + this.bindTexture(new ResourceLocation(res.getResourceDomain(), pathToTexture)); + } + + WavefrontObject model = ClientProxy.getModel(new ResourceLocation(res.getResourceDomain(), "models/block/models/" + name + ".obj")); + model.renderAll(); + + if (destroyStage >= 0) { + GlStateManager.matrixMode(5890); + GlStateManager.popMatrix(); + GlStateManager.matrixMode(5888); + } + + GlStateManager.popMatrix(); + } + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/RendererRocket.java b/src/main/java/zmaster587/advancedRocketry/client/render/RendererRocket.java index 61a0f1fb1..57a958948 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/RendererRocket.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/RendererRocket.java @@ -166,7 +166,6 @@ public void doRender(@Nonnull Entity entity, double x, double y, double z, float for (TileEntity tile : storage.getTileEntityList()) { TileEntitySpecialRenderer renderer = TileEntityRendererDispatcher.instance.renderers.get(tile.getClass()); if (renderer != null) { - if (tileEntityBlockChiseled == null || !tileEntityBlockChiseled.isInstance(tile)) { TileEntityRendererDispatcher.instance.render(tile, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), f1); } diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderButtonUIEntity.java b/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderButtonUIEntity.java index e64f1f95e..f29e76128 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderButtonUIEntity.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderButtonUIEntity.java @@ -36,7 +36,7 @@ public void doRender(EntityUIButton entity, double x, double y, double z, GL11.glTranslated(0, -.25, 0); - RenderHelper.renderTag(Minecraft.getMinecraft().player.getDistanceSqToEntity(entity), "Up a level", x, y, z, 8); + RenderHelper.renderTag(Minecraft.getMinecraft().player.getDistanceSq(entity), "Up a level", x, y, z, 8); GL11.glPopMatrix(); //Clean up and make player not transparent diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderStarUIEntity.java b/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderStarUIEntity.java index 0bb88c62e..69fa6dac2 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderStarUIEntity.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/entity/RenderStarUIEntity.java @@ -47,7 +47,7 @@ public void doRender(EntityUIStar entity, double x, double y, double z, GL11.glTranslated(x, y, z); GL11.glScalef(sizeScale, sizeScale, sizeScale); - RenderHelper.setupPlayerFacingMatrix(Minecraft.getMinecraft().player.getDistanceSqToEntity(entity), 0, -.45, 0); + RenderHelper.setupPlayerFacingMatrix(Minecraft.getMinecraft().player.getDistanceSq(entity), 0, -.45, 0); Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.locationSunNew); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/multiblocks/RendererCrystallizer.java b/src/main/java/zmaster587/advancedRocketry/client/render/multiblocks/RendererCrystallizer.java index 13c1db361..e4324f0a8 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/multiblocks/RendererCrystallizer.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/multiblocks/RendererCrystallizer.java @@ -95,7 +95,7 @@ public void render(TileEntity tile, double x, GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - int color = Minecraft.getMinecraft().getItemColors().getColorFromItemstack(stack, 0); + int color = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, 0); float divisor = 1 / 255f; diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderPlanetarySky.java b/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderPlanetarySky.java index 67ae1aa86..018fcebb3 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderPlanetarySky.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderPlanetarySky.java @@ -791,7 +791,12 @@ else if (DimensionManager.getInstance().isDimensionCreated(mc.world.provider.get GL11.glRotatef((float) myPhi, 0f, 0f, 1f); GL11.glRotatef(planetPositionTheta, 1f, 0f, 0f); - rotateAroundAntiAxis(); + + // THIS MESSES UP PLANET ROTATION ON SPACE STATIONS + // THIS SHOULD NOT BE CALLED WHEN ON SPACE STATION!!!!! + if (world.provider.getDimension() != ARConfiguration.getCurrentConfig().spaceDimId) { + rotateAroundAntiAxis(); + } float phiAngle = (float) ((myPhi) * Math.PI / 180f); @@ -869,10 +874,6 @@ else if (afloat != null && (planetPositionTheta < 105 || planetPositionTheta > 2 GL11.glPopMatrix(); GlStateManager.disableTexture2D(); - //GlStateManager.color(f1, f2, f3, 0.05F); - //GL11.glCallList(this.glSkyList); - - GlStateManager.color(0.0F, 0.0F, 0.0F); double d0 = this.mc.player.getPositionEyes(partialTicks).y - mc.world.getHorizon(); diff --git a/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderSpaceSky.java b/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderSpaceSky.java index df1c95f75..8efb2713c 100644 --- a/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderSpaceSky.java +++ b/src/main/java/zmaster587/advancedRocketry/client/render/planet/RenderSpaceSky.java @@ -50,6 +50,7 @@ public void renderPlanet2(BufferBuilder buffer, DimensionProperties properties, if (properties.isStar()) { planetOrbitalDistance = 190F; if (properties.getStar().isBlackHole()) { + float add_offset = 50; size = 10; GL11.glDepthMask(true); GL11.glEnable(GL11.GL_ALPHA_TEST); @@ -63,7 +64,7 @@ public void renderPlanet2(BufferBuilder buffer, DimensionProperties properties, //GL11.glRotatef(180, 0, 1, 0); GL11.glPushMatrix(); - GL11.glTranslatef(0, 100, 0); + GL11.glTranslatef(0, 100+add_offset, 0); f10 = size * 2f * AstronomicalBodyHelper.getBodySizeMultiplier(planetOrbitalDistance); GlStateManager.color(0,0,0); @@ -141,7 +142,7 @@ public void renderPlanet2(BufferBuilder buffer, DimensionProperties properties, GL11.glPushMatrix(); - GL11.glTranslatef(0, 100, 0); + GL11.glTranslatef(0, 100+add_offset, 0); GL11.glRotatef(90, 0f, 1f, 0f); //GL11.glRotatef(m, 1f, 0f, 0f); //GL11.glRotatef(diskangle, 0, 0, 1); @@ -165,7 +166,7 @@ public void renderPlanet2(BufferBuilder buffer, DimensionProperties properties, mc.renderEngine.bindTexture(TextureResources.locationAccretionDisk); GL11.glPushMatrix(); - GL11.glTranslatef(0, 100, 0); + GL11.glTranslatef(0, 100+add_offset, 0); GL11.glRotatef(60, 1, 0, 0); GL11.glRotatef((System.currentTimeMillis() % (int) (360 * 360 * speedMult)) / (360f * speedMult), 0, 1, 0); @@ -181,7 +182,7 @@ public void renderPlanet2(BufferBuilder buffer, DimensionProperties properties, GL11.glPushMatrix(); - GL11.glTranslatef(0, 99.9f, 0); + GL11.glTranslatef(0, 99.9f+add_offset, 0); GL11.glRotatef(60, 1, 0, 0); GL11.glRotatef((System.currentTimeMillis() % (int) (360 * 200 * speedMult)) / (200f * speedMult), 0, 1, 0); @@ -198,7 +199,7 @@ public void renderPlanet2(BufferBuilder buffer, DimensionProperties properties, GL11.glPushMatrix(); - GL11.glTranslatef(0, 99.8f, 0); + GL11.glTranslatef(0, 99.8f+add_offset, 0); GL11.glRotatef(60, 1, 0, 0); GL11.glRotatef((System.currentTimeMillis() % (int) (36000 * speedMult)) / (100f * speedMult), 0, 1, 0); diff --git a/src/main/java/zmaster587/advancedRocketry/dimension/DimensionManager.java b/src/main/java/zmaster587/advancedRocketry/dimension/DimensionManager.java index be318ba03..235cbaa94 100644 --- a/src/main/java/zmaster587/advancedRocketry/dimension/DimensionManager.java +++ b/src/main/java/zmaster587/advancedRocketry/dimension/DimensionManager.java @@ -127,6 +127,15 @@ public static DimensionProperties getEffectiveDimId(World world, BlockPos pos) { } else return getInstance().getDimensionProperties(dimId); } + public static DimensionProperties getEffectiveDimId_byID(int dimId, BlockPos pos) { + + if (dimId == ARConfiguration.getCurrentConfig().spaceDimId) { + ISpaceObject spaceObject = SpaceObjectManager.getSpaceManager().getSpaceStationFromBlockCoords(pos); + if (spaceObject != null) return (DimensionProperties) spaceObject.getProperties().getParentProperties(); + else return defaultSpaceDimensionProperties; + } else return getInstance().getDimensionProperties(dimId); + } + /** * @return an Integer array of dimensions registered with this DimensionManager */ @@ -601,12 +610,13 @@ public void saveDimensions(String filePath) throws Exception { NBTTagCompound dimNbt = new NBTTagCompound(); dimSet.getValue().writeToNBT(dimNbt); - + dimSet.getValue().write_terraforming_data(dimNbt); dimListnbt.setTag(dimSet.getKey().toString(), dimNbt); } nbt.setTag("dimList", dimListnbt); + //Stats NBTTagCompound stats = new NBTTagCompound(); stats.setBoolean("hasReachedMoon", hasReachedMoon); @@ -974,8 +984,7 @@ public void createAndLoadDimensions(boolean resetFromXml) { if (loadedPlanets.containsKey(properties.getId())) { DimensionProperties loadedDim = (DimensionProperties) loadedPlanets.get(properties.getId()); if (loadedDim != null) { - properties.copySatellites(loadedDim); - properties.copyTerraformedBiomes(loadedDim); + properties.copyData(loadedDim); } } if (properties.isNativeDimension) @@ -1082,6 +1091,7 @@ public Map loadDimensions(String filePath) { for (String key : dimListNbt.getKeySet()) { DimensionProperties properties = DimensionProperties.createFromNBT(Integer.parseInt(key), dimListNbt.getCompoundTag(key)); + properties.read_terraforming_data(dimListNbt.getCompoundTag(key)); int keyInt = Integer.parseInt(key); /*if(!net.minecraftforge.common.DimensionManager.isDimensionRegistered(keyInt) && properties.isNativeDimension && !properties.isGasGiant()) { diff --git a/src/main/java/zmaster587/advancedRocketry/dimension/DimensionProperties.java b/src/main/java/zmaster587/advancedRocketry/dimension/DimensionProperties.java index 8fd616303..fdf685881 100644 --- a/src/main/java/zmaster587/advancedRocketry/dimension/DimensionProperties.java +++ b/src/main/java/zmaster587/advancedRocketry/dimension/DimensionProperties.java @@ -10,6 +10,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -24,7 +25,11 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.relauncher.Side; import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.Sys; import zmaster587.advancedRocketry.AdvancedRocketry; import zmaster587.advancedRocketry.api.*; import zmaster587.advancedRocketry.api.atmosphere.AtmosphereRegister; @@ -32,6 +37,9 @@ import zmaster587.advancedRocketry.api.dimension.solar.StellarBody; import zmaster587.advancedRocketry.api.satellite.SatelliteBase; import zmaster587.advancedRocketry.atmosphere.AtmosphereType; +import zmaster587.advancedRocketry.common.CommonProxy; +import zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage.Afuckinginterface; +import zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage.serverlists; import zmaster587.advancedRocketry.inventory.TextureResources; import zmaster587.advancedRocketry.item.ItemBiomeChanger; import zmaster587.advancedRocketry.item.ItemSatelliteIdentificationChip; @@ -40,10 +48,7 @@ import zmaster587.advancedRocketry.satellite.SatelliteBiomeChanger; import zmaster587.advancedRocketry.satellite.SatelliteWeatherController; import zmaster587.advancedRocketry.stations.SpaceObjectManager; -import zmaster587.advancedRocketry.util.AstronomicalBodyHelper; -import zmaster587.advancedRocketry.util.OreGenProperties; -import zmaster587.advancedRocketry.util.SpacePosition; -import zmaster587.advancedRocketry.util.SpawnListEntryNBT; +import zmaster587.advancedRocketry.util.*; import zmaster587.advancedRocketry.world.ChunkManagerPlanet; import zmaster587.advancedRocketry.world.provider.WorldProviderPlanet; import zmaster587.libVulpes.api.IUniversalEnergy; @@ -121,7 +126,6 @@ public class DimensionProperties implements Cloneable, IDimensionProperties { private String name; //public ExtendedBiomeProperties biomeProperties; private LinkedList allowedBiomes; - private LinkedList terraformedBiomes; private LinkedList craterBiomeWeights; private boolean isRegistered = false; //private boolean isTerraformed = false; @@ -152,11 +156,22 @@ public class DimensionProperties implements Cloneable, IDimensionProperties { private int seaLevel; private int generatorType; //public int target_sea_level; - public List terraformingChangeList; - public List terraformingChunkListCurrentCycle; - public BiomeProvider chunkMgrTerraformed; + + + + + @SidedProxy(serverSide = "zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage.serverlists", clientSide = "zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage.clientlists") + public static Afuckinginterface proxylists; + + + + public List terraformingChunksAlreadyAdded; + + //class + public List water_source_locked_positions; + //public boolean water_can_exist; public DimensionProperties(int id) { name = "Temp"; @@ -176,7 +191,6 @@ public DimensionProperties(int id) { craterOres = new ArrayList<>(); allowedBiomes = new LinkedList<>(); - terraformedBiomes = new LinkedList<>(); craterBiomeWeights = new LinkedList<>(); satellites = new HashMap<>(); requiredArtifacts = new LinkedList<>(); @@ -208,11 +222,11 @@ public DimensionProperties(int id) { generatorType = 0; //target_sea_level = seaLevel; - terraformingChangeList = new LinkedList<>(); - terraformingChunkListCurrentCycle = new LinkedList<>(); //water_can_exist = true; water_source_locked_positions = new ArrayList<>(); + terraformingChunksAlreadyAdded = new ArrayList<>(); + ringAngle = 70; @@ -220,59 +234,116 @@ public DimensionProperties(int id) { //this.chunkMgrTerraformed = new ChunkManagerPlanet(net.minecraftforge.common.DimensionManager.getWorld(id), net.minecraftforge.common.DimensionManager.getWorld(getId()).getWorldInfo().getGeneratorOptions(), getTerraformedBiomes()); } - public void reset_chunkmgr(){ - World world = net.minecraftforge.common.DimensionManager.getWorld(getId()); - getAverageTemp(); - setTerraformedBiomes(DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).getViableBiomes(false)); - chunkMgrTerraformed = new ChunkManagerPlanet(world, world.getWorldInfo().getGeneratorOptions(), getTerraformedBiomes()); + public void load_terraforming_helper(boolean reset) { + if (!net.minecraftforge.common.DimensionManager.getWorld(getId()).isRemote) { + + if (!proxylists.isinitialized(getId())){ + proxylists.initdim(getId()); + } + + getAverageTemp(); + getViableBiomes(false); + if (reset) { + proxylists.getChunksFullyTerraformed(getId()).clear(); + terraformingChunksAlreadyAdded.clear(); + } + + System.out.println("load helper with protecting blocks: " + proxylists.getProtectingBlocksForDimension(getId()).size() + " (" + reset + ")"); + + proxylists.sethelper(getId(), new TerraformingHelper(getId(), getBiomesEntries(getViableBiomes(false)), proxylists.getChunksFullyTerraformed(getId()))); + + System.out.println("num biomes: "+ getViableBiomes(false).size()); + + Collection list = (net.minecraftforge.common.DimensionManager.getWorld(getId())).getChunkProvider().getLoadedChunks(); + if (!list.isEmpty()) { + for (Chunk chunk : list) { + add_chunk_to_terraforming_list(chunk); + } + } + } + } - public void add_chunk_to_terraforming_list(Chunk chunk) { - boolean is_there = false; - for (Chunk i : terraformingChunkListCurrentCycle) { - if (i.x == chunk.x && i.z == chunk.z) { - is_there = true; + public void registerProtectingBlock(BlockPos p) { + boolean already_registered = false; + for (BlockPos i : proxylists.getProtectingBlocksForDimension(getId())) { + if (i.equals(p)) { + already_registered = true; + break; } } - if (!is_there) { - terraformingChunkListCurrentCycle.add(chunk); - for (int i = 0; i < 256; i++) { - int coord = i; - int x = (coord & 0xF) + chunk.x * 16; - int z = (coord >> 4) + chunk.z * 16; - terraformingChangeList.add(new HashedBlockPosition(x, 0, z)); + //System.out.println("register protecting block called"); + if (!already_registered) { + proxylists.getProtectingBlocksForDimension(getId()).add(p); + //System.out.println("block registered"); + if (proxylists.gethelper(getId()) != null) { + proxylists.gethelper(getId()).recalculate_chunk_status(); } } } - private void reset_terraforming_chunk_positions(){ - terraformingChangeList.clear(); - terraformingChunkListCurrentCycle.clear(); - Collection list = (net.minecraftforge.common.DimensionManager.getWorld(getId())).getChunkProvider().getLoadedChunks(); - if (list.size() > 0) { - for (Chunk chunk:list){ - add_chunk_to_terraforming_list(chunk); + + public void unregisterProtectingBlock(BlockPos p) { + for (BlockPos i : proxylists.getProtectingBlocksForDimension(getId())) { + if (i.equals(p)) { + proxylists.getProtectingBlocksForDimension(getId()).remove(i); + if (proxylists.gethelper(getId()) != null) + proxylists.gethelper(getId()).recalculate_chunk_status(); + break; } } } - public HashedBlockPosition get_next_terraforming_block() { - if (terraformingChangeList.size() == 0) { - //long startTime = System.currentTimeMillis(); - reset_terraforming_chunk_positions(); - //long endTime = System.currentTimeMillis(); - //long executionTime = endTime - startTime; // Time in milliseconds - //System.out.println("reset chunklist: "+executionTime+"ms"); - } - if (terraformingChangeList.size() == 0) { - System.out.println("List is 0 - this should never happen!!"); - return null; // this should never happen. Yes it would crash the game, but if it does, my code is wrong and needs to be fixed anyway + + public void add_block_to_terraforming_queue(BlockPos p) { + //boolean is_there = false; + //for (BlockPos i : terraformingHelper.terraformingqueue) { + // if (i.equals(p)) { + // is_there = true; + // } + //} + //if (!is_there) + proxylists.gethelper(getId()).add_position_to_queue(p); + } + + public void add_chunk_to_terraforming_list(Chunk chunk) { + + if (proxylists.gethelper(getId()) != null) { + + boolean chunk_was_already_done = proxylists.getChunksFullyTerraformed(getId()).contains(new ChunkPos(chunk.x,chunk.z));; // do not add a chunk if it is already fully terraformed + if (chunk_was_already_done) + return; + + //System.out.println("add chunk to terraforming list: "+chunk.x+":"+chunk.z); + + chunkdata current_chunk = proxylists.gethelper(getId()).getChunkFromList(chunk.x, chunk.z); + if (current_chunk == null || !current_chunk.chunk_fully_generated) { + + boolean chunk_was_already_added = false; // do not add a chunk twice, the helper will manage it once it is added + for (ChunkPos i : terraformingChunksAlreadyAdded) { + if (chunk.x == i.x && chunk.z == i.z) { + chunk_was_already_added = true; + break; + } + } + if (chunk_was_already_added) + return; + + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + if (current_chunk == null || !current_chunk.fully_generated[x][z]) + // if a position in the chunk is already fully generated, skip + add_block_to_terraforming_queue(new BlockPos(chunk.x * 16 + x, 0, chunk.z * 16 + z)); + + } + } + } } - return terraformingChangeList.remove(nextInt(0,terraformingChangeList.size())); - //return terraformingChangeList.remove(0); } + public DimensionProperties(int id, String name) { this(id); this.name = name; } + public DimensionProperties(int id, boolean shouldRegister) { this(id); isStation = !shouldRegister; @@ -301,14 +372,11 @@ public static DimensionProperties createFromNBT(int id, NBTTagCompound nbt) { return properties; } - public void copySatellites(DimensionProperties props) { + public void copyData(DimensionProperties props) { this.satellites = props.satellites; this.tickingSatellites = props.tickingSatellites; } - public void copyTerraformedBiomes(DimensionProperties props) { - this.terraformedBiomes = props.terraformedBiomes; - } @Override public Object clone() { @@ -644,7 +712,7 @@ public void setParentOrbitalDistance(int distance) { * @return if a planet, the same as getParentOrbitalDistance(), if a moon, the moon's distance from the host star */ public int getSolarOrbitalDistance() { - if (this.isStar()){ + if (this.isStar()) { return 1; } if (parentPlanet != Constants.INVALID_PLANET) @@ -704,9 +772,6 @@ public boolean isMoon() { return parentPlanet != Constants.INVALID_PLANET && parentPlanet != SpaceObjectManager.WARPDIMID; } - /** - * @return true if currently terraformed - */ public int getAtmosphereDensity() { return atmosphereDensity; @@ -719,8 +784,7 @@ public void setAtmosphereDensity(int atmosphereDensity) { int prevAtm = this.atmosphereDensity; this.atmosphereDensity = atmosphereDensity; - reset_chunkmgr(); - + load_terraforming_helper(true); PacketHandler.sendToAll(new PacketDimInfo(getId(), this)); @@ -972,7 +1036,7 @@ public Collection getTickingSatellites() { public void tick() { Iterator iterator = tickingSatellites.values().iterator(); - + //System.out.println(":"+tickingSatellites.size()); while (iterator.hasNext()) { SatelliteBase satellite = iterator.next(); satellite.tickEntity(); @@ -994,14 +1058,15 @@ public void tick() { BlockPos p = i.pos.getBlockPos(); iterator_2.remove(); // Safe removal during iteration World world = (net.minecraftforge.common.DimensionManager.getWorld(getId())); - world.notifyNeighborsOfStateChange(p,world.getBlockState(p).getBlock(),false); + world.notifyNeighborsOfStateChange(p, world.getBlockState(p).getBlock(), false); } } } - public void add_water_locked_pos(HashedBlockPosition pos){ - for (watersourcelocked i : water_source_locked_positions){ - if (i.pos.equals(pos)){ + + public void add_water_locked_pos(HashedBlockPosition pos) { + for (watersourcelocked i : water_source_locked_positions) { + if (i.pos.equals(pos)) { i.reset_timer(); return; } @@ -1045,14 +1110,6 @@ public void setBiomes(List biomes) { addBiomes(biomes); } - public List getTerraformedBiomes() { - return terraformedBiomes; - } - - public void setTerraformedBiomes(List biomes) { - terraformedBiomes.clear(); - terraformedBiomes.addAll(getBiomesEntries(biomes)); - } /** * Used to determine if a biome is allowed to spawn on ANY planet @@ -1060,18 +1117,29 @@ public void setTerraformedBiomes(List biomes) { * @param biome biome to check * @return true if the biome is not allowed to spawn on any Dimension */ - public boolean isBiomeblackListed(Biome biome) { + public boolean isBiomeblackListed(Biome biome, boolean is_NOT_terraforming) { + + if (!is_NOT_terraforming) { + String modId = biome.getRegistryName().getResourceDomain(); + if (!ARConfiguration.getCurrentConfig().allowNonArBiomesInTerraforming) { + if (!modId.equals("minecraft") && !modId.equals("advancedrocketry")) { + return true; + } + } + } + if (biome.equals(AdvancedRocketryBiomes.spaceBiome)) return true; + return AdvancedRocketryBiomes.instance.getBlackListedBiomes().contains(Biome.getIdForBiome(biome)); } /** * @return a list of biomes allowed to spawn in this dimension */ - public List getViableBiomes(boolean allow_single_biome) { + public List getViableBiomes(boolean not_terraforming) { Random random = new Random(System.nanoTime()); List viableBiomes = new ArrayList<>(); - if (atmosphereDensity > AtmosphereTypes.LOW.value && random.nextInt(3) == 0 && allow_single_biome) { + if (atmosphereDensity > AtmosphereTypes.LOW.value && random.nextInt(3) == 0 && not_terraforming) { List list = new LinkedList<>(AdvancedRocketryBiomes.instance.getSingleBiome()); while (list.size() > 1) { @@ -1100,34 +1168,36 @@ public List getViableBiomes(boolean allow_single_biome) { } else if (Temps.getTempFromValue(averageTemperature).hotterOrEquals(Temps.HOT)) { for (Biome biome : Biome.REGISTRY) { - if (biome != null && (BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.HOT) || BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.OCEAN)) && !isBiomeblackListed(biome)) { + if (biome != null && (BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.HOT) || BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.OCEAN)) && !isBiomeblackListed(biome, not_terraforming)) { viableBiomes.add(biome); } } } else if (Temps.getTempFromValue(averageTemperature).hotterOrEquals(Temps.NORMAL)) { for (Biome biome : Biome.REGISTRY) { - if (biome != null && !BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.COLD) && !isBiomeblackListed(biome)) { + if (biome != null && !BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.COLD) && !isBiomeblackListed(biome, not_terraforming)) { viableBiomes.add(biome); } } - viableBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.OCEAN)); + //if (not_terraforming) + //viableBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.OCEAN)); } else if (Temps.getTempFromValue(averageTemperature).hotterOrEquals(Temps.COLD)) { for (Biome biome : Biome.REGISTRY) { - if (biome != null && !BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.HOT) && !isBiomeblackListed(biome)) { + if (biome != null && !BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.HOT) && !isBiomeblackListed(biome, not_terraforming)) { viableBiomes.add(biome); } } - viableBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.OCEAN)); + //if (not_terraforming) + //viableBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.OCEAN)); } else if (Temps.getTempFromValue(averageTemperature).hotterOrEquals(Temps.FRIGID)) { for (Biome biome : Biome.REGISTRY) { - if (biome != null && BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.COLD) && !isBiomeblackListed(biome)) { + if (biome != null && BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.COLD) && !isBiomeblackListed(biome, not_terraforming)) { viableBiomes.add(biome); } } } else { for (Biome biome : Biome.REGISTRY) { - if (biome != null && BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.COLD) && !isBiomeblackListed(biome)) { + if (biome != null && BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.COLD) && !isBiomeblackListed(biome, not_terraforming)) { viableBiomes.add(biome); } } @@ -1336,22 +1406,6 @@ private void readFromTechnicalNBT(NBTTagCompound nbt) { } else beaconLocations.clear(); - - //Load biomes - if (nbt.hasKey("biomesTerra")) { - - terraformedBiomes.clear(); - int[] biomeIds = nbt.getIntArray("biomesTerra"); - List biomesList = new ArrayList<>(); - - - for (int biomeId : biomeIds) { - biomesList.add(AdvancedRocketryBiomes.instance.getBiomeById(biomeId)); - } - - terraformedBiomes.addAll(getBiomesEntries(biomesList)); - } - //Satellites if (nbt.hasKey("satallites")) { @@ -1384,6 +1438,7 @@ private void readFromTechnicalNBT(NBTTagCompound nbt) { } public void readFromNBT(NBTTagCompound nbt) { + NBTTagList list; if (nbt.hasKey("skyColor")) { @@ -1579,9 +1634,12 @@ public void readFromNBT(NBTTagCompound nbt) { } else fillerBlock = null; + readFromTechnicalNBT(nbt); } + + private void writeTechnicalNBT(NBTTagCompound nbt) { NBTTagList list; if (!beaconLocations.isEmpty()) { @@ -1593,16 +1651,6 @@ private void writeTechnicalNBT(NBTTagCompound nbt) { nbt.setTag("beaconLocations", list); } - - if (!terraformedBiomes.isEmpty()) { - int[] biomeId = new int[terraformedBiomes.size()]; - for (int i = 0; i < terraformedBiomes.size(); i++) { - - biomeId[i] = Biome.getIdForBiome(terraformedBiomes.get(i).biome); - } - nbt.setIntArray("biomesTerra", biomeId); - } - //Satellites if (!satellites.isEmpty()) { @@ -1614,9 +1662,83 @@ private void writeTechnicalNBT(NBTTagCompound nbt) { allSatelliteNBT.setTag(entry.getKey().toString(), satelliteNBT); } nbt.setTag("satallites", allSatelliteNBT); + } } + + //terraforming data + public void read_terraforming_data(NBTTagCompound nbt){ + + int dimid =getId(); + if (!proxylists.isinitialized(dimid)){ + proxylists.initdim(dimid); + } + + if (nbt.hasKey("fullyGeneratedChunks")) { + + NBTTagList list = nbt.getTagList("fullyGeneratedChunks", NBT.TAG_COMPOUND); + if (!list.hasNoTags()) + proxylists.setChunksFullyTerraformed(dimid, new HashSet()); + for (NBTBase entry : list) { + assert entry instanceof NBTTagCompound; + int x = ((NBTTagCompound) entry).getInteger("x"); + int z = ((NBTTagCompound) entry).getInteger("z"); + System.out.println("Chunk fully terraformed: " + x + ":" + z); + + boolean chunk_was_already_done = false; + for (ChunkPos i : proxylists.getChunksFullyTerraformed(dimid)) { + if (x == i.x && z == i.z) { + chunk_was_already_done = true; + break; + } + } + if (!chunk_was_already_done) + proxylists.getChunksFullyTerraformed(dimid).add(new ChunkPos(x, z)); + else System.out.println("Chunk is already in list: " + x + ":" + z); + } + } + + if (nbt.hasKey("terraformingProtectedBlocks")) { + + NBTTagList list = nbt.getTagList("terraformingProtectedBlocks", NBT.TAG_COMPOUND); + if (!list.hasNoTags()) + proxylists.setProtectingBlocksForDimension(dimid, new ArrayList<>()); + for (NBTBase entry : list) { + assert entry instanceof NBTTagCompound; + int x = ((NBTTagCompound) entry).getInteger("x"); + int z = ((NBTTagCompound) entry).getInteger("z"); + int y = ((NBTTagCompound) entry).getInteger("y"); + proxylists.getProtectingBlocksForDimension(dimid).add(new BlockPos(x, y, z)); + System.out.println("read protecting block at " + x + ":" + y + ":" + z + " - - " + proxylists.getProtectingBlocksForDimension(dimid).size()); + } } } + public void write_terraforming_data(NBTTagCompound nbt) { + // write terraforming data + int dimid = getId(); + if (!proxylists.isinitialized(dimid)){ + return; + } + NBTTagList list = new NBTTagList(); + for (ChunkPos pos : proxylists.getChunksFullyTerraformed(dimid)) { + NBTTagCompound entry = new NBTTagCompound(); + entry.setInteger("x", pos.x); + entry.setInteger("z", pos.z); + list.appendTag(entry); + } + nbt.setTag("fullyGeneratedChunks", list); + + list = new NBTTagList(); + for (BlockPos pos : proxylists.getProtectingBlocksForDimension(dimid)) { + NBTTagCompound entry = new NBTTagCompound(); + entry.setInteger("x", pos.getX()); + entry.setInteger("y", pos.getY()); + entry.setInteger("z", pos.getZ()); + list.appendTag(entry); + } + nbt.setTag("terraformingProtectedBlocks", list); + + + } public void writeToNBT(NBTTagCompound nbt) { NBTTagList list; @@ -1779,6 +1901,7 @@ public void writeToNBT(NBTTagCompound nbt) { } + writeTechnicalNBT(nbt); } @@ -2052,6 +2175,7 @@ public int getTemp() { public boolean hotterThan(Temps type) { return this.compareTo(type) < 0; } + public boolean hotterOrEquals(Temps type) { return this.compareTo(type) <= 0; } diff --git a/src/main/java/zmaster587/advancedRocketry/entity/EntityLaserNode.java b/src/main/java/zmaster587/advancedRocketry/entity/EntityLaserNode.java index a88335917..03220988b 100644 --- a/src/main/java/zmaster587/advancedRocketry/entity/EntityLaserNode.java +++ b/src/main/java/zmaster587/advancedRocketry/entity/EntityLaserNode.java @@ -59,18 +59,7 @@ public void setDead() { * Removes all the light blocks created by the laser */ private void cleanUp() { - if (!this.world.isRemote && this.isDead) - new Thread(() -> { - for (int h = 0; h < world.getHeight(); h++) { - for (int i = 0; i < 9; i++) { - int x = (int) posX + (i % 3) - 1; - int z = (int) posZ + (i / 3) - 1; - BlockPos pos = new BlockPos(x, h, z); - if (world.getBlockState(pos).getBlock() == AdvancedRocketryBlocks.blockLightSource) - world.setBlockToAir(pos); - } - } - }).start(); + } @Override diff --git a/src/main/java/zmaster587/advancedRocketry/entity/EntityRocket.java b/src/main/java/zmaster587/advancedRocketry/entity/EntityRocket.java index 4ced94e0f..f91b1e92f 100644 --- a/src/main/java/zmaster587/advancedRocketry/entity/EntityRocket.java +++ b/src/main/java/zmaster587/advancedRocketry/entity/EntityRocket.java @@ -58,6 +58,7 @@ import zmaster587.advancedRocketry.event.PlanetEventHandler; import zmaster587.advancedRocketry.inventory.IPlanetDefiner; import zmaster587.advancedRocketry.inventory.TextureResources; +import zmaster587.advancedRocketry.inventory.modules.ModuleBrokenPart; import zmaster587.advancedRocketry.inventory.modules.ModulePlanetSelector; import zmaster587.advancedRocketry.inventory.modules.ModuleStellarBackground; import zmaster587.advancedRocketry.item.ItemAsteroidChip; @@ -68,7 +69,9 @@ import zmaster587.advancedRocketry.network.PacketSatellite; import zmaster587.advancedRocketry.stations.SpaceObjectManager; import zmaster587.advancedRocketry.stations.SpaceStationObject; +import zmaster587.advancedRocketry.tile.TileBrokenPart; import zmaster587.advancedRocketry.tile.TileGuidanceComputer; +import zmaster587.advancedRocketry.tile.TileRocketAssemblingMachine; import zmaster587.advancedRocketry.tile.hatch.TileSatelliteHatch; import zmaster587.advancedRocketry.util.*; import zmaster587.advancedRocketry.world.util.TeleporterNoPortal; @@ -723,7 +726,7 @@ private boolean hasHumanPassenger() { } public boolean isDescentPhase() { - return ARConfiguration.getCurrentConfig().automaticRetroRockets && isInOrbit() && this.posY < 300 && (this.motionY < -0.4f || world.isRemote); + return ARConfiguration.getCurrentConfig().automaticRetroRockets && isInOrbit() && ((this.posY < 500 && (this.motionY < -0.5f || world.isRemote)) || (this.posY < 200 && (this.motionY < -0.2f || world.isRemote))); } public boolean isStartupPhase() { @@ -848,6 +851,13 @@ private Vec3d calculatePullFromPlanets() { public void setFire(int seconds) { } + private void syncRocket() { + NBTTagCompound nbtdata = new NBTTagCompound(); + + this.writeToNBT(nbtdata); + PacketHandler.sendToNearby(new PacketEntity(this, (byte) 0, nbtdata), world.provider.getDimension(), new BlockPos(this), 64); + } + @Override public void onUpdate() { super.onUpdate(); @@ -988,6 +998,9 @@ else if (!getRCS() && rcs_mode_counter > 0) { double distanceSq = this.spacePosition.distanceToSpacePosition2(new SpacePosition()); //Land, only handle on server if (!world.isRemote) { + this.storage.damageParts(); + syncRocket(); + if (distanceSq < 0.5f * spacePosition.world.getRenderSizePlanetView() * spacePosition.world.getRenderSizePlanetView()) { this.destinationDimId = spacePosition.world.getId(); this.setRCS(false); @@ -1106,12 +1119,12 @@ else if (distanceSq > this.spacePosition.world.getRenderSizePlanetView() * this. //if the player holds the forward key then decelerate if (isInOrbit() && (burningFuel || descentPhase)) { float vel = descentPhase ? 1f : getPassengerMovingForward(); - this.motionY -= this.motionY * vel / 50f; + this.motionY -= this.motionY * vel / 40f; } this.velocityChanged = true; } else if (isInOrbit() && descentPhase) { //For unmanned rockets - this.motionY -= this.motionY / 50f; + this.motionY -= this.motionY / 40f; this.velocityChanged = true; } @@ -1119,7 +1132,7 @@ else if (distanceSq > this.spacePosition.world.getRenderSizePlanetView() * this. //If out of fuel or descending then accelerate downwards if (isInOrbit() || !burningFuel) { //this.motionY = Math.min(this.motionY - 0.001, 1); - this.motionY = this.motionY - 0.001; + this.motionY = this.motionY - 0.0001; } else //this.motionY = Math.min(this.motionY + 0.001, 1); this.motionY += stats.getAcceleration(DimensionManager.getInstance().getDimensionProperties(this.world.provider.getDimension()).getGravitationalMultiplier()) * deltaTime; @@ -1204,6 +1217,8 @@ else if (distanceSq > this.spacePosition.world.getRenderSizePlanetView() * this. if (this.posY < getTopBlock(getPosition()).getY() + 5 && this.posX > getTopBlock(getPosition()).getY() && ARConfiguration.getCurrentConfig().launchingDestroysBlocks && motionY < -0.1) { damageGroundBelowRocket(world, (int) this.posX, (int) this.posY - 1, (int) this.posZ, (int) Math.pow(stats.getThrust(), 0.4)); } + + //System.out.println("motiony:"+motionY); } public void onTurnRight(boolean state) { @@ -1520,7 +1535,7 @@ private void unpackSatellites() { } } else { int destinationId = storage.getDestinationDimId(world.provider.getDimension(), (int) posX, (int) posZ); - DimensionProperties properties = DimensionManager.getEffectiveDimId(world, this.getPosition()); + DimensionProperties properties = DimensionManager.getEffectiveDimId_byID(destinationId, this.getPosition()); int world2; if (destinationId == ARConfiguration.getCurrentConfig().spaceDimId || destinationId == Constants.INVALID_PLANET) world2 = properties.getId(); @@ -1561,6 +1576,39 @@ public void prepareLaunch() { } } + private double gauss(double mean, double div) { + Random rand = world.rand; + return mean + (rand.nextDouble() - 0.5F) * 2F * div; + } + + public void explode() { + if (world.isRemote && Minecraft.getMinecraft().gameSettings.particleSetting < 2) { + AxisAlignedBB bb = getCollisionBoundingBox(); + double meanX = (bb.maxX + bb.minX) / 2; + double meanY = (bb.maxY + bb.minY) / 2; + double meanZ = (bb.maxZ + bb.minZ) / 2; + double divX = (bb.maxX - bb.minX) / 1.2; + double divY = (bb.maxY - bb.minY) / 1.2; + double divZ = (bb.maxZ - bb.minZ) / 1.2; + + if (Minecraft.getMinecraft().gameSettings.particleSetting < 1) { + for (int i = 0; i < 10; i++) { + AdvancedRocketry.proxy.spawnParticle("rocketSmoke", world, + gauss(meanX, divX), gauss(meanY, divY), gauss(meanZ, divZ), + (this.rand.nextFloat() - 0.5f) / 4f, (this.rand.nextFloat() - 0.5f) / 4f, (this.rand.nextFloat() - 0.5f) / 4f); + } + } + + for (int i = 0; i < 50; i++) { + AdvancedRocketry.proxy.spawnParticle("rocketFlame", world, + gauss(meanX, divX), gauss(meanY, divY), gauss(meanZ, divZ), + (this.rand.nextFloat() - 0.5f) / 4f, (this.rand.nextFloat() - 0.5f) / 4f, (this.rand.nextFloat() - 0.5f) / 4f); + } + } + + this.setDead(); + } + /** * Launches the rocket post determining its height, checking whether it can launch to the selected planet and whether it can exist, * among other factors. Also handles orbital height calculations @@ -1573,7 +1621,27 @@ public void launch() { boolean allowLaunch = false; - this.stats.setWeight((int) storage.recalculateWeight()); + this.storage.recalculateStats(this.stats); + + NBTTagCompound nbtdata = new NBTTagCompound(); + writeToNBT(nbtdata); + PacketHandler.sendToNearby(new PacketEntity(this, (byte) 0, nbtdata), this.world.provider.getDimension(), this.getPosition(), 64); + + + if (ARConfiguration.getCurrentConfig().advancedWeightSystem) { + this.stats.setWeight((int) storage.recalculateWeight()); + for (HashedBlockPosition pos : this.infrastructureCoords) { + TileEntity te = world.getTileEntity(pos.getBlockPos()); + if (te instanceof TileRocketAssemblingMachine) { + ((TileRocketAssemblingMachine) te).getRocketStats().setWeight(this.stats.getWeight()); + } + } + } + + if (ARConfiguration.getCurrentConfig().partsWearSystem && storage.shouldBreak()) { + this.explode(); + return; + } if (ARConfiguration.getCurrentConfig().experimentalSpaceFlight && storage.getGuidanceComputer() != null && storage.getGuidanceComputer().isEmpty()) { allowLaunch = true; @@ -1621,6 +1689,10 @@ public void launch() { } + if (this.stats.getWeight() >= this.stats.getThrust()) { + allowLaunch = false; + } + //Check to see what place we should be going to //This is bad but it works and is mostly intelligible so it's here for now stats.orbitHeight = (storage.getGuidanceComputer() == null) ? getEntryHeight(this.world.provider.getDimension()) : storage.getGuidanceComputer().getLaunchSequence(this.world.provider.getDimension(), this.getPosition()); @@ -1628,8 +1700,6 @@ public void launch() { //TODO: Clean this logic a bit? if (allowLaunch || !stats.hasSeat() || ((DimensionManager.getInstance().isDimensionCreated(destinationDimId)) || destinationDimId == ARConfiguration.getCurrentConfig().spaceDimId || destinationDimId == 0)) { //Abort if destination is invalid - - setInFlight(true); Iterator connectedTiles = connectedInfrastructure.iterator(); @@ -1686,7 +1756,7 @@ public void deconstructRocket() { } //paste the rocket into the world as blocks - storage.pasteInWorld(this.world, (int) (this.posX - storage.getSizeX() / 2f), (int) this.posY, (int) (this.posZ - storage.getSizeZ() / 2f), true); + storage.pasteInWorld(this.world, (int) (this.posX - storage.getSizeX() / 2f), (int) this.posY, (int) (this.posZ - storage.getSizeZ() / 2f)); this.setDead(); } @@ -1787,6 +1857,9 @@ protected void readEntityFromNBT(NBTTagCompound nbt) { } setInFlight(isInFlight = nbt.getBoolean("flight")); + motionX = nbt.getDouble("motionX"); + motionY = nbt.getDouble("motionY"); + motionZ = nbt.getDouble("motionZ"); readMissionPersistentNBT(nbt); if (nbt.hasKey("data")) { @@ -1828,6 +1901,9 @@ protected void writeNetworkableNBT(NBTTagCompound nbt) { nbt.setBoolean("rcs_mode", rcs_mode); nbt.setInteger("rcs_mode_cnt", rcs_mode_counter); nbt.setBoolean("inSpaceFlight", getInSpaceFlight()); + nbt.setDouble("motionX", motionX); + nbt.setDouble("motionY", motionY); + nbt.setDouble("motionZ", motionZ); stats.writeToNBT(nbt); if (!infrastructureCoords.isEmpty()) { @@ -2084,10 +2160,12 @@ public void updatePassenger(@Nonnull Entity entity) { float xOffset = this.storage.getSizeX() % 2 == 0 ? 0.5f : 0f; float zOffset = this.storage.getSizeZ() % 2 == 0 ? 0.5f : 0f; float halfy = storage.getSizeY() / 2f; + float halfx = storage.getSizeX() / 2f; + float halfz = storage.getSizeZ() / 2f; - double xPos = seatPos.x + xOffset; - double yPos = seatPos.y - 0.5f - halfy; - double zPos = seatPos.z + zOffset; + double xPos = seatPos.x + xOffset - halfx+0.5; + double yPos = seatPos.y - 0.5f - halfy-0.5f; + double zPos = seatPos.z + zOffset - halfz+0.5; float angle = (float) (getRCSRotateProgress() * 0.9f * Math.PI / 180f); double yNew = (yPos) * MathHelper.cos(angle) + (-zPos - 0.5) * MathHelper.sin(angle); @@ -2125,6 +2203,23 @@ public List getModules(int ID, EntityPlayer player) { modules.add(new ModuleImage(173, 168, new IconResource(98, 168, 78, 3, CommonResources.genericBackground))); } + // Broken parts + // TODO Add check for the service monitor + + if (storage.hasServiceMonitor()) { + List serviceMonitorList = new ArrayList<>(); + + int ii = 0; + for (TileBrokenPart part : storage.getBrokenBlocks()) { + serviceMonitorList.add(new ModuleBrokenPart((ii % 5) * 18, (ii / 5) * 18, part.getDrop())); + ii++; + } + + modules.add(new ModuleContainerPanYOnly(8 + 80, 17, serviceMonitorList, new ArrayList<>(), null, 50, 45)); + modules.add(new ModuleText(80, 5, LibVulpes.proxy.getLocalizedString("msg.serviceStation.destroyProb") + + ": " + (int)(this.storage.getBreakingProbability() * 100) + "%", 0x000000)); + } + //TODO DEBUG tiles! //Render TEs in a pan-able list y-axis only List tiles = storage.getGUITiles(); @@ -2133,12 +2228,12 @@ public List getModules(int ID, EntityPlayer player) { TileEntity tile = tiles.get(i); IBlockState state = storage.getBlockState(tile.getPos()); try { - panModules.add(new ModuleSlotButton(18 * (i % 9), 18 * (i / 9), i + tilebuttonOffset, this, new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), world)); + panModules.add(new ModuleSlotButton(18 * (i % 4), 18 * (i / 4), i + tilebuttonOffset, this, new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), world)); } catch (NullPointerException e) { } } - modules.add(new ModuleContainerPanYOnly(8, 17, panModules, new LinkedList<>(), null, 171, 40, 0, 0)); + modules.add(new ModuleContainerPanYOnly(8, 17, panModules, new LinkedList<>(), null, 65, 45, 0, 0)); //Fuel modules.add(new ModuleProgress(192, 7, 0, new ProgressBarImage(2, 173, 12, 71, 17, 6, 3, 69, 1, 1, EnumFacing.UP, TextureResources.rocketHud), this)); @@ -2275,7 +2370,7 @@ public void onInventoryButtonPressed(int buttonId) { @Override public boolean canInteractWithContainer(EntityPlayer entity) { - boolean ret = !this.isDead && this.getDistanceToEntity(entity) < 64; + boolean ret = !this.isDead && this.getDistance(entity) < 64; if (!ret) RocketInventoryHelper.removePlayerFromInventoryBypass(entity); diff --git a/src/main/java/zmaster587/advancedRocketry/event/RocketEventHandler.java b/src/main/java/zmaster587/advancedRocketry/event/RocketEventHandler.java index 93df51a90..d653409bf 100644 --- a/src/main/java/zmaster587/advancedRocketry/event/RocketEventHandler.java +++ b/src/main/java/zmaster587/advancedRocketry/event/RocketEventHandler.java @@ -1,4 +1,7 @@ package zmaster587.advancedRocketry.event; +// This code does not work - it should display the earth below rockets at start but it does not. +// The detailed map is scaled too small and it is ugly even with correct scale +// maybe just use leo as earth? import net.minecraft.block.material.MapColor; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/Afuckinginterface.java b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/Afuckinginterface.java new file mode 100644 index 000000000..922b42118 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/Afuckinginterface.java @@ -0,0 +1,30 @@ +package zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage; + + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import zmaster587.advancedRocketry.util.TerraformingHelper; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +public interface Afuckinginterface { + + public void initdim(int dim); + + public boolean isinitialized(int dim); + + public List getProtectingBlocksForDimension(int dim); + + public void setProtectingBlocksForDimension(int dim, ArrayList blocks); + + public void setChunksFullyTerraformed(int dim, HashSet lpos); + + public HashSet getChunksFullyTerraformed(int dim); + + public void sethelper(int dim, TerraformingHelper helper); + + public TerraformingHelper gethelper(int dim); + +} diff --git a/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/clientlists.java b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/clientlists.java new file mode 100644 index 000000000..321218736 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/clientlists.java @@ -0,0 +1,56 @@ +package zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import zmaster587.advancedRocketry.util.TerraformingHelper; + +import java.util.*; + +public class clientlists implements Afuckinginterface { + Map terraforminginfolists; + + public clientlists(){ + this.terraforminginfolists = new HashMap<>(); + } + + public void initdim(int dim){ + if (terraforminginfolists.get(dim) != null){ + terraforminginfolists.get(dim).terraformingChunksDone = new HashSet<>(); + terraforminginfolists.get(dim).terraformingProtectedBlocks = new ArrayList<>(); + }else{ + dimensionTerraformingInfo info = new dimensionTerraformingInfo(); + info.terraformingChunksDone = new HashSet<>(); + info.terraformingProtectedBlocks = new ArrayList<>(); + terraforminginfolists.put(dim,info); + } + } + public boolean isinitialized(int dim){ + return (terraforminginfolists.get(dim) != null); + } + public List getProtectingBlocksForDimension(int dim){ + if (terraforminginfolists.get(dim) == null)return null; + return terraforminginfolists.get(dim).terraformingProtectedBlocks; + } + public void setProtectingBlocksForDimension(int dim, ArrayList blocks){ + if (terraforminginfolists.get(dim) == null)return; + terraforminginfolists.get(dim).terraformingProtectedBlocks = blocks; + } + + public void setChunksFullyTerraformed(int dim, HashSet lpos){ + if (terraforminginfolists.get(dim) == null)return; + terraforminginfolists.get(dim).terraformingChunksDone = lpos; + } + public HashSet getChunksFullyTerraformed(int dim){ + if (terraforminginfolists.get(dim) == null)return null; + return terraforminginfolists.get(dim).terraformingChunksDone; + } + + public void sethelper(int dim, TerraformingHelper helper){ + if (terraforminginfolists.get(dim) == null)return; + terraforminginfolists.get(dim).terraformingHelper= helper; + } + public TerraformingHelper gethelper(int dim){ + if (terraforminginfolists.get(dim) == null)return null; + return terraforminginfolists.get(dim).terraformingHelper; + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/dimensionTerraformingInfo.java b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/dimensionTerraformingInfo.java new file mode 100644 index 000000000..4ae5daf53 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/dimensionTerraformingInfo.java @@ -0,0 +1,16 @@ +package zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import zmaster587.advancedRocketry.util.TerraformingHelper; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +public class dimensionTerraformingInfo{ + public dimensionTerraformingInfo(){} + public ArrayList terraformingProtectedBlocks; + public HashSet terraformingChunksDone; + public TerraformingHelper terraformingHelper; +} diff --git a/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/serverlists.java b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/serverlists.java new file mode 100644 index 000000000..a5e7b4b24 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage/serverlists.java @@ -0,0 +1,57 @@ +package zmaster587.advancedRocketry.fuckin_bs_integrated_server_and_client_variable_sharing_crap_fix_fuckit_Im_in_rage; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import zmaster587.advancedRocketry.util.TerraformingHelper; + +import java.util.*; + + +public class serverlists implements Afuckinginterface { + Map terraforminginfolists; + + public serverlists(){ + this.terraforminginfolists = new HashMap<>(); + } + + public void initdim(int dim){ + if (terraforminginfolists.get(dim) != null){ + terraforminginfolists.get(dim).terraformingChunksDone = new HashSet<>(); + terraforminginfolists.get(dim).terraformingProtectedBlocks = new ArrayList<>(); + }else{ + dimensionTerraformingInfo info = new dimensionTerraformingInfo(); + info.terraformingChunksDone = new HashSet<>(); + info.terraformingProtectedBlocks = new ArrayList<>(); + terraforminginfolists.put(dim,info); + } + } + public boolean isinitialized(int dim){ + return (terraforminginfolists.get(dim) != null); + } + public List getProtectingBlocksForDimension(int dim){ + if (terraforminginfolists.get(dim) == null)return null; + return terraforminginfolists.get(dim).terraformingProtectedBlocks; + } + public void setProtectingBlocksForDimension(int dim, ArrayList blocks){ + if (terraforminginfolists.get(dim) == null)return; + terraforminginfolists.get(dim).terraformingProtectedBlocks = blocks; + } + + public void setChunksFullyTerraformed(int dim, HashSet lpos){ + if (terraforminginfolists.get(dim) == null)return; + terraforminginfolists.get(dim).terraformingChunksDone = lpos; + } + public HashSet getChunksFullyTerraformed(int dim){ + if (terraforminginfolists.get(dim) == null)return null; + return terraforminginfolists.get(dim).terraformingChunksDone; + } + + public void sethelper(int dim, TerraformingHelper helper){ + if (terraforminginfolists.get(dim) == null)return; + terraforminginfolists.get(dim).terraformingHelper= helper; + } + public TerraformingHelper gethelper(int dim){ + if (terraforminginfolists.get(dim) == null)return null; + return terraforminginfolists.get(dim).terraformingHelper; + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/inventory/ContainerOrbitalLaserDrill.java b/src/main/java/zmaster587/advancedRocketry/inventory/ContainerOrbitalLaserDrill.java index ca13db187..e69de29bb 100644 --- a/src/main/java/zmaster587/advancedRocketry/inventory/ContainerOrbitalLaserDrill.java +++ b/src/main/java/zmaster587/advancedRocketry/inventory/ContainerOrbitalLaserDrill.java @@ -1,164 +0,0 @@ -package zmaster587.advancedRocketry.inventory; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IContainerListener; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import zmaster587.advancedRocketry.api.AdvancedRocketryItems; -import zmaster587.advancedRocketry.tile.multiblock.orbitallaserdrill.TileOrbitalLaserDrill; -import zmaster587.libVulpes.gui.SlotSingleItem; - -import javax.annotation.Nonnull; - -public class ContainerOrbitalLaserDrill extends Container { - - private TileOrbitalLaserDrill laserTile; - private boolean finished, jammed; - private int prevEnergy = 0, prevLaserX = 0, prevLaserZ = 0, buildingX, buildingZ; - private TileOrbitalLaserDrill.MODE currMode; - - ContainerOrbitalLaserDrill(InventoryPlayer inventoryPlayer, TileOrbitalLaserDrill tile) { - super(); - laserTile = tile; - - addSlotToContainer(new SlotSingleItem(tile, 0, 56, 54, AdvancedRocketryItems.itemLens)); - - // Player inventory - for (int i1 = 0; i1 < 3; i1++) { - for (int l1 = 0; l1 < 9; l1++) { - addSlotToContainer(new Slot(inventoryPlayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 89 + i1 * 18)); - } - } - // Player hotbar - for (int j1 = 0; j1 < 9; j1++) { - addSlotToContainer(new Slot(inventoryPlayer, j1, 8 + j1 * 18, 147)); - } - - currMode = laserTile.getMode(); - jammed = false; - finished = false; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (laserTile.getBatteries().getUniversalEnergyStored() != prevEnergy) { - prevEnergy = laserTile.getBatteries().getUniversalEnergyStored(); - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 0, prevEnergy / 100); - } - } - - if (laserTile.laserX != prevLaserX) { - prevLaserX = laserTile.laserX; - - - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 1, prevLaserX & 65535); - - int j = prevLaserX >>> 16; - //if(j != 0) - listener.sendWindowProperty(this, 2, j); - } - } - - if (laserTile.laserZ != prevLaserZ) { - prevLaserZ = laserTile.laserZ; - - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 3, prevLaserZ & 65535); - - int j = prevLaserZ >>> 16; - //if(j != 0) - listener.sendWindowProperty(this, 4, j); - } - } - if (currMode.compareTo(laserTile.getMode()) != 0) { - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 5, laserTile.getMode().ordinal()); - } - } - if (jammed != laserTile.isJammed()) { - jammed = laserTile.isJammed(); - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 6, laserTile.isJammed() ? 1 : 0); - } - } - if (finished != laserTile.isFinished()) { - finished = laserTile.isFinished(); - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 7, laserTile.isFinished() ? 1 : 0); - } - } - } - - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - laserTile.setEnergy(value * 100); - } else if (id == 1) { - buildingX = value; - } else if (id == 2) { - buildingX |= value << 16; - laserTile.laserX = buildingX; - buildingX = 0; - } else if (id == 3) { - buildingZ = value; - } else if (id == 4) { - buildingZ |= value << 16; - laserTile.laserZ = buildingZ; - buildingZ = 0; - } else if (id == 5) { - laserTile.setMode(TileOrbitalLaserDrill.MODE.values()[value]); - } else if (id == 6) - laserTile.setJammed(value == 1); - else if (id == 7) - laserTile.setFinished(value == 1); - } - - @Override - @Nonnull - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - ItemStack stack = ItemStack.EMPTY; - Slot slotObject = inventorySlots.get(slot); - //null checks and checks if the item can be stacked (maxStackSize > 1) - if (slotObject != null && slotObject.getHasStack()) { - - ItemStack stackInSlot = slotObject.getStack(); - stack = stackInSlot.copy(); - - //merges the item into player inventory since its in the tileEntity - if (slot == 0) { - if (!this.mergeItemStack(stackInSlot, 1, 35, true)) { - return ItemStack.EMPTY; - } - } - //placing it into the tileEntity is possible since its in the player inventory - //check to make sure it's valid for the slot - else if (!laserTile.isItemValidForSlot(0, stack) || !this.mergeItemStack(stackInSlot, 0, 1, false)) { - return ItemStack.EMPTY; - } - - if (stackInSlot.getCount() == 0) { - slotObject.putStack(ItemStack.EMPTY); - } else { - slotObject.onSlotChanged(); - } - - if (stackInSlot.getCount() == stack.getCount()) { - return ItemStack.EMPTY; - } - slotObject.onTake(player, stackInSlot); - } - - return stack; - } - - - @Override - public boolean canInteractWith(@Nonnull EntityPlayer entityplayer) { - return laserTile.isUsableByPlayer(entityplayer); - } -} diff --git a/src/main/java/zmaster587/advancedRocketry/inventory/GuiOrbitalLaserDrill.java b/src/main/java/zmaster587/advancedRocketry/inventory/GuiOrbitalLaserDrill.java index 7dbd55da1..e69de29bb 100644 --- a/src/main/java/zmaster587/advancedRocketry/inventory/GuiOrbitalLaserDrill.java +++ b/src/main/java/zmaster587/advancedRocketry/inventory/GuiOrbitalLaserDrill.java @@ -1,196 +0,0 @@ -package zmaster587.advancedRocketry.inventory; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; -import zmaster587.advancedRocketry.tile.multiblock.orbitallaserdrill.TileOrbitalLaserDrill; -import zmaster587.libVulpes.gui.GuiImageButton; -import zmaster587.libVulpes.network.PacketHandler; -import zmaster587.libVulpes.network.PacketMachine; - -import java.io.IOException; -import java.util.LinkedList; - -/** - * @author zmaster587 - */ -public class GuiOrbitalLaserDrill extends GuiContainer { - - private ResourceLocation backdrop = new ResourceLocation("advancedrocketry", "textures/gui/LaserTile.png"); - private TileOrbitalLaserDrill laserTile; - private int prevX, prevZ; - - private GuiTextField xbox, ybox; - private GuiImageButton modeUp, modeDown; - - public GuiOrbitalLaserDrill(InventoryPlayer inventoryPlayer, TileOrbitalLaserDrill tile) { - super(new ContainerOrbitalLaserDrill(inventoryPlayer, tile)); - laserTile = tile; - } - - //TODO: enter button - @Override - public void initGui() { - super.initGui(); - - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - - //Create and setup the textboxes - xbox = new GuiTextField(0, this.fontRenderer, x + 113, y + 31, 50, 10); - ybox = new GuiTextField(1, this.fontRenderer, x + 113, y + 41, 50, 10); - xbox.setMaxStringLength(15); - xbox.setEnableBackgroundDrawing(true); - xbox.setFocused(true); - xbox.setCanLoseFocus(true); - xbox.setEnabled(true); - ybox.setMaxStringLength(15); - ybox.setEnableBackgroundDrawing(true); - ybox.setFocused(false); - ybox.setCanLoseFocus(true); - ybox.setEnabled(true); - - modeDown = new GuiImageButton(0, x + 103, y + 20, 5, 8, zmaster587.libVulpes.inventory.TextureResources.buttonLeft); - modeUp = new GuiImageButton(1, x + 157, y + 20, 5, 8, zmaster587.libVulpes.inventory.TextureResources.buttonRight); - this.buttonList.add(modeUp); - this.buttonList.add(modeDown); - this.buttonList.add(new GuiButton(2, x + 103, y + 62, 34, 20, "Reset")); - } - - @Override - protected void keyTyped(char par1, int par2) throws IOException { - //Don't let players change the coords while the machine is running - if (!laserTile.isRunning()) { - if (Character.isDigit(par1) || par1 == '-' || par2 == Keyboard.KEY_BACK || par2 == Keyboard.KEY_DELETE || par2 == Keyboard.KEY_LEFT || par2 == Keyboard.KEY_RIGHT) { - if (xbox.isFocused() && (par1 != '-' || (xbox.getCursorPosition() == 0 && !xbox.getText().startsWith("-")))) { - xbox.textboxKeyTyped(par1, par2); - - if (!xbox.getText().isEmpty() && !xbox.getText().contentEquals("-")) - laserTile.laserX = Integer.parseInt(xbox.getText()); - - PacketHandler.sendToServer(new PacketMachine(laserTile, (byte) 0)); - } else if (ybox.isFocused() && (par1 != '-' || (ybox.getCursorPosition() == 0 && !ybox.getText().startsWith("-")))) { - ybox.textboxKeyTyped(par1, par2); - if (!ybox.getText().isEmpty() && !ybox.getText().contentEquals("-")) - laserTile.laserZ = Integer.parseInt(ybox.getText()); - - PacketHandler.sendToServer(new PacketMachine(laserTile, (byte) 1)); - } - } - } - - if (par2 == Keyboard.KEY_TAB) { - if (xbox.isFocused()) { - xbox.setFocused(false); - ybox.setFocused(true); - } else if (ybox.isFocused()) { - xbox.setFocused(true); - ybox.setFocused(false); - } - } - - super.keyTyped(par1, par2); - } - - //Overridden so the mouse works properly - @Override - protected void actionPerformed(GuiButton guiButton) { - //TODO: debug - if (guiButton.id == 0) { - laserTile.decrementMode(); - } else if (guiButton.id == 1) { - laserTile.incrementMode(); - } else if (guiButton.id == 2) { - PacketHandler.sendToServer(new PacketMachine(laserTile, (byte) 4)); - return; - } else - return; - - if (!laserTile.isRunning()) - PacketHandler.sendToServer(new PacketMachine(laserTile, (byte) 3)); - } - - @Override - public void drawScreen(int a, int b, float c) { - super.drawScreen(a, b, c); - //Don't bother updating unless somthing has changed - if (laserTile.laserX != prevX) { - xbox.setText(String.valueOf(laserTile.laserX)); - prevX = laserTile.laserX; - } - if (laserTile.laserZ != prevZ) { - ybox.setText(String.valueOf(laserTile.laserZ)); - prevZ = laserTile.laserZ; - } - xbox.drawTextBox(); - ybox.drawTextBox(); - - int x = (width - xSize) / 2, y = (height - ySize) / 2; - - if (a > x + 11 && a < x + 27 && b < y + 85 && b > y + 43) { - LinkedList text = new LinkedList<>(); - text.add(laserTile.getBatteries().getUniversalEnergyStored() + " / " + laserTile.getBatteries().getMaxEnergyStored() + " RF"); - this.drawHoveringText(text, a, b, this.fontRenderer); - } - - //Buttons don't need to be drawn because that is taken care of by super - } - - /** - * Args: x, y, buttonClicked - * - * @throws IOException - */ - @Override - public void mouseClicked(int xPos, int yPos, int par3) throws IOException { - //Make sure we can focus the textboxes - int x = (width - xSize) / 2, y = (height - ySize) / 2; - if (!xbox.isFocused() && yPos < y + 40 && yPos > y + 31 && xPos < x + 163 && xPos > x + 113) { - xbox.setFocused(true); - ybox.setFocused(false); - } - - if (!ybox.isFocused() && yPos < y + 50 && yPos > y + 41 && xPos < x + 163 && xPos > x + 113) { - ybox.setFocused(true); - xbox.setFocused(false); - } - - super.mouseClicked(xPos, yPos, par3); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { - this.mc.renderEngine.bindTexture(backdrop); - //get starting X and Y for the interface - int x = (width - xSize) / 2, y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, 176, 171); - - //Render the energy bar only if energy exists - if (laserTile.hasEnergy()) { - int offset = laserTile.getEnergyPercentScaled(42); - this.drawTexturedModalRect(x + 11, y + 85 - offset, 176, 42 - offset, 16, offset); - } - - //Display status - if (laserTile.isFinished() || laserTile.getStackInSlot(0).isEmpty()) - this.drawTexturedModalRect(x + 145, y + 64, 32, 171, 16, 16); - else if (laserTile.isRunning() || laserTile.isJammed()) - this.drawTexturedModalRect(x + 145, y + 64, 16, 171, 16, 16); - else - this.drawTexturedModalRect(x + 145, y + 64, 0, 171, 16, 16); - - //Draw labels next to the input boxes - this.drawString(this.fontRenderer, "X:", x + 103, y + 31, 0xffffff); - this.drawString(this.fontRenderer, "Y:", x + 103, y + 41, 0xffffff); - - //Draw jamming indicator if jammed - if (laserTile.isJammed()) - this.drawString(this.fontRenderer, "Jam!", x + 143, y + 68, 0xffffff); - - //Draw mode indicator - this.drawCenteredString(this.fontRenderer, laserTile.getMode().toString(), x + 130, y + 20, 0xffffff); - } -} diff --git a/src/main/java/zmaster587/advancedRocketry/inventory/modules/ModuleBrokenPart.java b/src/main/java/zmaster587/advancedRocketry/inventory/modules/ModuleBrokenPart.java new file mode 100644 index 000000000..5066fa63f --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/inventory/modules/ModuleBrokenPart.java @@ -0,0 +1,74 @@ +package zmaster587.advancedRocketry.inventory.modules; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; +import zmaster587.libVulpes.LibVulpes; +import zmaster587.libVulpes.gui.CommonResources; +import zmaster587.libVulpes.inventory.modules.ModuleBase; + +import javax.annotation.Nonnull; +import java.util.Arrays; +import java.util.List; + +public class ModuleBrokenPart extends ModuleBase { + + private final ItemStack part; + + public ModuleBrokenPart(final int offsetX, final int offsetY, @Nonnull ItemStack part) { + super(offsetX, offsetY); + this.part = part; + this.sizeX = 18; + this.sizeY = 18; + } + + @SideOnly(Side.CLIENT) + @Override + public void renderBackground(GuiContainer gui, int x, int y, int mouseX, int mouseY, FontRenderer font) { + // render stack + + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(CommonResources.genericBackground); + gui.drawTexturedModalRect(x + this.offsetX - 1, y + this.offsetY - 1, 176, 0, 18, 18); + int relativeX = x + this.offsetX; + int relativeY = y + this.offsetY; + int zLevel = 500; + + GL11.glPushMatrix(); + RenderHelper.disableStandardItemLighting(); + RenderHelper.enableGUIStandardItemLighting(); + + GL11.glTranslatef(relativeX, relativeY, zLevel); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(part, 0, 0); + Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(font, part, 0, 0, ""); + + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + } + + private boolean isMouseOver(int mouseX, int mouseY) { + int relativeX = mouseX - this.offsetX; + int relativeY = mouseY - this.offsetY; + return relativeX > 0 && relativeX < this.sizeX && relativeY > 0 && relativeY < this.sizeY; + } + + @SideOnly(Side.CLIENT) + @Override + public void renderToolTip(final int guiOffsetX, final int guiOffsetY, final int mouseX, final int mouseY, final float zLevel, final GuiContainer gui, final FontRenderer font) { + super.renderToolTip(guiOffsetX, guiOffsetY, mouseX, mouseY, zLevel, gui, font); + + if (this.part != null && this.isMouseOver(mouseX, mouseY)) { + List list = Arrays.asList( + LibVulpes.proxy.getLocalizedString(this.part.getUnlocalizedName() + ".name"), + LibVulpes.proxy.getLocalizedString("msg.brokenstage.text") + ": " + this.part.getItemDamage() / 3 + ); + this.drawTooltip(gui, list, mouseX, mouseY, zLevel, font); + } + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/item/ItemBiomeChanger.java b/src/main/java/zmaster587/advancedRocketry/item/ItemBiomeChanger.java index e2eb16af5..eb460113d 100644 --- a/src/main/java/zmaster587/advancedRocketry/item/ItemBiomeChanger.java +++ b/src/main/java/zmaster587/advancedRocketry/item/ItemBiomeChanger.java @@ -47,12 +47,12 @@ public List getModules(int id, EntityPlayer player) { int j = 0; for (byte biomeByte : sat.discoveredBiomes()) { Biome biome = Biome.getBiome(biomeByte); - String biomeName = AdvancedRocketry.proxy.getNameFromBiome(biome); - - list2.add(new ModuleButton(32, 16 + 24 * (j++), Biome.getIdForBiome(biome), biomeName, this, TextureResources.buttonBuild)); + if (biome != null) { + String biomeName = AdvancedRocketry.proxy.getNameFromBiome(biome); + list2.add(new ModuleButton(32, 16 + 24 * (j++), Biome.getIdForBiome(biome), biomeName, this, TextureResources.buttonBuild)); + } } - //Relying on a bug, is this safe? ModuleContainerPan pan = new ModuleContainerPan(32, 16, list2, new LinkedList<>(), null, 128, 128, 0, -64, 0, 1000); @@ -78,7 +78,8 @@ else if (mapping == null) list.add(LibVulpes.proxy.getLocalizedString("msg.biomechanger.nosat")); else if (mapping.getDimensionId() == player.provider.getDimension()) { list.add(LibVulpes.proxy.getLocalizedString("msg.connected")); - list.add(LibVulpes.proxy.getLocalizedString("msg.biomechanger.selBiome") + mapping.getBiome().getBiomeName()); + if (mapping.getBiome()!=null) + list.add(LibVulpes.proxy.getLocalizedString("msg.biomechanger.selBiome") + mapping.getBiome().getBiomeName()); list.add(LibVulpes.proxy.getLocalizedString("msg.biomechanger.numBiome") + mapping.discoveredBiomes().size()); } else list.add(LibVulpes.proxy.getLocalizedString("msg.notconnected")); diff --git a/src/main/java/zmaster587/advancedRocketry/item/ItemJackHammer.java b/src/main/java/zmaster587/advancedRocketry/item/ItemJackHammer.java index ebae06bd7..6aa3551b3 100644 --- a/src/main/java/zmaster587/advancedRocketry/item/ItemJackHammer.java +++ b/src/main/java/zmaster587/advancedRocketry/item/ItemJackHammer.java @@ -21,7 +21,7 @@ public class ItemJackHammer extends ItemTool { public ItemJackHammer(ToolMaterial toolMaterial) { super(toolMaterial, items); - efficiencyOnProperMaterial = 50f; + efficiency = 50f; } @Override @@ -30,9 +30,10 @@ public boolean getIsRepairable(@Nonnull ItemStack stackMe, ItemStack stackItem) return OreDictionary.itemMatches(OreDictionary.getOres("stickTitanium").get(0), stackItem, false);//super.getIsRepairable(p_82789_1_, p_82789_2_); } + @Override @ParametersAreNonnullByDefault - public float getStrVsBlock(@Nonnull ItemStack stack, IBlockState state) { - return state.getMaterial() == Material.IRON || state.getMaterial() == Material.ROCK || state.getMaterial() == MaterialGeode.geode ? this.efficiencyOnProperMaterial : super.getStrVsBlock(stack, state); + public float getDestroySpeed(@Nonnull ItemStack stack, IBlockState state) { + return state.getMaterial() == Material.IRON || state.getMaterial() == Material.ROCK || state.getMaterial() == MaterialGeode.geode ? this.efficiency : super.getDestroySpeed(stack, state); } diff --git a/src/main/java/zmaster587/advancedRocketry/item/ItemSatellite.java b/src/main/java/zmaster587/advancedRocketry/item/ItemSatellite.java index 50eabb4aa..8510fc3f4 100644 --- a/src/main/java/zmaster587/advancedRocketry/item/ItemSatellite.java +++ b/src/main/java/zmaster587/advancedRocketry/item/ItemSatellite.java @@ -66,6 +66,7 @@ public void addInformation(@Nonnull ItemStack stack, World player, List SatelliteProperties properties = SatelliteRegistry.getSatelliteProperties(stack); int dataStorage, powerGeneration, powerStorage; + float weight; list.add(getName(stack)); list.add("ID: " + properties.getId()); @@ -90,6 +91,12 @@ public void addInformation(@Nonnull ItemStack stack, World player, List else list.add(ChatFormatting.YELLOW + LibVulpes.proxy.getLocalizedString("msg.itemsatellite.nodata")); } + + if ((weight = properties.getWeight()) > 0) + list.add(LibVulpes.proxy.getLocalizedString("msg.itemsatellite.weight") + weight); + else + list.add(ChatFormatting.YELLOW + LibVulpes.proxy.getLocalizedString("msg.itemsatellite.noweight")); + } else { list.add(ChatFormatting.RED + LibVulpes.proxy.getLocalizedString("msg.itemsatellite.empty")); } diff --git a/src/main/java/zmaster587/advancedRocketry/item/ItemSatelliteIdentificationChip.java b/src/main/java/zmaster587/advancedRocketry/item/ItemSatelliteIdentificationChip.java index b851f176a..dc39132a1 100644 --- a/src/main/java/zmaster587/advancedRocketry/item/ItemSatelliteIdentificationChip.java +++ b/src/main/java/zmaster587/advancedRocketry/item/ItemSatelliteIdentificationChip.java @@ -82,6 +82,7 @@ public void setSatellite(@Nonnull ItemStack stack, SatelliteProperties satellite nbt.setString("satelliteName", satellite2.getName()); nbt.setLong("satelliteId", satellite.getId()); + nbt.setFloat("weight", satellite.getWeight()); stack.setTagCompound(nbt); } diff --git a/src/main/java/zmaster587/advancedRocketry/item/tools/ItemBasicLaserGun.java b/src/main/java/zmaster587/advancedRocketry/item/tools/ItemBasicLaserGun.java index cf9f24fba..2e50ef406 100644 --- a/src/main/java/zmaster587/advancedRocketry/item/tools/ItemBasicLaserGun.java +++ b/src/main/java/zmaster587/advancedRocketry/item/tools/ItemBasicLaserGun.java @@ -41,7 +41,7 @@ public ItemBasicLaserGun() { } @Override - public float getStrVsBlock(@Nonnull ItemStack stack, IBlockState state) { + public float getDestroySpeed(@Nonnull ItemStack stack, IBlockState state) { return 0; } diff --git a/src/main/java/zmaster587/advancedRocketry/network/PacketBiomeIDChange.java b/src/main/java/zmaster587/advancedRocketry/network/PacketBiomeIDChange.java index 2edd83d15..fad66204f 100644 --- a/src/main/java/zmaster587/advancedRocketry/network/PacketBiomeIDChange.java +++ b/src/main/java/zmaster587/advancedRocketry/network/PacketBiomeIDChange.java @@ -66,10 +66,9 @@ public void executeClient(EntityPlayer thePlayer) { chunk.setBiomeArray(array); BlockPos pos2 = pos.getBlockPos();// new BlockPos(chunk.xPosition << 4, 48, chunk.zPosition << 4); thePlayer.world.markBlockRangeForRenderUpdate(pos2, pos2.add(1, 64, 1)); - - if (Minecraft.getMinecraft().gameSettings.particleSetting < 2) - AdvancedRocketry.proxy.spawnParticle("smallLazer", thePlayer.world, pos.x, pos.y, pos.z, 0, 0, 0); } + if (Minecraft.getMinecraft().gameSettings.particleSetting < 2) + AdvancedRocketry.proxy.spawnParticle("smallLazer", thePlayer.world, pos.x, pos.y, pos.z, 0, 0, 0); } } diff --git a/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteBiomeChanger.java b/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteBiomeChanger.java index 090b36f40..67639e104 100644 --- a/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteBiomeChanger.java +++ b/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteBiomeChanger.java @@ -99,7 +99,7 @@ public void tickEntity() { HashedBlockPosition pos = toChangeList.remove(world.rand.nextInt(toChangeList.size())); //HashedBlockPosition pos = toChangeList.remove(toChangeList.size()-1); - BiomeHandler.changeBiome(world, biomeId, pos.getBlockPos(), true); + BiomeHandler.terraform(world, biomeId, pos.getBlockPos(), true, world.provider.getDimension()); } } else break; diff --git a/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteData.java b/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteData.java index 2ba335720..5c36fa337 100644 --- a/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteData.java +++ b/src/main/java/zmaster587/advancedRocketry/satellite/SatelliteData.java @@ -53,6 +53,8 @@ public boolean acceptsItemInConstruction(@Nonnull ItemStack item) { public void setProperties(@Nonnull ItemStack satelliteProperties) { super.setProperties(satelliteProperties); data.setMaxData(this.satelliteProperties.getMaxDataStorage()); + powerConsumption = getPowerPerTick(); + collectionTime = (int) (200 / Math.sqrt(0.1 * powerConsumption)); } @@ -113,6 +115,7 @@ public void tickEntity() { //Add data to the buffer, if the satellite has enough power data.addData(getDataCreated(), data.getDataType(), true); + //System.out.println("data: "+data.getData()+":"+getDataCreated()+":"+collectionTime); } @Override diff --git a/src/main/java/zmaster587/advancedRocketry/tile/TileBrokenPart.java b/src/main/java/zmaster587/advancedRocketry/tile/TileBrokenPart.java index 3909eb0eb..8922ab5fb 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/TileBrokenPart.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/TileBrokenPart.java @@ -1,6 +1,8 @@ package zmaster587.advancedRocketry.tile; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import zmaster587.advancedRocketry.util.IBrokenPartBlock; import javax.annotation.Nonnull; import java.util.Random; @@ -67,6 +69,15 @@ public boolean transition() { return false; } + @Override + public boolean canRenderBreaking() { + return true; + } + + public ItemStack getDrop() { + return ((IBrokenPartBlock) this.getBlockType()).getDropItem(world.getBlockState(pos), world, this); + } + @Nonnull @Override public NBTTagCompound writeToNBT(final NBTTagCompound compound) { diff --git a/src/main/java/zmaster587/advancedRocketry/tile/TileEntitySyncable.java b/src/main/java/zmaster587/advancedRocketry/tile/TileEntitySyncable.java index 909793a55..ca3ca3df8 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/TileEntitySyncable.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/TileEntitySyncable.java @@ -10,8 +10,10 @@ public class TileEntitySyncable extends TileEntity { public void markDirty() { super.markDirty(); - IBlockState state = world.getBlockState(pos); - world.notifyBlockUpdate(pos, state, state, 3); + if (hasWorld()) { + IBlockState state = world.getBlockState(pos); + world.notifyBlockUpdate(pos, state, state, 3); + } } @Override diff --git a/src/main/java/zmaster587/advancedRocketry/tile/TileRocketAssemblingMachine.java b/src/main/java/zmaster587/advancedRocketry/tile/TileRocketAssemblingMachine.java index a85c9bee6..265f7db01 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/TileRocketAssemblingMachine.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/TileRocketAssemblingMachine.java @@ -240,7 +240,6 @@ public boolean isScanning() { } public void scanRocket(World world, BlockPos pos2, AxisAlignedBB bb) { - int thrustMonopropellant = 0; int thrustBipropellant = 0; int thrustNuclearNozzleLimit = 0; @@ -253,7 +252,7 @@ public void scanRocket(World world, BlockPos pos2, AxisAlignedBB bb) { int fuelCapacityBipropellant = 0; int fuelCapacityOxidizer = 0; int fuelCapacityNuclearWorkingFluid = 0; - int numBlocks = 0; + float drillPower = 0f; stats.reset(); @@ -318,9 +317,11 @@ public void scanRocket(World world, BlockPos pos2, AxisAlignedBB bb) { continue; } - numBlocks++; - - weight += WeightEngine.INSTANCE.getWeight(world, currBlockPos); + if (ARConfiguration.getCurrentConfig().advancedWeightSystem) { + weight += WeightEngine.INSTANCE.getWeight(world, currBlockPos); + } else { + weight += 1; + } //If rocketEngine increaseThrust final float x = xCurr - actualMinX - ((actualMaxX - actualMinX) / 2f); @@ -336,18 +337,18 @@ public void scanRocket(World world, BlockPos pos2, AxisAlignedBB bb) { monopropellantfuelUse += ((IRocketEngine) block).getFuelConsumptionRate(world, xCurr, yCurr, zCurr); thrustMonopropellant += ((IRocketEngine) block).getThrust(world, currBlockPos); } - stats.addEngineLocation(x, yCurr - actualMinY, z); + stats.addEngineLocation(x+0.5f, yCurr - actualMinY+0.5f, z+0.5f); } if (block instanceof IFuelTank) { - if (block instanceof BlockFuelTank) { - fuelCapacityMonopropellant += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); - } else if (block instanceof BlockBipropellantFuelTank) { + if (block instanceof BlockBipropellantFuelTank) { fuelCapacityBipropellant += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); } else if (block instanceof BlockOxidizerFuelTank) { fuelCapacityOxidizer += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); } else if (block instanceof BlockNuclearFuelTank) { fuelCapacityNuclearWorkingFluid += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); + } else if (block instanceof BlockFuelTank) { + fuelCapacityMonopropellant += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); } } @@ -366,12 +367,14 @@ public void scanRocket(World world, BlockPos pos2, AxisAlignedBB bb) { TileEntity tile = world.getTileEntity(currBlockPos); if (tile instanceof TileSatelliteHatch) { hasSatellite = true; - TileSatelliteHatch hatch = (TileSatelliteHatch) tile; - if (hatch.getSatellite() != null) { - weight += hatch.getSatellite().getProperties().getWeight(); - } else if (hatch.getStackInSlot(0).getItem() instanceof ItemPackedStructure) { - ItemPackedStructure struct = (ItemPackedStructure) hatch.getStackInSlot(0).getItem(); - weight += struct.getStructure(hatch.getStackInSlot(0)).getWeight(); + if (ARConfiguration.getCurrentConfig().advancedWeightSystem) { + TileSatelliteHatch hatch = (TileSatelliteHatch) tile; + if (hatch.getSatellite() != null) { + weight += hatch.getSatellite().getProperties().getWeight(); + } else if (hatch.getStackInSlot(0).getItem() instanceof ItemPackedStructure) { + ItemPackedStructure struct = (ItemPackedStructure) hatch.getStackInSlot(0).getItem(); + weight += struct.getStructure(hatch.getStackInSlot(0)).getWeight(); + } } } else if (tile instanceof TileGuidanceComputer) { hasGuidance = true; diff --git a/src/main/java/zmaster587/advancedRocketry/tile/atmosphere/TileOxygenVent.java b/src/main/java/zmaster587/advancedRocketry/tile/atmosphere/TileOxygenVent.java index 6f865e6bb..f154fd7f2 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/atmosphere/TileOxygenVent.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/atmosphere/TileOxygenVent.java @@ -55,7 +55,7 @@ public class TileOxygenVent extends TileInventoriedRFConsumerTank implements IBl private boolean hasFluid; private boolean soundInit; private boolean allowTrace; - private boolean lock; + private boolean blockUpdated; private int numScrubbers; private List scrubbers; private int radius = 0; @@ -103,23 +103,7 @@ public World getWorldObj() { @Override public void onAdjacentBlockUpdated() { - - if (isSealed) - activateAdjBlocks(); - scrubbers.clear(); - TileEntity[] tiles = new TileEntity[6]; - tiles[0] = world.getTileEntity(pos.add(1, 0, 0)); - tiles[1] = world.getTileEntity(pos.add(-1, 0, 0)); - tiles[2] = world.getTileEntity(pos.add(0, 1, 0)); - tiles[3] = world.getTileEntity(pos.add(0, -1, 0)); - tiles[4] = world.getTileEntity(pos.add(0, 0, 1)); - tiles[5] = world.getTileEntity(pos.add(0, 0, -1)); - - lock = true; - for (TileEntity tile : tiles) { - if (tile instanceof TileCO2Scrubber && world.getBlockState(tile.getPos()).getBlock() == AdvancedRocketryBlocks.blockCO2Scrubber) - scrubbers.add((TileCO2Scrubber) tile); - } + blockUpdated = true; // the performFunction will take it from here } private void activateAdjBlocks() { @@ -186,6 +170,28 @@ public boolean isTurnedOn() { @Override public void performFunction() { + + if (blockUpdated) { // this was moved from onAdjacentBlockUpdated(); to prevent crash + if (isSealed) + activateAdjBlocks(); + scrubbers.clear(); + TileEntity[] tiles = new TileEntity[6]; + tiles[0] = world.getTileEntity(pos.add(1, 0, 0)); + tiles[1] = world.getTileEntity(pos.add(-1, 0, 0)); + tiles[2] = world.getTileEntity(pos.add(0, 1, 0)); + tiles[3] = world.getTileEntity(pos.add(0, -1, 0)); + tiles[4] = world.getTileEntity(pos.add(0, 0, 1)); + tiles[5] = world.getTileEntity(pos.add(0, 0, -1)); + + + for (TileEntity tile : tiles) { + if (tile instanceof TileCO2Scrubber && world.getBlockState(tile.getPos()).getBlock() == AdvancedRocketryBlocks.blockCO2Scrubber) + scrubbers.add((TileCO2Scrubber) tile); + } + blockUpdated = false; + } + + /* NB: canPerformFunction returns false and must return true for performFunction to execute * if there is no O2 handler, this is why we can safely call AtmosphereHandler.getOxygenHandler * and not have to worry about an NPE being thrown @@ -232,8 +238,7 @@ public void performFunction() { } } - //Lock the vent while the scrubbers do their block updates - if (isSealed && !lock) { + if (isSealed) { //If scrubbers exist and the config allows then use the cartridge if (ARConfiguration.getCurrentConfig().scrubberRequiresCartrige) { @@ -266,8 +271,7 @@ public void performFunction() { hasFluid = false; } - } else - lock = false; + } } } diff --git a/src/main/java/zmaster587/advancedRocketry/tile/infrastructure/TileRocketServiceStation.java b/src/main/java/zmaster587/advancedRocketry/tile/infrastructure/TileRocketServiceStation.java new file mode 100644 index 000000000..af31a044c --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/tile/infrastructure/TileRocketServiceStation.java @@ -0,0 +1,562 @@ +package zmaster587.advancedRocketry.tile.infrastructure; + +import io.netty.buffer.ByteBuf; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import zmaster587.advancedRocketry.AdvancedRocketry; +import zmaster587.advancedRocketry.api.EntityRocketBase; +import zmaster587.advancedRocketry.api.IFuelTank; +import zmaster587.advancedRocketry.api.IInfrastructure; +import zmaster587.advancedRocketry.api.IMission; +import zmaster587.advancedRocketry.block.BlockBipropellantRocketMotor; +import zmaster587.advancedRocketry.block.BlockRocketMotor; +import zmaster587.advancedRocketry.block.BlockSeat; +import zmaster587.advancedRocketry.entity.EntityRocket; +import zmaster587.advancedRocketry.inventory.TextureResources; +import zmaster587.advancedRocketry.tile.TileBrokenPart; +import zmaster587.advancedRocketry.tile.multiblock.machine.TilePrecisionAssembler; +import zmaster587.advancedRocketry.util.IBrokenPartBlock; +import zmaster587.advancedRocketry.util.InventoryUtil; +import zmaster587.advancedRocketry.util.StorageChunk; +import zmaster587.advancedRocketry.util.nbt.NBTHelper; +import zmaster587.libVulpes.LibVulpes; +import zmaster587.libVulpes.block.BlockTile; +import zmaster587.libVulpes.interfaces.ILinkableTile; +import zmaster587.libVulpes.inventory.modules.*; +import zmaster587.libVulpes.items.ItemLinker; +import zmaster587.libVulpes.network.PacketEntity; +import zmaster587.libVulpes.network.PacketHandler; +import zmaster587.libVulpes.network.PacketMachine; +import zmaster587.libVulpes.tile.IComparatorOverride; +import zmaster587.libVulpes.tile.TileEntityRFConsumer; +import zmaster587.libVulpes.util.IAdjBlockUpdate; +import zmaster587.libVulpes.util.INetworkMachine; + +import javax.annotation.Nonnull; +import java.util.*; +import java.util.stream.Collectors; + +public class TileRocketServiceStation extends TileEntityRFConsumer implements IModularInventory, ITickable, IAdjBlockUpdate, IInfrastructure, ILinkableTile, INetworkMachine, IButtonInventory, IProgressBar, IComparatorOverride { + + EntityRocketBase linkedRocket; + + ModuleText destroyProbText; + ModuleText destroyProgressText; + ModuleText wornMotorsText; + ModuleText wornSeatsText; + ModuleText wornTanksText; + ModuleText wornMotorsCount; + ModuleText wornSeatsCount; + ModuleText wornTanksCount; + boolean was_powered = false; + + List assemblers = new ArrayList<>(); + List assemblerPoses = new ArrayList<>(); + TileBrokenPart[] partsProcessing = new TileBrokenPart[0]; + IBlockState[] statesProcessing = new IBlockState[0]; + + int initialPartToRepairCount; + List partsToRepair = new LinkedList<>(); + List statesToRepair = new LinkedList<>(); + + public TileRocketServiceStation() { + super(10000); + + destroyProbText = new ModuleText(90, 30, LibVulpes.proxy.getLocalizedString("msg.serviceStation.destroyProbNA"), 0x2b2b2b, true); + wornMotorsText = new ModuleText(40, 30 + 30, LibVulpes.proxy.getLocalizedString("msg.serviceStation.wornMotorsText"), 0x2b2b2b, true); + wornSeatsText = new ModuleText(90, 30 + 30, LibVulpes.proxy.getLocalizedString("msg.serviceStation.wornSeatsText"), 0x2b2b2b, true); + wornTanksText = new ModuleText(140, 30 + 30, LibVulpes.proxy.getLocalizedString("msg.serviceStation.wornTanksText"), 0x2b2b2b, true); + destroyProgressText = new ModuleText(90, 120, LibVulpes.proxy.getLocalizedString("msg.serviceStation.serviceProgressNA"), 0x2b2b2b, true); + + wornMotorsCount = new ModuleText(40, 30 + 30 + 10, "0", 0x2b2b2b, true); + wornSeatsCount = new ModuleText(90, 30 + 30 + 10, "0", 0x2b2b2b, true); + wornTanksCount = new ModuleText(140, 30 + 30 + 10, "0", 0x2b2b2b, true); + } + + @Override + public void invalidate() { + super.invalidate(); + + if (linkedRocket != null) { + linkedRocket.unlinkInfrastructure(this); + unlinkRocket(); + } + } + + public boolean getEquivalentPower() { + //if (state == RedstoneState.OFF) + // return false; + + boolean state2 = world.isBlockIndirectlyGettingPowered(pos) > 0; + + //if (state == RedstoneState.INVERTED) + // state2 = !state2; + return state2; + } + + @Override + public void onAdjacentBlockUpdated() { + + } + + @Override + public int getMaxLinkDistance() { + return 3000; + } + + public void updateRepairList() { + updateRepairList(true); + } + + private void updateRepairList(boolean initial) { + EntityRocket rocket = (EntityRocket) linkedRocket; + partsToRepair = new LinkedList<>(); + statesToRepair = new LinkedList<>(); + + for (TileEntity te : rocket.storage.getTileEntityList()) { + if (te instanceof TileBrokenPart) { + TileBrokenPart part = (TileBrokenPart) te; + if (part.getStage() > 0) { + partsToRepair.add(part); + statesToRepair.add(rocket.storage.getBlockState(te.getPos())); + } + } + } + + if (initial) { + initialPartToRepairCount = partsToRepair.size(); + } + } + + private void scanForAssemblers() { + this.assemblers = new ArrayList<>(); + + int size = 5; + + for (int x = getPos().getX() - size; x < getPos().getX() + size; x++) { + for (int y = getPos().getY() - size; y < getPos().getY() + size; y++) { + for (int z = getPos().getZ() - size; z < getPos().getZ() + size; z++) { + TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); + if (te instanceof TilePrecisionAssembler) { + this.assemblers.add((TilePrecisionAssembler) te); + } + } + } + } + + this.statesProcessing = new IBlockState[assemblers.size()]; + this.partsProcessing = new TileBrokenPart[assemblers.size()]; + } + + private boolean processAssemblerResult(int index) { + StorageChunk storage = ((EntityRocket) linkedRocket).storage; + TilePrecisionAssembler assembler = assemblers.get(index); + + if (InventoryUtil.hasItemInInventories(assembler.getItemOutPorts(), "rocket", true)) { + IBlockState state = statesProcessing[index]; + TileBrokenPart te = partsProcessing[index]; + + if (te == null) { + AdvancedRocketry.logger.warn("Rocket service station at " + getPos() + + " is out of sync with connected assemblers! Repairing part lost"); + return false; + } + + te.setStage(0); + storage.addTileEntity(te); + storage.setBlockState(te.getPos(), state); + + statesProcessing[index] = null; + partsProcessing[index] = null; + + assembler.markDirty(); + + return true; + } + return false; + } + + private void syncRocket() { + NBTTagCompound nbtdata = new NBTTagCompound(); + + linkedRocket.writeToNBT(nbtdata); + PacketHandler.sendToNearby(new PacketEntity((EntityRocket) linkedRocket, (byte) 0, nbtdata), linkedRocket.world.provider.getDimension(), this.pos, 64); + } + + private void consumePartToRepair(int assemblerIndex) { + StorageChunk storage = ((EntityRocket) linkedRocket).storage; + + TilePrecisionAssembler assembler = assemblers.get(assemblerIndex); + TileBrokenPart part = partsToRepair.get(0); + IBlockState state = statesToRepair.get(0); + if (!(part.getBlockType() instanceof IBrokenPartBlock)) { + AdvancedRocketry.logger.warn("Rocket part at " + part.getPos() + " is out of sync with its block! Removing"); + statesToRepair.remove(0); + partsToRepair.remove(0); + return; + } + IBrokenPartBlock partBlock = (IBrokenPartBlock) part.getBlockType(); + + // add to processing list + statesProcessing[assemblerIndex] = state; + partsProcessing[assemblerIndex] = part; + + // add to the assembler + ItemStack resultingStack = partBlock.getDropItem(statesToRepair.get(0), world, part); + if (!InventoryUtil.addItemToOneOfTheInventories(assembler.getItemInPorts(), resultingStack)) { + AdvancedRocketry.logger.error("Precision assembler at " + assembler.getPos() + " overflows. Repaired part lost"); + } + statesToRepair.remove(0); + partsToRepair.remove(0); + + // consume parts from the rocket + storage.getTileEntityList().remove(part); + storage.setBlockState(part.getPos(), Blocks.AIR.getDefaultState()); + assembler.onInventoryUpdated(); + } + + private void giveWorkToAssemblers() { + boolean dirty = false; + for (int i = 0; i < assemblers.size(); i++) { + if (assemblers.get(i).isInvalid()) { + // it is invalid, so we should not operate with it + assemblers.set(i, null); + partsProcessing[i] = null; + statesProcessing[i] = null; + continue; + } + + dirty = dirty || processAssemblerResult(i); + + TilePrecisionAssembler assembler = assemblers.get(i); + + if (InventoryUtil.hasItemInInventories(assembler.getItemInPorts(), "motor", false)) { + // assembler already have a motor for work, skipping + continue; + } + + if (!this.partsToRepair.isEmpty() && statesProcessing[i] == null) { + consumePartToRepair(i); + dirty = true; + } + } + if (dirty) { + syncRocket(); + } + } + + @Override + public void performFunction() { + if (linkedRocket instanceof EntityRocket) { + // stay with the right blockstate + IBlockState state = world.getBlockState(pos); + if (!state.getValue(BlockTile.STATE)) { + world.setBlockState(pos, state.withProperty(BlockTile.STATE, true)); + } + + if (getEquivalentPower() && linkedRocket != null) { + if (!was_powered) { + scanForAssemblers(); + was_powered = true; + } else { + if (assemblerPoses != null) { + // lazy access to assembler list loaded from NBT + assemblers = assemblerPoses.stream().map(pos -> (TilePrecisionAssembler) world.getTileEntity(pos)).collect(Collectors.toList()); + assemblerPoses = null; + + this.statesProcessing = new IBlockState[assemblers.size()]; + this.partsProcessing = new TileBrokenPart[assemblers.size()]; + + updateRepairList(false); + } + } + + giveWorkToAssemblers(); + } + } + if (!getEquivalentPower()) { + was_powered = false; + } + } + + @Override + public boolean canPerformFunction() { + if (world.isRemote || world.getWorldTime() % 20 != 0) { + return false; + } + + boolean hasWork = partsToRepair.size() > 0 || Arrays.stream(partsProcessing).anyMatch(Objects::nonNull); + + if (hasWork) { + return true; + } + + IBlockState state = world.getBlockState(pos); + if (state.getValue(BlockTile.STATE)) { + world.setBlockState(pos, state.withProperty(BlockTile.STATE, false)); + } + return false; + } + + @Override + public int getPowerPerOperation() { + return 10; + } + + @Override + public boolean onLinkStart(@Nonnull ItemStack item, TileEntity entity, EntityPlayer player, World world) { + ItemLinker.setMasterCoords(item, getPos()); + if (linkedRocket != null) { + linkedRocket.unlinkInfrastructure(this); + unlinkRocket(); + } + + if (player.world.isRemote) + Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("%s %s", new TextComponentTranslation("msg.serviceStation.link"), ": " + getPos().getX() + " " + getPos().getY() + " " + getPos().getZ())); + return true; + } + + @Override + public boolean onLinkComplete(@Nonnull ItemStack item, TileEntity entity, EntityPlayer player, World world) { + if (player.world.isRemote) + Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("msg.linker.error.firstMachine")); + return false; + } + + @Override + public void unlinkRocket() { + linkedRocket = null; + + dropRepairStats(); + } + + public void dropRepairStats() { + partsToRepair = new LinkedList<>(); + statesToRepair = new LinkedList<>(); + initialPartToRepairCount = 0; + } + + @Override + public boolean disconnectOnLiftOff() { + return true; + } + + @Override + public boolean linkRocket(EntityRocketBase rocket) { + this.linkedRocket = rocket; + if (rocket instanceof EntityRocket) { + updateRepairList(); + } + return true; + } + + @Override + public NBTTagCompound getUpdateTag() { + return writeToNBT(new NBTTagCompound()); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + was_powered = nbt.getBoolean("was_powered"); + initialPartToRepairCount = nbt.getInteger("initialPartToRepairCount"); + + assemblerPoses = NBTHelper.readCollection("assemblerPoses", nbt, ArrayList::new, NBTHelper::readBlockPos); + partsProcessing = NBTHelper.readCollection("partsProcessing", nbt, ArrayList::new, NBTHelper::readTileEntity).toArray(new TileBrokenPart[0]); + statesProcessing = NBTHelper.readCollection("statesProcessing", nbt, ArrayList::new, NBTHelper::readState).toArray(new IBlockState[0]); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setBoolean("was_powered", was_powered); + nbt.setInteger("initialPartToRepairCount", initialPartToRepairCount); + + NBTHelper.writeCollection("assemblerPoses", nbt, this.assemblers, te -> NBTHelper.writeBlockPos(te.getPos())); + NBTHelper.writeCollection("partsProcessing", nbt, Arrays.asList(this.partsProcessing), NBTHelper::writeTileEntity); + NBTHelper.writeCollection("statesProcessing", nbt, Arrays.asList(this.statesProcessing), NBTHelper::writeState); + + return nbt; + } + + @Override + public void writeDataToNetwork(ByteBuf out, byte id) { + + } + + @Override + public void readDataFromNetwork(ByteBuf in, byte packetId, + NBTTagCompound nbt) { + + } + + @Override + public List getModules(int ID, EntityPlayer player) { + LinkedList modules = new LinkedList<>(); + + modules.add(new ModulePower(10, 20, this.energy)); + modules.add(new ModuleButton(63 - 52 / 2, 100, 0, LibVulpes.proxy.getLocalizedString("msg.serviceStation.assemblerScan"), + this, zmaster587.libVulpes.inventory.TextureResources.buttonBuild, 104, 16)); + + updateText(); + + modules.add(destroyProbText); + modules.add(wornMotorsText); + modules.add(wornSeatsText); + modules.add(wornTanksText); + modules.add(destroyProgressText); + modules.add(wornMotorsCount); + modules.add(wornSeatsCount); + modules.add(wornTanksCount); + + modules.add(new ModuleProgress(32, 133, 0, TextureResources.progressToMission, this)); + + if (!world.isRemote) { + PacketHandler.sendToPlayer(new PacketMachine(this, (byte) 1), player); + } + + return modules; + } + + private void updateText() { + if (linkedRocket != null) { + if (!(linkedRocket instanceof EntityRocket)) { +// System.out.println("Huh, error...."); + destroyProbText.setText(LibVulpes.proxy.getLocalizedString("msg.serviceStation.destroyProbNA")); + return; + } + EntityRocket rocket = (EntityRocket) linkedRocket; + destroyProbText.setText(LibVulpes.proxy.getLocalizedString("msg.serviceStation.destroyProb") + ": " + rocket.storage.getBreakingProbability()); + List brokenParts = rocket.storage.getBrokenBlocks(); + long motorsCount = brokenParts + .stream() + .filter(te -> te.getStage() > 0 && (te.getBlockType() instanceof BlockRocketMotor + || te.getBlockType() instanceof BlockBipropellantRocketMotor)) + .count(); + long seatsCount = brokenParts + .stream() + .filter(te -> te.getStage() > 0 && te.getBlockType() instanceof BlockSeat) + .count(); + long tanksCount = brokenParts + .stream() + .filter(te -> te.getStage() > 0 && te.getBlockType() instanceof IFuelTank) + .count(); + + this.wornMotorsCount.setText(String.valueOf(motorsCount)); + this.wornSeatsCount.setText(String.valueOf(seatsCount)); + this.wornTanksCount.setText(String.valueOf(tanksCount)); + } else { + destroyProbText.setText(LibVulpes.proxy.getLocalizedString("msg.serviceStation.destroyProbNA")); + } + } + + @Override + public void useNetworkData(EntityPlayer player, Side side, byte id, + NBTTagCompound nbt) { + if (id == 0) { + scanForAssemblers(); + } + } + + @Override + public void onInventoryButtonPressed(int buttonId) { + if (buttonId == 0) { + PacketHandler.sendToServer(new PacketMachine(this, (byte) 0)); + } + } + + @Override + public String getModularInventoryName() { + return "container.servicestation"; + } + + @Override + public float getNormallizedProgress(int id) { + if (id == 1) { + return Math.max(Math.min(0.5f + (getProgress(id) / (float) getTotalProgress(id)), 1), 0f); + } + + //keep text updated + if (world.isRemote) + updateText(); + + return Math.min(getProgress(id) / (float) getTotalProgress(id), 1.0f); + } + + @Override + public void setProgress(int id, int progress) { + + } + + @Override + public int getProgress(int id) { + //Try to keep client synced with server, this also allows us to put the monitor on a different world altogether + if (world.isRemote) + if (id == 0) { + if (!(linkedRocket instanceof EntityRocket)) { +// System.out.println("Huh, error...."); + return 0; + } + return initialPartToRepairCount - partsToRepair.size() - (int) Arrays.stream(partsProcessing).filter(Objects::nonNull).count(); + } + + return 0; + } + + @Override + public int getTotalProgress(int id) { +// if (id == 0) +// return ARConfiguration.getCurrentConfig().orbit;ё +// else if (id == 1) +// return 200; + if (id == 0) { + return initialPartToRepairCount; + } + return 0; + } + + @Override + public void setTotalProgress(int id, int progress) { + //Should only become an issue if configs are desynced or fuel +// if (id == 2) +// maxFuelLevel = progress; + } + + @Override + public boolean canInteractWithContainer(EntityPlayer entity) { + return true; + } + + @Override + public boolean linkMission(IMission mission) { + return false; + } + + @Override + public void unlinkMission() { + updateText(); + } + + @Override + public boolean canRenderConnection() { + return false; + } + + @Override + public int getComparatorOverride() { +// if (linkedRocket instanceof EntityRocket) { +// return (int) (15 * ((EntityRocket) linkedRocket).getRelativeHeightFraction()); +// } + return 0; + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/MiningDrill.java b/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/MiningDrill.java index cdab4cff9..0ab3ac544 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/MiningDrill.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/MiningDrill.java @@ -2,11 +2,13 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.MinecraftForge; import zmaster587.advancedRocketry.AdvancedRocketry; @@ -14,6 +16,9 @@ import zmaster587.advancedRocketry.entity.EntityLaserNode; import zmaster587.advancedRocketry.event.BlockBreakEvent; +import java.util.ArrayList; +import java.util.List; + class MiningDrill extends AbstractDrill { protected boolean finished; @@ -27,7 +32,7 @@ class MiningDrill extends AbstractDrill { ItemStack[] performOperation() { - ItemStack[] stacks = new ItemStack[0]; + ArrayList stacks = new ArrayList<>(); for (int i = 0; i < 9; i++) { int x = (int) laser.posX + (i % 3) - 1; @@ -41,10 +46,19 @@ ItemStack[] performOperation() { if (event.isCanceled()) continue; + /* What is this shit? if (state == Blocks.AIR.getDefaultState() || state.getMaterial().isReplaceable() || state.getMaterial().isLiquid()) { laser.world.setBlockState(laserPos, AdvancedRocketryBlocks.blockLightSource.getDefaultState()); continue; } + */ + if (state.getMaterial().isReplaceable() || state.getMaterial().isLiquid()) { + laser.world.setBlockState(laserPos, Blocks.AIR.getDefaultState()); + continue; + } + if (state == Blocks.AIR.getDefaultState()){ + continue; + } NonNullList items = NonNullList.create(); state.getBlock().getDrops(items, laser.world, laserPos, state, 0); @@ -55,14 +69,13 @@ ItemStack[] performOperation() { if (items.isEmpty()) { - laser.world.setBlockState(laserPos, AdvancedRocketryBlocks.blockLightSource.getDefaultState()); + laser.world.setBlockState(laserPos, Blocks.AIR.getDefaultState()); continue; } - stacks = new ItemStack[items.size()]; - stacks = items.toArray(stacks); + stacks.addAll(items); - laser.world.setBlockState(laserPos, AdvancedRocketryBlocks.blockLightSource.getDefaultState()); + laser.world.setBlockState(laserPos, Blocks.AIR.getDefaultState()); } boolean blockInWay = false; @@ -98,26 +111,27 @@ ItemStack[] performOperation() { } } while (!blockInWay); - return stacks; + return stacks.toArray(new ItemStack[0]); } boolean activate(World world, int x, int z) { ticketLaser = ForgeChunkManager.requestTicket(AdvancedRocketry.instance, world, ForgeChunkManager.Type.NORMAL); if (ticketLaser != null) { - ForgeChunkManager.forceChunk(ticketLaser, new ChunkPos(x >> 4, z >> 4)); + Chunk chunk = world.getChunkFromBlockCoords(new BlockPos (x,0,z)); // force the chunk to generate + //System.out.println("pos"+x+":"+z); + //System.out.println("chunkpos"+chunk.x+":"+chunk.z); + ForgeChunkManager.forceChunk(ticketLaser, new ChunkPos(chunk.x, chunk.z)); int y = 64; - if (world.getChunkFromChunkCoords(x >> 4, z >> 4).isLoaded()) { int current; for (int i = 0; i < 9; i++) { current = world.getTopSolidOrLiquidBlock(new BlockPos(x + (i % 3) - 1, 0xFF, z + (i / 3) - 1)).getY(); if (current > y) y = current; } - } else - y = 255; + laser = new EntityLaserNode(world, x, y, z); laser.markValid(); diff --git a/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/TileOrbitalLaserDrill.java b/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/TileOrbitalLaserDrill.java index 483b9d39f..ef9bda350 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/TileOrbitalLaserDrill.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/multiblock/orbitallaserdrill/TileOrbitalLaserDrill.java @@ -3,11 +3,13 @@ import io.netty.buffer.ByteBuf; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -20,6 +22,7 @@ import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.items.CapabilityItemHandler; import zmaster587.advancedRocketry.AdvancedRocketry; import zmaster587.advancedRocketry.api.ARConfiguration; import zmaster587.advancedRocketry.api.AdvancedRocketryBlocks; @@ -39,16 +42,20 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.awt.*; import java.util.LinkedList; import java.util.List; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.items.IItemHandler; -public class TileOrbitalLaserDrill extends TileMultiPowerConsumer implements ISidedInventory, IGuiCallback, IButtonInventory { +public class TileOrbitalLaserDrill extends TileMultiPowerConsumer implements IGuiCallback, IButtonInventory { private static final int POWER_PER_OPERATION = (int) (10000 * ARConfiguration.getCurrentConfig().spaceLaserPowerMult); private final AbstractDrill drill; public int laserX, laserZ, tickSinceLastOperation; protected boolean isRunning, finished, isJammed; + private ModuleButton resetBtn; Object[][][] structure = new Object[][][]{ { {null, null, null, null, null, null, null, null, null, null, null}, @@ -84,25 +91,27 @@ public class TileOrbitalLaserDrill extends TileMultiPowerConsumer implements ISi {null, null, null, null, null, null, LibVulpesBlocks.blockAdvStructureBlock, AdvancedRocketryBlocks.blockVacuumLaser, AdvancedRocketryBlocks.blockVacuumLaser, AdvancedRocketryBlocks.blockVacuumLaser, null} }, }; - private ItemStack lens; - private int radius, xCenter, yCenter, numSteps; + public int radius, xCenter, yCenter, numSteps; private EnumFacing prevDir; private ModuleTextBox locationX, locationZ; - private ModuleText updateText; + private ModuleText updateText, positionText; private MultiInventory inv; private MODE mode; - private Ticket ticket; + //private Ticket ticket; // this is useless anyway because it would not load the energy supply system and the laser would run out of energy public TileOrbitalLaserDrill() { super(); - lens = ItemStack.EMPTY; radius = 0; xCenter = 0; yCenter = 0; numSteps = 0; prevDir = null; - + resetBtn = new ModuleButton(40, 20, 2, LibVulpes.proxy.getLocalizedString("msg.spacelaser.reset"), this, zmaster587.libVulpes.inventory.TextureResources.buttonBuild, 34, 20); + positionText = new ModuleText(83, 63, "empty... shit!", 0x0b0b0b); + updateText = new ModuleText(83, 63, "also empty...", 0x0b0b0b); + locationX = new ModuleNumericTextbox(this, 93, 31, 50, 10, 16); + locationZ = new ModuleNumericTextbox(this, 93, 41, 50, 10, 16); tickSinceLastOperation = 0; laserX = 0; laserZ = 0; @@ -143,37 +152,57 @@ public String getMachineName() { } /* - * ID 0: client changed xcoord in interface - * ID 1: client changed zcoord in interface * ID 2: sync whether the machine is running - * ID 3: sync Mode - * ID 4: jam reset + * ID 4: reset + * ID 1: send changes back to client + * ID 5 send only laser position to client + * ID 3: client requests update */ @Override public void writeDataToNetwork(ByteBuf out, byte id) { super.writeDataToNetwork(out, id); - if (id == 10) + if (id == 15) { out.writeInt(this.laserX); - else if (id == 11) out.writeInt(this.laserZ); + }else if (id == 11){ + out.writeInt(mode.ordinal()); + out.writeInt(this.xCenter); + out.writeInt(this.yCenter); + out.writeInt(this.laserX); + out.writeInt(this.laserZ); + } else if (id == 12) out.writeBoolean(isRunning); - else if (id == 13) + else if (id == 14){ out.writeInt(mode.ordinal()); + out.writeInt(this.xCenter); + out.writeInt(this.yCenter); + } } @Override public void readDataFromNetwork(ByteBuf in, byte id, NBTTagCompound nbt) { super.readDataFromNetwork(in, id, nbt); - if (id == 10) - nbt.setInteger("laserX", in.readInt()); - else if (id == 11) - nbt.setInteger("laserZ", in.readInt()); + if (id == 15){ + nbt.setInteger("currentX", in.readInt()); + nbt.setInteger("currentZ", in.readInt()); + } + else if (id == 11){ + nbt.setInteger("mode", in.readInt()); + nbt.setInteger("newX", in.readInt()); + nbt.setInteger("newZ", in.readInt()); + nbt.setInteger("currentX", in.readInt()); + nbt.setInteger("currentZ", in.readInt()); + } else if (id == 12) nbt.setBoolean("isRunning", in.readBoolean()); - else if (id == 13) + + else if (id == 14){ nbt.setInteger("mode", in.readInt()); + nbt.setInteger("newX", in.readInt()); + nbt.setInteger("newZ", in.readInt()); + } } @@ -182,27 +211,98 @@ public void useNetworkData(EntityPlayer player, Side side, byte id, NBTTagCompound nbt) { super.useNetworkData(player, side, id, nbt); - if (id == 10) { - this.laserX = nbt.getInteger("laserX"); - finished = false; - - if (mode == MODE.SPIRAL) - resetSpiral(); - } else if (id == 11) { - this.laserZ = nbt.getInteger("laserZ"); + if (id == 15) { + laserZ = nbt.getInteger("currentZ"); + laserX = nbt.getInteger("currentX"); + positionText.setText("position:\n"+this.laserX+" : "+this.laserZ); + }else if (id == 11){ + resetSpiral(); + mode = MODE.values()[nbt.getInteger("mode")]; + xCenter = nbt.getInteger("newX"); + yCenter = nbt.getInteger("newZ"); + laserZ = nbt.getInteger("currentZ"); + laserX = nbt.getInteger("currentX"); + positionText.setText("position:\n"+this.laserX+" : "+this.laserZ); + updateText.setText(this.getMode().toString()); + locationX.setText(String.valueOf(this.xCenter)); + locationZ.setText(String.valueOf(this.yCenter)); + //System.out.println("reset client:"+xCenter+":"+yCenter+":"+mode); + resetBtn.setColor(0xf0f0f0); + } + else if (id == 12) { + this.isRunning = nbt.getBoolean("isRunning"); + //System.out.println("is running: "+ isRunning); + } + else if (id == 14){ + resetSpiral(); + mode = MODE.values()[nbt.getInteger("mode")]; + xCenter = nbt.getInteger("newX"); + yCenter = nbt.getInteger("newZ"); + laserZ = yCenter; + laserX = xCenter; + //System.out.println("reset:"+xCenter+":"+yCenter+":"+mode); + // do all the reset stuff + if (drill != null) { + drill.deactivate(); + } finished = false; - if (mode == MODE.SPIRAL) - resetSpiral(); - } else if (id == 12) - this.isRunning = nbt.getBoolean("isRunning"); - else if (id == 13 && !isRunning()) - this.mode = MODE.values()[nbt.getInteger("mode")]; - else if (id == 14) - this.checkjam(); + setRunning(false); + checkjam(); + checkCanRun(); + //update clients on new data + PacketHandler.sendToNearby(new PacketMachine(this, (byte) 11), this.world.provider.getDimension(), pos, 128); + } + else if (id == 13) + //update clients on new data + PacketHandler.sendToNearby(new PacketMachine(this, (byte) 11), this.world.provider.getDimension(), pos, 128); markDirty(); } + public void transferItems(IInventory inventorySource, IItemHandler inventoryTarget) { + for (int i = 0; i < inventorySource.getSizeInventory(); i++) { + ItemStack stack = inventorySource.getStackInSlot(i).copy(); + + if (!stack.isEmpty()) { + for (int j = 0; j < inventoryTarget.getSlots(); j++) { + // Try to insert the item + ItemStack remaining = inventoryTarget.insertItem(j, stack, false); + + // If the entire stack was inserted, remove it from the source inventory + if (remaining.isEmpty()) { + inventorySource.decrStackSize(i, stack.getCount()); + break; + } + + // Otherwise, update the stack to the remaining amount + stack.setCount(remaining.getCount()); + } + } + } + } + + + + + public void outputItems() { + // Loop over each output hatch in your inventory + for (int ic = 0; ic < this.getItemOutPorts().size(); ic++) { + + IInventory inventory = itemOutPorts.get(ic); + if (inventory instanceof TileEntity) { + + + for (EnumFacing direction : EnumFacing.values()) { + TileEntity tileEntity = world.getTileEntity(((TileEntity) inventory).getPos().offset(direction)); + if (tileEntity != null) { + if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,null)){ + transferItems(inventory, tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,null)); + } + } + } + } + } + } private void resetSpiral() { radius = 0; prevDir = null; @@ -216,9 +316,14 @@ public boolean isRunning() { } public void setRunning(boolean value) { + if (world.isRemote){ + System.out.println("client should not call setRunning"); + return; + } isRunning = value; + PacketHandler.sendToNearby(new PacketMachine(this, (byte) 12), this.world.provider.getDimension(), pos, 128); + markDirty(); - //worldObj.notifyBlockUpdate(pos, worldObj.getBlockState(pos), worldObj.getBlockState(pos), 3); } public boolean isFinished() { @@ -238,9 +343,6 @@ public void setMode(MODE m) { } public void incrementMode() { - if (mode == MODE.SPIRAL) - resetSpiral(); - int num = mode.ordinal(); num++; @@ -251,9 +353,6 @@ public void incrementMode() { } public void decrementMode() { - if (mode == MODE.SPIRAL) - resetSpiral(); - int num = mode.ordinal(); num--; @@ -300,6 +399,10 @@ public void update() { this.tickSinceLastOperation = 0; } + if(!this.inv.isEmpty()){ + outputItems(); + } + } if (this.drill.isFinished()) { @@ -311,11 +414,7 @@ public void update() { this.finished = true; if (this.world.getStrongPower(getPos()) != 0) { - if (this.mode == MODE.LINE_X) { - this.laserX += 3; - } else if (this.mode == MODE.LINE_Z) { - this.laserZ += 3; - } else if (this.mode == MODE.SPIRAL) { + if (this.mode == MODE.SPIRAL) { this.numSteps++; if (this.radius < this.numSteps) { this.numSteps = 0; @@ -334,6 +433,8 @@ else if (prevDir == EnumFacing.EAST) { this.laserX += 3 * prevDir.getFrontOffsetX(); this.laserZ += 3 * prevDir.getFrontOffsetZ(); + PacketHandler.sendToNearby(new PacketMachine(this, (byte) 15), this.world.provider.getDimension(), pos,128); + } } } @@ -351,7 +452,7 @@ public void onDestroy() { if (this.drill != null) { this.drill.deactivate(); } - ForgeChunkManager.releaseTicket(ticket); + //ForgeChunkManager.releaseTicket(ticket); } @Override @@ -366,36 +467,28 @@ public void onChunkUnload() { public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound nbt = new NBTTagCompound(); this.writeToNBT(nbt); - - nbt.setBoolean("IsRunning", isRunning); - return new SPacketUpdateTileEntity(getPos(), 0, nbt); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { this.readFromNBT(pkt.getNbtCompound()); - isRunning = pkt.getNbtCompound().getBoolean("IsRunning"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - if (lens != null) { - NBTTagCompound tag = new NBTTagCompound(); - lens.writeToNBT(tag); - nbt.setTag("GlassPane", tag); - } - + nbt.setBoolean("isRunning", isRunning); nbt.setInteger("laserX", laserX); nbt.setInteger("laserZ", laserZ); nbt.setByte("mode", (byte) mode.ordinal()); nbt.setBoolean("jammed", this.isJammed); + nbt.setInteger("CenterX", xCenter); + nbt.setInteger("CenterY", yCenter); + if (mode == MODE.SPIRAL && prevDir != null) { - nbt.setInteger("CenterX", xCenter); - nbt.setInteger("CenterY", yCenter); nbt.setInteger("radius", radius); nbt.setInteger("numSteps", numSteps); nbt.setInteger("prevDir", prevDir.ordinal()); @@ -407,19 +500,18 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - if (nbt.hasKey("GlassPane")) { - NBTTagCompound tag = nbt.getCompoundTag("GlassPane"); - lens = new ItemStack(tag); - } + + isRunning = nbt.getBoolean("isRunning"); laserX = nbt.getInteger("laserX"); laserZ = nbt.getInteger("laserZ"); mode = MODE.values()[nbt.getByte("mode")]; this.isJammed = nbt.getBoolean("jammed"); + xCenter = nbt.getInteger("CenterX"); + yCenter = nbt.getInteger("CenterY"); + if (mode == MODE.SPIRAL && nbt.hasKey("prevDir")) { - xCenter = nbt.getInteger("CenterX"); - yCenter = nbt.getInteger("CenterY"); radius = nbt.getInteger("radius"); numSteps = nbt.getInteger("numSteps"); prevDir = EnumFacing.values()[nbt.getInteger("prevDir")]; @@ -453,7 +545,7 @@ private boolean canMachineSeeEarth() { } private boolean unableToRun() { - return lens.isEmpty() || !canMachineSeeEarth() || batteries.getUniversalEnergyStored() == 0 || !(this.world.provider instanceof WorldProviderSpace) || !zmaster587.advancedRocketry.dimension.DimensionManager.getInstance().canTravelTo(((WorldProviderSpace) this.world.provider).getDimensionProperties(getPos()).getParentPlanet()) || + return !canMachineSeeEarth() || batteries.getUniversalEnergyStored() == 0 || !(this.world.provider instanceof WorldProviderSpace) || !zmaster587.advancedRocketry.dimension.DimensionManager.getInstance().canTravelTo(((WorldProviderSpace) this.world.provider).getDimensionProperties(getPos()).getParentPlanet()) || ARConfiguration.getCurrentConfig().laserBlackListDims.contains(((WorldProviderSpace) this.world.provider).getDimensionProperties(getPos()).getParentPlanet()); } @@ -461,16 +553,13 @@ private boolean unableToRun() { * Checks to see if the situation for firing the laser exists... and changes the state accordingly */ public void checkCanRun() { - //Laser requires lense, redstone power, not be jammed, and be in orbit and energy to function + if (world.isRemote)return; // client has no business here + + //Laser redstone power, not be jammed, and be in orbit and energy to function if (this.finished || this.isJammed || world.isBlockIndirectlyGettingPowered(getPos()) == 0 || unableToRun()) { if (isRunning) { drill.deactivate(); setRunning(false); - if (!this.world.isRemote) { - PacketHandler.sendToNearby(new PacketMachine(this, (byte) 12), 128, pos, this.world.provider.getDimension()); - IBlockState state = world.getBlockState(getPos()); - world.notifyBlockUpdate(pos, state, state, 2); - } } } else if (world.isBlockIndirectlyGettingPowered(getPos()) > 0) { @@ -488,18 +577,13 @@ public void checkCanRun() { } - if (ticket == null) { - ticket = ForgeChunkManager.requestTicket(AdvancedRocketry.instance, this.world, Type.NORMAL); - if (ticket != null) - ForgeChunkManager.forceChunk(ticket, new ChunkPos(getPos().getX() / 16 - (getPos().getX() < 0 ? 1 : 0), getPos().getZ() / 16 - (getPos().getZ() < 0 ? 1 : 0))); - } + //if (ticket == null) { + // ticket = ForgeChunkManager.requestTicket(AdvancedRocketry.instance, this.world, Type.NORMAL); + // if (ticket != null) + // ForgeChunkManager.forceChunk(ticket, new ChunkPos(getPos().getX() / 16 - (getPos().getX() < 0 ? 1 : 0), getPos().getZ() / 16 - (getPos().getZ() < 0 ? 1 : 0))); + //} if (!isRunning) { setRunning(drill.activate(orbitWorld, laserX, laserZ)); - if (!this.world.isRemote) { - PacketHandler.sendToNearby(new PacketMachine(this, (byte) 12), 128, pos, this.world.provider.getDimension()); - IBlockState state = world.getBlockState(getPos()); - world.notifyBlockUpdate(pos, state, state, 2); - } } } @@ -514,106 +598,6 @@ public boolean hasEnergy() { return batteries.getUniversalEnergyStored() != 0; } - //InventoryHandling start - @Override - public int getSizeInventory() { - return inv.getSizeInventory(); - } - - @Override - @Nonnull - public ItemStack getStackInSlot(int i) { - if (i == 0) - return lens; - else { - i--; - return inv.getStackInSlot(i); - } - } - - @Override - @Nonnull - public ItemStack decrStackSize(int i, int j) { - ItemStack ret; - - if (i == 0) { - ret = lens.copy(); - lens = ItemStack.EMPTY; - return ret; - } - return ItemStack.EMPTY; - } - - @Override - public void setInventorySlotContents(int i, @Nonnull ItemStack itemstack) { - - //TODO: add gregcipies - if (i == 0) - lens = itemstack; - else { - - if (InventoryCompat.canInjectItems(inv, itemstack)) - InventoryCompat.injectItem(inv, itemstack); - - this.checkCanRun(); - } - } - - @Override - @Nonnull - public String getName() { - return getMachineName(); - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUsableByPlayer(EntityPlayer entityplayer) { - return entityplayer.getDistanceSq(pos) <= 64; - } - - @Override - public boolean isEmpty() { - return lens.isEmpty(); - } - - @Override - public void openInventory(EntityPlayer entity) { - // TODO Perhaps make sure laser isn't running - } - - @Override - public void closeInventory(EntityPlayer entity) { - // TODO Auto-generated method stub - - } - - @Override - @Nonnull - public int[] getSlotsForFace(EnumFacing side) { - return new int[]{}; - } - - @Override - public boolean canInsertItem(int index, @Nonnull ItemStack itemStackIn, @Nullable EnumFacing direction) { - return false; - } - - @Override - public boolean canExtractItem(int index, @Nonnull ItemStack stack, @Nullable EnumFacing direction) { - return false; - } - - @Override - public boolean isItemValidForSlot(int i, @Nonnull ItemStack itemstack) { - if (i == 0) - return AdvancedRocketryItems.itemLens == itemstack.getItem(); - - return inv.isItemValidForSlot(i, itemstack); - } /** * @return returns whether enough power is stored for the next operation @@ -643,26 +627,17 @@ public boolean isJammed() { public void setJammed(boolean b) { this.isJammed = b; } - - @Override - public boolean hasCustomName() { - return false; - } - @Override public void onModuleUpdated(ModuleBase module) { - + resetBtn.setColor(0x90ff90); if (module == locationX) { if (!((ModuleTextBox) module).getText().isEmpty() && !((ModuleTextBox) module).getText().contentEquals("-")) - laserX = Integer.parseInt(((ModuleTextBox) module).getText()); - PacketHandler.sendToServer(new PacketMachine(this, (byte) 10)); + xCenter = Integer.parseInt(((ModuleTextBox) module).getText()); } else if (module == locationZ) { if (!((ModuleTextBox) module).getText().isEmpty() && !((ModuleTextBox) module).getText().contentEquals("-")) - laserZ = Integer.parseInt(((ModuleTextBox) module).getText()); - PacketHandler.sendToServer(new PacketMachine(this, (byte) 11)); + yCenter = Integer.parseInt(((ModuleTextBox) module).getText()); } - } @Override @@ -670,25 +645,24 @@ public List getModules(int id, EntityPlayer player) { List modules = new LinkedList<>(); if (world.isRemote) { - modules.add(locationX = new ModuleNumericTextbox(this, 113, 31, 50, 10, 16)); - modules.add(locationZ = new ModuleNumericTextbox(this, 113, 41, 50, 10, 16)); + //request update on information + PacketHandler.sendToServer(new PacketMachine(this, (byte) 13)); + modules.add(locationX); + modules.add(locationZ); - locationX.setText(String.valueOf(this.laserX)); - locationZ.setText(String.valueOf(this.laserZ)); + modules.add(updateText = new ModuleText(110, 20, this.getMode().toString(), 0x0b0b0b, true)); + modules.add(new ModuleText(83, 33, "X:", 0x0b0b0b)); + modules.add(new ModuleText(83, 43, "Z:", 0x0b0b0b)); - modules.add(updateText = new ModuleText(130, 20, this.getMode().toString(), 0x0b0b0b, true)); - modules.add(new ModuleText(103, 33, "X:", 0x0b0b0b)); - modules.add(new ModuleText(103, 43, "Z:", 0x0b0b0b)); + modules.add(positionText); modules.add(new ModuleImage(8, 16, TextureResources.laserGuiBG)); } - modules.add(new ModuleButton(103, 20, 0, "", this, zmaster587.libVulpes.inventory.TextureResources.buttonLeft, 5, 8)); - modules.add(new ModuleButton(157, 20, 1, "", this, zmaster587.libVulpes.inventory.TextureResources.buttonRight, 5, 8)); - modules.add(new ModuleButton(103, 62, 2, LibVulpes.proxy.getLocalizedString("msg.spacelaser.reset"), this, zmaster587.libVulpes.inventory.TextureResources.buttonBuild, 34, 20)); + modules.add(new ModuleButton(83, 20, 0, "", this, zmaster587.libVulpes.inventory.TextureResources.buttonLeft, 5, 8)); + modules.add(new ModuleButton(137, 20, 1, "", this, zmaster587.libVulpes.inventory.TextureResources.buttonRight, 5, 8)); + modules.add(resetBtn); modules.add(new ModulePower(11, 25, batteries)); - modules.add(new ModuleSlotArray(56, 54, this, 0, 1)); - return modules; } @@ -705,7 +679,8 @@ public boolean canInteractWithContainer(EntityPlayer entity) { @Override public void onInventoryButtonPressed(int buttonId) { - + if (buttonId!=2) + resetBtn.setColor(0x90ff90); if (buttonId == 0) { this.decrementMode(); updateText.setText(this.getMode().toString()); @@ -717,41 +692,11 @@ public void onInventoryButtonPressed(int buttonId) { return; } else return; - - if (!this.isRunning()) - PacketHandler.sendToServer(new PacketMachine(this, (byte) 13)); - } - - @Override - @Nonnull - public ItemStack removeStackFromSlot(int index) { - return ItemStack.EMPTY; - } - - @Override - public int getField(int id) { - return 0; - } - - @Override - public void setField(int id, int value) { - } - @Override - public int getFieldCount() { - return 0; - } - - @Override - public void clear() { - - } public enum MODE { SINGLE, - LINE_X, - LINE_Z, SPIRAL } } \ No newline at end of file diff --git a/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileSatelliteBuilder.java b/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileSatelliteBuilder.java index b63c057b0..3d8847b2c 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileSatelliteBuilder.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileSatelliteBuilder.java @@ -14,6 +14,7 @@ import zmaster587.advancedRocketry.dimension.DimensionManager; import zmaster587.advancedRocketry.inventory.TextureResources; import zmaster587.advancedRocketry.item.*; +import zmaster587.advancedRocketry.util.WeightEngine; import zmaster587.libVulpes.LibVulpes; import zmaster587.libVulpes.client.util.ProgressBarImage; import zmaster587.libVulpes.inventory.modules.*; @@ -97,6 +98,7 @@ public boolean canAssembleSatellite() { public void assembleSatellite() { //Basic properties of the satellite int powerStorage = 0, powerGeneration = 0, maxData = 0; + float weight = 0; //Get the primary function from slot 0 String satType = SatelliteRegistry.getSatelliteProperty(getStackInSlot(primaryFunctionSlot)).getSatelliteType(); @@ -114,11 +116,13 @@ public void assembleSatellite() { if (SatelliteRegistry.getSatelliteProperty(stack).getPropertyFlag() == SatelliteProperties.Property.DATA.getFlag()) maxData += SatelliteRegistry.getSatelliteProperty(getStackInSlot(currentSlotIndex)).getMaxDataStorage(); } + + weight += WeightEngine.INSTANCE.getWeight(stack); } //Set final satellite properties //720 here is the base power buffer, so the satellite has SOMETHING to run on - SatelliteProperties properties = new SatelliteProperties(powerGeneration, powerStorage + 720, satType, maxData); + SatelliteProperties properties = new SatelliteProperties(powerGeneration, powerStorage + 720, satType, maxData, weight); properties.setId(DimensionManager.getInstance().getNextSatelliteId()); //Create the output item diff --git a/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileTerraformingTerminal.java b/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileTerraformingTerminal.java index 15a9a137e..6c541ac3d 100644 --- a/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileTerraformingTerminal.java +++ b/src/main/java/zmaster587/advancedRocketry/tile/satellite/TileTerraformingTerminal.java @@ -29,6 +29,7 @@ import zmaster587.advancedRocketry.util.BiomeHandler; import zmaster587.advancedRocketry.util.IDataInventory; import zmaster587.advancedRocketry.util.PlanetaryTravelHelper; +import zmaster587.advancedRocketry.util.TerraformingHelper; import zmaster587.advancedRocketry.world.ChunkManagerPlanet; import zmaster587.advancedRocketry.world.provider.WorldProviderPlanet; import zmaster587.libVulpes.LibVulpes; @@ -140,7 +141,7 @@ public void setInventorySlotContents(int slot, @Nonnull ItemStack stack) { public void update() { super.update(); boolean has_redstone = world.isBlockIndirectlyGettingPowered(getPos()) != 0; - int powerrequired = 120; + int powerrequired = 40; //120; if (!world.isRemote) { if (world.getTotalWorldTime() % 20 == 0) @@ -175,33 +176,36 @@ public void update() { SatelliteBiomeChanger sat = (SatelliteBiomeChanger) ItemSatelliteIdentificationChip.getSatellite(getStackInSlot(0)); IUniversalEnergy battery = sat.getBattery(); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 1000; i++) { //TODO: Better imp if (battery.getUniversalEnergyStored() > powerrequired) { - if (battery.extractEnergy(powerrequired, false) == powerrequired) { try { - HashedBlockPosition next_block = DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).get_next_terraforming_block(); - BiomeProvider chunkmgr = DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).chunkMgrTerraformed; + TerraformingHelper t = DimensionProperties.proxylists.gethelper(world.provider.getDimension()); - // this chunkmgr is not initialized by default because dimensionproperties - // inits during the forge mod init phase and some stuff is not loaded at this time. - // I will make sure it will be initialized here - // I have no idea where else to put it :( - if (chunkmgr == null) - DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).reset_chunkmgr(); + if (t == null) { + DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).load_terraforming_helper(false); + t = DimensionProperties.proxylists.gethelper(world.provider.getDimension()); + } + BiomeProvider chunkmgr = t.chunkMgrTerraformed; + BlockPos next_block_pos = t.get_next_position(false); - BiomeHandler.changeBiome(world, ((ChunkManagerPlanet) chunkmgr).getBiomeGenAt(next_block.x, next_block.z), new BlockPos(next_block.x, 0, next_block.z), false); + if (next_block_pos != null) { // it is null when there is everything terraformed + battery.extractEnergy(powerrequired, false); + BiomeHandler.terraform(world, ((ChunkManagerPlanet) chunkmgr).getBiomeGenAt(next_block_pos.getX(), next_block_pos.getZ()), next_block_pos, false, world.provider.getDimension()); + }else{ + //System.out.println("nothing to terraform"); + break; // nothing to do, everything is terraformed + } - - } catch (NullPointerException e) { - e.printStackTrace(); + //} catch (NullPointerException e) { + // e.printStackTrace(); } catch (NoClassDefFoundError e){ e.printStackTrace(); //WTF } - } + } else break; } diff --git a/src/main/java/zmaster587/advancedRocketry/util/BiomeHandler.java b/src/main/java/zmaster587/advancedRocketry/util/BiomeHandler.java index 844f67178..e9c747427 100644 --- a/src/main/java/zmaster587/advancedRocketry/util/BiomeHandler.java +++ b/src/main/java/zmaster587/advancedRocketry/util/BiomeHandler.java @@ -1,79 +1,245 @@ package zmaster587.advancedRocketry.util; import net.minecraft.block.*; +import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeDecorator; +import net.minecraft.world.biome.BiomeProvider; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.gen.ChunkGeneratorOverworld; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.fml.common.Loader; +import org.lwjgl.Sys; import zmaster587.advancedRocketry.api.IPlanetaryProvider; import zmaster587.advancedRocketry.api.dimension.IDimensionProperties; import zmaster587.advancedRocketry.dimension.DimensionManager; import zmaster587.advancedRocketry.dimension.DimensionProperties; import zmaster587.advancedRocketry.network.PacketBiomeIDChange; +import zmaster587.advancedRocketry.world.ChunkProviderPlanet; +import zmaster587.advancedRocketry.world.provider.WorldProviderPlanet; import zmaster587.libVulpes.network.PacketHandler; import zmaster587.libVulpes.util.HashedBlockPosition; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import java.util.*; import static zmaster587.advancedRocketry.util.AstronomicalBodyHelper.getAverageTemperature; - -public class BiomeHandler { +import static zmaster587.advancedRocketry.util.AstronomicalBodyHelper.getOrbitalPeriod; +public class BiomeHandler { - public static void changeBiome(World world, Biome biomeId, BlockPos pos, boolean regen_vegetation) { - Chunk chunk = world.getChunkFromBlockCoords(pos); - - Biome biome = world.getBiome(pos); + public static void decorate_simple(World world, Biome biomeId, Biome old_biome, BlockPos pos) { - if (biome != biomeId) { - BlockPos yy = world.getHeight(pos); - if (biome.topBlock != biomeId.topBlock) { + BlockPos yy = world.getHeight(pos); + while (!world.getBlockState(yy.down()).isOpaqueCube() && yy.getY() > 0) + yy = yy.down(); - while (!world.getBlockState(yy.down()).isOpaqueCube() && yy.getY() > 0) - yy = yy.down(); + if (old_biome.topBlock != biomeId.topBlock) { + if (world.getBlockState(yy.down()) == old_biome.topBlock) + world.setBlockState(yy.down(), biomeId.topBlock); + } - if (world.getBlockState(yy.down()) == biome.topBlock) - world.setBlockState(yy.down(), biomeId.topBlock); - } + decorateBiome(world, yy, biomeId); + } + // Bro I am sorry for changing this again and I know it will mess up your mixin but terraforming had a BIG update so.... + public static void changeBiome(World world, Biome biomeId, Biome old_biome, BlockPos pos) { + Chunk chunk = world.getChunkFromBlockCoords(pos); + if (old_biome != biomeId) { byte[] biomeArr = chunk.getBiomeArray(); try { biomeArr[(pos.getX() & 15) + (pos.getZ() & 15) * 16] = (byte) Biome.getIdForBiome(biomeId); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); } - decorateBiome(world, yy, biomeId); + } + } - PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new HashedBlockPosition(pos)), world.provider.getDimension(), pos, 256); + public static int get_height_blocks_only(IBlockState[] blocks) { + int h = blocks.length-1; + while (h>0 && (!blocks[h].isOpaqueCube())){ + h--; } - //for biome remote use - else if(regen_vegetation) { - BlockPos yy = world.getHeight(pos); + return h; + } + + public static int get_height_blocks_only(World world, BlockPos pos) { + BlockPos yy = world.getHeight(pos); + while ((!world.getBlockState(yy).isOpaqueCube()) && yy.getY() > 0) + yy = yy.down(); + return yy.getY(); + } + + public static void do_heavy_terraforming(World world, Biome biomeId, Biome old_biome, BlockPos pos, int dimId){ + + int inchunkx = ((pos.getX() % 16) + 16) % 16; + int inchunkz = ((pos.getZ() % 16) + 16) % 16; + + long startTime; + startTime = System.currentTimeMillis(); + DimensionProperties props = DimensionManager.getInstance().getDimensionProperties(dimId); + + ChunkPos cpos = DimensionProperties.proxylists.gethelper(props.getId()).getChunkPosFromBlockPos(pos); + + + IBlockState[] target_blocks = DimensionProperties.proxylists.gethelper(props.getId()).getBlocksAt(pos.getX(), pos.getZ()); + chunkdata data = DimensionProperties.proxylists.gethelper(props.getId()).getChunkFromList(cpos.x, cpos.z); + //System.out.println("d1"+(System.currentTimeMillis()-startTime)); + //startTime = System.currentTimeMillis(); + + if (data.type == TerraformingType.PROTECTED){ + //System.out.println("working protected"); + decorate_simple(world, biomeId,old_biome, pos); + DimensionProperties.proxylists.gethelper(props.getId()).getChunkFromList(cpos.x, cpos.z).set_position_fully_generated(inchunkx,inchunkz); + DimensionProperties.proxylists.gethelper(props.getId()).register_height_change(pos); // it does not really changetheheight but it will notify the border to update + } + else if (data.type == TerraformingType.ALLOWED) { + //System.out.println("working full"); + + if (!data.fully_generated[inchunkx][inchunkz]) { + //fast replacing + for (int i = 0; i < 255; i++) { + world.setBlockState(new BlockPos(pos.getX(), i, pos.getZ()), target_blocks[i], 2); + } + + + // as long as terrain does not match the target height, re-add position to queue + //System.out.println("heights:"+get_height_blocks_only(world, pos) +":"+ get_height_blocks_only(target_blocks)); + + // you need to check this for the entire chunk + // or the laser will reset on every new world load to its starting position and ignore the radius and iterate every chunk and skip over the ones that are already generated + // or make it like this: every time a single position is fully generated, check every chunk 3x3 around it and see if you can populate them + // use the chunk list again - replace spiral mod with global mode that scatters the chunks to make it a little more random. every new load it will start from its starting position again + if (get_height_blocks_only(world, pos) == get_height_blocks_only(target_blocks)) { + DimensionProperties.proxylists.gethelper(props.getId()).getChunkFromList(cpos.x, cpos.z).set_position_fully_generated(inchunkx, inchunkz); + } else { + DimensionProperties.proxylists.gethelper(props.getId()).add_position_to_queue(pos); + DimensionProperties.proxylists.gethelper(props.getId()).register_height_change(pos); + } + } + } + + else if (data.type == TerraformingType.BORDER){ + + //this is to be sure the top block is changed even if the height matches already + BlockPos yy = world.getHeight(pos); while (!world.getBlockState(yy.down()).isOpaqueCube() && yy.getY() > 0) yy = yy.down(); - if (world.getBlockState(yy.down()) == biome.topBlock) - world.setBlockState(yy.down(), biomeId.topBlock); + if (old_biome.topBlock != biomeId.topBlock) { + if (world.getBlockState(yy.down()) == old_biome.topBlock) + world.setBlockState(yy.down(), biomeId.topBlock); + } + + + if (target_blocks != null) { + + int filter_size = 5; + //System.out.println("working border"); + + world.getChunkFromBlockCoords(pos.add(-filter_size, 0, 0)); // Ensure the chunk of the target positions are generated + world.getChunkFromBlockCoords(pos.add(filter_size, 0, 0)); // Ensure the chunk of the target positions are generated + world.getChunkFromBlockCoords(pos.add(0, 0, -filter_size)); // Ensure the chunk of the target positions are generated + world.getChunkFromBlockCoords(pos.add(0, 0, filter_size)); // Ensure the chunk of the target positions are generated + + + //this has to be weighted by distance + float heightsum = 0; + float num_samples = 0; + for (int x = -filter_size; x <= filter_size; x++) { + for (int z = -filter_size; z <= filter_size; z++) { + float w = (1.0f / (0.2f + x*x + z*z)); + heightsum += get_height_blocks_only(world, pos.add(x, 0, z)) * w; + num_samples += 1 * w; + } + } + + int avg_height = Math.round(heightsum / num_samples); + + int prev_height = get_height_blocks_only(world, pos); + if (avg_height == prev_height) { // nothing to do + return; + } + + //now we want to set the target height to >= sea level to fill it with the oceanblock + avg_height = Math.max(props.getSeaLevel(),avg_height); + + //fast replacing + for (int i = 0; i < 256; i++) { + IBlockState target = target_blocks[i]; + if (i < avg_height) + if (target == Blocks.AIR.getDefaultState()) + target = biomeId.topBlock; + if (i == avg_height) + target = biomeId.topBlock; + if (i > avg_height) + target = Blocks.AIR.getDefaultState(); + world.setBlockState(new BlockPos(pos.getX(), i, pos.getZ()), target, 2); + } + + int new_height = get_height_blocks_only(world, pos); + if (prev_height != new_height) { + DimensionProperties.proxylists.gethelper(props.getId()).register_height_change(pos); + DimensionProperties.proxylists.gethelper(props.getId()).add_position_to_queue(pos); + } else { + DimensionProperties.proxylists.gethelper(props.getId()).check_next_border_chunk_fully_generated(cpos.x, cpos.z); // maybe this was the last border block in queue? if yes, its terrain is done! + } + } + else DimensionProperties.proxylists.gethelper(props.getId()).check_next_border_chunk_fully_generated(cpos.x, cpos.z); // maybe this was the last border block in queue? if yes, its terrain is done! + + + } + int can_populate = DimensionProperties.proxylists.gethelper(props.getId()).can_populate(cpos.x, cpos.z); + if (can_populate == -1){ + //because it can never be populated, it is considered "done with population" + DimensionProperties.proxylists.gethelper(props.getId()).getChunkFromList(cpos.x, cpos.z).set_position_decorated(inchunkx, inchunkz); + } + if (can_populate == 1) { - decorateBiome(world, yy, biomeId); + // we do some hacky tricks here to ensure that trees can fully generate + // we shift the actual tree generation by 8 blocks so that it overlaps with the chunks next to it + // can_populate() ensures that the chunks next to it are ready for decoration - PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new HashedBlockPosition(pos)), world.provider.getDimension(), pos, 256); + if (!DimensionProperties.proxylists.gethelper(props.getId()).getChunkFromList(cpos.x,cpos.z).fully_decorated[inchunkx][inchunkz]) { + //System.out.println("decorate block"); + int treegen = biomeId.decorator.treesPerChunk; + if (world.rand.nextInt(16 * 16) < treegen) + biomeId.getRandomTreeFeature(world.rand).generate(world, world.rand, world.getHeight(pos.add(8, 0, 8))); + DimensionProperties.proxylists.gethelper(props.getId()).getChunkFromList(cpos.x, cpos.z).set_position_decorated(inchunkx, inchunkz); + } } + } + public static void terraform(World world, Biome biomeId, BlockPos pos, boolean was_biome_remote, int dimId) { + Chunk chunk = world.getChunkFromBlockCoords(pos); + if (biomeId == null)return; + + Biome old_biome = world.getBiome(pos); + changeBiome(world,biomeId, old_biome, pos); + + //for biome remote use, only change top block and do simple decoration + if(was_biome_remote) { + decorate_simple(world, biomeId, old_biome, pos); + } + + if (!was_biome_remote) { // heavy terraforming here... + do_heavy_terraforming(world, biomeId,old_biome,pos,dimId); + } + + + PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new HashedBlockPosition(pos)), world.provider.getDimension(), pos, 1024); } @@ -143,4 +309,3 @@ private static void decorateBiome(World world, BlockPos pos, Biome biome) { } - diff --git a/src/main/java/zmaster587/advancedRocketry/util/GraphicsHelper.java b/src/main/java/zmaster587/advancedRocketry/util/GraphicsHelper.java new file mode 100644 index 000000000..5f966181c --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/GraphicsHelper.java @@ -0,0 +1,102 @@ +package zmaster587.advancedRocketry.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import org.lwjgl.opengl.GL11; + +public final class GraphicsHelper { + + public static void drawCenteredScaledString(String text, int x, int y, float scale, int color) { + drawCenteredScaledString(Minecraft.getMinecraft().fontRenderer, text, x, y, scale, color); + } + + public static void drawCenteredScaledString(FontRenderer fontRenderer, String text, int x, int y, float scale, int color) { + GlStateManager.pushMatrix(); + GlStateManager.scale(scale, scale, 1.0F); + drawCenteredString(fontRenderer, text, (int) (x / scale), (int) (y / scale), color); + GlStateManager.popMatrix(); + } + + public static void drawScaledString(String text, int x, int y, float scale, int color) { + drawScaledString(Minecraft.getMinecraft().fontRenderer, text, x, y, scale, color); + } + + public static void drawScaledString(FontRenderer fontRenderer, String text, int x, int y, float scale, int color) { + GlStateManager.pushMatrix(); + GlStateManager.scale(scale, scale, 1.0F); + drawString(fontRenderer, text, (int) (x / scale), (int) (y / scale), color); + GlStateManager.popMatrix(); + } + + public static void drawCenteredString(String text, int x, int y, int color) { + drawCenteredString(Minecraft.getMinecraft().fontRenderer, text, x, y, color); + } + + public static void drawCenteredString(FontRenderer fontRenderer, String text, int x, int y, int color) { + drawString(text, x - fontRenderer.getStringWidth(text) / 2, y, color); + } + + public static void drawString(String text, int x, int y, int color) { + drawString(Minecraft.getMinecraft().fontRenderer, text, x, y, color); + } + + public static void drawString(FontRenderer fontRenderer, String text, int x, int y, int color) { + fontRenderer.drawString(text, x, y, color); + } + + /** + * Represents the GUI adaptation of glScissor mechanism + * Given coordinates are from up-left corner + * + * @param x start X coordinate + * @param y start Y coordinate + * @param width new window width + * @param height new window height + */ + public static void glScissor(int x, int y, int width, int height) { + GL11.glScissor(x, Minecraft.getMinecraft().displayHeight - (y + height), width, height); + } + + public static void drawTexturedModalRect(int x, int y, int width, int height, int u, int v, int textureWidth, int textureHeight, int textureSizeX, int textureSizeY, float zLevel) { + float f = 1.0F / textureSizeX; + float f1 = 1.0F / textureSizeY; + + GlStateManager.enableTexture2D(); + + Tessellator tess = Tessellator.getInstance(); + BufferBuilder bb = tess.getBuffer(); + bb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + + bb.pos(x, y + height, zLevel).tex(u * f, (v + textureHeight) * f1).endVertex(); + bb.pos(x + width, y + height, zLevel).tex((u + textureWidth) * f, (v + textureHeight) * f1).endVertex(); + bb.pos(x + width, y, zLevel).tex((u + textureWidth) * f, v * f1).endVertex(); + bb.pos(x, y, zLevel).tex(u * f, v * f1).endVertex(); + + tess.draw(); + } + + public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height, float zLevel) { + drawTexturedModalRect(x, y, width, height, textureX, textureY, width, height, 256, 256, zLevel); + } + + public static void drawColoredModalRect(int x, int y, int width, int height, float r, float g, float b, float a, float zLevel) { + drawColoredModalRect(x, y, width, height, (int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255), zLevel); + } + + public static void drawColoredModalRect(int x, int y, int width, int height, int r, int g, int b, int a, float zLevel) { + Tessellator tess = Tessellator.getInstance(); + BufferBuilder bb = tess.getBuffer(); + bb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + + bb.pos(x, y + height, zLevel).color(r, g, b, a).endVertex(); + bb.pos(x + width, y + height, zLevel).color(r, g, b, a).endVertex(); + bb.pos(x + width, y, zLevel).color(r, g, b, a).endVertex(); + bb.pos(x, y, zLevel).color(r, g, b, a).endVertex(); + + tess.draw(); + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/IBreakable.java b/src/main/java/zmaster587/advancedRocketry/util/IBreakable.java new file mode 100644 index 000000000..70d02f6da --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/IBreakable.java @@ -0,0 +1,8 @@ +package zmaster587.advancedRocketry.util; + +public interface IBreakable { + + float getBreakingProbability(); + + boolean shouldBreak(); +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/IBrokenPartBlock.java b/src/main/java/zmaster587/advancedRocketry/util/IBrokenPartBlock.java new file mode 100644 index 000000000..73b57568f --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/IBrokenPartBlock.java @@ -0,0 +1,13 @@ +package zmaster587.advancedRocketry.util; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import zmaster587.advancedRocketry.tile.TileBrokenPart; + +import javax.annotation.Nullable; + +public interface IBrokenPartBlock { + + ItemStack getDropItem(final IBlockState state, final World world, final @Nullable TileBrokenPart te); +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/InventoryUtil.java b/src/main/java/zmaster587/advancedRocketry/util/InventoryUtil.java new file mode 100644 index 000000000..5e4e6062e --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/InventoryUtil.java @@ -0,0 +1,47 @@ +package zmaster587.advancedRocketry.util; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public class InventoryUtil { + + public static boolean hasItemInInventories(Iterable invs, String substr, boolean consume) { + for (IInventory inv : invs) { + if (hasItemInInventory(inv, substr, consume)) { + return true; + } + } + return false; + } + + public static boolean hasItemInInventory(IInventory inv, String substr, boolean consume) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + if (inv.getStackInSlot(i).getUnlocalizedName().toLowerCase().contains(substr.toLowerCase())) { + if (consume) { + inv.setInventorySlotContents(i, ItemStack.EMPTY); + } + return true; + } + } + return false; + } + + public static boolean addItemToOneOfTheInventories(Iterable invs, ItemStack stack) { + for (IInventory inv : invs) { + if (addItemToInventory(inv, stack)) { + return true; + } + } + return false; + } + + public static boolean addItemToInventory(IInventory inv, ItemStack stack) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + if (inv.getStackInSlot(i).isEmpty()) { + inv.setInventorySlotContents(i, stack); + return true; + } + } + return false; + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/StorageChunk.java b/src/main/java/zmaster587/advancedRocketry/util/StorageChunk.java index 55cbe0c10..daa190f7c 100644 --- a/src/main/java/zmaster587/advancedRocketry/util/StorageChunk.java +++ b/src/main/java/zmaster587/advancedRocketry/util/StorageChunk.java @@ -33,10 +33,12 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.items.CapabilityItemHandler; import zmaster587.advancedRocketry.AdvancedRocketry; -import zmaster587.advancedRocketry.api.Constants; -import zmaster587.advancedRocketry.api.EntityRocketBase; +import zmaster587.advancedRocketry.api.*; +import zmaster587.advancedRocketry.api.fuel.FuelRegistry; import zmaster587.advancedRocketry.api.satellite.SatelliteBase; import zmaster587.advancedRocketry.api.stations.IStorageChunk; +import zmaster587.advancedRocketry.block.*; +import zmaster587.advancedRocketry.item.ItemPackedStructure; import zmaster587.advancedRocketry.tile.TileBrokenPart; import zmaster587.advancedRocketry.tile.TileGuidanceComputer; import zmaster587.advancedRocketry.tile.hatch.TileSatelliteHatch; @@ -47,12 +49,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; +import java.util.*; -public class StorageChunk implements IBlockAccess, IStorageChunk, IWeighted { +public class StorageChunk implements IBlockAccess, IStorageChunk, IWeighted, IBreakable { public Chunk chunk; public WorldDummy world; @@ -60,16 +59,22 @@ public class StorageChunk implements IBlockAccess, IStorageChunk, IWeighted { private Block[][][] blocks; public int sizeX, sizeY, sizeZ; private short[][][] metas; + private Map pos2te = new HashMap<>(); private ArrayList tileEntities; //To store inventories (All inventories) private ArrayList inventoryTiles; private ArrayList liquidTiles; private Entity entity; private float weight; + private boolean hasServiceMonitor; - public Block[][][] getblocks(){ - return blocks; -} + public Block[][][] getblocks() { + return blocks; + } + + public boolean hasServiceMonitor() { + return hasServiceMonitor; + } public StorageChunk() { sizeX = 0; @@ -133,11 +138,147 @@ public float recalculateWeight() { // TEs for (TileEntity te : this.tileEntities) { this.weight += WeightEngine.INSTANCE.getTEWeight(te); - } + if (te instanceof TileSatelliteHatch) { + TileSatelliteHatch hatch = (TileSatelliteHatch) te; + if (hatch.getSatellite() != null) { + weight += hatch.getSatellite().getProperties().getWeight(); + } else if (hatch.getStackInSlot(0).getItem() instanceof ItemPackedStructure) { + ItemPackedStructure struct = (ItemPackedStructure) hatch.getStackInSlot(0).getItem(); + weight += struct.getStructure(hatch.getStackInSlot(0)).getWeight(); + } + } + } return this.weight; } + public void recalculateStats(StatsRocket stats) { + int thrustMonopropellant = 0; + int thrustBipropellant = 0; + int thrustNuclearNozzleLimit = 0; + int thrustNuclearReactorLimit = 0; + int thrustNuclearTotalLimit = 0; + int monopropellantfuelUse = 0; + int bipropellantfuelUse = 0; + int nuclearWorkingFluidUseMax = 0; + int fuelCapacityMonopropellant = 0; + int fuelCapacityBipropellant = 0; + int fuelCapacityOxidizer = 0; + int fuelCapacityNuclearWorkingFluid = 0; + + float drillPower = 0f; + stats.reset(); + + float weight = 0; + + for (int yCurr = 0; yCurr <= this.sizeY; yCurr++) { + for (int xCurr = 0; xCurr <= this.sizeX; xCurr++) { + for (int zCurr = 0; zCurr <= this.sizeZ; zCurr++) { + BlockPos currBlockPos = new BlockPos(xCurr, yCurr, zCurr); + BlockPos abovePos = new BlockPos(xCurr, yCurr + 1, zCurr); + BlockPos belowPos = new BlockPos(xCurr, yCurr - 1, zCurr); + + if (this.getBlockState(currBlockPos).getBlock() != Blocks.AIR) { + IBlockState state = world.getBlockState(currBlockPos); + Block block = state.getBlock(); + + if (ARConfiguration.getCurrentConfig().advancedWeightSystem) { + weight += WeightEngine.INSTANCE.getWeight(world, currBlockPos); + } else { + weight += 1; + } + + //If rocketEngine increaseThrust + if (block instanceof IRocketEngine && (world.getBlockState(belowPos).getBlock().isAir(world.getBlockState(belowPos), world, belowPos) || world.getBlockState(belowPos).getBlock() instanceof BlockLandingPad || world.getBlockState(belowPos).getBlock() == AdvancedRocketryBlocks.blockLaunchpad)) { + if (block instanceof BlockNuclearRocketMotor) { + nuclearWorkingFluidUseMax += ((IRocketEngine) block).getFuelConsumptionRate(world, xCurr, yCurr, zCurr); + thrustNuclearNozzleLimit += ((IRocketEngine) block).getThrust(world, currBlockPos); + } else if (block instanceof BlockBipropellantRocketMotor) { + bipropellantfuelUse += ((IRocketEngine) block).getFuelConsumptionRate(world, xCurr, yCurr, zCurr); + thrustBipropellant += ((IRocketEngine) block).getThrust(world, currBlockPos); + } else if (block instanceof BlockRocketMotor) { + monopropellantfuelUse += ((IRocketEngine) block).getFuelConsumptionRate(world, xCurr, yCurr, zCurr); + thrustMonopropellant += ((IRocketEngine) block).getThrust(world, currBlockPos); + } + stats.addEngineLocation(xCurr - (float) this.sizeX /2+0.5f, yCurr+0.5f, zCurr- (float) this.sizeZ /2+0.5f); + } + + if (block instanceof IFuelTank) { + if (block instanceof BlockBipropellantFuelTank) { + fuelCapacityBipropellant += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); + } else if (block instanceof BlockOxidizerFuelTank) { + fuelCapacityOxidizer += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); + } else if (block instanceof BlockNuclearFuelTank) { + fuelCapacityNuclearWorkingFluid += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); + }else if (block instanceof BlockFuelTank) { + fuelCapacityMonopropellant += (((IFuelTank) block).getMaxFill(world, currBlockPos, state) * ARConfiguration.getCurrentConfig().fuelCapacityMultiplier); + } + } + + if (block instanceof IRocketNuclearCore && ((world.getBlockState(belowPos).getBlock() instanceof IRocketNuclearCore) || (world.getBlockState(belowPos).getBlock() instanceof IRocketEngine))) { + thrustNuclearReactorLimit += ((IRocketNuclearCore) block).getMaxThrust(world, currBlockPos); + } + + if (block instanceof BlockSeat && world.getBlockState(abovePos).getBlock().isPassable(world, abovePos)) { + stats.addPassengerSeat(xCurr, yCurr, zCurr); + } + + if (block instanceof IMiningDrill) { + drillPower += ((IMiningDrill) block).getMiningSpeed(world, currBlockPos); + } + + if (block.getUnlocalizedName().contains("servicemonitor")) { + hasServiceMonitor = true; + } + + TileEntity tile = world.getTileEntity(currBlockPos); + if (tile instanceof TileSatelliteHatch) { + if (ARConfiguration.getCurrentConfig().advancedWeightSystem) { + TileSatelliteHatch hatch = (TileSatelliteHatch) tile; + if (hatch.getSatellite() != null) { + weight += hatch.getSatellite().getProperties().getWeight(); + } else if (hatch.getStackInSlot(0).getItem() instanceof ItemPackedStructure) { + ItemPackedStructure struct = (ItemPackedStructure) hatch.getStackInSlot(0).getItem(); + weight += struct.getStructure(hatch.getStackInSlot(0)).getWeight(); + } + } + } + } + } + } + } + + int nuclearWorkingFluidUse = 0; + if (thrustNuclearNozzleLimit > 0) { + //Only run the number of engines our cores can support - we can't throttle these effectively because they're small, so they shut off if they don't get full power + thrustNuclearTotalLimit = Math.min(thrustNuclearNozzleLimit, thrustNuclearReactorLimit); + nuclearWorkingFluidUse = (int) (nuclearWorkingFluidUseMax * (thrustNuclearTotalLimit / (float) thrustNuclearNozzleLimit)); + thrustNuclearTotalLimit = (nuclearWorkingFluidUse * thrustNuclearNozzleLimit) / nuclearWorkingFluidUseMax; + } + + //Set fuel stats + //Thrust depending on rocket type + stats.setBaseFuelRate(FuelRegistry.FuelType.LIQUID_MONOPROPELLANT, monopropellantfuelUse); + stats.setBaseFuelRate(FuelRegistry.FuelType.LIQUID_BIPROPELLANT, bipropellantfuelUse); + stats.setBaseFuelRate(FuelRegistry.FuelType.LIQUID_OXIDIZER, bipropellantfuelUse); + stats.setBaseFuelRate(FuelRegistry.FuelType.NUCLEAR_WORKING_FLUID, nuclearWorkingFluidUse); + //Fuel storage depending on rocket type + stats.setFuelCapacity(FuelRegistry.FuelType.LIQUID_MONOPROPELLANT, fuelCapacityMonopropellant); + stats.setFuelCapacity(FuelRegistry.FuelType.LIQUID_BIPROPELLANT, fuelCapacityBipropellant); + stats.setFuelCapacity(FuelRegistry.FuelType.LIQUID_OXIDIZER, fuelCapacityOxidizer); + stats.setFuelCapacity(FuelRegistry.FuelType.NUCLEAR_WORKING_FLUID, fuelCapacityNuclearWorkingFluid); + + //Non-fuel stats + stats.setWeight((int) weight); + stats.setThrust(Math.max(Math.max(thrustMonopropellant, thrustBipropellant), thrustNuclearTotalLimit)); + stats.setDrillingPower(drillPower); + } + + public void addTileEntity(TileEntity te) { + pos2te.put(te.getPos(), te); + tileEntities.add(te); + } + public static StorageChunk copyWorldBB(World world, AxisAlignedBB bb) { int actualMinX = (int) bb.maxX, actualMinY = (int) bb.maxY, @@ -188,6 +329,10 @@ public static StorageChunk copyWorldBB(World world, AxisAlignedBB bb) { ret.blocks[x - actualMinX][y - actualMinY][z - actualMinZ] = state.getBlock(); ret.metas[x - actualMinX][y - actualMinY][z - actualMinZ] = (short) state.getBlock().getMetaFromState(state); + if (state.getBlock() == AdvancedRocketryBlocks.blockServiceMonitor) { + ret.hasServiceMonitor = true; + } + TileEntity entity = world.getTileEntity(pos); if (entity != null) { NBTTagCompound nbt = new NBTTagCompound(); @@ -214,7 +359,7 @@ public static StorageChunk copyWorldBB(World world, AxisAlignedBB bb) { ret.liquidTiles.add(newTile); } - ret.tileEntities.add(newTile); + ret.addTileEntity(newTile); } } } @@ -229,15 +374,11 @@ public static StorageChunk copyWorldBB(World world, AxisAlignedBB bb) { public static StorageChunk cutWorldBB(World worldObj, AxisAlignedBB bb) { StorageChunk chunk = StorageChunk.copyWorldBB(worldObj, bb); - float weight = 0; - for (int x = (int) bb.minX; x <= bb.maxX; x++) { for (int z = (int) bb.minZ; z <= bb.maxZ; z++) { for (int y = (int) bb.minY; y <= bb.maxY; y++) { BlockPos pos = new BlockPos(x, y, z); - weight += WeightEngine.INSTANCE.getWeight(worldObj, pos); - //Workaround for dupe TileEntity tile = worldObj.getTileEntity(pos); if (tile instanceof IInventory) { @@ -252,8 +393,6 @@ public static StorageChunk cutWorldBB(World worldObj, AxisAlignedBB bb) { } } - chunk.weight = (int) weight; - //Carpenter's block's dupe for (Entity entity : worldObj.getEntitiesWithinAABB(EntityItem.class, bb.grow(5, 5, 5))) { entity.setDead(); @@ -323,7 +462,7 @@ public IBlockState getBlockState(BlockPos pos) { public void setBlockState(BlockPos pos, IBlockState state) { - System.out.println("Block "+pos.getX()+":"+pos.getY()+":"+pos.getZ()+" set to "+state.getBlock().getUnlocalizedName()); +// System.out.println("Block "+pos.getX()+":"+pos.getY()+":"+pos.getZ()+" set to "+state.getBlock().getUnlocalizedName()); int x = pos.getX(); int y = pos.getY(); @@ -333,85 +472,6 @@ public void setBlockState(BlockPos pos, IBlockState state) { metas[x][y][z] = (short) state.getBlock().getMetaFromState(state); } - //TODO: optimize the F*** out of this - public void writeToNBT(NBTTagCompound nbt) { - - if (world.isRemote) return; //client has no business writing here - - nbt.setInteger("xSize", sizeX); - nbt.setInteger("ySize", sizeY); - nbt.setInteger("zSize", sizeZ); - nbt.setFloat("weight", weight); - - Iterator tileEntityIterator = tileEntities.iterator(); - NBTTagList tileList = new NBTTagList(); - while (tileEntityIterator.hasNext()) { - TileEntity tile = tileEntityIterator.next(); - try { - NBTTagCompound tileNbt = new NBTTagCompound(); - tile.writeToNBT(tileNbt); - tileList.appendTag(tileNbt); - } catch (RuntimeException e) { - AdvancedRocketry.logger.warn("A tile entity has thrown an error: " + tile.getClass().getCanonicalName()); - blocks[tile.getPos().getX()][tile.getPos().getY()][tile.getPos().getZ()] = Blocks.AIR; - metas[tile.getPos().getX()][tile.getPos().getY()][tile.getPos().getZ()] = 0; - tileEntityIterator.remove(); - } - } - - int[] blockId = new int[sizeX * sizeY * sizeZ]; - int[] metasId = new int[sizeX * sizeY * sizeZ]; - for (int x = 0; x < sizeX; x++) { - for (int y = 0; y < sizeY; y++) { - for (int z = 0; z < sizeZ; z++) { - blockId[z + (sizeZ * y) + (sizeZ * sizeY * x)] = Block.getIdFromBlock(blocks[x][y][z]); - metasId[z + (sizeZ * y) + (sizeZ * sizeY * x)] = metas[x][y][z]; - } - } - } - - NBTTagIntArray idList = new NBTTagIntArray(blockId); - NBTTagIntArray metaList = new NBTTagIntArray(metasId); - - nbt.setTag("idList", idList); - nbt.setTag("metaList", metaList); - nbt.setTag("tiles", tileList); - - - /*for(int x = 0; x < sizeX; x++) { - for(int y = 0; y < sizeY; y++) { - for(int z = 0; z < sizeZ; z++) { - - idList.appendTag(new NBTTagInt(Block.getIdFromBlock(blocks[x][y][z]))); - metaList.appendTag(new NBTTagInt(metas[x][y][z])); - - //NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("block", Block.getIdFromBlock(blocks[x][y][z])); - tag.setShort("meta", metas[x][y][z]); - - NBTTagCompound tileNbtData = null; - - for(TileEntity tile : tileEntities) { - NBTTagCompound tileNbt = new NBTTagCompound(); - - tile.writeToNBT(tileNbt); - - if(tileNbt.getInteger("x") == x && tileNbt.getInteger("y") == y && tileNbt.getInteger("z") == z){ - tileNbtData = tileNbt; - break; - } - } - - if(tileNbtData != null) - tag.setTag("tile", tileNbtData); - - nbt.setTag(String.format("%d.%d.%d", x,y,z), tag); - } - - } - }*/ - } - public void rotateBy(EnumFacing dir) { HashedBlockPosition newSizes = new HashedBlockPosition(getSizeX(), getSizeY(), getSizeZ()); @@ -513,6 +573,86 @@ public HashedBlockPosition getNewCoord(HashedBlockPosition in, EnumFacing dir) { return out; } + //TODO: optimize the F*** out of this + public void writeToNBT(NBTTagCompound nbt) { + + if (world.isRemote) return; //client has no business writing here + + nbt.setInteger("xSize", sizeX); + nbt.setInteger("ySize", sizeY); + nbt.setInteger("zSize", sizeZ); + nbt.setFloat("weight", weight); + nbt.setBoolean("hasServiceMonitor", hasServiceMonitor); + + Iterator tileEntityIterator = tileEntities.iterator(); + NBTTagList tileList = new NBTTagList(); + while (tileEntityIterator.hasNext()) { + TileEntity tile = tileEntityIterator.next(); + try { + NBTTagCompound tileNbt = new NBTTagCompound(); + tile.writeToNBT(tileNbt); + tileList.appendTag(tileNbt); + } catch (RuntimeException e) { + AdvancedRocketry.logger.warn("A tile entity has thrown an error: " + tile.getClass().getCanonicalName()); + blocks[tile.getPos().getX()][tile.getPos().getY()][tile.getPos().getZ()] = Blocks.AIR; + metas[tile.getPos().getX()][tile.getPos().getY()][tile.getPos().getZ()] = 0; + tileEntityIterator.remove(); + } + } + + int[] blockId = new int[sizeX * sizeY * sizeZ]; + int[] metasId = new int[sizeX * sizeY * sizeZ]; + for (int x = 0; x < sizeX; x++) { + for (int y = 0; y < sizeY; y++) { + for (int z = 0; z < sizeZ; z++) { + blockId[z + (sizeZ * y) + (sizeZ * sizeY * x)] = Block.getIdFromBlock(blocks[x][y][z]); + metasId[z + (sizeZ * y) + (sizeZ * sizeY * x)] = metas[x][y][z]; + } + } + } + + NBTTagIntArray idList = new NBTTagIntArray(blockId); + NBTTagIntArray metaList = new NBTTagIntArray(metasId); + + nbt.setTag("idList", idList); + nbt.setTag("metaList", metaList); + nbt.setTag("tiles", tileList); + + + /*for(int x = 0; x < sizeX; x++) { + for(int y = 0; y < sizeY; y++) { + for(int z = 0; z < sizeZ; z++) { + + idList.appendTag(new NBTTagInt(Block.getIdFromBlock(blocks[x][y][z]))); + metaList.appendTag(new NBTTagInt(metas[x][y][z])); + + //NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("block", Block.getIdFromBlock(blocks[x][y][z])); + tag.setShort("meta", metas[x][y][z]); + + NBTTagCompound tileNbtData = null; + + for(TileEntity tile : tileEntities) { + NBTTagCompound tileNbt = new NBTTagCompound(); + + tile.writeToNBT(tileNbt); + + if(tileNbt.getInteger("x") == x && tileNbt.getInteger("y") == y && tileNbt.getInteger("z") == z){ + tileNbtData = tileNbt; + break; + } + } + + if(tileNbtData != null) + tag.setTag("tile", tileNbtData); + + nbt.setTag(String.format("%d.%d.%d", x,y,z), tag); + } + + } + }*/ + } + public void readFromNBT(NBTTagCompound nbt) { //System.out.println("read from nbt"); @@ -521,6 +661,7 @@ public void readFromNBT(NBTTagCompound nbt) { sizeY = nbt.getInteger("ySize"); sizeZ = nbt.getInteger("zSize"); weight = nbt.getFloat("weight"); + hasServiceMonitor = nbt.getBoolean("hasServiceMonitor"); blocks = new Block[sizeX][sizeY][sizeZ]; metas = new short[sizeX][sizeY][sizeZ]; @@ -534,7 +675,6 @@ public void readFromNBT(NBTTagCompound nbt) { int[] metasId = nbt.getIntArray("metaList"); - for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { for (int z = 0; z < sizeZ; z++) { @@ -542,7 +682,7 @@ public void readFromNBT(NBTTagCompound nbt) { metas[x][y][z] = (short) metasId[z + (sizeZ * y) + (sizeZ * sizeY * x)]; chunk.setBlockState(new BlockPos(x, y, z), this.blocks[x][y][z].getStateFromMeta(this.metas[x][y][z])); - world.checkLightFor(EnumSkyBlock.BLOCK,new BlockPos(x, y, z)); + world.checkLightFor(EnumSkyBlock.BLOCK, new BlockPos(x, y, z)); } } } @@ -563,7 +703,7 @@ public void readFromNBT(NBTTagCompound nbt) { liquidTiles.add(tile); } - tileEntities.add(tile); + this.addTileEntity(tile); tile.setWorld(world); chunk.addTileEntity(tile); @@ -613,13 +753,9 @@ else if(tag.hasKey("tile")) { this.chunk.generateSkylightMap(); } + //pass the coords of the xmin, ymin, zmin as well as the world to move the rocket @Override public void pasteInWorld(World world, int xCoord, int yCoord, int zCoord) { - this.pasteInWorld(world, xCoord, yCoord, zCoord, false); - } - - //pass the coords of the xmin, ymin, zmin as well as the world to move the rocket - public void pasteInWorld(World world, int xCoord, int yCoord, int zCoord, boolean damage) { //Set all the blocks for (int x = 0; x < sizeX; x++) { @@ -657,20 +793,20 @@ public void pasteInWorld(World world, int xCoord, int yCoord, int zCoord, boolea if (entity != null) entity.readFromNBT(nbt); + } + } - if (damage && entity instanceof TileBrokenPart) { - ((TileBrokenPart) entity).transition(); + public void damageParts() { + for (TileEntity tile : tileEntities) { + if (tile instanceof TileBrokenPart) { + ((TileBrokenPart) tile).transition(); } } } - @Override + @Nullable public TileEntity getTileEntity(@Nonnull BlockPos pos) { - for (TileEntity tileE : tileEntities) { - if (tileE.getPos().compareTo(pos) == 0) - return tileE; - } - return null; + return pos2te.getOrDefault(pos, null); } @Override @@ -741,6 +877,45 @@ public TileGuidanceComputer getGuidanceComputer() { return null; } + public float getBreakingProbability() { + float prob = 0; + + for (TileEntity te : tileEntities) { + if (te instanceof TileBrokenPart) { + TileBrokenPart brokenPart = (TileBrokenPart) te; + float additionalProb = 0; + + if (te.getBlockType() instanceof BlockNuclearRocketMotor) { + additionalProb = 1F; + } else if (te.getBlockType() instanceof BlockRocketMotor || te.getBlockType() instanceof BlockBipropellantRocketMotor) { + additionalProb = 0.2F; + } + prob += additionalProb * brokenPart.getStage() / 10; + if (prob >= 1) { + return Math.min(1, prob); + } + } + } + + return prob; + } + + public List getBrokenBlocks() { + List res = new ArrayList<>(); + + for (TileEntity te : tileEntities) { + if (te instanceof TileBrokenPart) { + res.add((TileBrokenPart) te); + } + } + + return res; + } + + public boolean shouldBreak() { + return world.rand.nextFloat() < this.getBreakingProbability(); + } + /** * @return destination ID or Constants.INVALID_PLANET if none */ @@ -826,7 +1001,8 @@ public void readtiles(ByteBuf in) { } } } - public void writetiles(ByteBuf out){ + + public void writetiles(ByteBuf out) { PacketBuffer buffer = new PacketBuffer(out); buffer.writeShort(tileEntities.size()); Iterator tileIterator = tileEntities.iterator(); @@ -854,7 +1030,7 @@ public void writetiles(ByteBuf out){ public void writeToNetwork(ByteBuf out) { - if (DimensionManager.getWorld(0).isRemote)System.out.println("This should have never been called!"); + if (DimensionManager.getWorld(0).isRemote) System.out.println("This should have never been called!"); PacketBuffer buffer = new PacketBuffer(out); @@ -893,10 +1069,11 @@ public void writeToNetwork(ByteBuf out) { tileIterator.remove(); } } + + buffer.writeBoolean(hasServiceMonitor); } public void readFromNetwork(ByteBuf in) { - //System.out.println("read from network"); finalized = false; @@ -912,7 +1089,6 @@ public void readFromNetwork(ByteBuf in) { chunk = new Chunk(world, 0, 0); - for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { for (int z = 0; z < sizeZ; z++) { @@ -932,7 +1108,7 @@ public void readFromNetwork(ByteBuf in) { TileEntity tile = ZUtils.createTile(nbt); tile.setWorld(world); - tileEntities.add(tile); + this.addTileEntity(tile); if (isInventoryBlock(tile)) { inventoryTiles.add(tile); @@ -948,6 +1124,9 @@ public void readFromNetwork(ByteBuf in) { e.printStackTrace(); } } + + hasServiceMonitor = buffer.readBoolean(); + //We are now ready to render this.chunk.generateSkylightMap(); finalized = true; diff --git a/src/main/java/zmaster587/advancedRocketry/util/TerraformingHelper.java b/src/main/java/zmaster587/advancedRocketry/util/TerraformingHelper.java new file mode 100644 index 000000000..08c0bb9ac --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/TerraformingHelper.java @@ -0,0 +1,301 @@ +package zmaster587.advancedRocketry.util; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.BiomeProvider; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraftforge.common.BiomeManager; +import org.lwjgl.Sys; +import zmaster587.advancedRocketry.dimension.DimensionManager; +import zmaster587.advancedRocketry.dimension.DimensionProperties; +import zmaster587.advancedRocketry.world.ChunkManagerPlanet; +import zmaster587.advancedRocketry.world.ChunkProviderPlanet; + +import java.util.*; + +import static org.apache.commons.lang3.RandomUtils.nextInt; + +enum TerraformingType{ + ALLOWED, BORDER, PROTECTED +} + +public class TerraformingHelper { + public BiomeProvider chunkMgrTerraformed; + public int dimId; + public List biomeList; + public World world; + public ChunkProviderPlanet generator; + private DimensionProperties props; + + private Map chunkDataMap = new HashMap<>(); + + + // A block is placed in queue if (OR) + // - Initial block placements - both only set blocks if the terrain at the BlockPos is not fully generated in the "real" world + // - The TerraformingHelper is created ( causes all loaded chunks to place their blocks here, from DimProps ) + // - A new chunk is loaded ( called from PlanetEventHandler ) + // - After the BiomeHandler has made a change at a BlockPos + // - For type ALLOWED: if the terrain heigt does not match the target, re-add the block to the queue + // - For type BORDER: if BiomeHandler has made a change of the height at BlockPos re-add to queue + // - For type BORDER: if a type.ALLOWED has changed its height it will add blocks next to it (if type==BORDER) to the queue + // - For type PROTECTED: the block is never re-added to queue because it will change its biome only once + // - When a protecting Block has been removed and chunk status is re-calculated + // add every chunk that was PROTECTED and no longer is PROTECTED to the queue for terraforming. + // doesn't matter if it is type ALLOWED or type BORDER + private List terraformingqueue; + + int safe_zone_radius = 3; // radius for protected zone + int border_zone = 3; // border zone size + + + public TerraformingHelper(int dimension, List biomes, HashSet generated_chunks){ + this.dimId = dimension; + this.props = DimensionManager.getInstance().getDimensionProperties(dimension); + this.biomeList = biomes; + this.world = net.minecraftforge.common.DimensionManager.getWorld(dimId); + this.chunkMgrTerraformed = new ChunkManagerPlanet(world, world.getWorldInfo().getGeneratorOptions(), biomeList); + this.terraformingqueue = new ArrayList<>(); + chunkDataMap = new HashMap<>(); + generator = new ChunkProviderPlanet(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), world.getWorldInfo().getGeneratorOptions()); + + for (ChunkPos i:generated_chunks){ + chunkdata data = new chunkdata(i.x,i.z,null, world, this); + data.chunk_fully_generated = true; + chunkDataMap.put(new ChunkPos(data.x,data.z), data); + } + recalculate_chunk_status(); + } + + //0 = no + //1 = yes + // -1 = never (if it includes a type.PROTECTED chunk + public int can_populate(int x, int z){ + chunkdata currentchunk = getChunkFromList(x,z); + chunkdata currentchunkx1 = getChunkFromList(x+1,z); + chunkdata currentchunkz1 = getChunkFromList(x,z+1); + chunkdata currentchunkx1z1 = getChunkFromList(x+1,z+1); + + if (currentchunk != null && currentchunkz1 != null && currentchunkx1 != null && currentchunkx1z1 != null){ + + if (currentchunk.type == TerraformingType.PROTECTED || currentchunkz1.type == TerraformingType.PROTECTED ||currentchunkx1.type == TerraformingType.PROTECTED ||currentchunkx1z1.type == TerraformingType.PROTECTED) + return -1; // chunks contain a protected chunk + + if (currentchunkz1.terrain_fully_generated && currentchunkx1.terrain_fully_generated && currentchunkx1z1.terrain_fully_generated && currentchunk.terrain_fully_generated) + return 1; + } + return 0; + } + + /* + used to add BORDER type block positions to queue for updating again + */ + public void register_height_change_actual(BlockPos pos){ + ChunkPos cpos = getChunkPosFromBlockPos(pos); + chunkdata data= getChunkFromList(cpos.x,cpos.z); + if (data !=null && data.type == TerraformingType.BORDER) + add_position_to_queue(pos); + } + public void register_height_change(BlockPos pos){ + register_height_change_actual(pos.add(1,0,0)); + register_height_change_actual(pos.add(-1,0,0)); + register_height_change_actual(pos.add(0,0,1)); + register_height_change_actual(pos.add(0,0,-1)); + } + + + /* + When a chunk is fully terrain-generated it will call this method to update border chunks next to it. + A Border chunk is considered fully generated when every type.ALLOWED chunks next to it are fully generated. + This is because a fully terrain generated chunk will no longer change its heightmap so it will not modify the heightmap of the border chunk next to it + */ + public synchronized void check_next_border_chunk_fully_generated(int px, int pz) { + + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + chunkdata data = getChunkFromList(px + x, pz + z); + if (data == null)continue; + if (data != null && !data.terrain_fully_generated && data.type == TerraformingType.BORDER) { + int chunkposxlow = data.x * 16; + int chunkposzlow = data.z * 16; + int chunkposxhigh = chunkposxlow + 16; + int chunkposzhigh = chunkposzlow + 16; + + + for(Vec3i p : terraformingqueue){ + if (p.getX() >= chunkposxlow && p.getX() < chunkposxhigh) { + if (p.getZ() >= chunkposzlow && p.getZ() < chunkposzhigh) { + return; + } + } + } + + + for (int x2 = -1; x2 <= 1; x2++) { + for (int z2 = -1; z2 <= 1; z2++) { + chunkdata data2 = getChunkFromList(px + x + x2, pz + z + z2); + if (data2 == null) return; + if (data2.type == TerraformingType.ALLOWED) { + if (!data2.terrain_fully_generated) { + return; + } + } + } + } + System.out.println("border chunk terrain fully generated"); + data.terrain_fully_generated = true; + data.blockStates = null; // no longer needed, gc should collect them now - actually, these are never needed but who cares... + check_next_border_chunk_fully_generated(data.x, data.z); // update border chunks next to this one to check if they can decorate + check_can_decorate(data.x, data.z); + + } + } + } + } + public void check_can_decorate(int px, int pz){ + // for every chunk next to this one, check if it can decorate (except for if it is already decorated) + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + if (getChunkFromList(px+x,pz+z) != null && !getChunkFromList(px+x,pz+z).chunk_fully_generated){ + if (can_populate(px+x,pz+z) != 0){ + //re-add all position to queue for decoration + System.out.println("chunk can populate now: "+(px+x)+":"+(pz+z)); + for (int bx = 0; bx < 16; bx++) { + for (int bz = 0; bz < 16; bz++) { + add_position_to_queue_at_front(new BlockPos((px+x)*16+bx, 0, (pz+z)*16+bz)); + } + } + } + } + } + } + + } + public ChunkPos getChunkPosFromBlockPos(BlockPos pos) { + return new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4); + } + + + + public TerraformingType get_chunk_type(int x, int z) { + + TerraformingType type = TerraformingType.ALLOWED; + for (BlockPos i : DimensionProperties.proxylists.getProtectingBlocksForDimension(props.getId())) { + //System.out.println("found protecting block at "+i.getX()+":"+i.getY()+":"+i.getZ()); + ChunkPos cpos = getChunkPosFromBlockPos(i); + int dx = cpos.x - x; + int dz = cpos.z - z; + if (Math.abs(dx) <= safe_zone_radius && Math.abs(dz) <= safe_zone_radius) + return TerraformingType.PROTECTED; + else if (Math.abs(dx) <= safe_zone_radius + border_zone && Math.abs(dz) <= safe_zone_radius + border_zone) { + type = TerraformingType.BORDER; + } + } + return type; + } + + public void recalculate_chunk_status() { + Iterator> iterator = chunkDataMap.entrySet().iterator(); + + while (iterator.hasNext()) { + + Map.Entry entry = iterator.next(); + + chunkdata data = entry.getValue(); + + TerraformingType prevtype = data.type; + + data.type = get_chunk_type(data.x, data.z); + + if (prevtype != TerraformingType.ALLOWED) + if (data.type == TerraformingType.ALLOWED || data.type == TerraformingType.BORDER) + if (data.terrain_fully_generated) + iterator.remove(); + + } + } + + + + + + public chunkdata getChunkFromList(int x, int z){ + ChunkPos key = new ChunkPos(x,z); + return chunkDataMap.get(key); + } + + + + public synchronized void add_position_to_queue(BlockPos p){ + //System.out.println("add position: "+p.getX()+":"+p.getZ()); + if (p == null){ + System.out.print("ERROR POSITION IS NULL"); + return; + } + terraformingqueue.add(new Vec3i(p.getX(),p.getY(),p.getZ())); + } + public synchronized void add_position_to_queue_at_front(BlockPos p){ + //System.out.println("add position: "+p.getX()+":"+p.getZ()); + if (p == null){ + System.out.print("ERROR POSITION IS NULL"); + return; + } + int insertionIndex; + insertionIndex = new Random().nextInt(Math.min(terraformingqueue.size(), 1000)); + + terraformingqueue.add(insertionIndex, new Vec3i(p.getX(),p.getY(),p.getZ())); + } + + + public synchronized BlockPos get_next_position(boolean random){ + if (terraformingqueue.isEmpty()) + return null; + int index = 0; + if (random) + index = nextInt(0,terraformingqueue.size()); + + Vec3i pos = terraformingqueue.remove(index); + return new BlockPos(pos); + } + + public IBlockState[] getBlocksAt(int x, int z){ + ChunkPos cpos = getChunkPosFromBlockPos(new BlockPos(x,0,z)); + chunkdata data = getChunkFromList(cpos.x,cpos.z); + if (data == null){ + System.out.println("generate new chunk: "+cpos.x+":"+cpos.z); + ChunkPrimer primer = generator.getChunkPrimer(cpos.x, cpos.z, chunkMgrTerraformed); + + IBlockState[][][] blockStates = new IBlockState[16][16][256]; + for (int px = 0; px < 16; px++) { + for (int pz = 0; pz < 16; pz++) { + for (int py = 0; py < 256; py++) { + blockStates[px][pz][py] = primer.getBlockState(px,py,pz); + } + } + } + + data = new chunkdata(cpos.x,cpos.z, blockStates, world, this); + chunkDataMap.put(new ChunkPos(data.x,data.z),data); + data.type = get_chunk_type(data.x,data.z); + + } + int chunkx = ((x % 16) + 16) % 16; + int chunkz = ((z % 16) + 16) % 16; + + if (data.blockStates == null) + return null; + + return data.blockStates[chunkx][chunkz]; + } + + + public void setChunkFullyGenerated(int x, int z) { + getChunkFromList(x,z).chunk_fully_generated = true; + DimensionProperties.proxylists.getChunksFullyTerraformed(props.getId()).add(new ChunkPos(x,z)); + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/chunkdata.java b/src/main/java/zmaster587/advancedRocketry/util/chunkdata.java new file mode 100644 index 000000000..ea33e69ee --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/chunkdata.java @@ -0,0 +1,97 @@ +package zmaster587.advancedRocketry.util; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.world.World; +import org.lwjgl.Sys; + +public class chunkdata { + public int x; + public int z; + public TerraformingType type; + + + // chunk can be populated if itself and the 3 chunks with (x+1), (z+1) and (x+1,z+1) are fully generated in the world + + + // if a chunks terrain is fully generated and does not need any future updates - causes it to set the IBlockState[][][] to null to free memory + // if the terrain is fully generated it allows for calling populate() + public boolean terrain_fully_generated; + + // will be set by BiomeHandler after calling the populate method, makes the chunk fully generated and it does not need any future updates + // as long as the atmosphere does not change, chunks that are fully generated will not register their blocks in the terraforming queue + public boolean chunk_fully_generated; + + // if the y values of new chunk and chunk in world match, terrain at this position is considered fully generated + public boolean[][] fully_generated; + + // if all positions have been decorated + public boolean[][] fully_decorated; + + + public IBlockState[][][] blockStates; + + World world; // used to call populate after decoration is finished + TerraformingHelper helper; + + public chunkdata(int x, int z, IBlockState[][][] blockStates, World world, TerraformingHelper helper) { + this.x = x; + this.world = world; + this.helper = helper; + this.z = z; + this.blockStates = blockStates; + this.type = TerraformingType.ALLOWED; + chunk_fully_generated = false; + terrain_fully_generated = false; + fully_generated = new boolean[16][16]; + fully_decorated = new boolean[16][16]; + } + + /* + sets if a blockpos is fully generated and computed if the chunk is fully generated + called from BiomeHandler + */ + public void set_position_fully_generated(int x, int z){ + fully_generated[x][z] = true; + boolean all_generated = true; + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + if (fully_generated[i][j] == false) { + all_generated = false; + } + } + } + if (all_generated){ + System.out.println("chunk fully generated: "+this.x+":"+this.z); + terrain_fully_generated = true; + this.blockStates = null; // no longer needed, gc should collect them now + helper.check_next_border_chunk_fully_generated(x,z); // update border chunks next to this one to check if they can decorate + helper.check_can_decorate(x,z); + + } + } + + public void set_position_decorated(int x, int z){ + + fully_decorated[x][z] = true; + boolean all_decorated = true; + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + if (fully_decorated[i][j] == false) { + all_decorated = false; + } + } + } + if (all_decorated){ + // populate uses the biome at blockpos 0,0, in the chunk x+1,z+1, that's why we need the chunks next to it generated + if (!chunk_fully_generated) + if (helper.can_populate(this.x, this.z) == 1){ + world.provider.createChunkGenerator().populate(this.x, this.z); + System.out.println("populate chunk "+this.x+":"+this.z); + } + helper.setChunkFullyGenerated(this.x,this.z); + } + + + } + +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/nbt/Factory.java b/src/main/java/zmaster587/advancedRocketry/util/nbt/Factory.java new file mode 100644 index 000000000..f31c09a3c --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/nbt/Factory.java @@ -0,0 +1,6 @@ +package zmaster587.advancedRocketry.util.nbt; + +public interface Factory { + + T create(); +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTHelper.java b/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTHelper.java new file mode 100644 index 000000000..573911ce8 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTHelper.java @@ -0,0 +1,257 @@ +package zmaster587.advancedRocketry.util.nbt; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.nbt.*; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.common.util.INBTSerializable; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Tool for NBT serializing and deserializing collections and other stuff + */ +@SuppressWarnings("unchecked") +public class NBTHelper { + + public static NBTBase NBT_NULL = new NBTTagString("null"); + + public static void writeCollection(String name, NBTTagCompound compound, Collection> collection) { + compound.setTag(name, collectionToNBT(collection)); + } + + public static void writeCollection(String name, NBTTagCompound compound, Collection collection, ParametrizedFactory serializer) { + compound.setTag(name, collectionToNBT(collection, serializer)); + } + + public static > C readCollection(String name, NBTTagCompound compound, Factory collectionFactory, ParametrizedFactory deserializer) { + return collectionFromNBT(getTagList(name, compound), collectionFactory, deserializer); + } + + public static NBTTagList collectionToNBT(Collection> collection) { + NBTTagList tag = new NBTTagList(); + collection.stream().map(INBTSerializable::serializeNBT).forEach(tag::appendTag); + return tag; + } + + public static NBTTagList collectionToNBT(Collection collection, ParametrizedFactory serializer) { + NBTTagList tag = new NBTTagList(); + collection.stream().map(serializer::create).forEach(tag::appendTag); + return tag; + } + + public static > C collectionFromNBT(NBTTagList tag, Factory collectionFactory, ParametrizedFactory deserializer) { + C collection = collectionFactory.create(); + tag.iterator().forEachRemaining(item -> collection.add(deserializer.create((NBT_T) item))); + return collection; + } + + public static void writeMap(String name, NBTTagCompound compound, Map> map) { + compound.setTag(name, mapToNBT(map)); + } + + public static void writeMap(String name, NBTTagCompound compound, Map map, ParametrizedFactory serializer) { + compound.setTag(name, mapToNBT(map, serializer)); + } + + public static Map readMap(String name, NBTTagCompound compound, ParametrizedFactory valueDeserializer) { + return readMap(name, compound, Objects::toString, valueDeserializer); + } + + public static Map readMap(String name, NBTTagCompound compound, ParametrizedFactory keyDeserializer, ParametrizedFactory valueDeserializer) { + return mapFromNBT(compound.getCompoundTag(name), HashMap::new, keyDeserializer, valueDeserializer); + } + + public static NBTTagCompound mapToNBT(Map> map) { + NBTTagCompound compound = new NBTTagCompound(); + map.forEach((key, value) -> write(key.toString(), value, compound)); + return compound; + } + + public static NBTTagCompound mapToNBT(Map map, ParametrizedFactory serializer) { + NBTTagCompound compound = new NBTTagCompound(); + map.forEach((key, value) -> write(key.toString(), serializer.create(value), compound)); + return compound; + } + + public static Map mapFromNBT(NBTTagCompound compound, ParametrizedFactory valueDeserializer) { + return mapFromNBT(compound, Objects::toString, valueDeserializer); + } + + public static Map mapFromNBT(NBTTagCompound compound, ParametrizedFactory keyDeserializer, ParametrizedFactory valueDeserializer) { + return mapFromNBT(compound, HashMap::new, keyDeserializer, valueDeserializer); + } + + public static Map mapFromNBT(NBTTagCompound compound, Factory> mapFactory, ParametrizedFactory keyDeserializer, ParametrizedFactory valueDeserializer) { + Map map = mapFactory.create(); + compound.getKeySet().forEach(key -> map.put(keyDeserializer.create(key), read(key, compound, valueDeserializer))); + return map; + } + + public static void write(String key, INBTSerializable value, NBTTagCompound compound) { + compound.setTag(key, value.serializeNBT()); + } + + public static void write(String key, Object value, NBTTagCompound compound) { + if (value instanceof Integer) { + compound.setInteger(key, (Integer) value); + } else if (value instanceof Long) { + compound.setLong(key, (Long) value); + } else if (value instanceof String) { + compound.setString(key, (String) value); + } else if (value instanceof Boolean) { + compound.setBoolean(key, (Boolean) value); + } else if (value instanceof Float) { + compound.setFloat(key, (Float) value); + } else if (value instanceof Double) { + compound.setDouble(key, (Double) value); + } else if (value instanceof Byte) { + compound.setByte(key, (Byte) value); + } else if (value instanceof NBTBase) { + compound.setTag(key, (NBTBase) value); + } else if (value instanceof byte[]) { + compound.setByteArray(key, (byte[]) value); + } else if (value instanceof int[]) { + compound.setIntArray(key, (int[]) value); + } + } + + public static T read(String key, NBTTagCompound compound, ParametrizedFactory factory) { + return factory.create((NBT_T) compound.getTag(key)); + } + + public static Object read(String key, NBTTagCompound compound) { + NBTBase tag = compound.getTag(key); + if (tag instanceof NBTTagInt) { + return ((NBTTagInt) tag).getInt(); + } else if (tag instanceof NBTTagLong) { + return ((NBTTagLong) tag).getLong(); + } else if (tag instanceof NBTTagString) { + return ((NBTTagString) tag).getString(); + } else if (tag instanceof NBTTagByte) { + return ((NBTTagByte) tag).getByte(); + } else if (tag instanceof NBTTagFloat) { + return ((NBTTagFloat) tag).getFloat(); + } else if (tag instanceof NBTTagDouble) { + return ((NBTTagDouble) tag).getDouble(); + } else if (tag instanceof NBTTagByteArray) { + return ((NBTTagByteArray) tag).getByteArray(); + } else if (tag instanceof NBTTagIntArray) { + return ((NBTTagIntArray) tag).getIntArray(); + } + return null; + } + + public static NBTTagList getTagList(String name, NBTTagCompound compound) { + NBTBase nbt = compound.tagMap.get(name); + if (!(nbt instanceof NBTTagList)) { + throw new IllegalArgumentException("Tag got by name " + name + "isn't NBTTagList!"); + } + return (NBTTagList) nbt; + } + + public static NBTBase writeBlockPos(BlockPos pos) { + return new NBTTagLong(pos.toLong()); + } + + public static BlockPos readBlockPos(NBTBase nbt) { + return BlockPos.fromLong(((NBTTagLong) nbt).getLong()); + } + + public static void writeBlockPos(String key, BlockPos pos, NBTTagCompound compound) { + compound.setLong(key, pos.toLong()); + } + + public static BlockPos readBlockPos(String key, NBTTagCompound compound) { + return BlockPos.fromLong(compound.getLong(key)); + } + + public static NBTBase writeState(IBlockState state) { + if (state == null) { + return NBT_NULL; + } + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("name", state.getBlock().getRegistryName().toString()); + compound.setShort("meta", (short) state.getBlock().getMetaFromState(state)); + return compound; + } + + public static IBlockState readState(NBTBase nbt) { + if (nbt.equals(NBT_NULL)) { + return null; + } + NBTTagCompound compound = (NBTTagCompound) nbt; + String blockName = compound.getString("name"); + Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockName)); + return block.getStateFromMeta(compound.getShort("meta")); + } + + public static void writeAABB(String key, NBTTagCompound compound, AxisAlignedBB aabb) { + compound.setTag(key, NBTTagCompoundBuilder + .create() + .setDouble("minX", aabb.minX) + .setDouble("minY", aabb.minY) + .setDouble("minZ", aabb.minZ) + .setDouble("maxX", aabb.maxX) + .setDouble("maxY", aabb.maxY) + .setDouble("maxZ", aabb.maxZ) + .build()); + } + + public static AxisAlignedBB readAABB(String key, NBTTagCompound compound) { + NBTTagCompound tag = compound.getCompoundTag(key); + return new AxisAlignedBB( + tag.getDouble("minX"), + tag.getDouble("minY"), + tag.getDouble("minZ"), + tag.getDouble("maxX"), + tag.getDouble("maxY"), + tag.getDouble("maxZ") + ); + } + + public static NBTBase writeTileEntity(final TileEntity tileEntity) { + if (tileEntity == null) { + return NBT_NULL; + } + + final NBTTagCompound compound = new NBTTagCompound(); + tileEntity.writeToNBT(compound); + return compound; + } + + public static TileEntity readTileEntity(final NBTBase compound) { + return readTileEntity(compound, null); + } + + public static TileEntity readTileEntity(final NBTBase nbt, final World world) { + if (nbt.equals(NBT_NULL)) { + return null; + } + NBTTagCompound compound = (NBTTagCompound) nbt; + return TileEntity.create(world, compound); + } + + public static NBTTagCompound writeEntityToCompound(final Entity entity) { + final NBTTagCompound entityCompound = new NBTTagCompound(); + if (entity.writeToNBTOptional(entityCompound)) { + return entityCompound; + } + + return null; + } + + public static Entity readEntityFromCompound(final NBTTagCompound nbtTagCompound, final World world) { + return EntityList.createEntityFromNBT(nbtTagCompound, world); + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTTagCompoundBuilder.java b/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTTagCompoundBuilder.java new file mode 100644 index 000000000..78dc6d011 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTTagCompoundBuilder.java @@ -0,0 +1,161 @@ +package zmaster587.advancedRocketry.util.nbt; + +import net.minecraft.nbt.*; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.INBTSerializable; + +import java.util.Collection; +import java.util.Map; +import java.util.UUID; +import java.util.function.Consumer; + +/** + * An utility class to functionally construct NBTTagCompound. + * Potentially can provide the advanced serializing to it. + */ +public class NBTTagCompoundBuilder { + + private final NBTTagCompound instance; + + private NBTTagCompoundBuilder(NBTTagCompound instance) { + this.instance = instance; + } + + public static NBTTagCompoundBuilder create() { + return new NBTTagCompoundBuilder(new NBTTagCompound()); + } + + public static NBTTagCompoundBuilder create(NBTTagCompound instance) { + return new NBTTagCompoundBuilder(instance); + } + + public NBTTagCompoundBuilder setString(String key, String value) { + instance.setString(key, value); + return this; + } + + public NBTTagCompoundBuilder setInt(String key, int value) { + instance.setInteger(key, value); + return this; + } + + public NBTTagCompoundBuilder setShort(String key, short value) { + instance.setShort(key, value); + return this; + } + + public NBTTagCompoundBuilder setLong(String key, long value) { + instance.setLong(key, value); + return this; + } + + public NBTTagCompoundBuilder setFloat(String key, float value) { + instance.setFloat(key, value); + return this; + } + + public NBTTagCompoundBuilder setDouble(String key, double value) { + instance.setDouble(key, value); + return this; + } + + public NBTTagCompoundBuilder setBoolean(String key, boolean value) { + instance.setBoolean(key, value); + return this; + } + + public NBTTagCompoundBuilder setIntArray(String key, int[] value) { + instance.setIntArray(key, value); + return this; + } + + public NBTTagCompoundBuilder setByteArray(String key, byte[] value) { + instance.setByteArray(key, value); + return this; + } + + public NBTTagCompoundBuilder setUniqueID(String key, UUID value) { + instance.setUniqueId(key, value); + return this; + } + + public NBTTagCompoundBuilder setSerializable(String key, INBTSerializable serializable) { + return setTag(key, serializable.serializeNBT()); + } + + public NBTTagCompoundBuilder setBlockPos(String key, BlockPos value) { + NBTHelper.writeBlockPos(key, value, instance); + return this; + } + + public NBTTagCompoundBuilder setAABB(String key, AxisAlignedBB value) { + NBTHelper.writeAABB(key, instance, value); + return this; + } + + public NBTTagCompoundBuilder setTag(String key, NBTBase value) { + instance.setTag(key, value); + return this; + } + + public NBTTagCompoundBuilder setCollection(String key, Collection> collection) { + NBTHelper.writeCollection(key, instance, collection); + return this; + } + + public NBTTagCompoundBuilder setStringCollection(String key, Collection collection) { + NBTHelper.writeCollection(key, instance, collection, NBTTagString::new); + return this; + } + + public NBTTagCompoundBuilder setIntegerCollection(String key, Collection collection) { + NBTHelper.writeCollection(key, instance, collection, NBTTagInt::new); + return this; + } + + public NBTTagCompoundBuilder setFloatCollection(String key, Collection collection) { + NBTHelper.writeCollection(key, instance, collection, NBTTagFloat::new); + return this; + } + + public NBTTagCompoundBuilder setDoubleCollection(String key, Collection collection) { + NBTHelper.writeCollection(key, instance, collection, NBTTagDouble::new); + return this; + } + + public NBTTagCompoundBuilder setByteCollection(String key, Collection collection) { + NBTHelper.writeCollection(key, instance, collection, NBTTagByte::new); + return this; + } + + public NBTTagCompoundBuilder setCollection(String key, Collection collection, ParametrizedFactory serializer) { + NBTHelper.writeCollection(key, instance, collection, serializer); + return this; + } + + public NBTTagCompoundBuilder setResourceLocation(String key, ResourceLocation value) { + instance.setString(key, value.toString()); + return this; + } + + public NBTTagCompoundBuilder setMap(String key, Map> map) { + NBTHelper.writeMap(key, instance, map); + return this; + } + + public NBTTagCompoundBuilder setMap(String key, Map map, ParametrizedFactory serializer) { + NBTHelper.writeMap(key, instance, map, serializer); + return this; + } + + public NBTTagCompoundBuilder execute(Consumer action) { + action.accept(instance); + return this; + } + + public NBTTagCompound build() { + return instance; + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTTagListCollector.java b/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTTagListCollector.java new file mode 100644 index 000000000..acc620c3f --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/nbt/NBTTagListCollector.java @@ -0,0 +1,48 @@ +package zmaster587.advancedRocketry.util.nbt; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagList; + +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collector; + +public class NBTTagListCollector implements Collector { + + static final Set CH_UNORDERED_ID + = Collections.unmodifiableSet(EnumSet.of(Characteristics.UNORDERED, + Characteristics.IDENTITY_FINISH)); + + @Override + public Supplier supplier() { + return NBTTagList::new; + } + + @Override + public BiConsumer accumulator() { + return NBTTagList::appendTag; + } + + @Override + public BinaryOperator combiner() { + return (o1, o2) -> { + o2.forEach(o1::appendTag); + return o1; + }; + } + + @Override + public Function finisher() { + return Function.identity(); + } + + @Override + public Set characteristics() { + return CH_UNORDERED_ID; + } +} diff --git a/src/main/java/zmaster587/advancedRocketry/util/nbt/ParametrizedFactory.java b/src/main/java/zmaster587/advancedRocketry/util/nbt/ParametrizedFactory.java new file mode 100644 index 000000000..87f6e5dc4 --- /dev/null +++ b/src/main/java/zmaster587/advancedRocketry/util/nbt/ParametrizedFactory.java @@ -0,0 +1,6 @@ +package zmaster587.advancedRocketry.util.nbt; + +public interface ParametrizedFactory { + + O create(I param); +} diff --git a/src/main/java/zmaster587/advancedRocketry/world/ChunkManagerPlanet.java b/src/main/java/zmaster587/advancedRocketry/world/ChunkManagerPlanet.java index eab63c020..6791c258c 100644 --- a/src/main/java/zmaster587/advancedRocketry/world/ChunkManagerPlanet.java +++ b/src/main/java/zmaster587/advancedRocketry/world/ChunkManagerPlanet.java @@ -12,6 +12,7 @@ import net.minecraft.world.gen.ChunkGeneratorSettings; import net.minecraft.world.gen.layer.*; import net.minecraftforge.common.BiomeManager.BiomeEntry; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import zmaster587.advancedRocketry.AdvancedRocketry; import zmaster587.advancedRocketry.dimension.DimensionManager; import zmaster587.advancedRocketry.dimension.DimensionProperties; @@ -37,6 +38,10 @@ private void setup(long seed, WorldType default1, String str, DimensionPropertie agenlayer = getModdedBiomeGenerators(default1, seed, agenlayer); this.genBiomes = agenlayer[0]; this.biomeIndexLayer = agenlayer[1]; + + ReflectionHelper.setPrivateValue(BiomeProvider.class, this, this.genBiomes, "genBiomes", "field_76944_d"); + ReflectionHelper.setPrivateValue(BiomeProvider.class, this, this.biomeIndexLayer, "biomeIndexLayer", "field_76945_e"); + } long seed; diff --git a/src/main/java/zmaster587/advancedRocketry/world/ChunkProviderPlanet.java b/src/main/java/zmaster587/advancedRocketry/world/ChunkProviderPlanet.java index 29529069d..a5bb0f935 100644 --- a/src/main/java/zmaster587/advancedRocketry/world/ChunkProviderPlanet.java +++ b/src/main/java/zmaster587/advancedRocketry/world/ChunkProviderPlanet.java @@ -13,6 +13,7 @@ import net.minecraft.world.WorldType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.SpawnListEntry; +import net.minecraft.world.biome.BiomeProvider; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.gen.*; @@ -153,8 +154,8 @@ public ChunkProviderPlanet(World worldIn, long seed, boolean mapFeaturesEnabledI this.mapFeaturesEnabled = dimProps.canGenerateStructures() && ARConfiguration.getCurrentConfig().generateVanillaStructures; //TODO: may break on little planets - float atmDensity = ((WorldProviderPlanet) worldObj.provider).getAtmosphereDensity(new BlockPos(0, 0, 0)); - habitable = ((WorldProviderPlanet) worldObj.provider).getAtmosphere(new BlockPos(0, 0, 0)).isBreathable(); + float atmDensity = dimProps.getAtmosphereDensity() / 100f; // this fucking shit does not belong here -> ((WorldProviderPlanet) worldObj.provider).getAtmosphereDensity(new BlockPos(0, 0, 0)); + habitable = dimProps.getAtmosphere().isBreathable(); if (ARConfiguration.getCurrentConfig().generateCraters && dimProps.canGenerateCraters() && atmDensity <= 0.05) @@ -193,11 +194,18 @@ public ChunkProviderPlanet(World worldIn, long seed, boolean mapFeaturesEnabledI } public void setBlocksInChunk(int x, int z, ChunkPrimer primer) { + setBlocksInChunk(x,z,primer,null); + } + public void setBlocksInChunk(int x, int z, ChunkPrimer primer, BiomeProvider bp) { byte b0 = 63; //TODO: may break for little planets - this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); - this.generateHeightmap(x * 4, 0, z * 4); - + if (bp == null) { + this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); + this.generateHeightmap(x * 4, 0, z * 4); + }else{ + this.biomesForGeneration = bp.getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); + this.generateHeightmap(x * 4, 0, z * 4); + } for (int i = 0; i < 4; ++i) { int j = i * 5; int k = (i + 1) * 5; @@ -266,13 +274,28 @@ public void replaceBiomeBlocks(int x, int z, ChunkPrimer primer, Biome[] biomesI } } - protected ChunkPrimer getChunkPrimer(int x, int z) { + public ChunkPrimer getChunkPrimer(int x, int z) { + return getChunkPrimer(x,z,null); + } + public ChunkPrimer getChunkPrimer(int x, int z, BiomeProvider bp) { this.rand.setSeed((long) x * 341873128712L + (long) z * 132897987541L); ChunkPrimer chunkprimer = new ChunkPrimer(); - this.setBlocksInChunk(x, z, chunkprimer); - this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16); - this.replaceBiomeBlocks(x, z, chunkprimer, this.biomesForGeneration); + boolean is_terraforming = false; + if (bp == null) { + this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16); + this.setBlocksInChunk(x, z, chunkprimer); // this messes up biome generation, needs to reset biomes + this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16); + this.replaceBiomeBlocks(x, z, chunkprimer, this.biomesForGeneration); + } + else { + this.biomesForGeneration = bp.getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16); + this.setBlocksInChunk(x, z, chunkprimer, bp); // this messes up biome generation, needs to reset biomes + this.biomesForGeneration = bp.getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16); + this.replaceBiomeBlocks(x, z, chunkprimer, this.biomesForGeneration); + is_terraforming = true; + } + if (this.settings.useCaves && caveGenerator != null) { this.caveGenerator.generate(this.worldObj, x, z, chunkprimer); @@ -282,13 +305,13 @@ protected ChunkPrimer getChunkPrimer(int x, int z) { this.ravineGenerator.generate(this.worldObj, x, z, chunkprimer); } - if (this.craterGeneratorSmall != null) + if (this.craterGeneratorSmall != null && !is_terraforming) this.craterGeneratorSmall.generate(this.worldObj, x, z, chunkprimer); - if (this.craterGenerator != null) + if (this.craterGenerator != null && !is_terraforming) this.craterGenerator.generate(this.worldObj, x, z, chunkprimer); - if (this.craterGeneratorHuge != null) + if (this.craterGeneratorHuge != null && !is_terraforming) this.craterGeneratorHuge.generate(this.worldObj, x, z, chunkprimer); if (this.volcanoGenerator != null) @@ -300,7 +323,7 @@ protected ChunkPrimer getChunkPrimer(int x, int z) { //Trees are always this.swampTreeGenerator.generate(this.worldObj, x, z, chunkprimer); - if (this.mapFeaturesEnabled && habitable) { + if (this.mapFeaturesEnabled && habitable && !is_terraforming) { // terraforming would destroy it all... if (this.settings.useMineShafts) { this.mineshaftGenerator.generate(this.worldObj, x, z, chunkprimer); } @@ -308,7 +331,6 @@ protected ChunkPrimer getChunkPrimer(int x, int z) { if (this.settings.useVillages) { this.villageGenerator.generate(this.worldObj, x, z, chunkprimer); } - if (this.settings.useStrongholds) { this.strongholdGenerator.generate(this.worldObj, x, z, chunkprimer); } @@ -316,7 +338,6 @@ protected ChunkPrimer getChunkPrimer(int x, int z) { if (this.settings.useTemples) { this.scatteredFeatureGenerator.generate(this.worldObj, x, z, chunkprimer); } - if (this.settings.useMonuments) { this.oceanMonumentGenerator.generate(this.worldObj, x, z, chunkprimer); } @@ -493,7 +514,6 @@ public void populate(int x, int z) { if (this.settings.useTemples) { this.scatteredFeatureGenerator.generateStructure(this.worldObj, this.rand, chunkpos); } - if (this.settings.useMonuments) { this.oceanMonumentGenerator.generateStructure(this.worldObj, this.rand, chunkpos); } @@ -550,18 +570,6 @@ public void populate(int x, int z) { } }//Forge: End ICE - - //If a planet is terraformed chenge upper blocks - // NO - because it causes mega-lag! - /* - if (zmaster587.advancedRocketry.api.ARConfiguration.getCurrentConfig().enableTerraforming && worldObj.provider.getClass() == WorldProviderPlanet.class) { - - if (DimensionManager.getInstance().getDimensionProperties(worldObj.provider.getDimension()).isTerraformed()) { - Chunk chunk = worldObj.getChunkFromChunkCoords(x, z); - PlanetEventHandler.modifyChunk(worldObj, (WorldProviderPlanet) worldObj.provider, chunk); - } - } - */ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, this.rand, x, z, flag); OreGenProperties oreGenProperties = DimensionManager.getInstance().getDimensionProperties(this.worldObj.provider.getDimension()).getOreGenProperties(this.worldObj); @@ -593,6 +601,7 @@ public boolean generateStructures(Chunk chunkIn, int x, int z) { @Override public void recreateStructures(Chunk chunkIn, int x, int z) { + if (this.mapFeaturesEnabled || !habitable) { if (this.settings.useMineShafts) { this.mineshaftGenerator.generate(this.worldObj, x, z, null); @@ -601,11 +610,11 @@ public void recreateStructures(Chunk chunkIn, int x, int z) { if (this.settings.useVillages) { this.villageGenerator.generate(this.worldObj, x, z, null); } - if (this.settings.useStrongholds) { this.strongholdGenerator.generate(this.worldObj, x, z, null); } + if (this.settings.useTemples) { this.scatteredFeatureGenerator.generate(this.worldObj, x, z, null); } @@ -613,6 +622,7 @@ public void recreateStructures(Chunk chunkIn, int x, int z) { if (this.settings.useMonuments) { this.oceanMonumentGenerator.generate(this.worldObj, x, z, null); } + } } diff --git a/src/main/java/zmaster587/advancedRocketry/world/biome/BiomeGenAlienForest.java b/src/main/java/zmaster587/advancedRocketry/world/biome/BiomeGenAlienForest.java index 1aaccaea9..25c669a3f 100644 --- a/src/main/java/zmaster587/advancedRocketry/world/biome/BiomeGenAlienForest.java +++ b/src/main/java/zmaster587/advancedRocketry/world/biome/BiomeGenAlienForest.java @@ -43,7 +43,7 @@ public void decorate(World worldIn, Random rand, BlockPos pos) { @Override @Nonnull public WorldGenAbstractTree getRandomTreeFeature(Random rand) { - return noTree; + return alienTree; } @Override diff --git a/src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenGeode.java b/src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenGeode.java index 1c03eff71..2636843a0 100644 --- a/src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenGeode.java +++ b/src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenGeode.java @@ -1,6 +1,7 @@ package zmaster587.advancedRocketry.world.decoration; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -99,8 +100,10 @@ protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_1807 //Generates ore hanging from the ceiling if (x % 4 > 0 && z % 4 > 0) { - for (int i = 1; i < size; i++) - chunkPrimerIn.setBlockState(x, avgY + count - i, z, ores.get((x / 4 + z / 4) % ores.size()).getBlockState()); + IBlockState ore = ores.get(world.rand.nextInt(ores.size())).getBlockState(); + for (int i = 1; i < size; i++) { + chunkPrimerIn.setBlockState(x, avgY + count - i, z, ore); + } } else { size -= 2; for (int i = 1; i < size; i++) { @@ -110,10 +113,11 @@ protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_1807 //Generates ore in the floor if ((x + 2) % 4 > 0 && (z + 2) % 4 > 0) { - for (int i = 1; i < size; i++) - chunkPrimerIn.setBlockState(x, avgY - count + i, z, ores.get((x / 4 + z / 4) % ores.size()).getBlockState()); + IBlockState ore = ores.get(world.rand.nextInt(ores.size())).getBlockState(); + for (int i = 1; i < size; i++) { + chunkPrimerIn.setBlockState(x, avgY - count + i, z, ore); + } } - } chunkPrimerIn.setBlockState(x, avgY - count, z, AdvancedRocketryBlocks.blocksGeode.getDefaultState()); diff --git a/src/main/resources/META-INF/accessTransformer.cfg b/src/main/resources/META-INF/accessTransformer.cfg index f74b95b40..9e21de8d0 100644 --- a/src/main/resources/META-INF/accessTransformer.cfg +++ b/src/main/resources/META-INF/accessTransformer.cfg @@ -1 +1,4 @@ -public net.minecraft.entity.Entity * \ No newline at end of file +public net.minecraft.entity.Entity * +public net.minecraft.nbt.NBTTagCompound * +public-f net.minecraft.inventory.InventoryBasic * +public net.minecraft.world.storage.MapStorage * diff --git a/src/main/resources/assets/advancedrocketry/blockstates/advbipropellantrocketmotor.json b/src/main/resources/assets/advancedrocketry/blockstates/advbipropellantrocketmotor.json index 362c031ce..9c42ab421 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/advbipropellantrocketmotor.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/advbipropellantrocketmotor.json @@ -4,16 +4,16 @@ "textures": { "#None": "advancedrocketry:/models/advbipropellantcombustion" }, - "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", + "model": "advancedrocketry:models/advbipropellantrocket.obj", "transform": "forge:default-block" }, "variants": { - "facing=north": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90 }, - "facing=south": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90, "y": 180 }, - "facing=west": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90, "y": 270 }, - "facing=east": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90, "y": 90 }, - "facing=up": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 180 }, - "facing=down": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion" }, - "inventory": { "model": "advancedrocketry:models/advbipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion"} + "facing=north": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90 }, + "facing=south": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90, "y": 180 }, + "facing=west": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90, "y": 270 }, + "facing=east": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 90, "y": 90 }, + "facing=up": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion", "x": 180 }, + "facing=down": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion" }, + "inventory": { "model": "advancedrocketry:models/advbipropellantrocket.obj", "texture": "advancedrocketry:textures/models/advbipropellantcombustion"} } } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/advrocketmotor.json b/src/main/resources/assets/advancedrocketry/blockstates/advrocketmotor.json index f91ec760f..84ff1f773 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/advrocketmotor.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/advrocketmotor.json @@ -4,16 +4,16 @@ "textures": { "#None": "advancedrocketry:/models/advcombustion" }, - "model": "advancedrocketry:models/advrocketmotor.obj", + "model": "advancedrocketry:models/advrocket.obj", "transform": "forge:default-block" }, "variants": { - "facing=north": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90 }, - "facing=south": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90, "y": 180 }, - "facing=west": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90, "y": 270 }, - "facing=east": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90, "y": 90 }, - "facing=up": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 180 }, - "facing=down": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion" }, - "inventory": { "model": "advancedrocketry:models/advrocketmotor.obj", "texture": "advancedrocketry:textures/models/advcombustion"} + "facing=north": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90 }, + "facing=south": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90, "y": 180 }, + "facing=west": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90, "y": 270 }, + "facing=east": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 90, "y": 90 }, + "facing=up": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion", "x": 180 }, + "facing=down": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion" }, + "inventory": { "model": "advancedrocketry:models/advrocket.obj", "texture": "advancedrocketry:textures/models/advcombustion"} } } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/bipropellantfueltank.json b/src/main/resources/assets/advancedrocketry/blockstates/bipropellantfueltank.json index ad2fd5453..a9dcfb8c9 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/bipropellantfueltank.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/bipropellantfueltank.json @@ -6,14 +6,32 @@ "transform": "forge:default-block" }, "variants": { - "tankstates=top": { "model": "advancedrocketry:models/toptank.obj" }, - "tankstates=middle": { "model": "advancedrocketry:models/middletank.obj" }, - "tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj" }, "inventory": { "model": "advancedrocketry:models/middletank.obj", "textures": { "layer0": "advancedrocketry:textures/models/tank" } - } + }, + "facing=north,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90 }, + "facing=south,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj"}, + "facing=down,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj"}, + + "facing=north,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90 }, + "facing=south,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=top": { "model": "advancedrocketry:models/toptank.obj"}, + "facing=down,tankstates=top": { "model": "advancedrocketry:models/toptank.obj"}, + + "facing=north,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90 }, + "facing=south,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj"}, + "facing=down,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj"} + } } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/bipropellantrocketmotor.json b/src/main/resources/assets/advancedrocketry/blockstates/bipropellantrocketmotor.json index 3f744738c..36bea8b6a 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/bipropellantrocketmotor.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/bipropellantrocketmotor.json @@ -4,18 +4,18 @@ "textures": { "#None": "advancedrocketry:/models/bipropellantcombustion" }, - "model": "advancedrocketry:models/bipropellantrocketmotor.obj", + "model": "advancedrocketry:models/bipropellantrocket.obj", "transform": "forge:default-block" }, "variants": { - "facing=north": { "model": "advancedrocketry:models/bipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90 }, - "facing=south": { "model": "advancedrocketry:models/bipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90, "y": 180 }, - "facing=west": { "model": "advancedrocketry:models/bipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90, "y": 270 }, - "facing=east": { "model": "advancedrocketry:models/bipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90, "y": 90 }, - "facing=up": { "model": "advancedrocketry:models/bipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 180 }, - "facing=down": { "model": "advancedrocketry:models/bipropellantrocketmotor.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png" }, + "facing=north": { "model": "advancedrocketry:models/bipropellantrocket.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90 }, + "facing=south": { "model": "advancedrocketry:models/bipropellantrocket.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90, "y": 180 }, + "facing=west": { "model": "advancedrocketry:models/bipropellantrocket.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90, "y": 270 }, + "facing=east": { "model": "advancedrocketry:models/bipropellantrocket.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 90, "y": 90 }, + "facing=up": { "model": "advancedrocketry:models/bipropellantrocket.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png", "x": 180 }, + "facing=down": { "model": "advancedrocketry:models/bipropellantrocket.obj", "texture": "advancedrocketry:textures/models/bipropellantcombustion.png" }, "inventory": { - "model": "advancedrocketry:models/bipropellantrocketmotor.obj", + "model": "advancedrocketry:models/bipropellantrocket.obj", "textures": { "layer0": "advancedrocketry:textures/models/bipropellantcombustion.png" } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/nuclearfueltank.json b/src/main/resources/assets/advancedrocketry/blockstates/nuclearfueltank.json index ad2fd5453..a9dcfb8c9 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/nuclearfueltank.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/nuclearfueltank.json @@ -6,14 +6,32 @@ "transform": "forge:default-block" }, "variants": { - "tankstates=top": { "model": "advancedrocketry:models/toptank.obj" }, - "tankstates=middle": { "model": "advancedrocketry:models/middletank.obj" }, - "tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj" }, "inventory": { "model": "advancedrocketry:models/middletank.obj", "textures": { "layer0": "advancedrocketry:textures/models/tank" } - } + }, + "facing=north,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90 }, + "facing=south,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj"}, + "facing=down,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj"}, + + "facing=north,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90 }, + "facing=south,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=top": { "model": "advancedrocketry:models/toptank.obj"}, + "facing=down,tankstates=top": { "model": "advancedrocketry:models/toptank.obj"}, + + "facing=north,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90 }, + "facing=south,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj"}, + "facing=down,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj"} + } } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/nuclearrocketmotor.json b/src/main/resources/assets/advancedrocketry/blockstates/nuclearrocketmotor.json index 12ae68144..8b318ce39 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/nuclearrocketmotor.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/nuclearrocketmotor.json @@ -4,18 +4,18 @@ "textures": { "#None": "advancedrocketry:/models/nuclearcombustion" }, - "model": "advancedrocketry:models/bipropellantrocketmotor.obj", + "model": "advancedrocketry:models/nuclearrocket.obj", "transform": "forge:default-block" }, "variants": { - "facing=north": { "model": "advancedrocketry:models/nuclearrocketmotor.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90 }, - "facing=south": { "model": "advancedrocketry:models/nuclearrocketmotor.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90, "y": 180 }, - "facing=west": { "model": "advancedrocketry:models/nuclearrocketmotor.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90, "y": 270 }, - "facing=east": { "model": "advancedrocketry:models/nuclearrocketmotor.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90, "y": 90 }, - "facing=up": { "model": "advancedrocketry:models/nuclearrocketmotor.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 180 }, - "facing=down": { "model": "advancedrocketry:models/nuclearrocketmotor.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png" }, + "facing=north": { "model": "advancedrocketry:models/nuclearrocket.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90 }, + "facing=south": { "model": "advancedrocketry:models/nuclearrocket.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90, "y": 180 }, + "facing=west": { "model": "advancedrocketry:models/nuclearrocket.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90, "y": 270 }, + "facing=east": { "model": "advancedrocketry:models/nuclearrocket.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 90, "y": 90 }, + "facing=up": { "model": "advancedrocketry:models/nuclearrocket.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png", "x": 180 }, + "facing=down": { "model": "advancedrocketry:models/nuclearrocket.obj", "texture": "advancedrocketry:textures/models/nuclearcombustion.png" }, "inventory": { - "model": "advancedrocketry:models/bipropellantrocketmotor.obj", + "model": "advancedrocketry:models/nuclearrocket.obj", "textures": { "layer0": "advancedrocketry:textures/models/nuclearcombustion.png" } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/oxidizerfueltank.json b/src/main/resources/assets/advancedrocketry/blockstates/oxidizerfueltank.json index ad2fd5453..a9dcfb8c9 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/oxidizerfueltank.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/oxidizerfueltank.json @@ -6,14 +6,32 @@ "transform": "forge:default-block" }, "variants": { - "tankstates=top": { "model": "advancedrocketry:models/toptank.obj" }, - "tankstates=middle": { "model": "advancedrocketry:models/middletank.obj" }, - "tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj" }, "inventory": { "model": "advancedrocketry:models/middletank.obj", "textures": { "layer0": "advancedrocketry:textures/models/tank" } - } + }, + "facing=north,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90 }, + "facing=south,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj"}, + "facing=down,tankstates=middle": { "model": "advancedrocketry:models/middletank.obj"}, + + "facing=north,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90 }, + "facing=south,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=top": { "model": "advancedrocketry:models/toptank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=top": { "model": "advancedrocketry:models/toptank.obj"}, + "facing=down,tankstates=top": { "model": "advancedrocketry:models/toptank.obj"}, + + "facing=north,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90 }, + "facing=south,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 180 }, + "facing=west,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 270 }, + "facing=east,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj", "x": 90, "y": 90 }, + "facing=up,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj"}, + "facing=down,tankstates=bottom": { "model": "advancedrocketry:models/bottomtank.obj"} + } } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/rocketmotor.json b/src/main/resources/assets/advancedrocketry/blockstates/rocketmotor.json index d41bf7e67..a9acbbecc 100644 --- a/src/main/resources/assets/advancedrocketry/blockstates/rocketmotor.json +++ b/src/main/resources/assets/advancedrocketry/blockstates/rocketmotor.json @@ -4,18 +4,18 @@ "textures": { "#None": "advancedrocketry:/models/combustion" }, - "model": "advancedrocketry:models/rocketmotor.obj", + "model": "advancedrocketry:models/rocket.obj", "transform": "forge:default-block" }, "variants": { - "facing=north": { "model": "advancedrocketry:models/rocketmotor.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90 }, - "facing=south": { "model": "advancedrocketry:models/rocketmotor.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90, "y": 180 }, - "facing=west": { "model": "advancedrocketry:models/rocketmotor.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90, "y": 270 }, - "facing=east": { "model": "advancedrocketry:models/rocketmotor.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90, "y": 90 }, - "facing=up": { "model": "advancedrocketry:models/rocketmotor.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 180 }, - "facing=down": { "model": "advancedrocketry:models/rocketmotor.obj", "texture": "advancedrocketry:textures/models/combustion.png" }, + "facing=north": { "model": "advancedrocketry:models/rocket.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90 }, + "facing=south": { "model": "advancedrocketry:models/rocket.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90, "y": 180 }, + "facing=west": { "model": "advancedrocketry:models/rocket.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90, "y": 270 }, + "facing=east": { "model": "advancedrocketry:models/rocket.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 90, "y": 90 }, + "facing=up": { "model": "advancedrocketry:models/rocket.obj", "texture": "advancedrocketry:textures/models/combustion.png", "x": 180 }, + "facing=down": { "model": "advancedrocketry:models/rocket.obj", "texture": "advancedrocketry:textures/models/combustion.png" }, "inventory": { - "model": "advancedrocketry:models/rocketmotor.obj", + "model": "advancedrocketry:models/rocket.obj", "textures": { "layer0": "advancedrocketry:textures/models/combustion.png" } diff --git a/src/main/resources/assets/advancedrocketry/blockstates/servicemonitor.json b/src/main/resources/assets/advancedrocketry/blockstates/servicemonitor.json new file mode 100644 index 000000000..939ed19e6 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/blockstates/servicemonitor.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "transform": "forge:default-block", + "model": "minecraft:orientable", + "textures": { + "top": "libvulpes:blocks/machinegeneric", + "front": "advancedrocketry:blocks/servicemachine", + "side": "libvulpes:blocks/machinegeneric" + } + }, + "variants": { + "normal": [{}], + "inventory" : [{}] + } +} diff --git a/src/main/resources/assets/advancedrocketry/blockstates/servicestation.json b/src/main/resources/assets/advancedrocketry/blockstates/servicestation.json new file mode 100644 index 000000000..42b0e7fbe --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/blockstates/servicestation.json @@ -0,0 +1,39 @@ +{ + "forge_marker": 1, + "defaults": { + "transform": "forge:default-block", + "model": "minecraft:orientable", + "textures": { + "top": "libvulpes:blocks/machinegeneric", + "front": "advancedrocketry:blocks/servicemachine", + "side": "libvulpes:blocks/machinegeneric" + } + }, + "variants": { + "facing=north,state=false": [{}], + "facing=south,state=false": { "model": "minecraft:orientable", "y": 180}, + "facing=west,state=false": { "model": "minecraft:orientable", "y": 270 }, + "facing=east,state=false": { "model": "minecraft:orientable", "y": 90 }, + "facing=north,state=true": { "model": "minecraft:orientable", "y": 0, + "textures": { + "front": "advancedrocketry:blocks/servicemachine_active_1" + } + }, + "facing=south,state=true": { "model": "minecraft:orientable", "y": 180, + "textures": { + "front": "advancedrocketry:blocks/servicemachine_active_2" + } + }, + "facing=west,state=true": { "model": "minecraft:orientable", "y": 270, + "textures": { + "front": "advancedrocketry:blocks/servicemachine_active_3" + } + }, + "facing=east,state=true": { "model": "minecraft:orientable", "y": 90, + "textures": { + "front": "advancedrocketry:blocks/servicemachine_active_4" + } + }, + "inventory" : [{}] + } +} diff --git a/src/main/resources/assets/advancedrocketry/lang/en_US.lang b/src/main/resources/assets/advancedrocketry/lang/en_US.lang index 07d489330..9c050be22 100644 --- a/src/main/resources/assets/advancedrocketry/lang/en_US.lang +++ b/src/main/resources/assets/advancedrocketry/lang/en_US.lang @@ -16,6 +16,7 @@ entity.hovercraft.name=Hovercraft tile.landingPad.name=Landing Pad tile.seat.name=Seat tile.pad.name=Launch Pad +tile.servicemonitor.name=Service monitor tile.structuretower.name=Structure Tower tile.rocketAssembler.name=Rocket Assembling Machine tile.turf.name=Moon Turf @@ -425,6 +426,16 @@ msg.itemplanetidchip.stationid=Station Id: msg.itemplanetidchip.artifacts=Artifacts: msg.vent.trace=Oxygen Trace +msg.serviceStation.destroyProbNA=Destroy probability: N/A +msg.serviceStation.destroyProb=Destroy probability +msg.serviceStation.serviceProgress=Service progress +msg.serviceStation.serviceProgressNA=Service progress: N/A +msg.serviceStation.wornMotorsText=Engines +msg.serviceStation.wornSeatsText=Seats +msg.serviceStation.wornTanksText=Tanks +msg.serviceStation.assemblerScan=Scan for assemblers +msg.serviceStation.link=You program the linker with the service station at + msg.itemsatellite.pwr=Power Storage: msg.itemsatellite.nopwr=No Power Storage msg.itemsatellite.pwrgen=Power Generation: @@ -433,6 +444,11 @@ msg.itemsatellite.microwavestatus=Collecting Power msg.itemsatellite.data=Data Storage: msg.itemsatellite.nodata=No Data Storage! msg.itemsatellite.empty=Empty Chassis +msg.itemsatellite.weight=Chassis weight: +msg.itemsatellite.noweight=Error in weight calculation + +msg.brokenstage.text=Destruction stage + msg.itemsatchip.id=ID: msg.itemsatchip.planet=Planet: msg.itemsatchip.planetunk=Planet: Unknown diff --git a/src/main/resources/assets/advancedrocketry/lang/ru_RU.lang b/src/main/resources/assets/advancedrocketry/lang/ru_RU.lang index eacf1b5c5..dfdbbb0db 100644 --- a/src/main/resources/assets/advancedrocketry/lang/ru_RU.lang +++ b/src/main/resources/assets/advancedrocketry/lang/ru_RU.lang @@ -7,6 +7,8 @@ entity.advancedRocketry.rocket.name=Ракета entity.rocket.name=Ракета tile.landingPad.name=Посадочная площадка +tile.serviceStation.name=Станция техобслуживания +tile.servicemonitor.name=Монитор состояния tile.seat.name=Сиденье tile.pad.name=Стартовая площадка tile.structuretower.name=Структурная башня @@ -180,6 +182,7 @@ container.observatory=Обсерватория container.satellite=Отсек для спутника container.monitoringstation=Станция мониторинга container.satelliteMonitor=Спутниковый терминал +container.servicestation=Станция техобслуживания enchantment.spaceBreathing=Герметичная изоляция @@ -265,6 +268,17 @@ msg.fuelingStation.link=Вы подключили частотный связы msg.monitoringStation.missionProgressNA=Прогресс миссии: Н/Д msg.monitoringStation.link=Вы подключили частотный связыватель к станции мониторинга на msg.monitoringStation.progress=Прогресс: + +msg.serviceStation.destroyProbNA=Вероятность разрушения: Н/Д +msg.serviceStation.destroyProb=Вероятность разрушения +msg.serviceStation.serviceProgress=Прогресс обслуживания +msg.serviceStation.serviceProgressNA=Прогресс обслуживания: Н/Д +msg.serviceStation.wornMotorsText=Двигатели +msg.serviceStation.wornSeatsText=Сиденья +msg.serviceStation.wornTanksText=Резервуары +msg.serviceStation.assemblerScan=Сканировать сборщики +msg.serviceStation.link=Вы подключили частотный связыватель к станции техобслуживания на + msg.guidanceComputerHatch.loadingState=Состояние загрузки: msg.guidanceComputerHatch.ejectonlanding=Автоматический выброс при посадке msg.guidanceComputerHatch.ejectonsatlanding=Разрешить выброс спутниковых чипов @@ -384,6 +398,11 @@ msg.itemsatellite.nopwrgen=Энергия не генерируется! msg.itemsatellite.data=Хранилище данных: msg.itemsatellite.nodata=Нет хранилища данных! msg.itemsatellite.empty=Пустое шасси +msg.itemsatellite.weight=Масса спутника: +msg.itemsatellite.noweight=Ошибка в подсчёте массы + +msg.brokenstage.text=Стадия повреждений + msg.itemsatchip.id=ID: msg.itemsatchip.planet=Планета: msg.itemsatchip.planetunk=Планета: Неизвестно diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocketmotor.mtl b/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocket.mtl similarity index 52% rename from src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocketmotor.mtl rename to src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocket.mtl index 84466e27b..250c3c6ff 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocketmotor.mtl +++ b/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocket.mtl @@ -2,4 +2,4 @@ # Material Count: 1 newmtl Material -map_Kd advancedrocketry:models/advbipropellantcombustion +map_Kd advancedrocketry:models/advbipropellantrocket diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocketmotor.obj b/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocket.obj similarity index 99% rename from src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocketmotor.obj rename to src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocket.obj index bb2d98a50..e7a2a2b56 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocketmotor.obj +++ b/src/main/resources/assets/advancedrocketry/models/block/models/advbipropellantrocket.obj @@ -1,6 +1,6 @@ # Blender v2.78 (sub 0) OBJ File: '' # www.blender.org -mtllib advbipropellantrocketmotor.mtl +mtllib advbipropellantrocket.mtl o Material v 0.050000 0.760000 0.400000 v 0.093301 0.577936 0.425000 diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/advrocketmotor.mtl b/src/main/resources/assets/advancedrocketry/models/block/models/advrocket.mtl similarity index 58% rename from src/main/resources/assets/advancedrocketry/models/block/models/advrocketmotor.mtl rename to src/main/resources/assets/advancedrocketry/models/block/models/advrocket.mtl index afa57a192..9e0eaaefc 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/advrocketmotor.mtl +++ b/src/main/resources/assets/advancedrocketry/models/block/models/advrocket.mtl @@ -2,4 +2,4 @@ # Material Count: 1 newmtl Material -map_Kd advancedrocketry:models/advcombustion +map_Kd advancedrocketry:models/advrocket diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/advrocketmotor.obj b/src/main/resources/assets/advancedrocketry/models/block/models/advrocket.obj similarity index 99% rename from src/main/resources/assets/advancedrocketry/models/block/models/advrocketmotor.obj rename to src/main/resources/assets/advancedrocketry/models/block/models/advrocket.obj index 8def6833c..8ed8c0f4b 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/advrocketmotor.obj +++ b/src/main/resources/assets/advancedrocketry/models/block/models/advrocket.obj @@ -1,6 +1,6 @@ # Blender v2.78 (sub 0) OBJ File: '' # www.blender.org -mtllib advrocketmotor.mtl +mtllib advrocket.mtl o Material v 0.050000 0.760000 0.400000 v 0.093301 0.577936 0.425000 diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocketmotor.mtl b/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocket.mtl similarity index 58% rename from src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocketmotor.mtl rename to src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocket.mtl index 9c1dd0767..908e4affa 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocketmotor.mtl +++ b/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocket.mtl @@ -2,4 +2,4 @@ # Material Count: 1 newmtl Material -map_Kd advancedrocketry:models/bipropellantcombustion +map_Kd advancedrocketry:models/bipropellantrocket diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocketmotor.obj b/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocket.obj similarity index 99% rename from src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocketmotor.obj rename to src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocket.obj index 3a085169d..c8314220b 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocketmotor.obj +++ b/src/main/resources/assets/advancedrocketry/models/block/models/bipropellantrocket.obj @@ -1,6 +1,6 @@ # Blender v2.77 (sub 0) OBJ File: 'combustion.blend' # www.blender.org -mtllib bipropellantrocketmotor.mtl +mtllib bipropellantrocket.mtl o rocketmotor v 0.500000 0.456373 0.220000 v 0.302010 0.456373 0.302010 diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.mtl b/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocket.mtl similarity index 61% rename from src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.mtl rename to src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocket.mtl index e9a9666f8..5c49b9236 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.mtl +++ b/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocket.mtl @@ -2,4 +2,4 @@ # Material Count: 2 newmtl Material -map_Kd advancedrocketry:models/nuclearengine +map_Kd advancedrocketry:models/nuclearrocket diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.obj b/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocket.obj similarity index 99% rename from src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.obj rename to src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocket.obj index 66c8741c8..5e345e18b 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.obj +++ b/src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocket.obj @@ -1,6 +1,6 @@ # Blender v2.79 (sub 0) OBJ File: 'rocket.blend' # www.blender.org -mtllib nuclearrocketmotor.mtl +mtllib nuclearrocket.mtl o rocketmotor v 0.302010 0.456373 0.302010 v 0.500000 0.005000 -0.000500 diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/rocketmotor.mtl b/src/main/resources/assets/advancedrocketry/models/block/models/rocket.mtl similarity index 64% rename from src/main/resources/assets/advancedrocketry/models/block/models/rocketmotor.mtl rename to src/main/resources/assets/advancedrocketry/models/block/models/rocket.mtl index ff7f7bf57..b192a1f1f 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/rocketmotor.mtl +++ b/src/main/resources/assets/advancedrocketry/models/block/models/rocket.mtl @@ -2,4 +2,4 @@ # Material Count: 1 newmtl Material -map_Kd advancedrocketry:models/combustion +map_Kd advancedrocketry:models/rocket diff --git a/src/main/resources/assets/advancedrocketry/models/block/models/rocketmotor.obj b/src/main/resources/assets/advancedrocketry/models/block/models/rocket.obj similarity index 99% rename from src/main/resources/assets/advancedrocketry/models/block/models/rocketmotor.obj rename to src/main/resources/assets/advancedrocketry/models/block/models/rocket.obj index ebe6651f0..64ca9614c 100644 --- a/src/main/resources/assets/advancedrocketry/models/block/models/rocketmotor.obj +++ b/src/main/resources/assets/advancedrocketry/models/block/models/rocket.obj @@ -1,6 +1,6 @@ # Blender v2.77 (sub 0) OBJ File: 'combustion.blend' # www.blender.org -mtllib rocketmotor.mtl +mtllib rocket.mtl o rocketmotor v 0.500000 0.456373 0.220000 v 0.302010 0.456373 0.302010 diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_1.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_1.json new file mode 100644 index 000000000..d83512cb3 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_1.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 1 + } + ], + "time": 900, + "energy": 100, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_2.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_2.json new file mode 100644 index 000000000..49dd453d8 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_2.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 2 + } + ], + "time": 900, + "energy": 200, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_3.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_3.json new file mode 100644 index 000000000..9d896d3c4 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_3.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 3 + } + ], + "time": 900, + "energy": 300, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_4.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_4.json new file mode 100644 index 000000000..126633b4d --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_4.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 4 + } + ], + "time": 1800, + "energy": 400, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_5.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_5.json new file mode 100644 index 000000000..65228913a --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_5.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 4 + } + ], + "time": 1800, + "energy": 500, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_6.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_6.json new file mode 100644 index 000000000..637ff5f24 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_6.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 4 + } + ], + "time": 1800, + "energy": 600, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_7.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_7.json new file mode 100644 index 000000000..6028086a3 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_7.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 7 + } + ], + "time": 2700, + "energy": 700, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_8.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_8.json new file mode 100644 index 000000000..f6b17f9c4 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_8.json @@ -0,0 +1,27 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 8 + } + ], + "time": 2700, + "energy": 800, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_9.json b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_9.json new file mode 100644 index 000000000..1b3ad83f0 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advbipropellantengine_repair_9.json @@ -0,0 +1,27 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "data": 9 + } + ], + "time": 2700, + "energy": 900, + "itemresults": + { + "item": "advancedrocketry:advbipropellantrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_1.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_1.json new file mode 100644 index 000000000..d9d39a83d --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_1.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 1 + } + ], + "time": 900, + "energy": 100, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_2.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_2.json new file mode 100644 index 000000000..75c0f7321 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_2.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 2 + } + ], + "time": 900, + "energy": 200, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_3.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_3.json new file mode 100644 index 000000000..6ef69df73 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_3.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 3 + } + ], + "time": 900, + "energy": 300, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_4.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_4.json new file mode 100644 index 000000000..f04a5a2cd --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_4.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 4 + } + ], + "time": 1800, + "energy": 400, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_5.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_5.json new file mode 100644 index 000000000..68169d40c --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_5.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 5 + } + ], + "time": 1800, + "energy": 500, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_6.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_6.json new file mode 100644 index 000000000..196ffd1ab --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_6.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 6 + } + ], + "time": 1800, + "energy": 600, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_7.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_7.json new file mode 100644 index 000000000..f7db81603 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_7.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 7 + } + ], + "time": 2700, + "energy": 700, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_8.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_8.json new file mode 100644 index 000000000..55f3a66bf --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_8.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 8 + } + ], + "time": 2700, + "energy": 900, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_9.json b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_9.json new file mode 100644 index 000000000..97899a05e --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/advengine_repair_9.json @@ -0,0 +1,27 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "item": "advancedrocketry:advrocketmotor", + "data": 9 + } + ], + "time": 2700, + "energy": 900, + "itemresults": + { + "item": "advancedrocketry:advrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_1.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_1.json new file mode 100644 index 000000000..9e1cd4453 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_1.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 1 + } + ], + "time": 900, + "energy": 100, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_2.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_2.json new file mode 100644 index 000000000..371c00ecd --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_2.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 2 + } + ], + "time": 900, + "energy": 200, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_3.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_3.json new file mode 100644 index 000000000..fd9dfa1f4 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_3.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 3 + } + ], + "time": 900, + "energy": 300, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_4.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_4.json new file mode 100644 index 000000000..94b45834a --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_4.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitanium" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 4 + } + ], + "time": 1800, + "energy": 400, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_5.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_5.json new file mode 100644 index 000000000..31457d18a --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_5.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitanium" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 5 + } + ], + "time": 1800, + "energy": 500, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_6.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_6.json new file mode 100644 index 000000000..0b4450bc3 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_6.json @@ -0,0 +1,25 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel" + }, + { + "type": "forge:ore_dict", + "ore": "plateTitanium" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 6 + } + ], + "time": 1800, + "energy": 600, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_7.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_7.json new file mode 100644 index 000000000..08cea1ca8 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_7.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitanium" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 7 + } + ], + "time": 2700, + "energy": 700, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_8.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_8.json new file mode 100644 index 000000000..3e0bd273d --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_8.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitanium" + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 7 + } + ], + "time": 2700, + "energy": 800, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/engine_repair_9.json b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_9.json new file mode 100644 index 000000000..f56951a72 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/engine_repair_9.json @@ -0,0 +1,27 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotSteel", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitanium", + "count": 2 + }, + { + "item": "advancedrocketry:rocketmotor", + "data": 7 + } + ], + "time": 2700, + "energy": 900, + "itemresults": + { + "item": "advancedrocketry:rocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine.json index b29197cbd..6f27d0805 100644 --- a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine.json +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine.json @@ -20,7 +20,8 @@ }, "d": { "type": "forge:ore_dict", - "ore": "gemDilithium"} + "ore": "gemDilithium" + } }, "result": { diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_1.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_1.json new file mode 100644 index 000000000..76b582ff6 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_1.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 1 + } + ], + "time": 2000, + "energy": 100, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_2.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_2.json new file mode 100644 index 000000000..394decbae --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_2.json @@ -0,0 +1,21 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium" + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 2 + } + ], + "time": 2000, + "energy": 200, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_3.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_3.json new file mode 100644 index 000000000..85506af06 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_3.json @@ -0,0 +1,22 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 3 + } + ], + "time": 2000, + "energy": 300, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_4.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_4.json new file mode 100644 index 000000000..d85324b67 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_4.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 4 + } + ], + "time": 3000, + "energy": 400, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_5.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_5.json new file mode 100644 index 000000000..d2514eee3 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_5.json @@ -0,0 +1,26 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide" + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 5 + } + ], + "time": 3000, + "energy": 500, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_6.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_6.json new file mode 100644 index 000000000..6a5a18478 --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_6.json @@ -0,0 +1,27 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 4 + } + ], + "time": 3000, + "energy": 600, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_7.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_7.json new file mode 100644 index 000000000..a4e6d86ea --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_7.json @@ -0,0 +1,27 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 7 + } + ], + "time": 4000, + "energy": 700, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_8.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_8.json new file mode 100644 index 000000000..3269646ae --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_8.json @@ -0,0 +1,31 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "gemDilithium" + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 8 + } + ], + "time": 4000, + "energy": 800, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_9.json b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_9.json new file mode 100644 index 000000000..a0b790dfc --- /dev/null +++ b/src/main/resources/assets/advancedrocketry/recipes/nuclearengine_repair_9.json @@ -0,0 +1,31 @@ +{ + "type": "advancedrocketry:precisionassembler", + "itemingredients": + [ + { + "type": "forge:ore_dict", + "ore": "ingotTitaniumIridium", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "plateTitaniumAluminide", + "count": 2 + }, + { + "type": "forge:ore_dict", + "ore": "gemDilithium" + }, + { + "item": "advancedrocketry:nuclearrocketmotor", + "data": 9 + } + ], + "time": 4000, + "energy": 900, + "itemresults": + { + "item": "advancedrocketry:nuclearrocketmotor", + "count": 1 + } +} diff --git a/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine.png b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine.png new file mode 100644 index 000000000..cb8dcf802 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_1.png b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_1.png new file mode 100644 index 000000000..a91042c75 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_2.png b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_2.png new file mode 100644 index 000000000..1a3ceba4c Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_3.png b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_3.png new file mode 100644 index 000000000..e541dde78 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_3.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_4.png b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_4.png new file mode 100644 index 000000000..6c34c7949 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/blocks/servicemachine_active_4.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantcombustion.png b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantcombustion.png deleted file mode 100644 index aa01bbb10..000000000 Binary files a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantcombustion.png and /dev/null differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket.png b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket.png new file mode 100644 index 000000000..86a9aefe1 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_0.png b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_0.png new file mode 100644 index 000000000..b6e6db9f1 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_0.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_1.png b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_1.png new file mode 100644 index 000000000..9c46e2794 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_2.png b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_2.png new file mode 100644 index 000000000..f5dbc7f73 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_3.png b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_3.png new file mode 100644 index 000000000..2b9480900 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advbipropellantrocket_3.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advcombustion.png b/src/main/resources/assets/advancedrocketry/textures/models/advcombustion.png deleted file mode 100644 index 22d995ec5..000000000 Binary files a/src/main/resources/assets/advancedrocketry/textures/models/advcombustion.png and /dev/null differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advrocket.png b/src/main/resources/assets/advancedrocketry/textures/models/advrocket.png new file mode 100644 index 000000000..479f8327c Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advrocket.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advrocket_0.png b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_0.png new file mode 100644 index 000000000..2fbbbed0b Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_0.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advrocket_1.png b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_1.png new file mode 100644 index 000000000..f54c5c75e Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advrocket_2.png b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_2.png new file mode 100644 index 000000000..c45946c85 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/advrocket_3.png b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_3.png new file mode 100644 index 000000000..34e237e11 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/advrocket_3.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantcombustion.png b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantcombustion.png deleted file mode 100644 index aa01bbb10..000000000 Binary files a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantcombustion.png and /dev/null differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket.png b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket.png new file mode 100644 index 000000000..86a9aefe1 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_0.png b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_0.png new file mode 100644 index 000000000..97ecac206 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_0.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_1.png b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_1.png new file mode 100644 index 000000000..58cf48378 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_2.png b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_2.png new file mode 100644 index 000000000..ec7a5225b Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_3.png b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_3.png new file mode 100644 index 000000000..0718d1baf Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/bipropellantrocket_3.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/combustion.png b/src/main/resources/assets/advancedrocketry/textures/models/combustion.png deleted file mode 100644 index 22d995ec5..000000000 Binary files a/src/main/resources/assets/advancedrocketry/textures/models/combustion.png and /dev/null differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/nuclearengine.png b/src/main/resources/assets/advancedrocketry/textures/models/nuclearengine.png deleted file mode 100644 index e9db55903..000000000 Binary files a/src/main/resources/assets/advancedrocketry/textures/models/nuclearengine.png and /dev/null differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket.png b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket.png new file mode 100644 index 000000000..ad17768a9 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_0.png b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_0.png new file mode 100644 index 000000000..6619d808f Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_0.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_1.png b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_1.png new file mode 100644 index 000000000..60d1874b0 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_2.png b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_2.png new file mode 100644 index 000000000..8b60cb8eb Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_3.png b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_3.png new file mode 100644 index 000000000..a374ac44d Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/nuclearrocket_3.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/rocket.png b/src/main/resources/assets/advancedrocketry/textures/models/rocket.png new file mode 100644 index 000000000..dbae1fbc0 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/rocket.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/rocket_0.png b/src/main/resources/assets/advancedrocketry/textures/models/rocket_0.png new file mode 100644 index 000000000..021874e43 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/rocket_0.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/rocket_1.png b/src/main/resources/assets/advancedrocketry/textures/models/rocket_1.png new file mode 100644 index 000000000..018d13e03 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/rocket_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/rocket_2.png b/src/main/resources/assets/advancedrocketry/textures/models/rocket_2.png new file mode 100644 index 000000000..951302374 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/rocket_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/rocket_3.png b/src/main/resources/assets/advancedrocketry/textures/models/rocket_3.png new file mode 100644 index 000000000..de572cc32 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/rocket_3.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/tank_0.png b/src/main/resources/assets/advancedrocketry/textures/models/tank_0.png new file mode 100644 index 000000000..4e715f296 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/tank_0.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/tank_1.png b/src/main/resources/assets/advancedrocketry/textures/models/tank_1.png new file mode 100644 index 000000000..fd781cb93 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/tank_1.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/tank_2.png b/src/main/resources/assets/advancedrocketry/textures/models/tank_2.png new file mode 100644 index 000000000..66e7bdb70 Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/tank_2.png differ diff --git a/src/main/resources/assets/advancedrocketry/textures/models/tank_3.png b/src/main/resources/assets/advancedrocketry/textures/models/tank_3.png new file mode 100644 index 000000000..d1a2152fe Binary files /dev/null and b/src/main/resources/assets/advancedrocketry/textures/models/tank_3.png differ