From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- src/main/java/gtPlusPlus/core/block/ModBlocks.java | 48 +- .../core/block/base/BasicTileBlockWithTooltip.java | 18 +- .../core/block/base/BlockBaseModular.java | 18 +- .../gtPlusPlus/core/block/base/BlockBaseOre.java | 18 +- .../core/block/general/BlockFluidTankInfinite.java | 141 +++++ .../core/block/general/BlockHellFire.java | 535 +++++++++++++++++++ .../core/block/general/BlockLightGlass.java | 137 +++++ .../core/block/general/BlockMiningExplosives.java | 193 +++++++ .../core/block/general/BlockSuperLight.java | 2 +- .../core/block/general/FluidTankInfinite.java | 141 ----- .../gtPlusPlus/core/block/general/HellFire.java | 535 ------------------- .../gtPlusPlus/core/block/general/LightGlass.java | 137 ----- .../core/block/general/MiningExplosives.java | 193 ------- .../core/block/machine/BlockCircuitProgrammer.java | 153 ++++++ .../core/block/machine/BlockDecayablesChest.java | 179 +++++++ .../core/block/machine/BlockFishTrap.java | 136 +++++ .../core/block/machine/BlockFlaskSetter.java | 157 ++++++ .../core/block/machine/BlockPestKiller.java | 137 +++++ .../core/block/machine/BlockPooCollector.java | 177 +++++++ .../core/block/machine/BlockProjectTable.java | 160 ++++++ .../core/block/machine/BlockSuperJukebox.java | 574 +++++++++++++++++++++ .../core/block/machine/CircuitProgrammer.java | 153 ------ .../core/block/machine/DecayablesChest.java | 179 ------- .../gtPlusPlus/core/block/machine/FishTrap.java | 136 ----- .../core/block/machine/Machine_PestKiller.java | 137 ----- .../core/block/machine/Machine_PooCollector.java | 177 ------- .../core/block/machine/Machine_ProjectTable.java | 160 ------ .../core/block/machine/Machine_SuperJukebox.java | 574 --------------------- .../core/block/machine/VolumetricFlaskSetter.java | 157 ------ 29 files changed, 2731 insertions(+), 2731 deletions(-) create mode 100644 src/main/java/gtPlusPlus/core/block/general/BlockFluidTankInfinite.java create mode 100644 src/main/java/gtPlusPlus/core/block/general/BlockHellFire.java create mode 100644 src/main/java/gtPlusPlus/core/block/general/BlockLightGlass.java create mode 100644 src/main/java/gtPlusPlus/core/block/general/BlockMiningExplosives.java delete mode 100644 src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java delete mode 100644 src/main/java/gtPlusPlus/core/block/general/HellFire.java delete mode 100644 src/main/java/gtPlusPlus/core/block/general/LightGlass.java delete mode 100644 src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockCircuitProgrammer.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockDecayablesChest.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockFishTrap.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockFlaskSetter.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockPestKiller.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockPooCollector.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockProjectTable.java create mode 100644 src/main/java/gtPlusPlus/core/block/machine/BlockSuperJukebox.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/FishTrap.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java delete mode 100644 src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java (limited to 'src/main/java/gtPlusPlus/core/block') diff --git a/src/main/java/gtPlusPlus/core/block/ModBlocks.java b/src/main/java/gtPlusPlus/core/block/ModBlocks.java index 417b342f7e..6169581257 100644 --- a/src/main/java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/main/java/gtPlusPlus/core/block/ModBlocks.java @@ -5,19 +5,19 @@ import net.minecraftforge.fluids.Fluid; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.general.BlockCompressedObsidian; -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.BlockFluidTankInfinite; +import gtPlusPlus.core.block.general.BlockHellFire; +import gtPlusPlus.core.block.general.BlockLightGlass; +import gtPlusPlus.core.block.general.BlockMiningExplosives; import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; -import gtPlusPlus.core.block.machine.CircuitProgrammer; -import gtPlusPlus.core.block.machine.DecayablesChest; -import gtPlusPlus.core.block.machine.FishTrap; -import gtPlusPlus.core.block.machine.Machine_PestKiller; -import gtPlusPlus.core.block.machine.Machine_PooCollector; -import gtPlusPlus.core.block.machine.Machine_ProjectTable; -import gtPlusPlus.core.block.machine.Machine_SuperJukebox; -import gtPlusPlus.core.block.machine.VolumetricFlaskSetter; +import gtPlusPlus.core.block.machine.BlockCircuitProgrammer; +import gtPlusPlus.core.block.machine.BlockDecayablesChest; +import gtPlusPlus.core.block.machine.BlockFishTrap; +import gtPlusPlus.core.block.machine.BlockFlaskSetter; +import gtPlusPlus.core.block.machine.BlockPestKiller; +import gtPlusPlus.core.block.machine.BlockPooCollector; +import gtPlusPlus.core.block.machine.BlockProjectTable; +import gtPlusPlus.core.block.machine.BlockSuperJukebox; import gtPlusPlus.core.fluids.FluidRegistryHandler; public final class ModBlocks { @@ -68,31 +68,31 @@ public final class ModBlocks { public static void registerBlocks() { Logger.INFO("Registering Blocks."); - MatterFabricatorEffectBlock = new LightGlass(false); + MatterFabricatorEffectBlock = new BlockLightGlass(false); // Fluids FluidRegistryHandler.registerFluids(); // Workbench - blockFishTrap = new FishTrap(); - blockInfiniteFLuidTank = new FluidTankInfinite(); - blockMiningExplosive = new MiningExplosives(); - blockHellfire = new HellFire(); - blockProjectTable = new Machine_ProjectTable(); + blockFishTrap = new BlockFishTrap(); + blockInfiniteFLuidTank = new BlockFluidTankInfinite(); + blockMiningExplosive = new BlockMiningExplosives(); + blockHellfire = new BlockHellFire(); + blockProjectTable = new BlockProjectTable(); blockWitherGuard = new BlockWitherProof(); blockCompressedObsidian = new BlockCompressedObsidian(); - blockCircuitProgrammer = new CircuitProgrammer(); + blockCircuitProgrammer = new BlockCircuitProgrammer(); - blockDecayablesChest = new DecayablesChest(); + blockDecayablesChest = new BlockDecayablesChest(); - blockCustomJukebox = new Machine_SuperJukebox(); + blockCustomJukebox = new BlockSuperJukebox(); - blockPooCollector = new Machine_PooCollector(); + blockPooCollector = new BlockPooCollector(); - blockPestKiller = new Machine_PestKiller(); + blockPestKiller = new BlockPestKiller(); - blockVolumetricFlaskSetter = new VolumetricFlaskSetter(); + blockVolumetricFlaskSetter = new BlockFlaskSetter(); } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java index c39565ea41..bace2937fd 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java +++ b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -30,7 +30,7 @@ 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.lib.GTPPCore; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.InventoryUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -63,7 +63,7 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement /** * Does this {@link Block} require special {@link ItemBlock} handling? - * + * * @return The {@link Class} that will be used for this {@link Block}. */ public Class getItemBlockClass() { @@ -72,28 +72,28 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement /** * 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(); /** * 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(); @@ -128,7 +128,7 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement /** * The String used for texture pathing. - * + * * @return Sanitized {@link String}, containing no spaces or illegal characters. */ private String getTileEntityNameForTexturePathing() { @@ -172,9 +172,9 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement // Default Path Name, this will make us look inside 'miscutils\textures\blocks' final String aPrefixTexPath = GTPlusPlus.ID + ":"; // Default Path Name, this will make us look in the subdirectory for this Tile Entity. - final String aTexPathMid = "TileEntities" + CORE.SEPERATOR + final String aTexPathMid = "TileEntities" + GTPPCore.SEPERATOR + getTileEntityNameForTexturePathing() - + CORE.SEPERATOR; + + GTPPCore.SEPERATOR; // Construct a full path String aTexPathBuilt = aPrefixTexPath + aTexPathMid; // File Name Suffixes, without meta tags diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java index b07c6d1529..abd83d7171 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -16,11 +16,11 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TextureSet; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; @@ -58,7 +58,7 @@ public class BlockBaseModular extends BasicBlock { registerComponent(); sBlockCache.put(material.getUnlocalizedName() + "." + blockType.name(), this); thisBlockMaterialTranslatedName = material.getTranslatedName(); - GT_LanguageManager.addStringLocalization("gtplusplus." + getUnlocalizedName() + ".name", getProperName()); + GTLanguageManager.addStringLocalization("gtplusplus." + getUnlocalizedName() + ".name", getProperName()); } protected BlockBaseModular(final String unlocalizedName, final String blockMaterialString, @@ -79,13 +79,13 @@ public class BlockBaseModular extends BasicBlock { ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); if (fx == 0) { - GT_OreDictUnificator + GTOreDictUnificator .registerOre("block" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); } else if (fx == 1) { - GT_OreDictUnificator + GTOreDictUnificator .registerOre("frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); } else if (fx == 2) { - GT_OreDictUnificator + GTOreDictUnificator .registerOre("frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); } } @@ -172,7 +172,7 @@ public class BlockBaseModular extends BasicBlock { @Override public String getLocalizedName() { - return GT_LanguageManager.getTranslation("gtplusplus." + getUnlocalizedName() + ".name") + return GTLanguageManager.getTranslation("gtplusplus." + getUnlocalizedName() + ".name") .replace("%s", "%temp") .replace("%material", this.thisBlockMaterialTranslatedName) .replace("%temp", "%s"); @@ -198,7 +198,7 @@ public class BlockBaseModular extends BasicBlock { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(final IIconRegister iIcon) { - if (!CORE.ConfigSwitches.useGregtechTextures || this.blockMaterial == null + if (!GTPPCore.ConfigSwitches.useGregtechTextures || this.blockMaterial == null || this.thisBlock == BlockTypes.ORE) { this.blockIcon = iIcon.registerIcon(GTPlusPlus.ID + ":" + this.thisBlock.getTexture()); } diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java index 1813090810..b0ee1c0c77 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -18,12 +18,12 @@ import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.GT_Mod; +import gregtech.GTMod; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; -import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GTOreDictUnificator; import gtPlusPlus.api.interfaces.ITexturedBlock; import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; import gtPlusPlus.core.item.base.itemblock.ItemBlockOre; @@ -31,8 +31,8 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_RenderedTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPRenderedTexture; public class BlockBaseOre extends BasicBlock implements ITexturedBlock { @@ -60,7 +60,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { this, ItemBlockOre.class, Utils.sanitizeString("ore" + Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); - GT_OreDictUnificator.registerOre( + GTOreDictUnificator.registerOre( "ore" + Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); } catch (Throwable t) { @@ -115,10 +115,10 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { @Override public ITexture[] getTexture(Block block, ForgeDirection side) { if (this.blockMaterial != null) { - GTPP_RenderedTexture aIconSet = new GTPP_RenderedTexture( + GTPPRenderedTexture aIconSet = new GTPPRenderedTexture( blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], this.blockMaterial.getRGBA()); - return new ITexture[] { new GTPP_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet }; + return new ITexture[] { new GTPPCopiedBlockTexture(Blocks.stone, 0, 0), aIconSet }; } if (hiddenTextureArray == null) { @@ -134,7 +134,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - return new ITexture[] { new GTPP_RenderedTexture(hiddenTextureArray[0], new short[] { 240, 240, 240, 0 }) }; + return new ITexture[] { new GTPPRenderedTexture(hiddenTextureArray[0], new short[] { 240, 240, 240, 0 }) }; } @Override @@ -167,7 +167,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { if (shouldSilkTouch) { drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); } else { - switch (GT_Mod.gregtechproxy.oreDropSystem) { + switch (GTMod.gregtechproxy.oreDropSystem) { case Item -> { drops.add( ItemUtils.getItemStackOfAmountFromOreDictNoBroken( diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockFluidTankInfinite.java b/src/main/java/gtPlusPlus/core/block/general/BlockFluidTankInfinite.java new file mode 100644 index 0000000000..a300b83577 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockFluidTankInfinite.java @@ -0,0 +1,141 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +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; + +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.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class BlockFluidTankInfinite extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + public BlockFluidTankInfinite() { + super(Material.iron); + this.setBlockName("blockInfiniteFluidTank"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockInfiniteFluidTank"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 1 ? this.textureTop + : (ordinalSide == 0 ? this.textureBottom + : ((ordinalSide != 2) && (ordinalSide != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureBottom = p_149651_1_ + .registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureFront = p_149651_1_ + .registerIcon(GTPlusPlus.ID + ":" + "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/BlockHellFire.java b/src/main/java/gtPlusPlus/core/block/general/BlockHellFire.java new file mode 100644 index 0000000000..b18a2d4b86 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockHellFire.java @@ -0,0 +1,535 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + +import java.util.IdentityHashMap; +import java.util.Map.Entry; +import java.util.Random; + +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 net.minecraftforge.common.util.ForgeDirection; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.objects.XSTR; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; + +public class BlockHellFire extends BlockFire { + + private final int[] field_149849_a = new int[Short.MAX_VALUE]; + + private final int[] field_149848_b = new int[Short.MAX_VALUE]; + + @SideOnly(Side.CLIENT) + private IIcon[] IIconArray; + + public BlockHellFire() { + this.setTickRandomly(true); + this.setLightLevel(1F); + this.setLightOpacity(0); + // this.setBlockTextureName(GTPlusPlus.ID + "hellfire/blockHellFire"); + this.setBlockName("blockHellFire"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, "blockHellFire"); + 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 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(GTPlusPlus.ID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), + IIconRegister.registerIcon(GTPlusPlus.ID + ":" + "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 ordinalSide, final int meta) { + 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 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 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 ====================================== + */ +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockLightGlass.java b/src/main/java/gtPlusPlus/core/block/general/BlockLightGlass.java new file mode 100644 index 0000000000..1e4df5c399 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockLightGlass.java @@ -0,0 +1,137 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import codechicken.nei.api.API; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; + +/* + * public class LightGlass extends BlockBreakable { + */ +public class BlockLightGlass 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 BlockLightGlass(final boolean bool) { + super(); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockMFEffect"); + this.setLightLevel(12F); + setHardness(0.1F); + setBlockTextureName(GTPlusPlus.ID + ":" + "blockMFEffect"); + setStepSound(Block.soundTypeGlass); + GameRegistry.registerBlock(this, "blockMFEffect"); + + API.hideItem(new ItemStack(this)); + } + + /** + * 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(GTPlusPlus.ID + ":" + "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"); + + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockMiningExplosives.java b/src/main/java/gtPlusPlus/core/block/general/BlockMiningExplosives.java new file mode 100644 index 0000000000..20b6fff9e6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockMiningExplosives.java @@ -0,0 +1,193 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.Random; + +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 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.entity.EntityPrimedMiningExplosive; + +public class BlockMiningExplosives extends BlockTNT { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + public BlockMiningExplosives() { + this.setBlockName("blockMiningExplosives"); + GameRegistry.registerBlock(this, "blockMiningExplosives"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 0 ? this.textureBottom : (ordinalSide == 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 final EntityArrow entityarrow) && !world.isRemote) { + + 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(GTPlusPlus.ID + ":" + "chrono/" + "MetalSheet2"); + this.textureTop = iconRegister.registerIcon(GTPlusPlus.ID + ":" + "chrono/" + "MetalFunnel"); + this.textureBottom = iconRegister.registerIcon(GTPlusPlus.ID + ":" + "chrono/" + "MetalPanel"); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java index dc6c92f065..4110c02fe3 100644 --- a/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java +++ b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java @@ -177,7 +177,7 @@ public class BlockSuperLight extends BlockContainer { // Turning Lights off else if (!enable && aLight > 0) { aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); - if (aBlockGet instanceof LightGlass) { + if (aBlockGet instanceof BlockLightGlass) { Logger.INFO("Dimmed air."); this.worldObj.setBlock(xOff, yOff, zOff, Blocks.air, 0, 3); } diff --git a/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java deleted file mode 100644 index 41a581394b..0000000000 --- a/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java +++ /dev/null @@ -1,141 +0,0 @@ -package gtPlusPlus.core.block.general; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -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; - -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.tileentities.general.TileEntityInfiniteFluid; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - -public class FluidTankInfinite extends BlockContainer { - - @SideOnly(Side.CLIENT) - private IIcon textureTop; - - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - public FluidTankInfinite() { - super(Material.iron); - this.setBlockName("blockInfiniteFluidTank"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, "blockInfiniteFluidTank"); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int ordinalSide, final int meta) { - return ordinalSide == 1 ? this.textureTop - : (ordinalSide == 0 ? this.textureBottom - : ((ordinalSide != 2) && (ordinalSide != 4) ? this.blockIcon : this.textureFront)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - this.textureBottom = p_149651_1_ - .registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - this.textureFront = p_149651_1_ - .registerIcon(GTPlusPlus.ID + ":" + "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(