aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/block/general
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-09-07 16:36:25 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-09-07 16:36:25 +1000
commit221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch)
treed6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/block/general
parent5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff)
downloadGT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz
GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2
GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/block/general')
-rw-r--r--src/Java/gtPlusPlus/core/block/general/LightGlass.java128
-rw-r--r--src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java276
-rw-r--r--src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java51
-rw-r--r--src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java50
4 files changed, 505 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/block/general/LightGlass.java b/src/Java/gtPlusPlus/core/block/general/LightGlass.java
new file mode 100644
index 0000000000..5aa9f5b818
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/LightGlass.java
@@ -0,0 +1,128 @@
+package gtPlusPlus.core.block.general;
+
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+
+import java.util.Random;
+
+import net.minecraft.block.BlockBreakable;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class LightGlass extends BlockBreakable
+{
+ private int state = 0;
+ private int a = 255;
+ private int r = 255;
+ private int g = 0;
+ private int b = 0;
+ private int hex;
+
+ public LightGlass(Material mat, boolean bool)
+ {
+ super("blockMFEffect", mat, bool);
+ this.setCreativeTab(AddToCreativeTab.tabBlock);
+ this.setBlockName("blockMFEffect");
+ this.setLightLevel(12F);
+ this.setLightOpacity(0);
+ this.setTickRandomly(true);
+ this.setResistance(1);
+ }
+
+ /**
+ * Returns the quantity of items to drop on block destruction.
+ */
+ @Override
+ public int quantityDropped(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 true;
+ }
+
+ /**
+ * 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(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(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
+ {
+ if(state == 0){
+ g++;
+ if(g == 255)
+ state = 1;
+ }
+ if(state == 1){
+ r--;
+ if(r == 0)
+ state = 2;
+ }
+ if(state == 2){
+ b++;
+ if(b == 255)
+ state = 3;
+ }
+ if(state == 3){
+ g--;
+ if(g == 0)
+ state = 4;
+ }
+ if(state == 4){
+ r++;
+ if(r == 255)
+ state = 5;
+ }
+ if(state == 5){
+ b--;
+ if(b == 0)
+ state = 0;
+ }
+ hex = (a << 24) + (r << 16) + (g << 8) + (b);
+ return hex;
+ }
+
+ /**
+ * A randomly called display update to be able to add particles or other items for display
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void randomDisplayTick(World world, int posX, int posY, int posZ, Random random){
+ Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud");
+
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java
new file mode 100644
index 0000000000..7fa890b6c8
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java
@@ -0,0 +1,276 @@
+package gtPlusPlus.core.block.general.antigrief;
+
+import static gtPlusPlus.core.block.ModBlocks.blockGriefSaver;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.general.TileEntityReverter;
+import gtPlusPlus.core.util.Utils;
+
+import java.util.List;
+import java.util.Random;
+
+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 cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+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);
+ setHardness(10.0F);
+ setResistance(35.0F);
+ setStepSound(Block.soundTypeWood);
+ setCreativeTab(AddToCreativeTab.tabMachines);
+ }
+
+ public int tickRate()
+ {
+ return 15;
+ }
+
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setBoolean("bUnbreakable", bUnbreakable);
+ }
+
+ public void loadNBTData(NBTTagCompound aNBT) {
+ bUnbreakable = aNBT.getBoolean("bUnbreakable");
+ }
+
+ public IIcon getIcon(int side, int meta)
+ {
+ return TEX_ANTIBUILDER;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief");
+ }
+
+ public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
+ {
+ par3List.add(new ItemStack(par1, 1, 9));
+ }
+
+ public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
+ {
+ int meta = par1World.getBlockMetadata(x, y, z);
+ return false;
+ }
+
+ public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ);
+ }
+
+ public float getBlockHardness(World world, int x, int y, int z)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ return super.getBlockHardness(world, x, y, z);
+ }
+
+ public static boolean areNearbyLockBlocks(World world, int x, int y, 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(World par1World, int x, int y, int z)
+ {
+ Block thereBlockID = par1World.getBlock(x, y, z);
+ 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(World par1World, int x, int y, int z, int meta)
+ {
+ 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);
+ }
+ }
+
+ public void onBlockAdded(World par1World, int x, int y, int z)
+ {
+ int meta = par1World.getBlockMetadata(x, y, z);
+ if (!par1World.isRemote) {
+
+ }
+ }
+
+ public void onNeighborBlockChange(World par1World, int x, int y, int z, Block myBlockID)
+ {
+ int meta = par1World.getBlockMetadata(x, y, z);
+ if (!par1World.isRemote)
+ {
+
+ }
+ }
+
+ public void updateTick(World par1World, int x, int y, int z, Random par5Random)
+ {
+ if (!par1World.isRemote)
+ {
+ int meta = par1World.getBlockMetadata(x, y, z);
+ }
+ }
+
+ private void letsBuild(World par1World, int x, int y, int z)
+ {
+
+ }
+
+ private boolean isInactiveTrapCharged(World par1World, int x, int y, int z)
+ {
+ return false;
+ }
+
+ private boolean isReactorReady(World world, int x, int y, 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;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random)
+ {
+ int meta = par1World.getBlockMetadata(x, y, z);
+ if ((meta == 3) || (meta == 1) || (meta == 9)) {
+ for (int i = 0; i < 1; i++) {
+ sparkle(par1World, x, y, z, par5Random);
+ }
+ }
+ }
+
+ public void sparkle(World world, int x, int y, int z, Random rand)
+ {
+ 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(World world, int x, int y, int z)
+ {
+ Block thereID = world.getBlock(x, y, z);
+ int thereMeta = world.getBlockMetadata(x, y, z);
+ }
+
+ public static void changeToActiveVanishBlock(World par1World, int x, int y, int z, 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);
+
+ Block thereBlockID = par1World.getBlock(x, y, z);
+ par1World.scheduleBlockUpdate(x, y, z, thereBlockID, getTickRateFor(thereBlockID, meta, par1World.rand));
+ }
+
+ private static int getTickRateFor(Block thereBlockID, int meta, Random rand)
+ {
+ return 15;
+ }
+
+ public int getLightValue(IBlockAccess world, int x, int y, int z)
+ {
+ Block blockID = world.getBlock(x, y, z);
+ int meta = world.getBlockMetadata(x, y, z);
+ if (blockID != this) {
+ return 0;
+ }
+ return 10;
+ }
+
+ public boolean hasTileEntity(int metadata)
+ {
+ return (metadata == 0);
+ }
+
+ public TileEntity createTileEntity(World world, int metadata)
+ {
+ if (metadata == 0) {
+ Utils.LOG_INFO("I have been created. [Antigriefer]"+this.getLocalizedName());
+ return new TileEntityReverter();
+ }
+ return null;
+ }
+
+ public Item getItemDropped(int meta, Random par2Random, int par3)
+ {
+ switch (meta)
+ {
+ case 0:
+ return null;
+ }
+ return Item.getItemFromBlock(this);
+ }
+
+ public int damageDropped(int meta)
+ {
+ return meta;
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java
new file mode 100644
index 0000000000..6096da7054
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java
@@ -0,0 +1,51 @@
+package gtPlusPlus.core.block.general.fluids;
+
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.BlockFluidClassic;
+import net.minecraftforge.fluids.Fluid;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockFluidJackDaniels extends BlockFluidClassic {
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon stillIcon;
+ @SideOnly(Side.CLIENT)
+ protected IIcon flowingIcon;
+
+ public BlockFluidJackDaniels(Fluid fluid, Material material) {
+ super(fluid, material);
+ setCreativeTab(AddToCreativeTab.tabMisc);
+ }
+
+ @Override
+ public IIcon getIcon(int side, int meta) {
+ return (side == 0 || side == 1)? stillIcon : flowingIcon;
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public void registerBlockIcons(IIconRegister register) {
+ stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels");
+ flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels");
+ }
+
+ @Override
+ public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
+ return super.canDisplace(world, x, y, z);
+ }
+
+ @Override
+ public boolean displaceIfPossible(World world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
+ return super.displaceIfPossible(world, x, y, z);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java b/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java
new file mode 100644
index 0000000000..bda2aae35b
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java
@@ -0,0 +1,50 @@
+package gtPlusPlus.core.block.general.fluids;
+
+import static gtPlusPlus.core.block.ModBlocks.blockFluidJackDaniels;
+import static gtPlusPlus.core.block.ModBlocks.fluidJackDaniels;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.block.material.Material;
+import net.minecraftforge.fluids.FluidRegistry;
+import cpw.mods.fml.common.registry.GameRegistry;
+
+public class FluidRegistryHandler {
+
+ //Fluids
+ /**
+ *
+ * Luminosity .setLuminosity(luminosity)
+ How much light does the fluid emit. Default: 0, Lava uses 15
+ Density .setDensity(density)
+ How dense is the fluid, the only effect is whether or not a fluid replaces another fluid when they flow into each other. Default: 1000, the density of water at 4 degrees Celsius in kg/m³
+ Temperature .setTemperature(temp)
+ How hot, or cold is the fluid. Has currently no effect. Default: 295, the "normal" room temperature in degrees Kelvin, this is approximately 72°F or 22°C.
+ Viscosity .setViscosity(viscosity)
+ How thick the fluid is. Determines how fast it flows. Default: 1000 for water, lava uses 6000
+ Is Gaseous .setGaseous(boolean)
+ Indicates if the fluid is gaseous. Used for rendering. Default: false
+ *
+ */
+
+ public static void registerFluids(){
+ run();
+ }
+
+ private static void run(){
+ fluidJackDaniels();
+ }
+
+ private static void fluidJackDaniels(){
+ //testFluid
+ fluidJackDaniels.setLuminosity(12);
+ fluidJackDaniels.setDensity(1200);
+ fluidJackDaniels.setTemperature(420);
+ fluidJackDaniels.setViscosity(750);
+ fluidJackDaniels.setGaseous(true);
+ fluidJackDaniels.setUnlocalizedName("fluidJackDaniels");
+ FluidRegistry.registerFluid(fluidJackDaniels);
+ blockFluidJackDaniels = new BlockFluidJackDaniels(fluidJackDaniels, Material.water).setBlockName("fluidBlockJackDaniels");
+ GameRegistry.registerBlock(blockFluidJackDaniels, CORE.MODID + "_" + blockFluidJackDaniels.getUnlocalizedName().substring(5));
+ fluidJackDaniels.setUnlocalizedName(blockFluidJackDaniels.getUnlocalizedName());
+ }
+
+}