diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/core/block')
46 files changed, 7739 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/core/block/ModBlocks.java b/src/main/java/gtPlusPlus/core/block/ModBlocks.java new file mode 100644 index 0000000000..b51915bb7b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/ModBlocks.java @@ -0,0 +1,162 @@ +package gtPlusPlus.core.block; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.general.BlockCompressedObsidian; +import gtPlusPlus.core.block.general.BlockNet; +import gtPlusPlus.core.block.general.BlockTankXpConverter; +import gtPlusPlus.core.block.general.FirePit; +import gtPlusPlus.core.block.general.FluidTankInfinite; +import gtPlusPlus.core.block.general.HellFire; +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.MiningExplosives; +import gtPlusPlus.core.block.general.PlayerDoors; +import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; +import gtPlusPlus.core.block.general.redstone.BlockGenericRedstoneDetector; +import gtPlusPlus.core.block.general.redstone.BlockGenericRedstoneTest; +import gtPlusPlus.core.block.machine.*; +import gtPlusPlus.core.block.machine.bedrock.Mining_Head_Fake; +import gtPlusPlus.core.block.machine.bedrock.Mining_Pipe_Fake; +import gtPlusPlus.core.fluids.FluidRegistryHandler; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.Fluid; + +public final class ModBlocks { + + public static Block blockRoundRobinator; + public static Block blockCircuitProgrammer; + public static Block blockVolumetricFlaskSetter; + public static Block blockFakeMiningPipe; + public static Block blockFakeMiningHead; + + public static Block blockFishTrap; + public static Block blockWorkbench; + public static Block blockWorkbenchAdvanced; + public static Block blockDecayablesChest; + public static Block blockEggBox; + + //Blocks + //public static Block blockBloodSteel; + //public static Block blockStaballoy; + // WIP TODO public static Block blockToolBuilder; + public static Block blockGriefSaver; + + public static Block blockCasingsMisc; + public static Block blockCasings2Misc; + public static Block blockCasings3Misc; + public static Block blockCasings4Misc; + public static Block blockCasings5Misc; + public static Block blockCasingsTieredGTPP; + public static Block blockSpecialMultiCasings; + public static Block blockCustomMachineCasings; + + public static Block blockMetaTileEntity; + public static Block blockHeliumGenerator; + public static Block blockNHG; + public static Block blockCharger; + + public static Block MatterFabricatorEffectBlock; + + public static Fluid fluidSludge = new Fluid("fluid.sludge"); + public static Block blockFluidSludge; + + public static Block blockFirePit; + + public static Block blockOreFluorite; + + public static Block blockMiningExplosive; + + public static Block blockHellfire; + public static Block blockInfiniteFLuidTank; + public static Block blockProjectTable; + public static Block blockTradeTable; + public static Block blockModularTable; + + public static Block blockWitherGuard; + public static Block blockXpConverter; + public static Block blockCompressedObsidian; + public static Block blockNet; + + public static Block blockPlayerDoorWooden; + public static Block blockPlayerDoorIron; + public static Block blockPlayerDoorCustom_Glass; + public static Block blockPlayerDoorCustom_Ice; + public static Block blockPlayerDoorCustom_Cactus; + + public static Block blockCustomMobSpawner; + public static Block blockCustomSuperLight; + public static Block blockCustomJukebox; + + public static Block blockPooCollector; + + public static Block blockPestKiller; + + public static void init() { + Logger.INFO("Initializing Blocks."); + //blockGriefSaver = new TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); + + registerBlocks(); + } + + public static void registerBlocks(){ + + Logger.INFO("Registering Blocks."); + MatterFabricatorEffectBlock = new LightGlass(false); + + //Fluids + FluidRegistryHandler.registerFluids(); + + //Workbench + blockWorkbench = new Machine_Workbench().setHardness(1.5F); + blockWorkbenchAdvanced = new Machine_WorkbenchAdvanced().setHardness(2.5F); + blockHeliumGenerator = new HeliumGenerator(); + blockFirePit = new FirePit(); + blockFishTrap = new FishTrap(); + blockInfiniteFLuidTank = new FluidTankInfinite(); + //blockOreFluorite = new BlockBaseOre.oldOreBlock("oreFluorite", "Fluorite", Material.rock, BlockTypes.ORE, Utils.rgbtoHexValue(120, 120, 30), 3); + blockMiningExplosive = new MiningExplosives(); + blockHellfire = new HellFire(); + blockProjectTable = new Machine_ProjectTable(); + blockTradeTable = new Machine_TradeTable(); + blockModularTable = new Machine_ModularityTable(); + blockWitherGuard = new BlockWitherProof(); + blockXpConverter = new BlockTankXpConverter(); + blockCompressedObsidian = new BlockCompressedObsidian(); + blockNet = new BlockNet(); + + blockFakeMiningPipe = new Mining_Pipe_Fake(); + blockFakeMiningHead = new Mining_Head_Fake(); + + blockCircuitProgrammer = new CircuitProgrammer(); + + blockDecayablesChest = new DecayablesChest(); + blockEggBox = new EggBox(); + + blockPlayerDoorWooden = new PlayerDoors(Material.wood, "door_wood", true); + blockPlayerDoorIron = new PlayerDoors(Material.iron, "door_iron", true); + blockPlayerDoorCustom_Glass = new PlayerDoors(Material.glass, "door_glass", false); + blockPlayerDoorCustom_Ice = new PlayerDoors(Material.ice, "door_ice", false); + blockPlayerDoorCustom_Cactus = new PlayerDoors(Material.cactus, "door_cactus", false, 0.6f, Block.soundTypeGrass, "Cactus"); + + //blockCustomSuperLight = new BlockSuperLight(); + blockCustomJukebox = new Machine_SuperJukebox(); + + blockPooCollector = new Machine_PooCollector(); + + blockPestKiller = new Machine_PestKiller(); + + blockRoundRobinator = new Machine_RoundRobinator(); + + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + blockVolumetricFlaskSetter = new VolumetricFlaskSetter(); + } + + new BlockGenericRedstoneDetector(); + new BlockGenericRedstoneTest(); + + } + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java new file mode 100644 index 0000000000..f63762a2d7 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -0,0 +1,39 @@ +package gtPlusPlus.core.block.base; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.lib.CORE; + +public class AdvancedBlock extends Block { + + protected AdvancedBlock(final String unlocalizedName, final Material material, final CreativeTabs x, final float blockHardness, final float blockResistance, final float blockLightLevel, + final String blockHarvestTool, final int blockHarvestLevel, final SoundType BlockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(x); + this.setHardness(blockHardness); //block Hardness + this.setResistance(blockResistance); + this.setLightLevel(blockLightLevel); + this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); + this.setStepSound(BlockSound); + } + + @Override + public boolean onBlockActivated(final World p_149727_1_, final int p_149727_2_, final int p_149727_3_, final int p_149727_4_, final EntityPlayer p_149727_5_, final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, final float p_149727_9_) + { + return false; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java b/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java new file mode 100644 index 0000000000..6014388cda --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java @@ -0,0 +1,81 @@ +package gtPlusPlus.core.block.base; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +public class BasicBlock extends BlockContainer { + + public BasicBlock(final String unlocalizedName, final Material material) { + this(BlockTypes.STANDARD, unlocalizedName, material, 2); + } + + public BasicBlock(final BlockTypes type, final String unlocalizedName, final Material material) { + this(type, unlocalizedName, material, 2); + } + + public BasicBlock(BlockTypes type, final String unlocalizedName, final Material material, final int harvestLevel) { + super(material); + this.setBlockName(Utils.sanitizeString(unlocalizedName)); + + if (type != BlockTypes.ORE && !unlocalizedName.toLowerCase().contains("ore")) { + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + } + + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHardness(1.0f*harvestLevel); + this.setHarvestLevel("pickaxe", harvestLevel); + this.setStepSound(soundTypeMetal); + } + + + public static enum BlockTypes { + STANDARD("blockBlock", "pickaxe", soundTypeMetal), + FRAME("blockFrameGt", "wrench", soundTypeMetal), + ORE("blockStone", "pickaxe", soundTypeStone); + + private String TEXTURE_NAME; + private String HARVEST_TOOL; + private SoundType soundOfBlock; + private BlockTypes (final String textureName, final String harvestTool, final SoundType blockSound) + { + this.TEXTURE_NAME = textureName; + this.HARVEST_TOOL = harvestTool; + this.soundOfBlock = blockSound; + } + + public String getTexture() { + return this.TEXTURE_NAME; + } + + public String getHarvestTool(){ + return this.HARVEST_TOOL; + } + + public SoundType getBlockSoundType(){ + return this.soundOfBlock; + } + + } + + + @Override + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { + return null; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java new file mode 100644 index 0000000000..2bfd09d848 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -0,0 +1,328 @@ +package gtPlusPlus.core.block.base; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.api.objects.minecraft.SafeTexture; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BasicTileBlockWithTooltip extends BlockContainer implements ITileTooltip { + + /** + * Each mapped object holds the data for the six sides. + */ + @SideOnly(Side.CLIENT) + private AutoMap<CubicObject<SafeTexture>> mSidedTextureArray; + + /** + * Holds the data for the six sides, each side holds an array of data for each respective meta. + */ + @SideOnly(Side.CLIENT) + private AutoMap<CubicObject<String>> mSidedTexturePathArray; + + /** + * Does this block have any meta at all? + * @return + */ + public final boolean hasMeta() { + return getMetaCount() > 0; + } + + /** + * The amount of meta this block has. + * @return + */ + public abstract int getMetaCount(); + + /** + * Does this {@link Block} require special {@link ItemBlock} handling? + * @return The {@link Class} that will be used for this {@link Block}. + */ + public Class<? extends ItemBlock> getItemBlockClass() { + return ItemBlock.class; + } + + /** + * A lazy way to declare the unlocal name for the block, makes boilerplating easy. + * @return The internal name for this block. + */ + public abstract String getUnlocalBlockName(); + + /** + * Does this Block have {@link ITileTooltip} support? + * @return {@link boolean} that represents if this block supports {@link ITileTooltip} or not. + */ + public final boolean hasTooltip() { + return getTooltipID() >= -1; + } + + /** + * Lazy Boilerplating. + * @return Block Hardness. + */ + protected abstract float initBlockHardness(); + + /** + * Lazy Boilerplating. + * @return Block Resistance. + */ + protected abstract float initBlockResistance(); + + /** + * Lazy Boilerplating. + * @return The {@link CreativeTab} this Block is shown on. + */ + protected abstract CreativeTabs initCreativeTab(); + + /** + * The ID used by the {@link ITileTooltip} handler. Return -1 if you are not providing a custom {@link ItemBlock} in {@link #getItemBlockClass}(). + * @return + */ + @Override + public abstract int getTooltipID(); + + public BasicTileBlockWithTooltip(Material aBlockMat){ + super(aBlockMat); + //Use Abstract method values + this.setHardness(initBlockHardness()); + this.setResistance(initBlockResistance()); + this.setBlockName(getUnlocalBlockName()); + this.setCreativeTab(initCreativeTab()); + // Register the block last. + GameRegistry.registerBlock(this, getItemBlockClass(), getUnlocalBlockName()); + Logger.INFO("Registered "+getTileEntityName()+"."); + if (Utils.isClient()) { + // Handle Textures + handleTextures(); + } + } + + /** + * The name of the Tile Entity. + * @return + */ + protected abstract String getTileEntityName(); + + /** + * The String used for texture pathing. + * @return Sanitized {@link String}, containing no spaces or illegal characters. + */ + private final String getTileEntityNameForTexturePathing() { + return Utils.sanitizeString(getTileEntityName().replace(" ", "")); + } + + /** + * An array of CubicObjects, one for each meta, else just a single cell array. + * Expected to be null regularly, as the default texture handling should suffice. + * Handy if re-using textures or using a non-standard structure for them. FULL texture path must be used, + * inclusive of the MODID and a colon. + * @return + */ + public CubicObject<String>[] getCustomTextureDirectoryObject(){ + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public final IIcon getIcon(final int aSide, final int aMeta) { + return mSidedTextureArray.get(aMeta).get(aSide).getIcon(); + } + + @Override + public IIcon getIcon(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + return super.getIcon(aWorld, aX, aY, aZ, aSide); + } + + @SideOnly(Side.CLIENT) + private final void handleTextures() { + + Logger.INFO("[TeTexture] Building Texture Maps for "+getTileEntityName()+"."); + + // Init on the Client side only, to prevent Field initialisers existing in the Server side bytecode. + mSidedTextureArray = new AutoMap<CubicObject<SafeTexture>>(); + mSidedTexturePathArray = new AutoMap<CubicObject<String>>(); + + + //Store them in forge order + //DOWN, UP, NORTH, SOUTH, WEST, EAST + + // Default Path Name, this will make us look inside 'miscutils\textures\blocks' + final String aPrefixTexPath = CORE.MODID + ":"; + // Default Path Name, this will make us look in the sub-directory for this Tile Entity. + final String aTexPathMid = "TileEntities"+CORE.SEPERATOR+getTileEntityNameForTexturePathing()+CORE.SEPERATOR; + // Construct a full path + String aTexPathBuilt = aPrefixTexPath + aTexPathMid; + // File Name Suffixes, without meta tags + String aStringBot; + String aStringTop; + String aStringBack; + String aStringFront; + String aStringLeft; + String aStringRight; + // Do we provide a matrix of custom data to be used for texture processing instead? + if (getCustomTextureDirectoryObject() != null) { + // Get custom provided texture data. + CubicObject<String>[] aDataMap = getCustomTextureDirectoryObject(); + Logger.INFO("[TeTexture] Found custom texture data, using this instead. Size: "+aDataMap.length); + // Map each meta string data to the main map. + for (int i=0;i<aDataMap.length;i++) { + mSidedTexturePathArray.put(aDataMap[i]); + Logger.INFO("Mapped value for meta "+i+"."); + } + } + else { + Logger.INFO("[TeTexture] Processing "+(1+getMetaCount())+" sets."); + // Iterate once for each meta + for (int i=0;i<(1+getMetaCount());i++) { + + // File Name Suffixes, without meta tags + aStringBot = "Bottom"; + aStringTop = "Top"; + aStringBack = "Back"; + aStringFront = "Front"; + aStringLeft = "Left"; + aStringRight = "Right"; + + // Add tails if we have meta + if (hasMeta()) { + aStringBot = aStringBot + "_"+i; + aStringTop = aStringTop + "_"+i; + aStringBack = aStringBack + "_"+i; + aStringFront = aStringFront + "_"+i; + aStringLeft = aStringLeft + "_"+i; + aStringRight = aStringRight + "_"+i; + } + // Append the full path + aStringBot = aTexPathBuilt + aStringBot; + aStringTop = aTexPathBuilt + aStringTop; + aStringBack = aTexPathBuilt + aStringBack; + aStringFront = aTexPathBuilt + aStringFront; + aStringLeft = aTexPathBuilt + aStringLeft; + aStringRight = aTexPathBuilt + aStringRight; + // Convenience Blob + CubicObject<String> aMetaBlob = new CubicObject<String>(aStringBot, aStringTop, aStringBack, aStringFront, aStringLeft, aStringRight); + mSidedTexturePathArray.put(aMetaBlob); + Logger.INFO("[TeTexture] Added Texture Path data to map for meta "+i); + } + } + Logger.INFO("[TeTexture] Map size for pathing: "+mSidedTexturePathArray.size()); + + // Iteration Index + int aIndex = 0; + + // Iterate each CubicObject, holding the six texture paths for each meta. + for (CubicObject<String> aMetaBlob : mSidedTexturePathArray) { + // Make a Safe Texture for each side + SafeTexture aBottom = SafeTexture.register(aMetaBlob.DOWN); + SafeTexture aTop = SafeTexture.register(aMetaBlob.UP); + SafeTexture aBack = SafeTexture.register(aMetaBlob.NORTH); + SafeTexture aFont = SafeTexture.register(aMetaBlob.SOUTH); + SafeTexture aWest = SafeTexture.register(aMetaBlob.WEST); + SafeTexture aEast = SafeTexture.register(aMetaBlob.EAST); + // Store them in an Array + SafeTexture[] aInjectBlob = new SafeTexture[] { + aBottom, + aTop, + aBack, + aFont, + aWest, + aEast + }; + // Convenience Blob + CubicObject<SafeTexture> aMetaBlob2 = new CubicObject<SafeTexture>(aInjectBlob); + // Store this Blob into + mSidedTextureArray.put(aMetaBlob2); + Logger.INFO("[TeTexture] Added SafeTexture data to map for meta "+(aIndex++)); + } + Logger.INFO("[TeTexture] Map size for registration: "+mSidedTextureArray.size()); + + + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerBlockIcons(final IIconRegister aRegisterer){ + this.blockIcon = aRegisterer.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + /** + * Called when {@link #breakBlock}() is called, but before {@link InventoryUtils#dropInventoryItems} and the super call. + */ + public void onBlockBreak() { + + } + + @Override + public final void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + onBlockBreak(); + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { + if (hasMeta()) { + for (int i=0;i<getMetaCount();i++) { + aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); + } + } + else { + aList.add(ItemUtils.getSimpleStack(aItem)); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + + + /** + * Get the block's damage value (for use with pick block). + */ + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + int l = aWorld.getBlockMetadata(aX, aY, aZ); + return l; + } + + + public Item getItemDropped(int meta, Random rand, int p_149650_3_){ + return ItemUtils.getSimpleStack(this, 1).getItem(); + } + + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){ + ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + return drops; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java new file mode 100644 index 0000000000..db37e18a32 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java @@ -0,0 +1,103 @@ +package gtPlusPlus.core.block.base; + +import java.util.Random; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import gtPlusPlus.core.client.renderer.particle.EntityDropParticleFX; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +public class BlockBaseFluid extends BlockFluidClassic { + + private final String name; + private final IIcon textureArray[] = new IIcon[6]; + + protected float particleRed = 1.0F; + protected float particleGreen = 1.0F; + protected float particleBlue = 1.0F; + + public BlockBaseFluid(String materialName, Fluid fluid, Material material) { + super(fluid, material); + this.setLightOpacity(2); + this.name = Utils.sanitizeString(materialName); + this.setBlockName("fluid"+this.name); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "fluid"+this.name); + } + + public BlockFluidClassic setParticleColor(int arg0) { + return this.setParticleColor((arg0 >> 16 & 255) / 255.0F, (arg0 >> 8 & 255) / 255.0F, + (arg0 >> 0 & 255) / 255.0F); + } + + public BlockFluidClassic setParticleColor(float arg0, float arg1, float arg2) { + this.particleRed = arg0; + this.particleGreen = arg1; + this.particleBlue = arg2; + return this; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType arg0, IBlockAccess arg1, int arg2, int arg3, int arg4) { + return false; + } + + public boolean preInit() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side <= 1 ? this.textureArray[0] : this.textureArray[1]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Still"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Flow"); + //IconRegistry.addIcon("Fluid" + this.name, this.modName + ":fluid/Fluid_" + this.name + "_Still", arg0); + //IconRegistry.addIcon("Fluid" + this.name + "1", this.modName + ":fluid/Fluid_" + this.name + "_Flow", arg0); + } + + @Override + @Optional.Method(modid = "CoFHCore") + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World arg0, int arg1, int arg2, int arg3, Random arg4) { + super.randomDisplayTick(arg0, arg1, arg2, arg3, arg4); + double arg5 = arg1 + arg4.nextFloat(); + double arg7 = arg2 - 1.05D; + double arg9 = arg3 + arg4.nextFloat(); + if (super.density < 0) { + arg7 = arg2 + 2.1D; + } + + if (arg4.nextInt(20) == 0 + && arg0.isSideSolid(arg1, arg2 + super.densityDir, arg3, + super.densityDir == -1 ? ForgeDirection.UP : ForgeDirection.DOWN) + && !arg0.getBlock(arg1, arg2 + 2 * super.densityDir, arg3).getMaterial().blocksMovement()) { + EntityDropParticleFX arg11 = new EntityDropParticleFX(arg0, arg5, arg7, arg9, this.particleRed, + this.particleGreen, this.particleBlue, super.densityDir); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(arg11); + } + + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java new file mode 100644 index 0000000000..c0113e869b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -0,0 +1,211 @@ +package gtPlusPlus.core.block.base; + +import java.util.HashMap; +import java.util.Map; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtFrameBox; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BlockBaseModular extends BasicBlock { + + protected Material blockMaterial; + + protected int blockColour; + protected BlockTypes thisBlock; + protected String thisBlockMaterial; + protected final String thisBlockType; + + public BlockBaseModular(final Material material, final BlockTypes blockType) { + this(material, blockType, material.getRgbAsHex()); + } + + public BlockBaseModular(final Material material, final BlockTypes blockType, final int colour) { + this(material.getUnlocalizedName(), material.getLocalizedName(), net.minecraft.block.material.Material.iron, + blockType, colour, Math.min(Math.max(material.vTier, 1), 6)); + blockMaterial = material; + registerComponent(); + } + + protected BlockBaseModular(final String unlocalizedName, final String blockMaterial, + final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, + final int miningLevel) { + super(blockType, unlocalizedName, vanillaMaterial, miningLevel); + this.setHarvestLevel(blockType.getHarvestTool(), miningLevel); + this.setBlockTextureName(CORE.MODID + ":" + blockType.getTexture()); + this.blockColour = colour; + this.thisBlock = blockType; + this.thisBlockMaterial = blockMaterial; + this.thisBlockType = blockType.name().toUpperCase(); + this.setBlockName(this.GetProperName()); + int fx = getBlockTypeMeta(); + if (fx == 0) { + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + GT_OreDictUnificator.registerOre( + "block" + getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "") + .replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), + ItemUtils.getSimpleStack(this)); + } + else if (fx == 1) { + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + GT_OreDictUnificator.registerOre( + "frameGt" + getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "") + .replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), + ItemUtils.getSimpleStack(this)); + } + else if (fx == 2) { + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + GT_OreDictUnificator.registerOre( + "block" + getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "") + .replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), + ItemUtils.getSimpleStack(this)); + } + } + + public boolean registerComponent() { + Logger.MATERIALS("Attempting to register "+this.getUnlocalizedName()+"."); + if (this.blockMaterial == null) { + Logger.MATERIALS("Tried to register "+this.getUnlocalizedName()+" but the material was null."); + return false; + } + String aName = blockMaterial.getUnlocalizedName(); + //Register Component + Map<String, ItemStack> aMap = Material.mComponentMap.get(aName); + if (aMap == null) { + aMap = new HashMap<String, ItemStack>(); + } + int fx = getBlockTypeMeta(); + String aKey = (fx == 0 ? OrePrefixes.block.name() : ( fx == 1 ? OrePrefixes.frameGt.name() : OrePrefixes.ore.name())); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: ["+aName+"] Map: ["+aKey+"]"); + Material.mComponentMap.put(aName, aMap); + return true; + } + else { + //Bad + Logger.MATERIALS("Tried to double register a material component."); + return false; + } + } + + public int getBlockTypeMeta() { + if (this.thisBlockType.equals(BlockTypes.STANDARD.name().toUpperCase())) { + return 0; + } + else if (this.thisBlockType.equals(BlockTypes.FRAME.name().toUpperCase())) { + return 1; + } + else if (this.thisBlockType.equals(BlockTypes.ORE.name().toUpperCase())) { + return 2; + } + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 + * for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + if (this.thisBlock == BlockTypes.FRAME) { + return 1; + } + return 0; + } + + public String GetProperName() { + String tempIngot; + if (this.thisBlock == BlockTypes.STANDARD) { + tempIngot = "Block of " + this.thisBlockMaterial; + } + else if (this.thisBlock == BlockTypes.FRAME) { + tempIngot = this.thisBlockMaterial + " Frame Box"; + } + else if (this.thisBlock == BlockTypes.ORE) { + tempIngot = this.thisBlockMaterial + " Ore [Old]"; + } + else { + + tempIngot = this.getUnlocalizedName().replace("tile.blockGt", "ingot"); + } + return tempIngot; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + public Material getMaterialEx(){ + return this.blockMaterial; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + if (!CORE.ConfigSwitches.useGregtechTextures || this.blockMaterial == null || this.thisBlock == BlockTypes.ORE){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); + } + String metType = "9j4852jyo3rjmh3owlhw9oe"; + if (this.blockMaterial != null) { + TextureSet u = this.blockMaterial.getTextureSet(); + if (u != null) { + metType = u.mSetName; + } + } + metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); + int tier = blockMaterial != null ? this.blockMaterial.vTier : 0; + String aType = (this.thisBlock == BlockTypes.FRAME) ? "frameGt" : (tier <= 4 ? "block1" : "block5"); + this.blockIcon = iIcon.registerIcon("gregtech" + ":" + "materialicons/"+ metType +"/" + aType); + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getBlockColor() { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java new file mode 100644 index 0000000000..e4dff82ec4 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java @@ -0,0 +1,81 @@ +package gtPlusPlus.core.block.base; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; + +public abstract class BlockBaseNBT extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public BlockBaseNBT(final Material material, final String unlocalName, final String displayName){ + super(material); + this.setBlockName(unlocalName); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockNBT.class, unlocalName); + //LanguageRegistry.addName(this, displayName); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_){ + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int meta) { + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { + super.onBlockDestroyedByPlayer(world, x, y, z, meta); + } + + @Override + public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, final Explosion explosion) { + super.onBlockDestroyedByExplosion(world, x, y, z, explosion); + } + + @Override + public void onBlockHarvested(final World world, final int x, final int y, final int z, final int meta, final EntityPlayer player) { + super.onBlockHarvested(world, x, y, z, meta, player); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { + super.onBlockExploded(world, x, y, z, explosion); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java new file mode 100644 index 0000000000..e1bc3462be --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -0,0 +1,229 @@ +package gtPlusPlus.core.block.base; + +import java.lang.reflect.Field; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.interfaces.ITexturedBlock; +import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; +import gtPlusPlus.core.item.base.itemblock.ItemBlockOre; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class BlockBaseOre extends BasicBlock implements ITexturedBlock { + + private final Material blockMaterial; + + public BlockBaseOre(final Material material, final BlockTypes blockType, final int colour) { + super(blockType, Utils.sanitizeString(material.getUnlocalizedName()), net.minecraft.block.material.Material.rock, Math.min(Math.max(material.vTier, 1), 6)); + int aMaterialTierForMining = Math.min(Math.max(material.vTier, 1), 6); + this.blockMaterial = material; + this.setHardness(1.0f*aMaterialTierForMining); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", aMaterialTierForMining); + this.setStepSound(soundTypeStone); + this.setBlockName("Ore"+Utils.sanitizeString(Utils.sanitizeString(material.getUnlocalizedName()))); + this.setBlockTextureName("stone"); + try { + GameRegistry.registerBlock(this, ItemBlockOre.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); + GT_OreDictUnificator.registerOre("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); + } + catch (Throwable t){ + t.printStackTrace(); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + public Material getMaterialEx(){ + return this.blockMaterial; + } + + @Override + public int getRenderType() { + try { + if (CustomOreBlockRenderer.INSTANCE != null){ + return CustomOreBlockRenderer.INSTANCE.mRenderID; + } + return super.getRenderType(); + } + catch (NullPointerException n) { + return 0; + } + } + + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + /** + * GT Texture Handler + */ + + //.08 compat + public static IIconContainer[] hiddenTextureArray; + public ITexture[] getTexture(byte arg0) { + return getTexture(null, arg0); + } + + public ITexture[] getTexture(Block block, byte side) { + if (this.blockMaterial != null){ + GT_RenderedTexture aIconSet = new GT_RenderedTexture(blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], this.blockMaterial.getRGBA()); + if (aIconSet != null){ + return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; + } + } + + if (hiddenTextureArray == null){ + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + hiddenTextureArray = Textures.BlockIcons.GRANITES; + } + else { + try { + Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); + if (o != null){ + hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); + } + if (hiddenTextureArray == null){ + hiddenTextureArray = new IIconContainer[6]; + } + } + catch (IllegalArgumentException | IllegalAccessException e) { + hiddenTextureArray = new IIconContainer[6]; + } + } + } + return new ITexture[]{new GT_RenderedTexture(hiddenTextureArray[0], new short[]{240, 240, 240, 0})}; + } + + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + + } + + public static class oldOreBlock extends BlockBaseModular implements ITexturedBlock{ + + public oldOreBlock(final String unlocalizedName, final String blockMaterial, final BlockTypes blockType, final int colour) { + this(unlocalizedName, blockMaterial, net.minecraft.block.material.Material.iron, blockType, colour, 2); + } + + public oldOreBlock(final String unlocalizedName, final String blockMaterial, final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, final int miningLevel) { + super(unlocalizedName, blockMaterial, vanillaMaterial, blockType, colour, miningLevel); + } + + /*@Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); + //this.base = iIcon.registerIcon(CORE.MODID + ":" + "blockStone"); + //this.overlay = iIcon.registerIcon(CORE.MODID + ":" + "blockOre_Overlay"); + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + }*/ + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getRenderType() { + if (CustomOreBlockRenderer.INSTANCE != null){ + return CustomOreBlockRenderer.INSTANCE.mRenderID; + } + return super.getRenderType(); + } + + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + /** + * GT Texture Handler + */ + + //.08 compat + IIconContainer[] hiddenTextureArray; + public ITexture[] getTexture(byte arg0) { + return getTexture(null, arg0); + } + + public ITexture[] getTexture(Block block, byte side) { + if (this.blockMaterial != null){ + GT_RenderedTexture aIconSet = new GT_RenderedTexture(blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], this.blockMaterial.getRGBA()); + if (aIconSet != null){ + return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; + } + } + + if (hiddenTextureArray == null){ + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + hiddenTextureArray = Textures.BlockIcons.GRANITES; + } + else { + try { + Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); + if (o != null){ + hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); + } + if (hiddenTextureArray == null){ + hiddenTextureArray = new IIconContainer[6]; + } + } + catch (IllegalArgumentException | IllegalAccessException e) { + hiddenTextureArray = new IIconContainer[6]; + } + } + } + return new ITexture[]{new GT_RenderedTexture(hiddenTextureArray[0], new short[]{240, 240, 240, 0})}; + } + + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java b/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java new file mode 100644 index 0000000000..880bb3a597 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.block.base; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; + +public class MetaBlock extends MultiTextureBlock { + + protected MetaBlock(final String unlocalizedName, final Material material, final SoundType soundType) { + super(unlocalizedName, material, soundType); + } + + @Override + public int damageDropped(final int meta) { + return meta; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 6; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java b/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java new file mode 100644 index 0000000000..a04bf841ba --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java @@ -0,0 +1,37 @@ +package gtPlusPlus.core.block.base; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +public class MultiTextureBlock extends Block { + + public IIcon[] icons = new IIcon[6]; + + protected MultiTextureBlock(final String unlocalizedName, final Material material, final SoundType blockSound) + { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setStepSound(blockSound); + } + + @Override + public void registerBlockIcons(final IIconRegister reg) { + for (int i = 0; i < 6; i ++) { + this.icons[i] = reg.registerIcon(this.textureName + "_" + i); + } + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return this.icons[side]; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java b/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java new file mode 100644 index 0000000000..03ca846b7d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java @@ -0,0 +1,94 @@ +package gtPlusPlus.core.block.general; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockObsidian; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; + +public class BlockCompressedObsidian extends BlockObsidian { + + private final IIcon textureArray[] = new IIcon[6]; + + public BlockCompressedObsidian() { + this.setBlockName("blockCompressedObsidian"); + this.setHardness(50.0F); + this.setResistance(2000.0F); + this.setStepSound(soundTypePiston); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); + } + + @Override + public MapColor getMapColor(final int meta) { + if (meta != 5) { + return MapColor.obsidianColor; + } + else { + return MapColor.sandColor; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian1"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian2"); + this.textureArray[2] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian3"); + this.textureArray[3] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian4"); + this.textureArray[4] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian5"); + this.textureArray[5] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian_invert"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int meta) { + return this.textureArray[meta]; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 6; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int metadata, + final int fortune) { + int m = metadata; + if (m == 5) { + m = 1; + } + return super.getDrops(world, x, y, z, m, fortune); + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockNet.java b/src/main/java/gtPlusPlus/core/block/general/BlockNet.java new file mode 100644 index 0000000000..1f0f145392 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockNet.java @@ -0,0 +1,37 @@ +package gtPlusPlus.core.block.general; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockWeb; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; + +public class BlockNet extends BlockWeb{ + + public BlockNet(){ + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setLightOpacity(1); + this.setHardness(4.0F); + this.setBlockName("blockNet"); + GameRegistry.registerBlock(this, "blockNet"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_){ + return ModItems.itemRope; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java new file mode 100644 index 0000000000..a1ba3be487 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java @@ -0,0 +1,220 @@ +package gtPlusPlus.core.block.general; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockSuperLight extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + //propecia (Inhibit DHD - recover hair get depression) + + public BlockSuperLight() { + super(Material.circuits); + this.setBlockName("blockSuperLight"); + this.setCreativeTab(CreativeTabs.tabRedstone); + GameRegistry.registerBlock(this, "blockSuperLight"); + LanguageRegistry.addName(this, "Shining Star"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlBigBlue"); + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the + * block. + */ + public TileEntity createNewTileEntity(World aWorld, int p_149915_2_) { + return new TileEntitySuperLight(); + } + + public static class TileEntitySuperLight extends TileEntity { + + private long mCreated; + + private long mLastUpdateTick = 0; + + private int mLitBlockCount = 0; + + private int[][][][] aLitBlocks = new int[50][10][50][1]; + + private boolean mPowered = false; + + public TileEntitySuperLight() { + mCreated = System.currentTimeMillis(); + Logger.INFO("Created Super-Lamp"); + } + + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + mCreated = aNBT.getLong("mCreated"); + mPowered = aNBT.getBoolean("mPowered"); + NBTTagCompound aLightingData = aNBT.getCompoundTag("lighting"); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int aData = aLightingData.getInteger("["+x+"]["+y+"]["+z+"]"); + aLitBlocks[x][y][z][0] = aData; + } + } + } + } + + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setLong("mCreated", mCreated); + aNBT.setBoolean("mPowered", mPowered); + NBTTagCompound aLightingData = new NBTTagCompound(); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int aFlag = aLitBlocks[x][y][z][0]; + aLightingData.setInteger("["+x+"]["+y+"]["+z+"]", aFlag); + } + } + } + aNBT.setTag("lighting", aLightingData); + } + + @Override + public void updateEntity() { + super.updateEntity(); + + if (this.worldObj.isRemote) { + return; + } + + try { + if (mLastUpdateTick == 0 || (System.currentTimeMillis() - mLastUpdateTick) >= 30000) { + boolean powered = (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)); + boolean aLastState = mPowered; + //Logger.INFO("Powered: "+powered); + mPowered = powered; + if (mPowered != aLastState) { + updateLighting(powered); + } + } + } catch (Throwable t) { + } + } + + @Override + public void markDirty() { + super.markDirty(); + } + + @Override + public boolean canUpdate() { + return super.canUpdate(); + } + + public void updateLighting(boolean enable) { + + + mLastUpdateTick = System.currentTimeMillis(); + + if (false) { + return; + } + + aLitBlocks = new int[50][10][50][1]; + int aLitCounter = 0; + AutoMap<BlockPos> aBlocksToUpdate = new AutoMap<BlockPos>(); + Logger.INFO("Trying to relight area."); + + BlockPos aStartIterationPoint = new BlockPos(this.xCoord-24, this.yCoord-4, this.zCoord-24, this.worldObj); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int xOff = aStartIterationPoint.xPos + x; + int yOff = aStartIterationPoint.yPos + y; + int zOff = aStartIterationPoint.zPos + z; + Block aBlockGet = this.worldObj.getBlock(xOff, yOff, zOff); + if (aBlockGet != null) { + if (aBlockGet instanceof BlockAir || aBlockGet instanceof LightGlass) { + + int aLight = aBlockGet.getLightValue(); + + //Don't Need to relight anything. + if ((enable && aLight > 0) || (!enable && aLight == 0)) { + continue; + } + //Turning Lights on + else if (enable && aLight == 0) { + aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); + if (aBlockGet instanceof BlockAir) { + Logger.INFO("Lit air."); + this.worldObj.setBlock(xOff, yOff, zOff, ModBlocks.MatterFabricatorEffectBlock, 0, 3); + } + //aBlockGet.setLightLevel(15); + aLitCounter++; + } + //Turning Lights off + else if (!enable && aLight > 0) { + aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); + if (aBlockGet instanceof LightGlass) { + Logger.INFO("Dimmed air."); + this.worldObj.setBlock(xOff, yOff, zOff, Blocks.air, 0, 3); + } + //aBlockGet.setLightLevel(0); + } + aLitBlocks[x][y][z][0] = enable ? 15 : 0; + } + else { + aLitBlocks[x][y][z][0] = -1; + } + } + else { + aLitBlocks[x][y][z][0] = -1; + } + } + } + } + mLitBlockCount = aLitCounter; + doLargeBlockUpdate(aBlocksToUpdate); + } + + public void doLargeBlockUpdate(AutoMap<BlockPos> aUpdateMap) { + if (aUpdateMap.isEmpty()) { + return; + } + for (BlockPos p : aUpdateMap) { + //this.worldObj.markBlockForUpdate(p.xPos, p.yPos, p.zPos); + //this.worldObj.markBlocksDirtyVertical(p_72975_1_, p_72975_2_, p_72975_3_, p_72975_4_); + } + } + + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java new file mode 100644 index 0000000000..f7f0b446ce --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -0,0 +1,192 @@ +package gtPlusPlus.core.block.general; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockTankXpConverter extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public BlockTankXpConverter() { + super(Material.iron); + this.setBlockName("blockTankXpConverter"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); + LanguageRegistry.addName(this, "Xp Converter"); + this.generateRainbowMap(); + if (!this.getTickRandomly()) { + this.setTickRandomly(true); + } + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop + : (p_149691_1_ == 0 ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + + return true; + + /* + if (world.isRemote) { + return true; + } + else { + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = true; + tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + + } + } + catch (final Throwable t) { + mDidScrewDriver = false; + } + + if (!mDidScrewDriver) { + + try { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null) { + tile.onRightClick((byte) side, player, x, y, z); + } + } + catch (final Throwable t) { + } + + final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tank != null) { + if (tank.tankEssence.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankEssence.getFluidAmount() + + "L of " + tank.tankEssence.getFluid().getLocalizedName()); + } + if (tank.tankLiquidXp.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankLiquidXp.getFluidAmount() + + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); + } + if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)) { + PlayerUtils.messagePlayer(player, "This is worth " + + EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount()) + " levels."); + } + } + } + } + return true; + */} + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + //return new TileEntityXpConverter(); + return null; + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } + + private final boolean generateRainbowMap() { + return true; + } + + @Override + public int getBlockColor() { + return super.getBlockColor(); + } + + @Override + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, + final int p_149720_4_) { + return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); + } + + @Override + public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { + // this.mRainbowTick++; + super.updateTick(world, x, y, z, rand); + } + + @Override + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + //this.mRainbowTick++; + super.randomDisplayTick(world, x, y, z, rand); + } + + @Override + public int tickRate(final World p_149738_1_) { + return 20; + } + + @Override + public int getLightValue() { + return 6; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/FirePit.java b/src/main/java/gtPlusPlus/core/block/general/FirePit.java new file mode 100644 index 0000000000..6f35715c48 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/FirePit.java @@ -0,0 +1,230 @@ +package gtPlusPlus.core.block.general; + +import static net.minecraftforge.common.util.ForgeDirection.*; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gtPlusPlus.core.block.base.BasicBlock; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.tileentities.general.TileEntityFirepit; +import net.minecraftforge.common.util.ForgeDirection; + +public class FirePit extends BasicBlock{ + private static IIcon[] TEXTURE; + public static final int META_ANTIBUILDER = 2; + private int meta; + + @SuppressWarnings("deprecation") + public FirePit() { + super("blockFirePit", Material.wood); + this.setBlockName("blockFirePit"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(10.0F); + this.setResistance(35.0F); + this.setStepSound(Block.soundTypeWood); + GameRegistry.registerBlock(this, "blockFirePit"); + LanguageRegistry.addName(this, "Fire Pit"); + } + + @Override + public int tickRate(final World aParWorld) { + return 30; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int i) { + return new TileEntityFirepit(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister par1IconRegister){ + TEXTURE = new IIcon[] {par1IconRegister.registerIcon(this.getTextureName() + "_layer_0"), par1IconRegister.registerIcon(this.getTextureName() + "_layer_1")}; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List){ + par3List.add(new ItemStack(par1, 1, 2)); + } + + @Override + public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random){ + if (!par1World.isRemote){ + //Sets meta. + this.meta = par1World.getBlockMetadata(x, y, z); + //If Raining, Put out. + if (par1World.isRaining() + && (par1World.canLightningStrikeAt(x, y, z) + || par1World.canLightningStrikeAt(x - 1, y, z) + || par1World.canLightningStrikeAt(x + 1, y, z) + || par1World.canLightningStrikeAt(x, y, z - 1) + || par1World.canLightningStrikeAt(x, y, z + 1))){ + //Fire goes out + par1World.setBlockMetadataWithNotify(x, y, z, 1, 4); + } + if (isNeighborBurning(par1World, x, y, z)){ + //Fire can ignite from a nearby flame source. + par1World.setBlockMetadataWithNotify(x, y, z, 2, 4); + } + } + } + + @Override + public Item getItemDropped(final int meta, final Random par2Random, final int par3){ + switch (meta){ + case 0: + return null; + default: + break; + } + return Item.getItemFromBlock(this); + } + + @Override + public int damageDropped(final int meta){ + return meta; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + public int getRenderType(){ + return -1; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 1; + } + + @Override + public boolean renderAsNormalBlock(){ + return false; + } + + /*@Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aParWorld, int x, int y, int z){ + return null; + }*/ + + @Override + protected boolean canSilkHarvest(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World p_149734_1_, final int p_149734_2_, final int p_149734_3_, final int p_149734_4_, final Random p_149734_5_){ + int l; + float f; + float f1; + float f2; + if (this.meta == 2) { + if (p_149734_5_.nextInt(24) == 0){ + p_149734_1_.playSound(p_149734_2_ + 0.5F, p_149734_3_ + 0.5F, p_149734_4_ + 0.5F, "fire.fire", 1.0F + p_149734_5_.nextFloat(), (p_149734_5_.nextFloat() * 0.7F) + 0.3F, false); + } + } + if (this.meta == 2) { + if (!World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && !Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_, UP)){ + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ - 1, p_149734_3_, p_149734_4_, EAST)){ + for (l = 0; l < 2; ++l){ + f = p_149734_2_ + (p_149734_5_.nextFloat() * 0.1F); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ + 1, p_149734_3_, p_149734_4_, WEST)){ + for (l = 0; l < 2; ++l){ + f = p_149734_2_ + 1 - (p_149734_5_.nextFloat() * 0.1F); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ - 1, SOUTH)){ + for (l = 0; l < 2; ++l){ + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + (p_149734_5_.nextFloat() * 0.1F); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ + 1, NORTH)){ + for (l = 0; l < 2; ++l){ + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + 1 - (p_149734_5_.nextFloat() * 0.1F); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ + 1, p_149734_4_, DOWN)){ + for (l = 0; l < 2; ++l){ + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + 1 - (p_149734_5_.nextFloat() * 0.1F); + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + } + else{ + if (this.meta == 2) { + for (l = 0; l < 3; ++l){ + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + (p_149734_5_.nextFloat() * 0.5F) + 0.5F; + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + } + } + } + + @SideOnly(Side.CLIENT) + public static IIcon getFireIcon(final int p_149840_1_){ + return FirePit.TEXTURE[p_149840_1_]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_){ + return FirePit.TEXTURE[0]; + } + + private static boolean isNeighborBurning(final World world, final int x, final int y, final int z){ + return canCatchFire(world, x + 1, y, z, WEST ) || + canCatchFire(world, x - 1, y, z, EAST ) || + canCatchFire(world, x, y - 1, z, UP ) || + canCatchFire(world, x, y + 1, z, DOWN ) || + canCatchFire(world, x, y, z - 1, SOUTH) || + canCatchFire(world, x, y, z + 1, NORTH); + } + + public static boolean canCatchFire(final World world, final int x, final int y, final int z, final ForgeDirection face) + { + return world.getBlock(x, y, z).isFireSource(world, x, y, z, face); + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java new file mode 100644 index 0000000000..b979f7864b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java @@ -0,0 +1,136 @@ +package gtPlusPlus.core.block.general; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.ItemFluidContainer; + +public class FluidTankInfinite extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public FluidTankInfinite() { + super(Material.iron); + this.setBlockName("blockInfiniteFluidTank"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockInfiniteFluidTank"); + LanguageRegistry.addName(this, "Infinite Fluid Tank"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop + : (p_149691_1_ == 0 ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + if (world.isRemote) { + return true; + } else { + TileEntityInfiniteFluid tank = (TileEntityInfiniteFluid) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem().getItem(); + } catch (Throwable t) { + handItem = null; + } + if (handItem != null + && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); + + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tank.getFluidAmount() + "L of " + + tank.tank.getFluid().getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityInfiniteFluid(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/HellFire.java b/src/main/java/gtPlusPlus/core/block/general/HellFire.java new file mode 100644 index 0000000000..233f200815 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/HellFire.java @@ -0,0 +1,557 @@ +package gtPlusPlus.core.block.general; + +import static net.minecraftforge.common.util.ForgeDirection.*; + +import java.util.IdentityHashMap; +import java.util.Map.Entry; +import java.util.Random; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFire; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraftforge.common.util.ForgeDirection; + +public class HellFire extends BlockFire { + @Deprecated + private final int[] field_149849_a = new int[Short.MAX_VALUE]; + @Deprecated + private final int[] field_149848_b = new int[Short.MAX_VALUE]; + @SideOnly(Side.CLIENT) + private IIcon[] IIconArray; + + public HellFire() { + this.setTickRandomly(true); + this.setLightLevel(1F); + this.setLightOpacity(0); + //this.setBlockTextureName(CORE.MODID + "hellfire/blockHellFire"); + this.setBlockName("blockHellFire"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, "blockHellFire"); + LanguageRegistry.addName(this, "Hellish Fire"); + this.enableBrutalFire(); + } + + private void enableBrutalFire() { + for (final Object o : Block.blockRegistry.getKeys()) + { + + try { + + final String name = (String)o; + final Block b = Block.getBlockFromName(name); + if (b != Blocks.air) + { + final int spread = Blocks.fire.getEncouragement(b); + final int flamm = Blocks.fire.getFlammability(b); + if (flamm > 0 && spread > 0) { + this.setFireInfo(b, spread * 4, flamm * 4); + } + } + + } + catch (Throwable t) { + t.printStackTrace(); + } + } + + //Special Case madness + this.setFireInfo(Blocks.brown_mushroom_block, 20, 100); + this.setFireInfo(Blocks.red_mushroom_block, 20, 100); + this.setFireInfo(Blocks.grass, 20, 100); + this.setFireInfo(Blocks.mycelium, 20, 100); + + } + + /** + * How many world ticks before ticking + */ + @Override + public int tickRate(final World world) { + return 5; + } + + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(final World world, final int x, final int y, final int z, Random random) { + + random = new XSTR(); + + if (world.getGameRules().getGameRuleBooleanValue("doFireTick")) { + final boolean flag = world.getBlock(x, y - 1, z).isFireSource(world, x, y - 1, z, UP); + + if (!this.canPlaceBlockAt(world, x, y, z)) { + world.setBlockToAir(x, y, z); + } + + if (!flag && world.isRaining() + && (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x - 1, y, z) + || world.canLightningStrikeAt(x + 1, y, z) || world.canLightningStrikeAt(x, y, z - 1) + || world.canLightningStrikeAt(x, y, z + 1))) { + + if (MathUtils.randInt(0, 100) >= 90){ + world.setBlockToAir(x, y, z); + } + } + else { + final int blockMeta = world.getBlockMetadata(x, y, z); + + if (blockMeta < 15) { + world.setBlockMetadataWithNotify(x, y, z, blockMeta + (random.nextInt(3) / 2), 4); + } + + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + random.nextInt(10)); + + if (!flag && !this.canNeighborBurn(world, x, y, z)) { + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || (blockMeta > 3)) { + world.setBlockToAir(x, y, z); + } + } + else if (!flag && !this.canCatchFire(world, x, y - 1, z, UP) && (blockMeta == 15) && (random.nextInt(4) == 0)) { + world.setBlockToAir(x, y, z); + } + else { + final boolean flag1 = world.isBlockHighHumidity(x, y, z); + byte b0 = 0; + + if (flag1) { + b0 = -50; + } + + this.tryCatchFire(world, x + 1, y, z, 300 + b0, random, blockMeta, WEST); + this.tryCatchFire(world, x - 1, y, z, 300 + b0, random, blockMeta, EAST); + this.tryCatchFire(world, x, y - 1, z, 250 + b0, random, blockMeta, UP); + this.tryCatchFire(world, x, y + 1, z, 250 + b0, random, blockMeta, DOWN); + this.tryCatchFire(world, x, y, z - 1, 300 + b0, random, blockMeta, SOUTH); + this.tryCatchFire(world, x, y, z + 1, 300 + b0, random, blockMeta, NORTH); + + for (int i1 = x - 1; i1 <= (x + 1); ++i1) { + for (int j1 = z - 1; j1 <= (z + 1); ++j1) { + for (int k1 = y - 1; k1 <= (y + 4); ++k1) { + if ((i1 != x) || (k1 != y) || (j1 != z)) { + int l1 = 100; + + if (k1 > (y + 1)) { + l1 += (k1 - (y + 1)) * 100; + } + + final int neighbourFireChance = this.getChanceOfNeighborsEncouragingFire(world, i1, k1, j1); + + if (neighbourFireChance > 0) { + int j2 = (neighbourFireChance + 40 + (world.difficultySetting.getDifficultyId() * 14)) / (blockMeta + 30); + + if (flag1) { + j2 /= 2; + } + + if ((j2 > 0) && (random.nextInt(l1) <= j2) + && (!world.isRaining() || !world.canLightningStrikeAt(i1, k1, j1)) + && !world.canLightningStrikeAt(i1 - 1, k1, z) + && !world.canLightningStrikeAt(i1 + 1, k1, j1) + && !world.canLightningStrikeAt(i1, k1, j1 - 1) + && !world.canLightningStrikeAt(i1, k1, j1 + 1)) { + int k2 = blockMeta + (random.nextInt(5) / 4); + + if (k2 > 15) { + k2 = 15; + } + + world.setBlock(i1, k1, j1, this, k2, 3); + } + } + } + } + } + } + } + } + } + } + + private void tryCatchFire(final World world, final int p_149841_2_, final int p_149841_3_, final int p_149841_4_, final int p_149841_5_, final Random p_149841_6_, final int p_149841_7_, final ForgeDirection face) { + final int j1 = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_).getFlammability(world, p_149841_2_, + p_149841_3_, p_149841_4_, face); + + if (p_149841_6_.nextInt(p_149841_5_) < j1) { + final boolean flag = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt; + + if ((p_149841_6_.nextInt(p_149841_7_ + 10) < 5) + && !world.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_)) { + int k1 = p_149841_7_ + (p_149841_6_.nextInt(5) / 4); + + if (k1 > 15) { + k1 = 15; + } + + world.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, k1, 3); + } + else { + world.setBlockToAir(p_149841_2_, p_149841_3_, p_149841_4_); + } + + if (flag) { + Blocks.tnt.onBlockDestroyedByPlayer(world, p_149841_2_, p_149841_3_, p_149841_4_, 1); + } + } + } + + /** + * Returns true if at least one block next to this one can burn. + */ + private boolean canNeighborBurn(final World world, final int x, final int y, final int z) { + return this.canCatchFire(world, x + 1, y, z, WEST) + || this.canCatchFire(world, x - 1, y, z, EAST) + || this.canCatchFire(world, x, y - 1, z, UP) + || this.canCatchFire(world, x, y + 1, z, DOWN) + || this.canCatchFire(world, x, y, z - 1, SOUTH) + || this.canCatchFire(world, x, y, z + 1, NORTH); + } + + /** + * Gets the highest chance of a neighbor block encouraging this block to + * catch fire + */ + private int getChanceOfNeighborsEncouragingFire(final World world, final int x, final int y, final int z) { + final byte b0 = 0; + + if (!world.isAirBlock(x, y, z)) { + return 0; + } + else { + int l = b0; + l = this.getChanceToEncourageFire(world, x + 1, y, z, l, WEST); + l = this.getChanceToEncourageFire(world, x - 1, y, z, l, EAST); + l = this.getChanceToEncourageFire(world, x, y - 1, z, l, UP); + l = this.getChanceToEncourageFire(world, x, y + 1, z, l, DOWN); + l = this.getChanceToEncourageFire(world, x, y, z - 1, l, SOUTH); + l = this.getChanceToEncourageFire(world, x, y, z + 1, l, NORTH); + return l; + } + } + + /** + * Checks the specified block coordinate to see if it can catch fire. Args: + * blockAccess, x, y, z + */ + @Override + @Deprecated + public boolean canBlockCatchFire(final IBlockAccess p_149844_1_, final int p_149844_2_, final int p_149844_3_, final int p_149844_4_) { + return this.canCatchFire(p_149844_1_, p_149844_2_, p_149844_3_, p_149844_4_, UP); + } + + /** + * Checks to see if its valid to put this block at the specified + * coordinates. Args: world, x, y, z + */ + @Override + public boolean canPlaceBlockAt(final World worldObj, final int x, final int y, final int z) { + return World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) + || this.canNeighborBurn(worldObj, x, y, z); + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which + * neighbor changed (coordinates passed are their own) Args: x, y, z, + * neighbor Block + */ + @Override + public void onNeighborBlockChange(final World worldObj, final int x, final int y, final int z, final Block blockObj) { + if (!World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) + && !this.canNeighborBurn(worldObj, x, y, z)) { + worldObj.setBlockToAir(x, y, z); + } + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + if ((world.provider.dimensionId > 0) + || !Blocks.portal.func_150000_e(world, x, y, z)) { + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) + && !this.canNeighborBurn(world, x, y, z)) { + world.setBlockToAir(x, y, z); + } + else { + world.scheduleBlockUpdate(x, y, z, this, + this.tickRate(world) + world.rand.nextInt(10)); + } + } + } + + //Burn + @Override + public void onEntityWalking(final World world, final int i, final int j, final int k, final Entity entity) { + entity.setFire(10); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + //Burn + @Override + public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, final Entity entity) { + entity.setFire(10); + } + + /** + * A randomly called display update to be able to add particles or other + * items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int x, final int y, final int z, Random randomObj) { + + randomObj = new XSTR(); + + if (randomObj.nextInt(24) == 0) { + world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", + 1.0F + randomObj.nextFloat(), (randomObj.nextFloat() * 0.7F) + 0.3F, false); + } + + int l; + float f; + float f1; + float f2; + + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) + && !Blocks.fire.canCatchFire(world, x, y - 1, z, UP)) { + if (Blocks.fire.canCatchFire(world, x - 1, y, z, EAST)) { + for (l = 0; l < 2; ++l) { + f = x + (randomObj.nextFloat() * 0.1F); + f1 = y + randomObj.nextFloat(); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); + + } + } + + if (Blocks.fire.canCatchFire(world, x + 1, y, z, WEST)) { + for (l = 0; l < 2; ++l) { + f = (x + 1) - (randomObj.nextFloat() * 0.1F); + f1 = y + randomObj.nextFloat(); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y, z - 1, SOUTH)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + randomObj.nextFloat(); + f2 = z + (randomObj.nextFloat() * 0.1F); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y, z + 1, NORTH)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + randomObj.nextFloat(); + f2 = (z + 1) - (randomObj.nextFloat() * 0.1F); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y + 1, z, DOWN)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = (y + 1) - (randomObj.nextFloat() * 0.1F); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + } + else { + for (l = 0; l < 5; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + (randomObj.nextFloat() * 0.5F) + 0.5F; + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister IIconRegister) { + this.IIconArray = new IIcon[] { + IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), + IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_1") }; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getFireIcon(final int p_149840_1_) { + return this.IIconArray[p_149840_1_]; + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return this.IIconArray[0]; + } + + @Override + public MapColor getMapColor(final int p_149728_1_) { + return MapColor.snowColor; + } + + /* + * ================================= Forge Start + * ====================================== + */ + private static class FireInfo { + private int encouragement = 0; + private int flammibility = 0; + } + + private final IdentityHashMap<Block, FireInfo> blockInfo = Maps.newIdentityHashMap(); + + @Override + public void setFireInfo(final Block block, final int encouragement, final int flammibility) { + try { + if (block == Blocks.air) { + throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + } + final int id = Block.getIdFromBlock(block); + if (id >= 4096 || id >= field_149849_a.length || id >= field_149848_b.length) { + return; + } + this.field_149849_a[id] = encouragement; + this.field_149848_b[id] = flammibility; + + final FireInfo info = this.getInfo(block, true); + info.encouragement = encouragement; + info.flammibility = flammibility; + } + catch (Throwable t) {} + } + + private FireInfo getInfo(final Block block, final boolean garentee) { + FireInfo ret = this.blockInfo.get(block); + if ((ret == null) && garentee) { + ret = new FireInfo(); + this.blockInfo.put(block, ret); + } + return ret; + } + + @Override + public void rebuildFireInfo() { + for (int x = 0; x < 4096; x++) { + // If we care.. we could detect changes in here and make sure we + // keep them, however + // it's my thinking that anyone who hacks into the private variables + // should DIAF and we don't care about them. + this.field_149849_a[x] = 0; + this.field_149848_b[x] = 0; + } + + for (final Entry<Block, FireInfo> e : this.blockInfo.entrySet()) { + final int id = Block.getIdFromBlock(e.getKey()); + if ((id >= 0) && (id < 4096)) { + this.field_149849_a[id] = e.getValue().encouragement; + this.field_149848_b[id] = e.getValue().flammibility; + } + } + } + + @Override + public int getFlammability(final Block block) { + final int id = Block.getIdFromBlock(block); + return (id >= 0) && (id < 4096) ? this.field_149848_b[id] : 0; + } + + @Override + public int getEncouragement(final Block block) { + final int id = Block.getIdFromBlock(block); + return (id >= 0) && (id < 4096) ? this.field_149849_a[id] : 0; + } + + /** + * Side sensitive version that calls the block function. + * + * @param world + * The current world + * @param x + * X Position + * @param y + * Y Position + * @param z + * Z Position + * @param face + * The side the fire is coming from + * @return True if the face can catch fire. + */ + @Override + public boolean canCatchFire(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) { + return world.getBlock(x, y, z).isFlammable(world, x, y, z, face); + } + + /** + * Side sensitive version that calls the block function. + * + * @param world + * The current world + * @param x + * X Position + * @param y + * Y Position + * @param z + * Z Position + * @param oldChance + * The previous maximum chance. + * @param face + * The side the fire is coming from + * @return The chance of the block catching fire, or oldChance if it is + * higher + */ + @Override + public int getChanceToEncourageFire(final IBlockAccess world, final int x, final int y, final int z, final int oldChance, final ForgeDirection face) { + final int newChance = world.getBlock(x, y, z).getFireSpreadSpeed(world, x, y, z, face); + return (newChance > oldChance ? newChance : oldChance); + } + /* + * ================================= Forge Start + * ====================================== + */ +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/general/LightGlass.java b/src/main/java/gtPlusPlus/core/block/general/LightGlass.java new file mode 100644 index 0000000000..30da7f1d56 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/LightGlass.java @@ -0,0 +1,144 @@ +package gtPlusPlus.core.block.general; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +/*public class LightGlass extends BlockBreakable +{*/ +public class LightGlass extends BlockAir +{ + +private int state = 0; + private final int a = 255; + private int r = 255; + private int g = 0; + private int b = 0; + private int hex; + + public LightGlass(final boolean bool) + { + //super("blockMFEffect", Material.air, bool); + super(); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockMFEffect"); + this.setLightLevel(12F); + setHardness(0.1F); + setBlockTextureName(CORE.MODID + ":" + "blockMFEffect"); + setStepSound(Block.soundTypeGlass); + GameRegistry.registerBlock(this, "blockMFEffect"); + + /* + this.setLightOpacity(0); + this.setTickRandomly(true); + this.setResistance(1);*/ + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(final Random rand) + { + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 0; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + /** + * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + */ + @Override + protected boolean canSilkHarvest() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockMFEffect"); + } + + @Override + //http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) + { + if(this.state == 0){ + this.g++; + if(this.g == 255) { + this.state = 1; + } + } + if(this.state == 1){ + this.r--; + if(this.r == 0) { + this.state = 2; + } + } + if(this.state == 2){ + this.b++; + if(this.b == 255) { + this.state = 3; + } + } + if(this.state == 3){ + this.g--; + if(this.g == 0) { + this.state = 4; + } + } + if(this.state == 4){ + this.r++; + if(this.r == 255) { + this.state = 5; + } + } + if(this.state == 5){ + this.b--; + if(this.b == 0) { + this.state = 0; + } + } + this.hex = (this.a << 24) + (this.r << 16) + (this.g << 8) + (this.b); + return this.hex; + } + + /** + * A randomly called display update to be able to add particles or other items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int posX, final int posY, final int posZ, final Random random){ + //Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java b/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java new file mode 100644 index 0000000000..8925962e4e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java @@ -0,0 +1,172 @@ +package gtPlusPlus.core.block.general; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockTNT; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; +import gtPlusPlus.core.lib.CORE; + +public class MiningExplosives extends BlockTNT { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + public MiningExplosives(){ + this.setBlockName("blockMiningExplosives"); + GameRegistry.registerBlock(this, "blockMiningExplosives"); + LanguageRegistry.addName(this, "Earth Blasting Explosives"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_){ + return p_149691_1_ == 0 ? this.textureBottom : (p_149691_1_ == 1 ? this.textureTop : this.blockIcon); + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z){ + super.onBlockAdded(world, x, y, z); + + if (world.isBlockIndirectlyGettingPowered(x, y, z)) + { + this.onBlockDestroyedByPlayer(world, x, y, z, 1); + world.setBlockToAir(x, y, z); + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor Block + */ + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block neighbourblock){ + if (world.isBlockIndirectlyGettingPowered(x, y, z)) + { + this.onBlockDestroyedByPlayer(world, x, y, z, 1); + world.setBlockToAir(x, y, z); + } + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(final Random random){ + return 1; + } + + /** + * Called upon the block being destroyed by an explosion + */ + @Override + public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, final Explosion bang){ + if (!world.isRemote) + { + final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive(world, x + 0.5F, y + 0.5F, z + 0.5F, bang.getExplosivePlacedBy()); + EntityPrimedMiningExplosive.fuse = world.rand.nextInt(EntityPrimedMiningExplosive.fuse / 4) + (EntityPrimedMiningExplosive.fuse / 8); + world.spawnEntityInWorld(EntityPrimedMiningExplosive); + } + } + + /** + * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData + */ + @Override + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta){ + this.func_150114_a(world, x, y, z, meta, (EntityLivingBase)null); + } + + //TODO Spawns Primed TNT? + @Override + public void func_150114_a(final World world, final int p_150114_2_, final int p_150114_3_, final int p_150114_4_, final int p_150114_5_, final EntityLivingBase entityLiving){ + if (!world.isRemote) + { + if ((p_150114_5_ & 1) == 1) + { + final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive(world, p_150114_2_ + 0.5F, p_150114_3_ + 0.5F, p_150114_4_ + 0.5F, entityLiving); + world.spawnEntityInWorld(EntityPrimedMiningExplosive); + world.playSoundAtEntity(EntityPrimedMiningExplosive, "game.tnt.primed", 1.0F, 1.0F); + } + } + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer clickingPlayer, final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, final float p_149727_9_){ + if ((clickingPlayer.getCurrentEquippedItem() != null) && (clickingPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel)) + { + this.func_150114_a(world, x, y, z, 1, clickingPlayer); + world.setBlockToAir(x, y, z); + clickingPlayer.getCurrentEquippedItem().damageItem(1, clickingPlayer); + return true; + } + else + { + return super.onBlockActivated(world, x, y, z, clickingPlayer, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + } + + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + @Override + public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entityTriggering){ + if ((entityTriggering instanceof EntityArrow) && !world.isRemote) + { + final EntityArrow entityarrow = (EntityArrow)entityTriggering; + + if (entityarrow.isBurning()) + { + this.func_150114_a(world, x, y, z, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null); + world.setBlockToAir(x, y, z); + } + } + } + + /** + * Return whether this block can drop from an explosion. + */ + @Override + public boolean canDropFromExplosion(final Explosion bang){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister){ + // + /*this.blockIcon = iconRegister.registerIcon(this.getTextureName() + "_side"); + this.textureTop = iconRegister.registerIcon(this.getTextureName() + "_top"); + this.textureBottom = iconRegister.registerIcon(this.getTextureName() + "_bottom");*/ + this.blockIcon = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalSheet2"); + this.textureTop = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalFunnel"); + this.textureBottom = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalPanel"); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java b/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java new file mode 100644 index 0000000000..a4c0c1a0a5 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java @@ -0,0 +1,467 @@ +package gtPlusPlus.core.block.general; + +import java.util.HashMap; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.base.itemblock.ItemBlockDoor; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityPlayerDoorBase; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDoor; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.IconFlipped; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class PlayerDoors extends BlockDoor implements ITileEntityProvider { + + @SideOnly(Side.CLIENT) + private IIcon[] aTextureUpper; + @SideOnly(Side.CLIENT) + private IIcon[] aTextureLower; + + private final static HashMap<Material, BlockDoor> mDoorMap = new HashMap<Material, BlockDoor>(); + + public PlayerDoors(Material aMaterial, String aTextureName, boolean vanillaType) { + this(aMaterial, aTextureName, vanillaType, 0f, null, null); + } + + public PlayerDoors(Material aMaterial, String aTextureName, boolean vanillaType, float aHardness, + SoundType aStepSound, String aBlockExtensionName) { + super(aMaterial); + this.disableStats(); + this.isBlockContainer = true; + if (mDoorMap.get(aMaterial) == null) { + mDoorMap.put(aMaterial, this); + } + float f = 0.5F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + + this.setBlockName("playerDoor_" + aTextureName); + if (aMaterial == Material.wood) { + setHardness(3.0F); + setStepSound(soundTypeWood); + setBlockName("playerDoor" + "Wood"); + this.setHarvestLevel("axe", 1); + } else if (aMaterial == Material.iron) { + setHardness(5.0F); + setStepSound(Block.soundTypeMetal); + setBlockName("playerDoor" + "Iron"); + this.setHarvestLevel("pickaxe", 1); + + } else if (aMaterial == Material.glass) { + setHardness(0.1F); + setStepSound(Block.soundTypeGlass); + setBlockName("playerDoor" + "Glass"); + this.setHarvestLevel("pickaxe", 1); + + } else if (aMaterial == Material.ice) { + setHardness(0.5F); + setStepSound(Block.soundTypeSnow); + setBlockName("playerDoor" + "Ice"); + this.setHarvestLevel("pickaxe", 1); + } else { + setHardness(aHardness); + setStepSound(aStepSound); + setBlockName("playerDoor" + aBlockExtensionName); + this.setHarvestLevel("axe", 1); + + } + this.setBlockTextureName(vanillaType ? aTextureName : CORE.MODID + ":" + aTextureName); + GameRegistry.registerBlock(this, ItemBlockDoor.class, Utils.sanitizeString(this.getUnlocalizedName())); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return this.aTextureLower[0]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aAccess, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + if (p_149673_5_ != 1 && p_149673_5_ != 0) { + int i1 = this.getState(aAccess, p_149673_2_, p_149673_3_, p_149673_4_); + int j1 = i1 & 3; + boolean flag = (i1 & 4) != 0; + boolean flag1 = false; + boolean flag2 = (i1 & 8) != 0; + + if (flag) { + if (j1 == 0 && p_149673_5_ == 2) { + flag1 = !flag1; + } else if (j1 == 1 && p_149673_5_ == 5) { + flag1 = !flag1; + } else if (j1 == 2 && p_149673_5_ == 3) { + flag1 = !flag1; + } else if (j1 == 3 && p_149673_5_ == 4) { + flag1 = !flag1; + } + } else { + if (j1 == 0 && p_149673_5_ == 5) { + flag1 = !flag1; + } else if (j1 == 1 && p_149673_5_ == 3) { + flag1 = !flag1; + } else if (j1 == 2 && p_149673_5_ == 4) { + flag1 = !flag1; + } else if (j1 == 3 && p_149673_5_ == 2) { + flag1 = !flag1; + } + + if ((i1 & 16) != 0) { + flag1 = !flag1; + } + } + + return flag2 ? this.aTextureUpper[flag1 ? 1 : 0] : this.aTextureLower[flag1 ? 1 : 0]; + } else { + return this.aTextureLower[0]; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) { + this.aTextureUpper = new IIcon[2]; + this.aTextureLower = new IIcon[2]; + this.aTextureUpper[0] = p_149651_1_.registerIcon(this.getTextureName() + "_upper"); + this.aTextureLower[0] = p_149651_1_.registerIcon(this.getTextureName() + "_lower"); + this.aTextureUpper[1] = new IconFlipped(this.aTextureUpper[0], true, false); + this.aTextureLower[1] = new IconFlipped(this.aTextureLower[0], true, false); + } + + public boolean getBlocksMovement(IBlockAccess aAccess, int aX, int aY, int aZ) { + int l = this.getState(aAccess, aX, aY, aZ); + return (l & 4) != 0; + } + + /** + * If this block doesn't render as an ordinary block it will return False + * (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() { + return false; + } + + /** + * The type of render function that is called for this block + */ + public int getRenderType() { + return 7; + } + + /** + * Returns the bounding box of the wired rectangular prism to render. + */ + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + this.setBlockBoundsBasedOnState(aWorld, aX, aY, aZ); + return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means this box + * can change after the pool has been cleared to be reused) + */ + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + this.setBlockBoundsBasedOnState(aWorld, aX, aY, aZ); + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + public void setBlockBoundsBasedOnState(IBlockAccess aAccess, int aX, int aY, int aZ) { + this.setBounds(this.getState(aAccess, aX, aY, aZ)); + } + + public int func_150013_e(IBlockAccess p_150013_1_, int p_150013_2_, int p_150013_3_, int p_150013_4_) { + return this.getState(p_150013_1_, p_150013_2_, p_150013_3_, p_150013_4_) & 3; + } + + public boolean func_150015_f(IBlockAccess p_150015_1_, int p_150015_2_, int p_150015_3_, int p_150015_4_) { + return (this.getState(p_150015_1_, p_150015_2_, p_150015_3_, p_150015_4_) & 4) != 0; + } + + private void setBounds(int aState) { + float f = 0.1875F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); + int j = aState & 3; + boolean flag = (aState & 4) != 0; + boolean flag1 = (aState & 16) != 0; + + if (j == 0) { + if (flag) { + if (!flag1) { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } else { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } else if (j == 1) { + if (flag) { + if (!flag1) { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + } else if (j == 2) { + if (flag) { + if (!flag1) { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + } else { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } else if (j == 3) { + if (flag) { + if (!flag1) { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } else { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } else { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + } + } + + /** + * Called upon block activation (right click on the block.) + */ + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int p_149727_6_, + float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (this.blockMaterial == Material.iron) { + return false; // Allow items to interact with the door + } else { + int i1 = this.getState(aWorld, aX, aY, aZ); + int j1 = i1 & 7; + j1 ^= 4; + + if ((i1 & 8) == 0) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, j1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY, aZ, aX, aY, aZ); + } else { + aWorld.setBlockMetadataWithNotify(aX, aY - 1, aZ, j1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY - 1, aZ, aX, aY, aZ); + } + + aWorld.playAuxSFXAtEntity(aPlayer, 1003, aX, aY, aZ, 0); + return true; + } + } + + public void func_150014_a(World aWorld, int aX, int aY, int aZ, boolean aFlag) { + int l = this.getState(aWorld, aX, aY, aZ); + boolean flag1 = (l & 4) != 0; + + if (flag1 != aFlag) { + int i1 = l & 7; + i1 ^= 4; + + if ((l & 8) == 0) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, i1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY, aZ, aX, aY, aZ); + } else { + aWorld.setBlockMetadataWithNotify(aX, aY - 1, aZ, i1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY - 1, aZ, aX, aY, aZ); + } + + aWorld.playAuxSFXAtEntity((EntityPlayer) null, 1003, aX, aY, aZ, 0); + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which + * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor + * Block + */ + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aNeighbour) { + int l = aWorld.getBlockMetadata(aX, aY, aZ); + + if ((l & 8) == 0) { + boolean flag = false; + + if (aWorld.getBlock(aX, aY + 1, aZ) != this) { + aWorld.setBlockToAir(aX, aY, aZ); + flag = true; + } + + if (!World.doesBlockHaveSolidTopSurface(aWorld, aX, aY - 1, aZ)) { + aWorld.setBlockToAir(aX, aY, aZ); + flag = true; + + if (aWorld.getBlock(aX, aY + 1, aZ) == this) { + aWorld.setBlockToAir(aX, aY + 1, aZ); + } + } + + if (flag) { + if (!aWorld.isRemote) { + this.dropBlockAsItem(aWorld, aX, aY, aZ, l, 0); + } + } else { + boolean flag1 = aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ) + || aWorld.isBlockIndirectlyGettingPowered(aX, aY + 1, aZ); + + if ((flag1 || aNeighbour.canProvidePower()) && aNeighbour != this) { + this.func_150014_a(aWorld, aX, aY, aZ, flag1); + } + } + } else { + if (aWorld.getBlock(aX, aY - 1, aZ) != this) { + aWorld.setBlockToAir(aX, aY, aZ); + } + + if (aNeighbour != this) { + this.onNeighborBlockChange(aWorld, aX, aY - 1, aZ, aNeighbour); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random aRand, int p_149650_3_) { + if ((p_149650_1_ & 8) != 0) { + return null; + } else { + Block b = mDoorMap.get(this.blockMaterial); + if (b != null) { + return Item.getItemFromBlock(b); + } + } + return null; + } + + /** + * Ray traces through the blocks collision from start vector to end vector + * returning a ray trace hit. Args: world, x, y, z, startVec, endVec + */ + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, + Vec3 p_149731_5_, Vec3 p_149731_6_) { + this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); + return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + /** + * Checks to see if its valid to put this block at the specified coordinates. + * Args: world, x, y, z + */ + public boolean canPlaceBlockAt(World aWorld, int aX, int aY, int aZ) { + boolean aHeight = (aY < aWorld.getHeight() - 1); + boolean aSolidTopSurface = World.doesBlockHaveSolidTopSurface(aWorld, aX, aY - 1, aZ); + + boolean aCanPlace = aWorld.getBlock(aX, aY, aZ).isReplaceable(aWorld, aX, aY, aZ); + boolean aCanPlace2 = aWorld.getBlock(aX, aY, aZ).isReplaceable(aWorld, aX, aY + 1, aZ); + + // Logger.INFO(""+aY+"/"+aWorld.getHeight()+" | Trying to place door. Good + // height? "+aHeight+" | Solid top surface? "+aSolidTopSurface+" | Can Place? + // "+aCanPlace+"|"+aCanPlace2); + + return aHeight && aSolidTopSurface && aCanPlace && aCanPlace2; + } + + /** + * Returns the mobility information of the block, 0 = free, 1 = can't push but + * can move over, 2 = total immobility and stop pistons + */ + public int getMobilityFlag() { + return 1; + } + + public int getState(IBlockAccess aAccess, int aX, int aY, int aZ) { + int l = aAccess.getBlockMetadata(aX, aY, aZ); + boolean flag = (l & 8) != 0; + int i1; + int j1; + + if (flag) { + i1 = aAccess.getBlockMetadata(aX, aY - 1, aZ); + j1 = l; + } else { + i1 = l; + j1 = aAccess.getBlockMetadata(aX, aY + 1, aZ); + } + + boolean flag1 = (j1 & 1) != 0; + return i1 & 7 | (flag ? 8 : 0) | (flag1 ? 16 : 0); + } + + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + Block b = mDoorMap.get(this.blockMaterial); + if (b != null) { + return Item.getItemFromBlock(b); + } + // return this.blockMaterial == Material.iron ? Items.iron_door : + // Items.wooden_door; + return null; + } + + /** + * Called when the block is attempted to be harvested + */ + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, + EntityPlayer p_149681_6_) { + if (p_149681_6_.capabilities.isCreativeMode && (p_149681_5_ & 8) != 0 + && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, + int p_149749_6_) { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + p_149749_1_.removeTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + } + + @Override + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, + int p_149696_5_, int p_149696_6_) { + super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_); + TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_); + return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; + } + + @Override + public TileEntity createNewTileEntity(World world, int metadata) { + return new TileEntityPlayerDoorBase(this, metadata); + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEntityPlayerDoorBase(this, metadata); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java new file mode 100644 index 0000000000..2210e68e8a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -0,0 +1,166 @@ +package gtPlusPlus.core.block.general.antigrief; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +public class BlockWitherProof extends Block{ + + public BlockWitherProof(){ + super(Material.redstoneLight); + this.setBlockName(Utils.sanitizeString("blockBlackGate")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(5000.0F); + this.setHarvestLevel("pickaxe", 3); + this.setStepSound(soundTypeMetal); + //LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); + } + + public String GetProperName(){ + return "Wither Cage"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 1; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ + //prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, + final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { + + } + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, + final Entity entity) { + if ((entity == null) || !entity.isEntityAlive()){ + return false; + } + if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) || (entity instanceof IBossDisplayData)){ + return false; + } + else { + return super.canEntityDestroy(world, x, y, z, entity); + } + } + + + //Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @Override + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World p_149737_2_, int p_149737_3_, int p_149737_4_, int p_149737_5_) { + if (aPlayer != null && aPlayer instanceof EntityPlayerMP) { + return 1f; + } + return -1f; + } + + @Override + public float getExplosionResistance(Entity p_149638_1_) { + return Float.MAX_VALUE; + } + + @Override + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) { + super.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if ((entity == null) || !entity.isEntityAlive()){ + return; + } + if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) || (entity instanceof IBossDisplayData)){ + return; + } + else { + super.onEntityCollidedWithBlock(world, x, y, z, entity); + } + } + + @Override + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) { + super.harvestBlock( p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + if (player != null && player instanceof EntityPlayerMP) { + return true; + } + return super.canHarvestBlock(player, meta); + } + + @Override + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) { + return Float.MAX_VALUE; + } + + + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java b/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java new file mode 100644 index 0000000000..01a2116a0b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java @@ -0,0 +1,293 @@ +package gtPlusPlus.core.block.general.antigrief; + +import static gtPlusPlus.core.block.ModBlocks.blockGriefSaver; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityReverter; + +public class TowerDevice extends Block { + private static IIcon TEX_ANTIBUILDER; + public static final int META_ANTIBUILDER = 9; + private boolean bUnbreakable; + + public TowerDevice() + { + super(Material.wood); + this.setHardness(10.0F); + this.setResistance(35.0F); + this.setStepSound(Block.soundTypeWood); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + public int tickRate() + { + return 15; + } + + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("bUnbreakable", this.bUnbreakable); + } + + public void loadNBTData(final NBTTagCompound aNBT) { + this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); + } + + @Override + public IIcon getIcon(final int side, final int meta) + { + return TEX_ANTIBUILDER; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister par1IconRegister) + { + TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief"); + } + + @Override + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) + { + par3List.add(new ItemStack(par1, 1, 9)); + } + + @Override + public boolean onBlockActivated(final World par1World, final int x, final int y, final int z, final EntityPlayer par5EntityPlayer, final int par6, final float par7, final float par8, final float par9) + { + final int meta = par1World.getBlockMetadata(x, y, z); + return false; + } + + @Override + public float getExplosionResistance(final Entity par1Entity, final World world, final int x, final int y, final int z, final double explosionX, final double explosionY, final double explosionZ) + { + final int meta = world.getBlockMetadata(x, y, z); + return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); + } + + @Override + public float getBlockHardness(final World world, final int x, final int y, final int z) + { + final int meta = world.getBlockMetadata(x, y, z); + return super.getBlockHardness(world, x, y, z); + } + + public static boolean areNearbyLockBlocks(final World world, final int x, final int y, final int z) + { + boolean locked = false; + for (int dx = x - 2; dx <= (x + 2); dx++) { + for (int dy = y - 2; dy <= (y + 2); dy++) { + for (int dz = z - 2; dz <= (z + 2); dz++) { + if ((world.getBlock(dx, dy, dz) == blockGriefSaver) && (world.getBlockMetadata(dx, dy, dz) == 4)) { + locked = true; + } + } + } + } + return locked; + } + + public static void unlockBlock(final World par1World, final int x, final int y, final int z) + { + final Block thereBlockID = par1World.getBlock(x, y, z); + final int thereBlockMeta = par1World.getBlockMetadata(x, y, z); + if ((thereBlockID == blockGriefSaver) || (thereBlockMeta == 4)) + { + changeToBlockMeta(par1World, x, y, z, 5); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, 0.6F); + } + } + + private static void changeToBlockMeta(final World par1World, final int x, final int y, final int z, final int meta) + { + final Block thereBlockID = par1World.getBlock(x, y, z); + if ((thereBlockID == blockGriefSaver)) + { + par1World.setBlock(x, y, z, thereBlockID, meta, 3); + par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z); + par1World.notifyBlocksOfNeighborChange(x, y, z, thereBlockID); + } + } + + @Override + public void onBlockAdded(final World par1World, final int x, final int y, final int z) + { + final int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) { + + } + } + + @Override + public void onNeighborBlockChange(final World par1World, final int x, final int y, final int z, final Block myBlockID) + { + final int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) + { + + } + } + + @Override + public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random) + { + if (!par1World.isRemote) + { + final int meta = par1World.getBlockMetadata(x, y, z); + } + } + + private void letsBuild(final World par1World, final int x, final int y, final int z) + { + + } + + private boolean isInactiveTrapCharged(final World par1World, final int x, final int y, final int z) + { + return false; + } + + private boolean isReactorReady(final World world, final int x, final int y, final int z) + { + if ((world.getBlock(x, y + 1, z) != Blocks.redstone_block) || + (world.getBlock(x, y - 1, z) != Blocks.redstone_block) || + (world.getBlock(x + 1, y, z) != Blocks.redstone_block) || + (world.getBlock(x - 1, y, z) != Blocks.redstone_block) || + (world.getBlock(x, y, z + 1) != Blocks.redstone_block) || + (world.getBlock(x, y, z - 1) != Blocks.redstone_block)) { + return false; + } + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World par1World, final int x, final int y, final int z, final Random par5Random) + { + final int meta = par1World.getBlockMetadata(x, y, z); + if ((meta == 3) || (meta == 1) || (meta == 9)) { + for (int i = 0; i < 1; i++) { + this.sparkle(par1World, x, y, z, par5Random); + } + } + } + + public void sparkle(final World world, final int x, final int y, final int z, final Random rand) + { + final double offset = 0.0625D; + for (int side = 0; side < 6; side++) + { + double rx = x + rand.nextFloat(); + double ry = y + rand.nextFloat(); + double rz = z + rand.nextFloat(); + if ((side == 0) && (!world.getBlock(x, y + 1, z).isOpaqueCube())) { + ry = y + 1 + offset; + } + if ((side == 1) && (!world.getBlock(x, y - 1, z).isOpaqueCube())) { + ry = (y + 0) - offset; + } + if ((side == 2) && (!world.getBlock(x, y, z + 1).isOpaqueCube())) { + rz = z + 1 + offset; + } + if ((side == 3) && (!world.getBlock(x, y, z - 1).isOpaqueCube())) { + rz = (z + 0) - offset; + } + if ((side == 4) && (!world.getBlock(x + 1, y, z).isOpaqueCube())) { + rx = x + 1 + offset; + } + if ((side == 5) && (!world.getBlock(x - 1, y, z).isOpaqueCube())) { + rx = (x + 0) - offset; + } + if ((rx < x) || (rx > (x + 1)) || (ry < 0.0D) || (ry > (y + 1)) || (rz < z) || (rz > (z + 1))) { + world.spawnParticle("reddust", rx, ry, rz, 0.0D, 0.0D, 0.0D); + } + } + } + + public static void checkAndActivateVanishBlock(final World world, final int x, final int y, final int z) + { + final Block thereID = world.getBlock(x, y, z); + final int thereMeta = world.getBlockMetadata(x, y, z); + } + + public static void changeToActiveVanishBlock(final World par1World, final int x, final int y, final int z, final int meta) + { + changeToBlockMeta(par1World, x, y, z, meta); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.3F, 0.6F); + + final Block thereBlockID = par1World.getBlock(x, y, z); + par1World.scheduleBlockUpdate(x, y, z, thereBlockID, getTickRateFor(thereBlockID, meta, par1World.rand)); + } + + private static int getTickRateFor(final Block thereBlockID, final int meta, final Random rand) + { + return 15; + } + + @Override + public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) + { + final Block blockID = world.getBlock(x, y, z); + final int meta = world.getBlockMetadata(x, y, z); + if (blockID != this) { + return 0; + } + return 10; + } + + @Override + public boolean hasTileEntity(final int metadata) + { + return (metadata == 0); + } + + @Override + public TileEntity createTileEntity(final World world, final int metadata) + { + if (metadata == 0) { + Logger.INFO("I have been created. [Antigriefer]"+this.getLocalizedName()); + return new TileEntityReverter(); + } + return null; + } + + @Override + public Item getItemDropped(final int meta, final Random par2Random, final int par3) + { + switch (meta) + { + case 0: + return null; + } + return Item.getItemFromBlock(this); + } + + @Override + public int damageDropped(final int meta) + { + return meta; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java b/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java new file mode 100644 index 0000000000..6af27639ae --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java @@ -0,0 +1,63 @@ +package gtPlusPlus.core.block.general.fluids; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +public class BlockFluidSludge extends BlockFluidClassic { + + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockFluidSludge(final Fluid fluid, final Material material) { + super(fluid, material); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return ((side == 0) || (side == 1))? this.stillIcon : this.flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(final IIconRegister register) { + this.stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); + this.flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); + } + + @Override + public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java new file mode 100644 index 0000000000..b84c96be99 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java @@ -0,0 +1,370 @@ +package gtPlusPlus.core.block.general.redstone; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class BlockGenericRedstone extends BlockContainer { + + + @SuppressWarnings("deprecation") + public BlockGenericRedstone(String aUnlocalizedSuffix, String aDisplayName) { + super(Material.redstoneLight); + this.setBlockName("blockGenericRedstone." + aUnlocalizedSuffix); + this.setHardness(3f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockGenericRedstone." + aUnlocalizedSuffix); + LanguageRegistry.addName(this, aDisplayName); + + } + + + private final HashMap<Integer, HashMap<ForgeDirection, IIcon>> mTextures = new HashMap<Integer, HashMap<ForgeDirection, IIcon>>(); + + /** + * A map of the textures used for this blocks. The key is the meta, then each internal map holds textures tied to each forge direction. Do not use unknown direction. + * @return + */ + public HashMap<Integer, HashMap<ForgeDirection, IIcon>> getTextureArray() { + return mTextures; + } + + public abstract void generateTextureArray(final IIconRegister iicon); + + + @Override + @SideOnly(Side.CLIENT) + public final void registerBlockIcons(final IIconRegister iicon) { + generateTextureArray(iicon); + this.blockIcon = iicon.registerIcon("redstone_block"); + } + + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + + if (world.isRemote) { + return true; + } + + boolean mDidTool = false; + // Check For Tools + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (ItemUtils.isItemGregtechTool(mHandStack)) { + + Logger.INFO("Found Tool in players hand!"); + + final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) world.getTileEntity(x, y, z); + if (tile != null) { + if (tile.isScrewdriverable()) { + if (ItemUtils.isToolScrewdriver(mHandStack)){ + mDidTool = tile.onScrewdriverRMB(); + PlayerUtils.messagePlayer(player, "Adjusted Light level by 0.0625f. "+tile.getLightBrightness()); + } + } + if (tile.isMalletable()) { + if (ItemUtils.isToolMallet(mHandStack)){ + mDidTool = tile.onMalletRMB(); + PlayerUtils.messagePlayer(player, "Light Mode active: "+mDidTool); + } + } + if (tile.isWrenchable()) { + if (ItemUtils.isToolWrench(mHandStack)){ + mDidTool = tile.onWrenchRMB(); + } + } + } + } + } + catch (final Throwable t) {} + if (mDidTool) { + return true; + } + + return false; + } + + + + @Override + public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { + + boolean mDidTool = false; + // Check For Tools + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(aWorld, aPlayer.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (mHandItem instanceof GT_MetaGenerated_Tool_01) { + + final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) aWorld.getTileEntity(aX, aY, aZ); + if (tile != null) { + if (tile.isScrewdriverable()) { + if (ItemUtils.isToolScrewdriver(mHandStack)){ + mDidTool = tile.onScrewdriverLMB(); + } + } + if (tile.isMalletable()) { + if (ItemUtils.isToolMallet(mHandStack)){ + mDidTool = tile.onMalletLMB(); + } + } + if (tile.isWrenchable()) { + if (ItemUtils.isToolWrench(mHandStack)){ + mDidTool = tile.onWrenchLMB(); + } + } + } + } + } + catch (Throwable t) {} + + if (!mDidTool && !aPlayer.capabilities.isCreativeMode) { + super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer); + } + else { + return; + } + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, + final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityRedstoneHandler) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } + + @Override + public int getLightValue() { + return super.getLightValue(); + } + + @Override + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, + float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) { + // TODO Auto-generated method stub + return super.onBlockPlaced(p_149660_1_, p_149660_2_, p_149660_3_, p_149660_4_, p_149660_5_, p_149660_6_, + p_149660_7_, p_149660_8_, p_149660_9_); + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.isProvidingWeakPower(world, x, y, z, side); + } + return 0; + } + + @Override + public boolean canProvidePower() { + return false; + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.isProvidingStrongPower(world, x, y, z, side); + } + return 0; + } + + @Override + public boolean hasComparatorInputOverride() { + // TODO Auto-generated method stub + return super.hasComparatorInputOverride(); + } + + @Override + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, + int p_149736_5_) { + // TODO Auto-generated method stub + return super.getComparatorInputOverride(p_149736_1_, p_149736_2_, p_149736_3_, p_149736_4_, p_149736_5_); + } + + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.canConnectRedstone(world, x, y, z, side); + } + return false; + } + + @Override + public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.shouldCheckWeakPower(world, x, y, z, side); + } + return isNormalCube(); + } + + @Override + public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.getWeakChanges(world, x, y, z); + } + return false; + } + + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public abstract IIcon getIcon(final int side, final int meta); + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public abstract void getSubBlocks(final Item item, final CreativeTabs tab, final List list); + + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ); + + if (!aWorld.isRemote) { + if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4); + } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2); + } + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which + * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor + * Block + */ + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) { + + TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ); + + if (!aWorld.isRemote) { + if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4); + } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2); + } + } + } + + /** + * Ticks the block if it's been scheduled + */ + public void updateTick(World aWorld, int aX, int aY, int aZ, Random p_149674_5_) { + TileEntityRedstoneHandler aTile = getTileEntity(aWorld, aX, aY, aZ); + // Client side handling + if (aTile != null) { + this.setLightLevel(aTile.getLightBrightness()); + } + // Only continue on server + if (aWorld.isRemote) { + return; + } + if (aTile != null) { + if (aTile.isGettingIndirectlyPowered()) { + } + } + } + + public TileEntityRedstoneHandler getTileEntity(IBlockAccess world, int aX, int aY, int aZ) { + TileEntity aTemp = world.getTileEntity(aX, aY, aZ); + if (aTemp != null) { + if (aTemp instanceof TileEntityRedstoneHandler) { + TileEntityRedstoneHandler g = (TileEntityRedstoneHandler) aTemp; + if (g != null) { + return g; + } + } + } + return null; + } + + + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @SideOnly(Side.CLIENT) + @Override + public abstract Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_); + + /** + * Returns an item stack containing a single instance of the current block type. + * 'i' is the block's subtype/damage and is ignored for blocks which do not + * support subtypes. Blocks which cannot be harvested should return null. + */ + @Override + protected abstract ItemStack createStackedBlock(int p_149644_1_); + + @Override + public abstract ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int metadata, final int fortune); + + @Override + public abstract Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_); + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java new file mode 100644 index 0000000000..43247110f1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java @@ -0,0 +1,131 @@ +package gtPlusPlus.core.block.general.redstone; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockGenericRedstoneDetector extends BlockGenericRedstone { + + public BlockGenericRedstoneDetector() { + super("detector", "Redstone Detector"); + setTickRandomly(true); + } + + @Override + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TileEntityRedstoneDetector(); + } + + public class TileEntityRedstoneDetector extends TileEntityRedstoneHandler { + public TileEntityRedstoneDetector() { + super(0); + } + + @Override + protected Class<? extends TileEntity> getTileEntityClass() { + return this.getClass(); + } + + @Override + protected String getTileEntityNameForRegistration() { + return "TileEntityRedstoneDetector"; + } + } + + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) { + aList.add(ItemUtils.getSimpleStack(this)); + } + + + @Override + public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) { + super.updateTick(aWorld, aX, aY, aZ, aRand); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + // TODO Auto-generated method stub + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + // TODO Auto-generated method stub + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + protected ItemStack createStackedBlock(int p_149644_1_) { + return ItemUtils.simpleMetaStack(this, p_149644_1_, 1); + } + + public void generateTextureArray(final IIconRegister iicon) { + HashMap<Integer, HashMap<ForgeDirection, IIcon>> aTextures = new HashMap<Integer, HashMap<ForgeDirection, IIcon>>(); + + + //New Block for Each Meta + int aMeta = 0; + { + HashMap<ForgeDirection, IIcon> aTempMap = new HashMap<ForgeDirection, IIcon>(); + aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTextures.put(aMeta++, aTempMap); + } + + } + + @Override + public IIcon getIcon(int side, int meta) { + HashMap<ForgeDirection, IIcon> aTemp = getTextureArray().get(meta); + if (aTemp != null) { + IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + else { + //Smart calculate missing sides + if (side <= 1) { + for (int ss = 0; ss < 2; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + for (int ss = 2; ss < 6; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + } + return blockIcon; + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); + aDrops.add(ItemUtils.getSimpleStack(this)); + return aDrops; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java new file mode 100644 index 0000000000..df8a929302 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java @@ -0,0 +1,5 @@ +package gtPlusPlus.core.block.general.redstone; + +public class BlockGenericRedstoneEmitter { + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java new file mode 100644 index 0000000000..0f1f983cd0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java @@ -0,0 +1,201 @@ +package gtPlusPlus.core.block.general.redstone; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.world.explosions.ExplosionHandler; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockGenericRedstoneTest extends BlockGenericRedstone { + + public BlockGenericRedstoneTest() { + super("test", "Redstone Test"); + setTickRandomly(true); + } + + @Override + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TileEntityRedstoneTest(); + } + + public class TileEntityRedstoneTest extends TileEntityRedstoneHandler { + public TileEntityRedstoneTest() { + super(2); + } + + @Override + public boolean isScrewdriverable() { + return true; + } + + @Override + public boolean onScrewdriverLMB() { + return super.onScrewdriverLMB(); + } + + @Override + public boolean onScrewdriverRMB() { + if (this.mLightValue + 0.0625f <= 1) { + this.mLightValue += 0.0625f; + } + else { + this.mLightValue = 0; + } + this.markForUpdate(); + return true; + } + + @Override + public boolean isMalletable() { + return true; + } + + @Override + public boolean onMalletLMB() { + return super.onMalletLMB(); + } + + @Override + public boolean onMalletRMB() { + this.mLightMode = Utils.invertBoolean(mLightMode); + this.markForUpdate(); + return mLightMode; + } + + @Override + public boolean isWrenchable() { + return true; + } + + @Override + public boolean onWrenchLMB() { + return super.onWrenchLMB(); + } + + @Override + public boolean onWrenchRMB() { + Logger.INFO("Found Wrench"); + ExplosionHandler explode = new ExplosionHandler(); + explode.createExplosion(this.worldObj, null, this.xCoord, this.yCoord, this.zCoord, 1f, false, true); + return true; + } + + @Override + protected Class<? extends TileEntity> getTileEntityClass() { + return this.getClass(); + } + + @Override + protected String getTileEntityNameForRegistration() { + return "TileEntityRedstoneTest"; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return super.isProvidingWeakPower(world, x, y, z, side); + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + return super.isProvidingStrongPower(world, x, y, z, side); + } + } + + @SuppressWarnings("unchecked") + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) { + aList.add(ItemUtils.getSimpleStack(this)); + } + + + @Override + public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) { + super.updateTick(aWorld, aX, aY, aZ, aRand); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + protected ItemStack createStackedBlock(int p_149644_1_) { + return ItemUtils.simpleMetaStack(this, p_149644_1_, 1); + } + + public void generateTextureArray(final IIconRegister iicon) { + HashMap<Integer, HashMap<ForgeDirection, IIcon>> aTextures = new HashMap<Integer, HashMap<ForgeDirection, IIcon>>(); + + + //New Block for Each Meta + int aMeta = 0; + { + HashMap<ForgeDirection, IIcon> aTempMap = new HashMap<ForgeDirection, IIcon>(); + aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put(ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTextures.put(aMeta++, aTempMap); + } + + } + + @Override + public IIcon getIcon(int side, int meta) { + HashMap<ForgeDirection, IIcon> aTemp = getTextureArray().get(meta); + if (aTemp != null) { + IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + else { + //Smart calculate missing sides + if (side <= 1) { + for (int ss = 0; ss < 2; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + for (int ss = 2; ss < 6; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + } + return blockIcon; + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); + aDrops.add(ItemUtils.getSimpleStack(this)); + return aDrops; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java new file mode 100644 index 0000000000..a4ed895b13 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.block.machine; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.IBlockAccess; + +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.block.base.MetaBlock; +import gtPlusPlus.core.lib.CORE; + +public class BlockGtFrameBox extends MetaBlock { + + private int[] colours; + private int totalColours; + + public BlockGtFrameBox( + final String unlocalizedName, final Material material, + final BlockTypes blockTypeENUM, final boolean recolour, final int... colour) { + super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); + this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); + this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); + if (recolour && ((colour != null) && (colour.length > 0))){ + this.colours = colour; + this.totalColours = this.colours.length; + } + } + + @Override + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, + final int p_149720_3_, final int p_149720_4_) { + for (final int i : this.colours){ + + } + return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java new file mode 100644 index 0000000000..7d8b3eb708 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java @@ -0,0 +1,159 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class CircuitProgrammer extends BasicTileBlockWithTooltip { + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 4; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public CircuitProgrammer(){ + super(Material.iron); + LanguageRegistry.addName(this, "Circuit Programmer"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityCircuitProgrammer tile = (TileEntityCircuitProgrammer) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } + catch (final Throwable t) {} + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityCircuitProgrammer)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI8, world, x, y, z); + return true; + } + } + else { + return true; + } + + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityCircuitProgrammer(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityCircuitProgrammer) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockCircuitProgrammer"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Circuit Programmer"; + } + + @Override + public CubicObject<String>[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I" + }; + CubicObject<String>[] aTextureData = new CubicObject[] {new CubicObject<String>(aTexData)}; + return aTextureData; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java b/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java new file mode 100644 index 0000000000..15d330defc --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java @@ -0,0 +1,223 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.client.renderer.RenderDecayChest; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class DecayablesChest extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 5; + public final int field_149956_a = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public DecayablesChest() + { + super(Material.iron); + this.setBlockName("blockDecayablesChest"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockDecayablesChest"); + LanguageRegistry.addName(this, "Lead Lined Box"); + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + public boolean isOpaqueCube() + { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() + { + return false; + } + + /** + * The type of render function that is called for this block + */ + @SideOnly(Side.CLIENT) + public int getRenderType(){ + try { + if (RenderDecayChest.INSTANCE != null){ + return RenderDecayChest.INSTANCE.mRenderID; + } + return super.getRenderType(); + } + catch (NullPointerException n) { + return 0; + } + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ - 1) == this) + { + this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F); + } + else if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ + 1) == this) + { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F); + } + else if (p_149719_1_.getBlock(p_149719_2_ - 1, p_149719_3_, p_149719_4_) == this) + { + this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + else if (p_149719_1_.getBlock(p_149719_2_ + 1, p_149719_3_, p_149719_4_) == this) + { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F); + } + else + { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + } + + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_bottom"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityDecayablesChest)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI13, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityDecayablesChest(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityDecayablesChest) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + + /** + * Update Chest Meta - Stub + * @param aWorld + * @param xPos + * @param yPos + * @param zPos + */ + @Deprecated + public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) + { + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/EggBox.java b/src/main/java/gtPlusPlus/core/block/machine/EggBox.java new file mode 100644 index 0000000000..630c4b5bc2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/EggBox.java @@ -0,0 +1,175 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class EggBox extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 7; + public final int field_149956_a = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public EggBox(){ + super(Material.wood); + this.setBlockName("blockEggBox"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockEggBox"); + LanguageRegistry.addName(this, "Egg Box"); + + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() + { + return true; + } + + /** + * The type of render function that is called for this block + */ + @SideOnly(Side.CLIENT) + public int getRenderType(){ + return super.getRenderType(); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : this.textureFront; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityEggBox)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI17, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityEggBox(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityEggBox) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + + /** + * Update Chest Meta - Stub + * @param aWorld + * @param xPos + * @param yPos + * @param zPos + */ + @Deprecated + public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) + { + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java b/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java new file mode 100644 index 0000000000..037ec61ced --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java @@ -0,0 +1,152 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.util.minecraft.InventoryUtils; + +public class FishTrap extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public FishTrap() + { + super(Material.iron); + this.setBlockName("blockFishTrap"); + this.setHardness(5f); + this.setResistance(1f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockFishTrap"); + LanguageRegistry.addName(this, "Fish Catcher"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityFishTrap)){ + player.openGui(GTplusplus.instance, 5, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityFishTrap(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java b/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java new file mode 100644 index 0000000000..5dc8604a93 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java @@ -0,0 +1,95 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; + +public class HeliumGenerator extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + + @SuppressWarnings("deprecation") + public HeliumGenerator() + { + super(Material.wood); + this.setBlockName("blockHeliumGenerator"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockHeliumGenerator"); + LanguageRegistry.addName(this, "Helium Generator"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityHeliumGenerator)){ //TODO + player.openGui(GTplusplus.instance, 1, world, x, y, z); //TODO + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityHeliumGenerator(); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java new file mode 100644 index 0000000000..6f60d39ce7 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java @@ -0,0 +1,103 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; + +public class Machine_ModularityTable extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 1; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public Machine_ModularityTable() + { + super(Material.iron); + this.setBlockName("blockModularity"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockModularity"); + LanguageRegistry.addName(this, "Modularity Configurator"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_side"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_output"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_side"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz){ + if (world.isRemote) { + return true; + } + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityModularityTable)){ + player.openGui(GTplusplus.instance, 1, world, x, y, z); + Logger.INFO("Player opened GUI"); + return true; + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityModularityTable(); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java new file mode 100644 index 0000000000..11fa80f439 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java @@ -0,0 +1,137 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class Machine_PestKiller extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 6; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public Machine_PestKiller() + { + super(Material.wood); + this.setBlockName("blockPestKiller"); + this.setHardness(5f); + this.setResistance(1f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockPestKiller"); + LanguageRegistry.addName(this, "Pest Killer"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int p_149691_2_) + { + return aSide == 1 ? this.textureTop : (aSide == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_PESTKILLER_TOP"); + this.textureBottom = p_149651_1_.registerIcon("planks_acacia"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityPestKiller)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI15, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityPestKiller(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityPestKiller) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java new file mode 100644 index 0000000000..945cf7b581 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java @@ -0,0 +1,182 @@ +package gtPlusPlus.core.block.machine; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityBaseFluidCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class Machine_PooCollector extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureTop2; + @SideOnly(Side.CLIENT) + private IIcon textureSide; + @SideOnly(Side.CLIENT) + private IIcon textureSide2; + + public Machine_PooCollector() { + super(Material.iron); + this.setHardness(5f); + this.setResistance(1f); + this.setBlockName("blockPooCollector"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class,"blockPooCollector"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int aMeta) { + if (aMeta <= 7) { + blockIcon = textureSide; + return aSide <= 1 ? this.textureTop : this.textureSide; + } + else { + blockIcon = textureSide2; + return aSide <= 1 ? this.textureTop2 : this.textureSide2; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_top"); + this.textureTop2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_top"); + this.textureSide = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_sides"); + this.textureSide2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_sides"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + if (world.isRemote) { + return true; + } else { + TileEntityBaseFluidCollector tank = (TileEntityBaseFluidCollector) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem().getItem(); + } catch (Throwable t) { + handItem = null; + } + + //Fluid container code + /*if (handItem != null + && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); + + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + }*/ + + if (!tank.mInventory.isEmpty()) { + PlayerUtils.messagePlayer(player, "Inventory contains:"); + PlayerUtils.messagePlayer(player, ItemUtils.getArrayStackNames(tank.mInventory.getRealInventory())); + } + else { + PlayerUtils.messagePlayer(player, "No solids collected yet."); + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer(player, "Tank contains " + tank.tank.getFluidAmount() + "L of " + + tank.tank.getFluid().getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return super.isOpaqueCube(); + } + + @Override + public TileEntity createNewTileEntity(final World world, final int aMeta) { + return aMeta <= 7 ? new TileEntityPooCollector() : new TileEntityAdvPooCollector(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public int getBlockColor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public int getRenderColor(int aMeta) { + return super.getRenderColor(aMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 8)); + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java new file mode 100644 index 0000000000..fdb6b1a0a8 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -0,0 +1,164 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.item.tool.ItemToolWrench; + +@Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") +public class Machine_ProjectTable extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 3; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public Machine_ProjectTable() + { + super(Material.iron); + this.setBlockName("blockProjectBench"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockProjectBench"); + LanguageRegistry.addName(this, "Project Workbench"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + + ItemStack heldItem = null; + if (world.isRemote){ + heldItem = PlayerUtils.getItemStackInPlayersHand(); + } + + boolean holdingWrench = false; + + if (heldItem != null){ + holdingWrench = isWrench(heldItem); + } + + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityProjectTable)) + { + if (!holdingWrench){ + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + } + Logger.INFO("Holding a Wrench, doing wrench things instead."); + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityProjectTable(); + } + + public static boolean isWrench(final ItemStack item){ + if (item.getItem() instanceof ItemToolWrench){ + return true; + } + if (LoadedMods.BuildCraft){ + return checkBuildcraftWrench(item); + } + if (LoadedMods.EnderIO){ + return checkEnderIOWrench(item); + } + return false; + } + + @Optional.Method(modid = "EnderIO") + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { + Class<?> wrenchClass; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Optional.Method(modid = "Buildcraft") + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { + Class<?> wrenchClass; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java new file mode 100644 index 0000000000..dc87b885b9 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java @@ -0,0 +1,131 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockRoundRobinator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Machine_RoundRobinator extends BasicTileBlockWithTooltip { + + + public Machine_RoundRobinator(){ + super(Material.iron); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + if (ItemUtils.isToolScrewdriver(mHandStack)) { + final TileEntityRoundRobinator tile = (TileEntityRoundRobinator) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } + catch (final Throwable t) {} + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityRoundRobinator)){ + return ((TileEntityRoundRobinator) te).onRightClick((byte) side, player, x, y, z); + } + return false; + } + else { + return true; + } + } + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityRoundRobinator(); + } + + @Override + public int getMetaCount() { + return 5; + } + + @Override + public String getUnlocalBlockName() { + return "blockRoundRobinator"; + } + + @Override + protected float initBlockHardness() { + return 1; + } + + @Override + protected float initBlockResistance() { + return 1; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + public int getTooltipID() { + return -1; + } + + @Override + protected String getTileEntityName() { + return "Round Robinator"; + } + + @Override + public Class<? extends ItemBlock> getItemBlockClass() { + return ItemBlockRoundRobinator.class; + } + + @Override + public CubicObject<String>[] getCustomTextureDirectoryObject() { + AutoMap<String[]> aTemp = new AutoMap<String[]>(); + for (int i=0;i<5;i++) { + String[] aTexData = new String[] { + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + }; + aTemp.put(aTexData); + } + AutoMap<CubicObject<String>> aTemp2 = new AutoMap<CubicObject<String>>(); + for (String[] y : aTemp) { + aTemp2.put(new CubicObject<String>(y)); + } + CubicObject<String>[] aTextureData = new CubicObject[] {aTemp2.get(0), aTemp2.get(1), aTemp2.get(2), aTemp2.get(3), aTemp2.get(4)}; + return aTextureData; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java new file mode 100644 index 0000000000..021279f820 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java @@ -0,0 +1,579 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.inventories.Inventory_SuperJukebox; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockJukebox; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemRecord; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class Machine_SuperJukebox extends BlockJukebox +{ + @SideOnly(Side.CLIENT) + private IIcon mIcon; + + public Machine_SuperJukebox(){ + this.setBlockName("blockSuperJukebox"); + this.setCreativeTab(CreativeTabs.tabRedstone); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypePiston); + setBlockTextureName("jukebox"); + GameRegistry.registerBlock(this, "blockSuperJukebox"); + LanguageRegistry.addName(this, "Sir Mixalot [Jukebox]"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon(int aSide, int aMeta) + { + return aSide == 1 ? this.mIcon : this.blockIcon; + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntitySuperJukebox)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI14, world, x, y, z); + return true; + } + return false; + + + /* if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) + { + return false; + } + else + { + this.func_149925_e(aWorld, aX, aY, aZ); + return true; + }*/ + } + + /** + * Set the record in the {@link SuperJukebox} {@link TileEntity}. + */ + @Override + public final void func_149926_b(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { + setRecordInJukeBox(aWorld, aX, aY, aZ, aStackToSet); + } + + public void setRecordInJukeBox(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + if (tileentityjukebox != null && aStackToSet.getItem() instanceof ItemRecord) { + tileentityjukebox.setCurrentRecord(aStackToSet.copy()); + //aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 1, 2); + } + } + } + + /** + * Function to handle playing of records. + */ + @Override + public final void func_149925_e(World aWorld, int aX, int aY, int aZ) { + playJukeboxRecord(aWorld, aX, aY, aZ); + } + + public void playJukeboxRecord(World aWorld, int aX, int aY, int aZ) { + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, + aY, aZ); + + if (tileentityjukebox != null) { + ItemStack itemstack = tileentityjukebox.func_145856_a(); + + if (itemstack != null) { + + + + aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(itemstack.getItem())); + //aWorld.playRecord((String) null, aX, aY, aZ); + //tileentityjukebox.func_145857_a((ItemStack) null); + //aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 0, 2); + /*float f = 0.7F; + double d0 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; + double d2 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + ItemStack itemstack1 = itemstack.copy(); + EntityItem entityitem = new EntityItem(aWorld, (double) aX + d0, + (double) aY + d1, (double) aZ + d2, itemstack1); + entityitem.delayBeforeCanPickup = 10; + aWorld.spawnEntityInWorld(entityitem);*/ + } + } + } + } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + /** + * Drops the block items with a specified chance of dropping the specified items + */ + @Override + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!p_149690_1_.isRemote) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0); + } + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the block. + */ + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntitySuperJukebox(); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.mIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + } + + public static class TileEntitySuperJukebox extends TileEntityJukebox implements ISidedInventory { + + /** The number of players currently using this chest */ + public int numPlayersUsing; + private ItemStack mCurrentlyPlayingStack; + private final Inventory_SuperJukebox inventoryContents; + private String customName; + + + /* + * Important Data + */ + + public int a_TEST_INT_VAR_1; + public int a_TEST_INT_VAR_2; + public int a_TEST_INT_VAR_3; + public int a_TEST_INT_VAR_4; + + public boolean mIsPlaying = false; + public boolean mIsLooping = false; + public boolean a_TEST_BOOL_VAR_3; + public boolean a_TEST_BOOL_VAR_4; + + + + public TileEntitySuperJukebox() { + this.inventoryContents = new Inventory_SuperJukebox(); + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + + if (aNBT.hasKey("RecordItem", 10)) { + this.func_145857_a(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("RecordItem"))); + } else if (aNBT.getInteger("Record") > 0) { + this.func_145857_a(new ItemStack(Item.getItemById(aNBT.getInteger("Record")), 1, 0)); + } + + this.inventoryContents.readFromNBT(aNBT.getCompoundTag("ContentsChest")); + if (aNBT.hasKey("CustomName", 8)) { + this.setCustomName(aNBT.getString("CustomName")); + } + + mIsPlaying = aNBT.getBoolean("mIsPlaying"); + mIsLooping = aNBT.getBoolean("mIsLooping"); + + + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + + if (this.getCurrentRecord() != null) { + aNBT.setTag("RecordItem", this.func_145856_a().writeToNBT(new NBTTagCompound())); + aNBT.setInteger("Record", Item.getIdFromItem(this.func_145856_a().getItem())); + } + + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + aNBT.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + aNBT.setString("CustomName", this.getCustomName()); + } + + aNBT.setBoolean("mIsPlaying", mIsPlaying); + aNBT.setBoolean("mIsLooping", mIsLooping); + + } + + /** + * Called to get the internal stack + */ + @Override + public ItemStack func_145856_a() { + return this.mCurrentlyPlayingStack; + } + + /** + * Called to get the internal stack, wraps vanilla function + * {@link func_145856_a}. + */ + public ItemStack getCurrentRecord() { + return func_145856_a(); + } + + /** + * Called to set the internal stack + */ + @Override + public void func_145857_a(ItemStack p_145857_1_) { + this.mCurrentlyPlayingStack = p_145857_1_; + this.markDirty(); + } + + /** + * Called to set the internal stack, wraps vanilla function + * {@link func_145857_a}. + */ + public void setCurrentRecord(ItemStack aStack) { + func_145857_a(aStack); + this.markDirty(); + } + + public Inventory_SuperJukebox getInventory() { + return this.inventoryContents; + } + + + + + + public boolean playRecord(ItemStack aRecord) { + + + + return false; + } + + public boolean stopRecord() { + return openDiscDrive(); + } + + public void setLoopState(boolean isShufflingForever) { + + + + } + + + //Play button pressed + public boolean jukeboxLogicUpdate() { + + if (this.worldObj.isRemote) { + return true; + } + + Logger.INFO("a"); + if (this.mIsPlaying || this.mIsLooping) { + return selectRecordToPlayFromInventoryAndSetViaVanillaHandler(); + } + else { + return stopRecord(); + } + } + + + //Determine which record to play + public boolean selectRecordToPlayFromInventoryAndSetViaVanillaHandler() { + AutoMap<ItemStack> mValidRecords = new AutoMap<ItemStack>(); + for (ItemStack g : this.getInventory().getInventory()) { + if (g != null) { + if (g.getItem() instanceof ItemRecord) { + mValidRecords.put(g); + } + } + } + + Logger.INFO("b1"); + //Select First Record + ItemStack aRecordToPlay; + if (mValidRecords.size() == 0) { + Logger.INFO("bX"); + return false; + } + else { + aRecordToPlay = mValidRecords.get(!mIsLooping ? 0 : MathUtils.randInt(0, (mValidRecords.size()-1))); + } + Logger.INFO("b2 - "+aRecordToPlay.getDisplayName()); + + int aSlotCounter = 0; + for (ItemStack g : this.getInventory().getInventory()) { + if (g != null && aSlotCounter <= 17) { + Logger.INFO("b3 - "+g.getDisplayName()); + if (GT_Utility.areStacksEqual(g, aRecordToPlay, true)) { + IInventory aThisInv = this.getInventory(); + if (aThisInv.getStackInSlot(20) != null) { + openDiscDrive(); + } + + GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, aSlotCounter, 20, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + setCurrentRecord(aThisInv.getStackInSlot(20)); + + World aWorld = this.worldObj; + int aX = this.xCoord; + int aY = this.yCoord; + int aZ = this.zCoord; + if (!aWorld.isRemote) { + aRecordToPlay = this.func_145856_a(); + if (aRecordToPlay != null) { + aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(aRecordToPlay.getItem())); + this.markDirty(); + return true; + } + } + + Logger.INFO("b++"); + this.markDirty(); + return false; + } + } + aSlotCounter++; + } + + + Logger.INFO("b4"); + this.markDirty(); + return false; + } + + + public boolean genericMethodThree(Object a1, Object a2, Object a3, Object a4) { + return false; + } + + + public void vanillaStopJukebox() { + World aWorld = this.worldObj; + int aX = this.xCoord; + int aY = this.yCoord; + int aZ = this.zCoord; + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + if (tileentityjukebox != null) { + ItemStack aRecordToPlay = tileentityjukebox.func_145856_a(); + if (aRecordToPlay != null) { + aWorld.playAuxSFX(1005, aX, aY, aZ, 0); + aWorld.playRecord((String) null, aX, aY, aZ); + tileentityjukebox.func_145857_a((ItemStack) null); + this.markDirty(); + } + } + } + } + + public boolean openDiscDrive() { + int aSlotCounter = 17; + + ItemStack g; + + for (int i = 17; i >= 0; i--) { + g = this.getInventory().getInventory()[i]; + if (g == null && aSlotCounter >= 0) { + IInventory aThisInv = this.getInventory(); + GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, i, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + vanillaStopJukebox(); + Logger.INFO("b++"); + this.markDirty(); + return true; + + } + } + + + /*for (ItemStack g : this.getInventory().getInventory()) { + if (g == null && aSlotCounter >= 0) { + IInventory aThisInv = this.getInventory(); + GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, aSlotCounter, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + vanillaStopJukebox(); + Logger.INFO("b++"); + return true; + + } + aSlotCounter--; + } */ + this.markDirty(); + return false; + } + + + + + + + + + + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, + 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory()-3; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + } + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, + this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + } + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, + this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + if (slot >= 18) { + return false; + } + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + private final static int[] SIDED_SLOTS = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return SIDED_SLOTS; + + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + if (p_102007_1_ >= 18) { + return false; + } + return this.getInventory().isItemValidForSlot(p_102007_1_, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + if (p_102008_1_ >= 18) { + return false; + } + return this.getInventory().isItemValidForSlot(p_102008_1_, p_102008_2_); + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.SuperJukebox"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java new file mode 100644 index 0000000000..5195e0f18c --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java @@ -0,0 +1,86 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.base.BlockBaseNBT; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; + +public class Machine_TradeTable extends BlockBaseNBT implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 2; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + public Machine_TradeTable(){ + super(Material.leaves, "blockTradeBench", "Trade-o-Mat"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_){ + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "workbench_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz){ + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityTradeTable)) + { + //Utils.LOG_INFO("Clicked on TE - ok"); + player.openGui(GTplusplus.instance, 6, world, x, y, z); + return true; + } + else { + Logger.INFO("Bad TE"); + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityTradeTable(); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java new file mode 100644 index 0000000000..e964a9da01 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java @@ -0,0 +1,5 @@ +package gtPlusPlus.core.block.machine; + +public class Machine_WireiusDeletus { //A Block that removes GT Cable and Wire from it's inventory. + +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_Workbench.java new file mode 100644 index 0000000000..5c08612042 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -0,0 +1,152 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.item.tool.ItemToolWrench; + +@Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") +public class Machine_Workbench extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public Machine_Workbench() + { + super(Material.iron); + this.setBlockName("blockWorkbenchGT"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockWorkbenchGT"); + LanguageRegistry.addName(this, "Bronze Workbench"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side_cabinet"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_top_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side_cabinet"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + + ItemStack heldItem = null; + if (world.isRemote){ + heldItem = PlayerUtils.getItemStackInPlayersHand(); + } + + boolean holdingWrench = false; + + if (heldItem != null){ + holdingWrench = isWrench(heldItem); + } + + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityWorkbench)) + { + if (!holdingWrench){ + player.openGui(GTplusplus.instance, 3, world, x, y, z); + return true; + } + Logger.INFO("Holding a Wrench, doing wrench things instead."); + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityWorkbench(); + } + + public static boolean isWrench(final ItemStack item){ + if (item.getItem() instanceof ItemToolWrench){ + return true; + } + if (LoadedMods.BuildCraft){ + return checkBuildcraftWrench(item); + } + if (LoadedMods.EnderIO){ + return checkEnderIOWrench(item); + } + return false; + } + + @Optional.Method(modid = "EnderIO") + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { + Class<?> wrenchClass; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Optional.Method(modid = "Buildcraft") + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { + Class<?> wrenchClass; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java new file mode 100644 index 0000000000..af2f9f82e0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java @@ -0,0 +1,111 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; + +public class Machine_WorkbenchAdvanced extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public Machine_WorkbenchAdvanced() + { + super(Material.iron); + this.setBlockName("blockWorkbenchGTAdvanced"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockWorkbenchGTAdvanced"); + LanguageRegistry.addName(this, "Advanced Workbench"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + + /*final ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(player); + if (world.isRemote) { + return true; + } + boolean holdingWrench = false; + + if (heldItem != null){ + if (heldItem.getItem() instanceof ItemToolWrench){ + holdingWrench = true; + } + else if (heldItem.getItem() instanceof IToolWrench){ + holdingWrench = true; + } + else if (heldItem.getItem() instanceof ITool){ + holdingWrench = true; + } + else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ + GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) heldItem.getItem(); + if (testTool.canWrench(player, x, y, z)){ + holdingWrench = true; + } + } + else { + holdingWrench = false; + } + } + + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityWorkbenchAdvanced)) + { + if (!holdingWrench){ + player.openGui(GTplusplus.instance, 4, world, x, y, z); + return true; + } + Utils.LOG_INFO("Holding a Wrench, doing wrench things instead."); + }*/ + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityWorkbenchAdvanced(128000, 2); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java new file mode 100644 index 0000000000..90f9c1056a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java @@ -0,0 +1,164 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui2; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class VolumetricFlaskSetter extends BasicTileBlockWithTooltip { + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 8; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @Override + public Class<? extends ItemBlock> getItemBlockClass() { + return ItemBlockBasicTile.class; + } + + @SuppressWarnings("deprecation") + public VolumetricFlaskSetter(){ + super(Material.iron); + LanguageRegistry.addName(this, "Volumetric Flask Configurator"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityVolumetricFlaskSetter tile = (TileEntityVolumetricFlaskSetter) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } + catch (final Throwable t) {} + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityVolumetricFlaskSetter)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI18, world, x, y, z); + TileEntityVolumetricFlaskSetter aTile = (TileEntityVolumetricFlaskSetter) te; + //new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); + return true; + } + } + else { + return true; + } + + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityVolumetricFlaskSetter(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityVolumetricFlaskSetter) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockVolumetricFlaskSetter"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Volumetric Flask Configurator"; + } + + @Override + public CubicObject<String>[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_A", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_C", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H" + }; + CubicObject<String>[] aTextureData = new CubicObject[] {new CubicObject<String>(aTexData)}; + return aTextureData; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java new file mode 100644 index 0000000000..b8f9662ac7 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java @@ -0,0 +1,159 @@ +package gtPlusPlus.core.block.machine.bedrock; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; + +public class Mining_Head_Fake extends Block{ + + public Mining_Head_Fake(){ + super(Material.lava); + this.setBlockName(Utils.sanitizeString("blockMiningHeadFake")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(50000.0F); + this.setHarvestLevel("pickaxe", 10); + this.setStepSound(soundTypeMetal); + //LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockMiningHeadFake")); + } + + public String GetProperName(){ + return "Hardened Mining Head"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 1; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ + //prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, + final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { + + } + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, + final Entity entity) { + return false; + } + + + //Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(175, 64, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public boolean isCollidable() { + return true; + } + + @Override + public void randomDisplayTick(World world, int posX, int posY, int posZ, + Random rand) { + generateVoidParticlesAroundBlockPos(new BlockPos(posX, posY, posZ, world), 2); + super.randomDisplayTick(world, posX, posY, posZ, rand); + } + + @Override + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, + Entity ent) { + EntityUtils.doDamage(ent, DamageSource.outOfWorld, 20); + EntityUtils.setEntityOnFire(ent, 100); + super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, ent); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + return false; + } + + public static void generateVoidParticlesAroundBlockPos(BlockPos Pos, int range){ + for (BlockPos G : Pos.getSurroundingBlocks()) { + int i1 = G.xPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); + int j1 = G.yPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); + int k1 = G.zPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); + + Block block = Pos.world.getBlock(i1, j1, k1); + + if (block.getMaterial() == Material.air){ + + //lava + if (Pos.yPos <= 7) { + Pos.world.spawnParticle("portal", (double)((float)i1 + CORE.RANDOM.nextFloat()), (double)((float)j1 + CORE.RANDOM.nextFloat()), (double)((float)k1 + CORE.RANDOM.nextFloat()), 0.0D, 0.0D, 0.0D); + Pos.world.spawnParticle("lava", (double)((float)i1 + CORE.RANDOM.nextFloat()), (double)((float)j1 + CORE.RANDOM.nextFloat()), (double)((float)k1 + CORE.RANDOM.nextFloat()), 0.0D, 0.0D, 0.0D); + } + else { + Pos.world.spawnParticle("portal", (double)((float)i1 + CORE.RANDOM.nextFloat()), (double)((float)j1 + CORE.RANDOM.nextFloat()), (double)((float)k1 + CORE.RANDOM.nextFloat()), 0.0D, 0.0D, 0.0D); + } + + } + } + } + + +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java new file mode 100644 index 0000000000..bba185a0c1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java @@ -0,0 +1,136 @@ +package gtPlusPlus.core.block.machine.bedrock; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; + +public class Mining_Pipe_Fake extends Block{ + + public Mining_Pipe_Fake(){ + super(Material.cactus); + this.setBlockName(Utils.sanitizeString("blockMiningPipeFake")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(50000.0F); + this.setHarvestLevel("pickaxe", 8); + this.setStepSound(soundTypeMetal); + //LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockMiningPipeFake")); + } + + public String GetProperName(){ + return "Hardened Mining Pipe"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 1; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ + //prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, + final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { + + } + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, + final Entity entity) { + return false; + } + + + //Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public boolean isCollidable() { + return true; + } + + @Override + public void randomDisplayTick(World world, int posX, int posY, int posZ, + Random rand) { + Mining_Head_Fake.generateVoidParticlesAroundBlockPos(new BlockPos(posX, posY, posZ, world), 2); + super.randomDisplayTick(world, posX, posY, posZ, rand); + } + + @Override + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity ent) { + if (MathUtils.randInt(0, 100) < 5) { + EntityUtils.doDamage(ent, DamageSource.outOfWorld, 1); + } + super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, ent); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + return false; + } + + + +} |