aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/blocks/regularBlock
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
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')
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/Casing.java123
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java58
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/Frame.java36
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java180
4 files changed, 397 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/Casing.java b/src/main/java/goodgenerator/blocks/regularBlock/Casing.java
new file mode 100644
index 0000000000..7a1db3278d
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/Casing.java
@@ -0,0 +1,123 @@
+package goodgenerator.blocks.regularBlock;
+
+import goodgenerator.main.GoodGenerator;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+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.EnumCreatureType;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+import java.util.List;
+
+public class Casing extends Block {
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon[] texture;
+ String[] textureNames;
+ protected String name;
+
+ public Casing(String name) {
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public Casing(String name, String[] texture){
+ 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 Casing(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);
+ }
+
+ @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);
+ }
+ }
+
+ @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;
+ }
+
+}
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java b/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java
new file mode 100644
index 0000000000..18a1629cbf
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java
@@ -0,0 +1,58 @@
+package goodgenerator.blocks.regularBlock;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+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 java.util.List;
+
+public class ComplexTextureCasing extends Casing{
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon[] texture1, texture2;
+ String[] textureSide;
+ String[] textureTopAndDown;
+
+ public ComplexTextureCasing(String name, String[] textureSide, String[] textureTopAndDown){
+ super(name);
+ this.textureSide = textureSide;
+ this.textureTopAndDown = textureTopAndDown;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta) {
+ if (side < 2) {
+ return meta < this.texture2.length ? this.texture2[meta] : this.texture2[0];
+ }
+ else {
+ return meta < this.texture1.length ? this.texture1[meta] : this.texture1[0];
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.texture1 = new IIcon[this.textureSide.length];
+ for (int i = 0; i < this.textureSide.length; i++) {
+ this.texture1[i] = par1IconRegister.registerIcon(this.textureSide[i]);
+ }
+ this.texture2 = new IIcon[this.textureTopAndDown.length];
+ for (int i = 0; i < this.textureTopAndDown.length; i++) {
+ this.texture2[i] = par1IconRegister.registerIcon(this.textureTopAndDown[i]);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
+ public void getSubBlocks(Item item, CreativeTabs tab, List list) {
+ for (int i = 0; i < Math.max(this.textureSide.length, this.textureTopAndDown.length); i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/Frame.java b/src/main/java/goodgenerator/blocks/regularBlock/Frame.java
new file mode 100644
index 0000000000..90c38c4cce
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/Frame.java
@@ -0,0 +1,36 @@
+package goodgenerator.blocks.regularBlock;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.block.material.Material;
+import net.minecraft.world.IBlockAccess;
+
+public class Frame extends Casing{
+ public Frame(String name,String[] texture){
+ super(name,texture, Material.iron);
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) {
+ if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof Frame)
+ return false;
+ return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getRenderBlockPass() {
+ return 1;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+}
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;
+ }
+}