Prevent breaking of tank air blocks in creative + survival

This commit is contained in:
Arthur Uzulin committed 2013-10-08 21:27:21 +11:00
1 parent 0213cd9206
commit 56e975335e
3 files changed
+27 -3

No files matched your search

+9 -2
View File
@@ -1,11 +1,12 @@
package tconstruct.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cpw.mods.fml.relauncher.*;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import tconstruct.blocks.logic.TankAirLogic;
import tconstruct.client.block.TankAirRender;
@@ -47,4 +48,10 @@ public class TankAirBlock extends BlockContainer
{
return false;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return null;
}
}
+1 -1
View File
@@ -405,7 +405,7 @@ public class TContent implements IFuelHandler
GameRegistry.registerBlock(castingChannel, CastingChannelItem.class, "CastingChannel");
GameRegistry.registerTileEntity(CastingChannelLogic.class, "CastingChannel");
tankAir = new TankAirBlock(PHConstruct.airTank, Material.air).setUnlocalizedName("tconstruct.tank.air");
tankAir = new TankAirBlock(PHConstruct.airTank, Material.air).setBlockUnbreakable().setUnlocalizedName("tconstruct.tank.air");
GameRegistry.registerBlock(tankAir, "TankAir");
GameRegistry.registerTileEntity(TankAirLogic.class, "tconstruct.tank.air");
+17
View File
@@ -1,5 +1,11 @@
package tconstruct.util;
import tconstruct.blocks.TankAirBlock;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
@@ -1554,4 +1560,15 @@ public class TEventHandler
}
}
//Player interact event - prevent breaking of tank air blocks in creative
@ForgeSubscribe
public void playerInteract(PlayerInteractEvent event){
if(event.action == Action.LEFT_CLICK_BLOCK){
Block block = Block.blocksList[event.entity.worldObj.getBlockId(event.x, event.y, event.z)];
if(block instanceof TankAirBlock){
event.setCanceled(true);
}
}
}
}