From 259b55e31b9db9079d4797e4b179737208e40695 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sat, 26 Dec 2020 15:50:50 -0800 Subject: Adds long distance Item & Fluid pipelines and pipes. Inspired/ported from GT6 under LGPL. --- .../api/items/GT_Block_LongDistancePipe.java | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java (limited to 'src/main/java/gregtech/api/items') diff --git a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java new file mode 100644 index 0000000000..3a634df6e4 --- /dev/null +++ b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java @@ -0,0 +1,99 @@ +package gregtech.api.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Item_LongDistancePipe; +import gregtech.common.blocks.GT_Material_Machines; +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +public class GT_Block_LongDistancePipe extends GT_Generic_Block { + public GT_Block_LongDistancePipe() { + super(GT_Item_LongDistancePipe.class, "gt.block.longdistancepipe", new GT_Material_Machines()); + setStepSound(soundTypeMetal); + setCreativeTab(GregTech_API.TAB_GREGTECH); + GregTech_API.registerMachineBlock(this, -1); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName()+".0.name", "Long Distance Fluid Pipeline Pipe"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName()+".1.name", "Long Distance Item Pipeline Pipe"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); + + ItemList.Long_Distance_Pipeline_Fluid_Pipe.set(new ItemStack(this, 1, 0)); + ItemList.Long_Distance_Pipeline_Item_Pipe.set(new ItemStack(this, 1, 1)); + } + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + super.breakBlock(aWorld, aX, aY, aZ, par5, par6); + } + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + public int getHarvestLevel(int aMeta) { + return 2; + } + + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + public IIcon getIcon(int aSide, int aMeta) { + return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + public int quantityDropped(Random par1Random) { + return 1; + } + + public Item getItemDropped(int par1, Random par2Random, int par3) { + return Item.getItemFromBlock(this); + } + + public int damageDropped(int par1) { + return par1; + } + + public int getDamageValue(World par1World, int par2, int par3, int par4) { + return par1World.getBlockMetadata(par2, par3, par4); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i < 3; i++) { + ItemStack aStack = new ItemStack(aItem, 1, i); + if (!aStack.getDisplayName().contains(".name")) aList.add(aStack); + } + } +} -- cgit From 82edef8ca76f8f594bf10137cbe6831b15b2ccf1 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sat, 26 Dec 2020 17:16:01 -0800 Subject: Add ~~stolen~~ borrowed textures for long distance pipes --- src/main/java/gregtech/api/enums/Textures.java | 3 +++ .../gregtech/api/items/GT_Block_LongDistancePipe.java | 9 ++++----- .../textures/blocks/iconsets/LONG_DISTANCE_PIPE_FLUID.png | Bin 0 -> 408 bytes .../textures/blocks/iconsets/LONG_DISTANCE_PIPE_ITEM.png | Bin 0 -> 418 bytes 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_FLUID.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_ITEM.png (limited to 'src/main/java/gregtech/api/items') diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 213f9bbc14..18203faed1 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -53,6 +53,9 @@ public class Textures { OVERLAY_PIPELINE_ITEM_BACK, OVERLAY_PIPELINE_ITEM_FRONT, OVERLAY_PIPELINE_ITEM_SIDE, + + LONG_DISTANCE_PIPE_FLUID, + LONG_DISTANCE_PIPE_ITEM, MACHINE_CASING_TANK_1, MACHINE_CASING_TANK_2, diff --git a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java index 3a634df6e4..542892c030 100644 --- a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java +++ b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java @@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.util.GT_LanguageManager; import gregtech.common.blocks.GT_Item_LongDistancePipe; import gregtech.common.blocks.GT_Material_Machines; @@ -22,6 +23,7 @@ import java.util.List; import java.util.Random; public class GT_Block_LongDistancePipe extends GT_Generic_Block { + public IIconContainer[] mIcons; public GT_Block_LongDistancePipe() { super(GT_Item_LongDistancePipe.class, "gt.block.longdistancepipe", new GT_Material_Machines()); setStepSound(soundTypeMetal); @@ -34,6 +36,7 @@ public class GT_Block_LongDistancePipe extends GT_Generic_Block { ItemList.Long_Distance_Pipeline_Fluid_Pipe.set(new ItemStack(this, 1, 0)); ItemList.Long_Distance_Pipeline_Item_Pipe.set(new ItemStack(this, 1, 1)); + mIcons = new IIconContainer[]{Textures.BlockIcons.LONG_DISTANCE_PIPE_FLUID, Textures.BlockIcons.LONG_DISTANCE_PIPE_ITEM}; } public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { super.onBlockAdded(aWorld, aX, aY, aZ); @@ -61,12 +64,8 @@ public class GT_Block_LongDistancePipe extends GT_Generic_Block { return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); } - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - public IIcon getIcon(int aSide, int aMeta) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); + return mIcons[aMeta % mIcons.length].getIcon(); } public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_FLUID.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_FLUID.png new file mode 100644 index 0000000000..eda6e9363d Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_FLUID.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_ITEM.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_ITEM.png new file mode 100644 index 0000000000..195f5927d6 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/LONG_DISTANCE_PIPE_ITEM.png differ -- cgit From 23b550192c3b528dac9ef25c85da99611e00529f Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Thu, 31 Dec 2020 00:12:45 +0100 Subject: add hardness to the blocks (cherry picked from commit f21a80dcdd61f004b6cc78639c4448a120b76cdd) --- .../java/gregtech/api/items/GT_Block_LongDistancePipe.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java/gregtech/api/items') diff --git a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java index 542892c030..734eae19f4 100644 --- a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java +++ b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java @@ -11,7 +11,9 @@ import gregtech.common.blocks.GT_Item_LongDistancePipe; import gregtech.common.blocks.GT_Material_Machines; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -56,6 +58,15 @@ public class GT_Block_LongDistancePipe extends GT_Generic_Block { return 2; } + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + public float getExplosionResistance(Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + public String getUnlocalizedName() { return this.mUnlocalizedName; } -- cgit