aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java
diff options
context:
space:
mode:
authorGlodBlock <1356392126@qq.com>2021-12-07 23:02:17 +0800
committerGlodBlock <1356392126@qq.com>2021-12-07 23:02:17 +0800
commit92238a0f3b06a80683f50dfd2d6e9164d2d0f1ab (patch)
tree2d1118c74e43d5f4337266c3d64f1921c0526d42 /src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java
parent06cac63657f40c489477abe923ea3f144fe6749c (diff)
downloadGT5-Unofficial-92238a0f3b06a80683f50dfd2d6e9164d2d0f1ab.tar.gz
GT5-Unofficial-92238a0f3b06a80683f50dfd2d6e9164d2d0f1ab.tar.bz2
GT5-Unofficial-92238a0f3b06a80683f50dfd2d6e9164d2d0f1ab.zip
rename package
Diffstat (limited to 'src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java')
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java180
1 files changed, 180 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java b/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java
new file mode 100644
index 0000000000..b33dbffdec
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java
@@ -0,0 +1,180 @@
+package goodgenerator.blocks.regularBlock;
+
+import goodgenerator.blocks.tileEntity.EssentiaHatch;
+import goodgenerator.main.GoodGenerator;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.util.GT_Utility;
+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.Entity;
+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.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.IEssentiaContainerItem;
+
+import java.util.List;
+
+public class TEBlock extends BlockContainer {
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon[] texture;
+ String[] textureNames;
+ protected String name;
+ protected int index;
+
+ public TEBlock(String name, String[] texture, CreativeTabs Tab){
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public TEBlock(String name, String[] texture, int index){
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.index = index;
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public TEBlock(String name, String[] texture, Material material){
+ super(material);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ @Override
+ public int damageDropped(int meta) {
+ return meta;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta) {
+ return meta < this.texture.length ? this.texture[meta] : this.texture[0];
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.texture = new IIcon[this.textureNames.length];
+ for (int i = 0; i < this.textureNames.length; i++) {
+ this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
+ public void getSubBlocks(Item item, CreativeTabs tab, List list) {
+ for (int i = 0; i < this.textureNames.length; i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ @Override
+ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ aWorld.removeTileEntity(aX, aY, aZ);
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return this.name;
+ }
+
+ @Override
+ public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
+ return false;
+ }
+
+ @Override
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public TileEntity createTileEntity(World world, int meta) {
+ if (index == 1)
+ return new EssentiaHatch();
+ return null;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
+ if (world.isRemote) {
+ return false;
+ } else {
+ TileEntity tile = world.getTileEntity(x, y, z);
+ if (index == 1) {
+ if (tile instanceof EssentiaHatch) {
+ ItemStack tItemStack = player.getHeldItem();
+ if (tItemStack != null) {
+ Item tItem = tItemStack.getItem();
+ if (tItem instanceof IEssentiaContainerItem && ((IEssentiaContainerItem) tItem).getAspects(player.getHeldItem()) != null && ((IEssentiaContainerItem) tItem).getAspects(player.getHeldItem()).size() > 0) {
+ Aspect tLocked = ((IEssentiaContainerItem) tItem).getAspects(player.getHeldItem()).getAspects()[0];
+ ((EssentiaHatch) tile).setLockedAspect(tLocked);
+ GT_Utility.sendChatToPlayer(player, String.format(StatCollector.translateToLocal("essentiahatch.chat.0"), tLocked.getLocalizedDescription()));
+ }
+ }
+ else {
+ ((EssentiaHatch) tile).setLockedAspect(null);
+ GT_Utility.sendChatToPlayer(player, StatCollector.translateToLocal("essentiahatch.chat.1"));
+ }
+ world.markBlockForUpdate(x, y, z);
+ return true;
+ }
+ else return false;
+ }
+ else return false;
+ }
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
+ return null;
+ }
+}