mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-21 04:32:12 +00:00
Now structure of Energy Storage is configurable.
This commit is contained in:
1 parent
dcf8ea9983
commit
95b8a64ace
5 files changed
+86
-17
No files matched your search
@@ -87,6 +87,7 @@ public class CommonProxy {
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent event) {
|
||||
BalanceConfigHandler.finishLoading();
|
||||
CraftingHandler.init();
|
||||
registerGuiHandeler();
|
||||
registerWorldGen();
|
||||
|
||||
+19
-10
@@ -1,9 +1,14 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks.multiblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.brandon3055.brandonscore.common.utills.InfoHelper;
|
||||
import com.brandon3055.brandonscore.common.utills.Utills;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.blocks.BlockDE;
|
||||
import com.brandon3055.draconicevolution.common.handler.BalanceConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon;
|
||||
@@ -27,10 +32,6 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 25/07/2014.
|
||||
*/
|
||||
@@ -84,11 +85,19 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock {
|
||||
if (meta == 0)
|
||||
return Item.getItemFromBlock(ModBlocks.draconiumBlock);
|
||||
else if (meta == 1)
|
||||
return Item.getItemFromBlock(Blocks.redstone_block);
|
||||
return Item.getItemFromBlock(BalanceConfigHandler.energyStorageStructureBlock);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata)
|
||||
{
|
||||
if (metadata == 1)
|
||||
{
|
||||
return BalanceConfigHandler.energyStorageStructureBlockMetadata;
|
||||
}
|
||||
return super.damageDropped(metadata);
|
||||
}
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
@@ -149,7 +158,7 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock {
|
||||
if (meta == 0)
|
||||
world.setBlock(x, y, z, ModBlocks.draconiumBlock);
|
||||
else if (meta == 1)
|
||||
world.setBlock(x, y, z, Blocks.redstone_block);
|
||||
world.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,10 +188,10 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock {
|
||||
}
|
||||
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta == 2){
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, x, y, z);
|
||||
@@ -195,7 +204,7 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock {
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
return new ItemStack(ModBlocks.draconiumBlock);
|
||||
else if (world.getBlockMetadata(x, y, z) == 1)
|
||||
return new ItemStack(Blocks.redstone_block);
|
||||
return new ItemStack(BalanceConfigHandler.energyStorageStructureBlock, 1, BalanceConfigHandler.energyStorageStructureBlockMetadata);
|
||||
else
|
||||
return new ItemStack(Blocks.glass);
|
||||
}
|
||||
|
||||
+53
-1
@@ -2,7 +2,12 @@ package com.brandon3055.draconicevolution.common.handler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
public class BalanceConfigHandler
|
||||
{
|
||||
@@ -57,6 +62,8 @@ public class BalanceConfigHandler
|
||||
public static int grinderExternalEnergyBufferSize = 100000;
|
||||
public static int grinderMaxReceive = 32000;
|
||||
public static int grinderEnergyPerKill = 1000;
|
||||
public static Block energyStorageStructureBlock = null;
|
||||
public static int energyStorageStructureBlockMetadata = 0;
|
||||
public static boolean grinderShouldUseLooting = false;
|
||||
private static Configuration config;
|
||||
public static void init(File modConfigurationDirectory)
|
||||
@@ -65,9 +72,30 @@ public class BalanceConfigHandler
|
||||
{
|
||||
config = new Configuration(new File(modConfigurationDirectory, "DraconicEvolution.Balance.cfg"));
|
||||
config.load();
|
||||
config.setCategoryRequiresMcRestart("tweaks", true);
|
||||
syncConfig();
|
||||
}
|
||||
}
|
||||
// This method should be loaded after all mods add blocks => after pre-init
|
||||
public static void finishLoading()
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
energyStorageStructureBlock =
|
||||
getBlock("tweaks.machines", "Multiblock Energy Storage: Main block of structure", Blocks.redstone_block,
|
||||
"WARNING! Changing of this value will replace blocks of all existing Energy Storage Multiblocks!");
|
||||
energyStorageStructureBlockMetadata =
|
||||
getInteger("tweaks.machines", "Multiblock Energy Storage: Metadata of main block of structure",
|
||||
energyStorageStructureBlockMetadata,
|
||||
"WARNING! Changing of this value will replace blocks of all existing Energy Storage " +
|
||||
"Multiblocks!");
|
||||
if (config.hasChanged())
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
private static void syncConfig()
|
||||
{
|
||||
wyvernArmorBaseStorage =
|
||||
@@ -209,6 +237,26 @@ public class BalanceConfigHandler
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
private static Block getBlock(String category, String propertyName, Block defaultValue, String comment)
|
||||
{
|
||||
String defaultName = Block.blockRegistry.getNameForObject(defaultValue);
|
||||
Property property = config.get(category, propertyName, defaultName, comment);
|
||||
String value = property.getString();
|
||||
if (value == null || !value.contains(":"))
|
||||
{
|
||||
property.set(defaultName);
|
||||
return defaultValue;
|
||||
}
|
||||
String modId = value.split(":")[0];
|
||||
String name = value.split(":")[1];
|
||||
Block block = GameRegistry.findBlock(modId, name);
|
||||
if (block == null || block instanceof ITileEntityProvider)
|
||||
{
|
||||
property.set(defaultName);
|
||||
return defaultValue;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
private static boolean getBoolean(String category, String propertyName, boolean defaultValue)
|
||||
{
|
||||
return config.get(category, propertyName, defaultValue).getBoolean(defaultValue);
|
||||
@@ -217,9 +265,13 @@ public class BalanceConfigHandler
|
||||
{
|
||||
return config.get(categoty, propertyName, defaultValue).getInt(defaultValue);
|
||||
}
|
||||
private static int getInteger(String categoty, String propertyName, int defaultValue, String comment)
|
||||
{
|
||||
return config.get(categoty, propertyName, defaultValue, comment).getInt(defaultValue);
|
||||
}
|
||||
private static long getLong(String category, String propertyName, long defaultValue)
|
||||
{
|
||||
return (long) config.get(category, propertyName, (double) defaultValue, "", 0D, (double) Long.MAX_VALUE)
|
||||
.getDouble((long) defaultValue);
|
||||
.getDouble((double) defaultValue);
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -97,8 +97,12 @@ public class TileEnergyStorageCore extends TileObjectSync {
|
||||
for (int z = zCoord - 1; z <= zCoord + 1; z++) {
|
||||
if (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock)
|
||||
{
|
||||
if (worldObj.getBlockMetadata(x, y, z) == 0) worldObj.setBlock(x, y, z, ModBlocks.draconiumBlock);
|
||||
else if (worldObj.getBlockMetadata(x, y, z) == 1) worldObj.setBlock(x, y, z, Blocks.redstone_block);
|
||||
if (worldObj.getBlockMetadata(x, y, z) == 0) {
|
||||
worldObj.setBlock(x, y, z, ModBlocks.draconiumBlock);
|
||||
}
|
||||
else if (worldObj.getBlockMetadata(x, y, z) == 1) {
|
||||
worldObj.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,9 +548,12 @@ public class TileEnergyStorageCore extends TileObjectSync {
|
||||
private boolean testForOrActivateRedstone(int x, int y, int z, boolean set, boolean activate){
|
||||
if (!activate) {
|
||||
if (set) {
|
||||
worldObj.setBlock(x, y, z, Blocks.redstone_block);
|
||||
worldObj.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3);
|
||||
return true;
|
||||
} else return worldObj.getBlock(x, y, z) == Blocks.redstone_block || (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 1);
|
||||
} else {
|
||||
return (worldObj.getBlock(x, y, z) == BalanceConfigHandler.energyStorageStructureBlock && worldObj.getBlockMetadata(x, y, z) == BalanceConfigHandler.energyStorageStructureBlockMetadata) ||
|
||||
(worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 1);
|
||||
}
|
||||
}else{
|
||||
return activateRedstone(x, y, z);
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
|
||||
import com.brandon3055.draconicevolution.common.handler.BalanceConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -75,6 +75,6 @@ public class TileInvisibleMultiblock extends TileEntity {
|
||||
if (meta == 0)
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.draconiumBlock);
|
||||
else if (meta == 1)
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.redstone_block);
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user