merged with builder branch
This commit is contained in:
commit
ef2980ccc2
10 changed files with 376 additions and 188 deletions
|
@ -29,7 +29,7 @@ if (System.getenv().BUILD_NUMBER)
|
|||
else
|
||||
logger.lifecycle "SETTING BUILDNUMBER TO 0"
|
||||
|
||||
version = "5.0.1"
|
||||
version = "5.0.2"
|
||||
group= "com.mod-buildcraft"
|
||||
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
|
||||
|
||||
|
@ -48,7 +48,7 @@ minecraft {
|
|||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'common/buildcraft'
|
||||
srcDir 'common'
|
||||
// exclude 'some exclusion'
|
||||
// include 'some inclusion'
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
BuildCraftCore.mainConfiguration.save();
|
||||
|
||||
laserBlock = new BlockLaser();
|
||||
laserBlock.setBlockName("laserBlock");
|
||||
CoreProxy.proxy.registerBlock(laserBlock);
|
||||
|
||||
assemblyTableBlock = new BlockLaserTable();
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
|
@ -27,6 +28,7 @@ import buildcraft.api.recipes.BuildcraftRecipes;
|
|||
import buildcraft.api.transport.IExtractionHandler;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.BuildCraftConfiguration;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.InterModComms;
|
||||
|
@ -157,6 +159,8 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
// public static Item pipeItemsStipes;
|
||||
public static Item pipeStructureCobblestone;
|
||||
public static int groupItemsTrigger;
|
||||
public static String[] facadeBlacklist;
|
||||
|
||||
public static BCTrigger[] triggerPipe = new BCTrigger[PipeContents.values().length];
|
||||
public static BCTrigger[] triggerPipeWireActive = new BCTrigger[PipeWire.values().length];
|
||||
public static BCTrigger[] triggerPipeWireInactive = new BCTrigger[PipeWire.values().length];
|
||||
|
@ -175,6 +179,7 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
public static BCAction actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW);
|
||||
public IIconProvider pipeIconProvider = new PipeIconProvider();
|
||||
public IIconProvider wireIconProvider = new WireIconProvider();
|
||||
|
||||
@Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
|
||||
|
@ -255,6 +260,9 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
} else
|
||||
excludedFluidBlocks = new String[0];
|
||||
|
||||
filteredBufferBlock = new BlockFilteredBuffer();
|
||||
CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock"));
|
||||
|
||||
PipeManager.registerExtractionHandler(new ExtractionHandler(excludedItemBlocks, excludedFluidBlocks));
|
||||
|
||||
GateExpansions.registerExpansion(GateExpansionPulsar.INSTANCE);
|
||||
|
@ -265,7 +273,38 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
groupItemsTriggerProp.comment = "when reaching this amount of objects in a pipes, items will be automatically grouped";
|
||||
groupItemsTrigger = groupItemsTriggerProp.getInt();
|
||||
|
||||
Property facadeBlacklistProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "facade.blacklist", new String[] {
|
||||
Block.blockRegistry.getNameForObject(Blocks.bedrock),
|
||||
Block.blockRegistry.getNameForObject(Blocks.command_block),
|
||||
Block.blockRegistry.getNameForObject(Blocks.end_portal_frame),
|
||||
Block.blockRegistry.getNameForObject(Blocks.grass),
|
||||
Block.blockRegistry.getNameForObject(Blocks.leaves),
|
||||
Block.blockRegistry.getNameForObject(Blocks.leaves2),
|
||||
Block.blockRegistry.getNameForObject(Blocks.lit_pumpkin),
|
||||
Block.blockRegistry.getNameForObject(Blocks.lit_redstone_lamp),
|
||||
Block.blockRegistry.getNameForObject(Blocks.mob_spawner),
|
||||
Block.blockRegistry.getNameForObject(Blocks.monster_egg),
|
||||
Block.blockRegistry.getNameForObject(Blocks.redstone_lamp),
|
||||
Block.blockRegistry.getNameForObject(Blocks.double_stone_slab),
|
||||
Block.blockRegistry.getNameForObject(Blocks.double_wooden_slab),
|
||||
Block.blockRegistry.getNameForObject(Blocks.sponge),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.architectBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.builderBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.fillerBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.libraryBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.autoWorkbenchBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.floodGateBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.miningWellBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.pumpBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.quarryBlock)),
|
||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)),
|
||||
});
|
||||
|
||||
facadeBlacklistProp.comment = "Blocks listed here will not have facades created. The format is modid:blockname.\nFor mods with a | character, the value needs to be surrounded with quotes.";
|
||||
facadeBlacklist = facadeBlacklistProp.getStringList();
|
||||
|
||||
pipeWaterproof = new ItemBuildCraft(CreativeTabBuildCraft.TIER_2);
|
||||
|
||||
pipeWaterproof.setUnlocalizedName("pipeWaterproof");
|
||||
LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant");
|
||||
CoreProxy.proxy.registerItem(pipeWaterproof);
|
||||
|
@ -438,6 +477,7 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
|
||||
//Facade turning helper
|
||||
GameRegistry.addRecipe(facadeItem.new FacadeRecipe());
|
||||
RecipeSorter.register("facadeTurningHelper", ItemFacade.FacadeRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
||||
|
||||
BuildcraftRecipes.assemblyTable.addRecipe(1000, new ItemStack(plugItem, 8), new ItemStack(pipeStructureCobblestone));
|
||||
}
|
||||
|
|
|
@ -25,4 +25,11 @@ public class BuildCraftConfiguration extends Configuration {
|
|||
super.save();
|
||||
}
|
||||
|
||||
public static String surroundWithQuotes(String stringToSurroundWithQuotes){
|
||||
return String.format("\"%s\"", stringToSurroundWithQuotes);
|
||||
}
|
||||
|
||||
public static String stripSurroundingQuotes(String stringToStripQuotes) {
|
||||
return stringToStripQuotes.replaceAll("^\"|\"$", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft.core;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
@ -26,70 +27,104 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
|||
|
||||
public class InterModComms {
|
||||
|
||||
public static void processIMC(IMCEvent event) {
|
||||
for (IMCMessage m : event.getMessages()) {
|
||||
if ("add-facade".equals(m.key)) {
|
||||
processFacadeIMC(event, m);
|
||||
} else if (m.key.equals("oil-lake-biome")) {
|
||||
processOilLakeBiomeIMC(event, m);
|
||||
} else if (m.key.equals("oil-gen-exclude")) {
|
||||
processOilGenExcludeIMC(event, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void processIMC(IMCEvent event) {
|
||||
for (IMCMessage m : event.getMessages()) {
|
||||
if (m.key.equals("add-facade")) {
|
||||
processAddFacadeIMC(event, m);
|
||||
} else if (m.key.equals("blacklist-facade")) {
|
||||
processBlacklistFacadeIMC(event, m);
|
||||
} else if (m.key.equals("oil-lake-biome")) {
|
||||
processOilLakeBiomeIMC(event, m);
|
||||
} else if (m.key.equals("oil-gen-exclude")) {
|
||||
processOilGenExcludeIMC(event, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void processFacadeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
if (m.isStringMessage()) {
|
||||
Splitter splitter = Splitter.on("@").trimResults();
|
||||
public static void processAddFacadeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
if (m.isStringMessage()) {
|
||||
Splitter splitter = Splitter.on("@").trimResults();
|
||||
|
||||
String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
|
||||
if (array.length != 2) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
Integer blId = Ints.tryParse(array[0]);
|
||||
Integer metaId = Ints.tryParse(array[1]);
|
||||
|
||||
if (blId == null || metaId == null) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
Block block = (Block) Block.blockRegistry.getObjectById(blId);
|
||||
ItemFacade.addFacade(new ItemStack(block, 1, metaId));
|
||||
}
|
||||
}
|
||||
} else if (m.isItemStackMessage()) {
|
||||
ItemFacade.addFacade(m.getItemStackValue());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
|
||||
if (array.length != 2) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
String blockName = array[0];
|
||||
Integer metaId = Ints.tryParse(array[1]);
|
||||
|
||||
}
|
||||
}
|
||||
if (Strings.isNullOrEmpty(blockName)|| metaId == null) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
Block block = (Block) Block.blockRegistry.getObject(blockName);
|
||||
if(block.getRenderType() != 0 && block.getRenderType() != 31) {
|
||||
ItemFacade.addFacade(new ItemStack(block, 1, metaId));
|
||||
} else {
|
||||
logRedundantAddFacadeMessage(m, block.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (m.isItemStackMessage()) {
|
||||
ItemStack modItemStack = m.getItemStackValue();
|
||||
|
||||
public static void processOilLakeBiomeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
String biomeID = m.getStringValue().trim();
|
||||
int id = Integer.valueOf(biomeID);
|
||||
if (id >= BiomeGenBase.getBiomeGenArray().length) {
|
||||
throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.getBiomeGenArray().length);
|
||||
}
|
||||
OilPopulate.INSTANCE.surfaceDepositBiomes.add(id);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
Block block = Block.getBlockFromItem(modItemStack.getItem());
|
||||
if(block != null && block.getRenderType() != 0 && block.getRenderType() != 31) {
|
||||
ItemFacade.addFacade(modItemStack);
|
||||
} else {
|
||||
logRedundantAddFacadeMessage(m, block.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void processOilGenExcludeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
String biomeID = m.getStringValue().trim();
|
||||
int id = Integer.valueOf(biomeID);
|
||||
if (id >= BiomeGenBase.getBiomeGenArray().length) {
|
||||
throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.getBiomeGenArray().length);
|
||||
}
|
||||
OilPopulate.INSTANCE.excludedBiomes.add(id);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
public static void processBlacklistFacadeIMC(IMCEvent event, IMCMessage message){
|
||||
try {
|
||||
if(message.isItemStackMessage()) {
|
||||
ItemStack modItemStack = message.getItemStackValue();
|
||||
|
||||
Block block = Block.getBlockFromItem(modItemStack.getItem());
|
||||
if(block != null) {
|
||||
String blockName = Block.blockRegistry.getNameForObject(block);
|
||||
ItemFacade.blacklistFacade(blockName);
|
||||
}
|
||||
} else {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Invalid blacklist-facade message from mod %s. Send an ItemStackMessage instead.", message.getSender()));
|
||||
}
|
||||
} catch (Throwable _) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void logRedundantAddFacadeMessage(IMCMessage m, String blockName)
|
||||
{
|
||||
Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("%s is trying to add %s a facade that Buildcraft will add later. Facade not added.", m.getSender(), blockName));
|
||||
}
|
||||
|
||||
public static void processOilLakeBiomeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
String biomeID = m.getStringValue().trim();
|
||||
int id = Integer.valueOf(biomeID);
|
||||
if (id >= BiomeGenBase.getBiomeGenArray().length) {
|
||||
throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.getBiomeGenArray().length);
|
||||
}
|
||||
OilPopulate.INSTANCE.surfaceDepositBiomes.add(id);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
|
||||
public static void processOilGenExcludeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
String biomeID = m.getStringValue().trim();
|
||||
int id = Integer.valueOf(biomeID);
|
||||
if (id >= BiomeGenBase.getBiomeGenArray().length) {
|
||||
throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.getBiomeGenArray().length);
|
||||
}
|
||||
OilPopulate.INSTANCE.excludedBiomes.add(id);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
*/
|
||||
package buildcraft.core;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import net.minecraftforge.event.terraingen.TerrainGen;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class SpringPopulate {
|
||||
|
||||
|
@ -28,6 +28,7 @@ public class SpringPopulate {
|
|||
boolean doGen = TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkX, event.hasVillageGenerated, PopulateChunkEvent.Populate.EventType.CUSTOM);
|
||||
|
||||
if (!doGen) {
|
||||
event.setResult(Result.ALLOW);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,15 @@
|
|||
*/
|
||||
package buildcraft.energy.worldgen;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.DESERT;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.FOREST;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.FROZEN;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.WASTELAND;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -24,17 +25,17 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.DESERT;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.FOREST;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.FROZEN;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.WASTELAND;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
|
||||
import net.minecraftforge.event.terraingen.TerrainGen;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class OilPopulate {
|
||||
|
||||
|
@ -65,6 +66,7 @@ public class OilPopulate {
|
|||
boolean doGen = TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkX, event.hasVillageGenerated, EVENT_TYPE);
|
||||
|
||||
if (!doGen) {
|
||||
event.setResult(Result.ALLOW);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -256,7 +258,7 @@ public class OilPopulate {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isReplaceableFluid(World world, int x, int y, int z) {
|
||||
private boolean isReplaceableFluid(World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return (block instanceof BlockFluidBase || block instanceof IFluidBlock) && block.getMaterial() != Material.lava;
|
||||
}
|
||||
|
@ -268,33 +270,33 @@ public class OilPopulate {
|
|||
|
||||
private boolean isReplaceableForLake(World world, BiomeGenBase biome, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
|
||||
if (block == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (block == biome.fillerBlock || block == biome.topBlock) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!block.getMaterial().blocksMovement()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// TODO: The code below doesn't seem to have been replaced by something
|
||||
// in 1.7.2 - to update or remove.
|
||||
//if (block.isGenMineableReplaceable(world, x, y, z, Blocks.stone)) {
|
||||
// return true;
|
||||
//}
|
||||
|
||||
|
||||
if (block instanceof BlockFlower) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!block.isOpaqueCube()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -352,27 +354,27 @@ public class OilPopulate {
|
|||
|
||||
for (; y > 0; --y) {
|
||||
Block block = chunk.getBlock(trimmedX, y, trimmedZ);
|
||||
|
||||
|
||||
if (block == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (block instanceof BlockFluidBase) {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
if (block instanceof IFluidBlock) {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
if (!block.getMaterial().blocksMovement()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (block instanceof BlockFlower) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
return y - 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import buildcraft.core.BlockSpring;
|
||||
import buildcraft.core.BuildCraftConfiguration;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -41,6 +43,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public class ItemFacade extends ItemBuildCraft {
|
||||
|
||||
public final static LinkedList<ItemStack> allFacades = new LinkedList<ItemStack>();
|
||||
public final static LinkedList<String> blacklistedFacades = new LinkedList<String>();
|
||||
|
||||
public ItemFacade() {
|
||||
super(CreativeTabBuildCraft.FACADES);
|
||||
|
@ -62,7 +65,13 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
if (Item.getItemFromBlock(decodedBlock) != null) {
|
||||
name += ": " + CoreProxy.proxy.getItemDisplayName(newStack);
|
||||
} else {
|
||||
name += " < BROKEN (" + decodedBlock.getLocalizedName() + ":" + decodedMeta + " )>";
|
||||
String localizedName;
|
||||
try {
|
||||
localizedName = decodedBlock.getLocalizedName();
|
||||
} catch(NullPointerException npe) {
|
||||
localizedName = "Null";
|
||||
}
|
||||
name += " < BROKEN (" + localizedName + ":" + decodedMeta + " )>";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
@ -95,11 +104,11 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
TileGenericPipe pipeTile = (TileGenericPipe) tile;
|
||||
|
||||
if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getBlock(stack), ItemFacade.getMetaData(stack))) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.stackSize--;
|
||||
}
|
||||
stack.stackSize--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -107,58 +116,88 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
for (Object o : Block.blockRegistry) {
|
||||
Block b = (Block) o;
|
||||
|
||||
if (!(b == Blocks.glass)) {
|
||||
if (b == Blocks.bedrock
|
||||
|| b == Blocks.grass
|
||||
|| b == Blocks.leaves
|
||||
|| b == Blocks.sponge
|
||||
|| b == Blocks.chest
|
||||
|| b == Blocks.redstone_lamp
|
||||
|| b == Blocks.lit_redstone_lamp
|
||||
|| b == Blocks.lit_pumpkin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!b.isOpaqueCube()
|
||||
|| b.hasTileEntity(0)
|
||||
|| !b.renderAsNormalBlock()
|
||||
|| b.getRenderType() != 0) {
|
||||
continue;
|
||||
}
|
||||
if (!isBlockValidForFacade(b))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Item item = Item.getItemFromBlock(b);
|
||||
|
||||
if (item != null) {
|
||||
ItemStack base = new ItemStack(item, 1);
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (base.getHasSubtypes()) {
|
||||
Set<String> names = Sets.newHashSet();
|
||||
if (isBlockBlacklisted(b))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int meta = 0; meta <= 15; meta++) {
|
||||
ItemStack is = new ItemStack(item, 1, meta);
|
||||
registerValidFacades(b, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Strings.isNullOrEmpty(is.getUnlocalizedName())
|
||||
&& names.add(is.getUnlocalizedName())) {
|
||||
private static void registerValidFacades(Block block, Item item)
|
||||
{
|
||||
Set<String> names = Sets.newHashSet();
|
||||
|
||||
try {
|
||||
ItemFacade.addFacade(is);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
for(int i=0; i <= 15; i++) {
|
||||
try {
|
||||
ItemStack stack = new ItemStack(item, 1, i);
|
||||
|
||||
if(!Strings.isNullOrEmpty(stack.getUnlocalizedName())
|
||||
&& names.add(stack.getUnlocalizedName())) {
|
||||
ItemFacade.addFacade(stack);
|
||||
|
||||
// prevent adding multiple facades if it's a rotatable block
|
||||
if(block.getRenderType() == 31) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
ItemFacade.addFacade(base);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch(Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBlockBlacklisted(Block block)
|
||||
{
|
||||
String blockName = Block.blockRegistry.getNameForObject(block);
|
||||
for (String blacklistedBlock : BuildCraftTransport.facadeBlacklist) {
|
||||
if(blockName.equals(BuildCraftConfiguration.stripSurroundingQuotes(blacklistedBlock))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for(String blacklistedBlock : blacklistedFacades){
|
||||
if(blockName.equals(blacklistedBlock)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isBlockValidForFacade(Block block)
|
||||
{
|
||||
if(block.getRenderType() != 0 && block.getRenderType() != 31)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!block.renderAsNormalBlock()) {
|
||||
if((block != Blocks.glass && block != Blocks.stained_glass)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(block instanceof BlockSpring || block instanceof BlockGenericPipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getMetaData(ItemStack stack) {
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("meta")) {
|
||||
return stack.getTagCompound().getInteger("meta");
|
||||
|
@ -168,11 +207,23 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
}
|
||||
|
||||
public static Block getBlock(ItemStack stack) {
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("id")) {
|
||||
return (Block) Block.blockRegistry.getObjectById(stack.getTagCompound().getInteger("id"));
|
||||
} else {
|
||||
return (Block) Block.blockRegistry.getObjectById((stack.getItemDamage() & 0xFFF0) >>> 4);
|
||||
if(!stack.hasTagCompound()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Block facadeBlock = null;
|
||||
NBTTagCompound stackTagCompound = stack.getTagCompound();
|
||||
// reading the 'id' tag is kept to maintain back-compat.
|
||||
// The stack gets upgraded the first time this code is run.
|
||||
if(stackTagCompound.hasKey("id")) {
|
||||
facadeBlock = (Block)Block.blockRegistry.getObjectById(stackTagCompound.getInteger("id"));
|
||||
stackTagCompound.removeTag("id");
|
||||
stackTagCompound.setString("name", Block.blockRegistry.getNameForObject(facadeBlock));
|
||||
} else if (stackTagCompound.hasKey("name")) {
|
||||
facadeBlock = (Block) Block.blockRegistry.getObject(stackTagCompound.getString("name"));
|
||||
}
|
||||
|
||||
return facadeBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,26 +234,20 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
|
||||
public static void addFacade(ItemStack itemStack) {
|
||||
ItemStack facade = getStack(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage());
|
||||
allFacades.add(facade);
|
||||
if(!allFacades.contains(facade)) {
|
||||
allFacades.add(facade);
|
||||
|
||||
ItemStack facade6 = facade.copy();
|
||||
facade6.stackSize = 6;
|
||||
ItemStack facade6 = facade.copy();
|
||||
facade6.stackSize = 6;
|
||||
|
||||
// 3 Structurepipes + this block makes 6 facades
|
||||
BuildcraftRecipes.assemblyTable.addRecipe(8000, facade6, new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack);
|
||||
// 3 Structurepipes + this block makes 6 facades
|
||||
BuildcraftRecipes.assemblyTable.addRecipe(8000, facade6, new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
Block bl = Block.getBlockFromItem(itemStack.getItem());
|
||||
|
||||
// Special handling for logs
|
||||
if (bl != null && bl.getRenderType() == 31) {
|
||||
ItemStack rotLog1 = getStack(
|
||||
Block.getBlockFromItem(itemStack.getItem()),
|
||||
itemStack.getItemDamage() | 4);
|
||||
ItemStack rotLog2 = getStack(
|
||||
Block.getBlockFromItem(itemStack.getItem()),
|
||||
itemStack.getItemDamage() | 8);
|
||||
allFacades.add(rotLog1);
|
||||
allFacades.add(rotLog2);
|
||||
public static void blacklistFacade(String blockName) {
|
||||
if(!blacklistedFacades.contains(blockName)) {
|
||||
blacklistedFacades.add(blockName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,51 +258,85 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inventorycrafting, World world) {
|
||||
ItemStack slotmatch = null;
|
||||
for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) {
|
||||
ItemStack slot = inventorycrafting.getStackInSlot(i);
|
||||
if (slot != null && slot.getItem() == ItemFacade.this && slotmatch == null) {
|
||||
slotmatch = slot;
|
||||
} else if (slot != null) {
|
||||
slotmatch = NO_MATCH;
|
||||
}
|
||||
}
|
||||
if (slotmatch != null && slotmatch != NO_MATCH) {
|
||||
Block block = ItemFacade.getBlock(slotmatch);
|
||||
return block != null && block.getRenderType() == 31;
|
||||
}
|
||||
Object[] facade = getFacadeBlockFromCraftingGrid(inventorycrafting);
|
||||
|
||||
return false;
|
||||
return facade != null && facade[0] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) {
|
||||
Object[] facade = getFacadeBlockFromCraftingGrid(inventorycrafting);
|
||||
if(facade == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Block block = (Block)facade[0];
|
||||
ItemStack originalFacade = (ItemStack)facade[1];
|
||||
|
||||
if(block == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getNextFacadeItemStack(block, originalFacade);
|
||||
}
|
||||
|
||||
private Object[] getFacadeBlockFromCraftingGrid(InventoryCrafting inventorycrafting) {
|
||||
ItemStack slotmatch = null;
|
||||
int countOfItems = 0;
|
||||
for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) {
|
||||
ItemStack slot = inventorycrafting.getStackInSlot(i);
|
||||
|
||||
if (slot != null && slot.getItem() == ItemFacade.this && slotmatch == null) {
|
||||
slotmatch = slot;
|
||||
countOfItems++;
|
||||
} else if (slot != null) {
|
||||
slotmatch = NO_MATCH;
|
||||
}
|
||||
|
||||
if(countOfItems > 1) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotmatch != null && slotmatch != NO_MATCH) {
|
||||
Block block = ItemFacade.getBlock(slotmatch);
|
||||
int blockMeta = ItemFacade.getMetaData(slotmatch);
|
||||
|
||||
|
||||
if (block != null && block.getRenderType() == 31 && (blockMeta & 0xC) == 0)
|
||||
return getStack(block, (blockMeta & 0x3) | 4);
|
||||
// Meta | 4 = true
|
||||
if (block != null && block.getRenderType() == 31 && (blockMeta & 0x8) == 0)
|
||||
return getStack(block, (blockMeta & 0x3) | 8);
|
||||
// Meta | 8 = true
|
||||
if (block != null && block.getRenderType() == 31 && (blockMeta & 0x4) == 0)
|
||||
return getStack(block, (blockMeta & 0x3));
|
||||
return new Object[] { ItemFacade.getBlock(slotmatch), slotmatch };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack getNextFacadeItemStack(Block block, ItemStack originalFacade)
|
||||
{
|
||||
int blockMeta = ItemFacade.getMetaData(originalFacade);
|
||||
int stackMeta = 0;
|
||||
|
||||
switch(block.getRenderType()) {
|
||||
case 1:
|
||||
//supports cycling through variants (wool, planks, etc)
|
||||
if(blockMeta >= 15) {
|
||||
stackMeta = 0;
|
||||
} else {
|
||||
stackMeta = blockMeta + 1;
|
||||
}
|
||||
break;
|
||||
case 31:
|
||||
if ((blockMeta & 0xC) == 0) {
|
||||
// Meta | 4 = true
|
||||
stackMeta = (blockMeta & 0x3) | 4;
|
||||
} else if ((blockMeta & 0x8) == 0) {
|
||||
// Meta | 8 = true
|
||||
stackMeta = (blockMeta & 0x3) | 8;
|
||||
} else if ((blockMeta & 0x4) == 0) {
|
||||
stackMeta = (blockMeta & 0x3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
stackMeta = blockMeta;
|
||||
}
|
||||
|
||||
return getStack(block, stackMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 1;
|
||||
|
@ -285,7 +364,7 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("meta", metadata);
|
||||
nbt.setInteger("id", Block.blockRegistry.getIDForObject(block));
|
||||
nbt.setString("name", Block.blockRegistry.getNameForObject(block));
|
||||
stack.setTagCompound(nbt);
|
||||
return stack;
|
||||
}
|
||||
|
|
|
@ -87,18 +87,27 @@ public final class GateDefinition {
|
|||
|
||||
AND, OR;
|
||||
public static final GateLogic[] VALUES = values();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconLit;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconDark;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconItem;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconLit() {
|
||||
return iconLit;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconDark() {
|
||||
return iconDark;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconItem() {
|
||||
return iconItem;
|
||||
}
|
||||
|
@ -107,11 +116,13 @@ public final class GateDefinition {
|
|||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcon(IIconRegister iconRegister) {
|
||||
iconLit = iconRegister.registerIcon("buildcraft:gates/gate_lit_" + getTag());
|
||||
iconDark = iconRegister.registerIcon("buildcraft:gates/gate_dark_" + getTag());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerItemIcon(IIconRegister iconRegister) {
|
||||
iconItem = iconRegister.registerIcon("buildcraft:gates/gate_logic_" + getTag());
|
||||
}
|
||||
|
|
|
@ -16,11 +16,10 @@ import buildcraft.transport.PipeIconProvider;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class FacadeItemRenderer implements IItemRenderer {
|
||||
|
@ -38,38 +37,42 @@ public class FacadeItemRenderer implements IItemRenderer {
|
|||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (block == null)
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(block.getIcon(0, decodedMeta) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Render Facade
|
||||
GL11.glPushMatrix();
|
||||
block.setBlockBounds(0F, 0F, 1F - 1F / 16F, 1F, 1F, 1F);
|
||||
render.setRenderBoundsFromBlock(block);
|
||||
GL11.glTranslatef(translateX, translateY, translateZ);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, decodedMeta));
|
||||
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 0, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, decodedMeta));
|
||||
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 1, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, decodedMeta));
|
||||
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 2, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, decodedMeta));
|
||||
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 3, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, decodedMeta));
|
||||
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 4, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, decodedMeta));
|
||||
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 5, decodedMeta));
|
||||
tessellator.draw();
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
|
@ -111,6 +114,15 @@ public class FacadeItemRenderer implements IItemRenderer {
|
|||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private IIcon tryGetBlockIcon( Block block, int side, int decodedMeta)
|
||||
{
|
||||
try {
|
||||
return block.getIcon(side, decodedMeta);
|
||||
} catch (Throwable t) {
|
||||
return Blocks.cobblestone.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
switch (type) {
|
||||
|
|
Loading…
Reference in a new issue