mirror of
https://github.com/GTNewHorizons/Advanced-Botany.git
synced 2026-11-24 22:04:43 +00:00
no message
This commit is contained in:
1 parent
8c1bd5995b
commit
93f114dceb
645 files changed
+59797
No files matched your search
@@ -0,0 +1,80 @@
|
||||
package ab.common.item;
|
||||
|
||||
import java.util.List;
|
||||
import ab.common.lib.register.BlockListAB;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
|
||||
public class ItemAntigravityCharm extends ItemMod {
|
||||
|
||||
public static IIcon[] icons;
|
||||
|
||||
public ItemAntigravityCharm() {
|
||||
super("antigravityCharm");
|
||||
this.setMaxStackSize(1);
|
||||
this.setNoRepair();
|
||||
}
|
||||
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
icons = new IIcon[2];
|
||||
for(int i = 0; i < icons.length; i++) {
|
||||
icons[i] = icons[i] = ir.registerIcon("ab:" + "itemAntigravityCharm_" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int pass) {
|
||||
int iconID = Math.min(1, pass);
|
||||
return this.icons[iconID];
|
||||
}
|
||||
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if(player.isSneaking())
|
||||
ItemNBTHelper.setBoolean(stack, "isActive", !ItemNBTHelper.getBoolean(stack, "isActive", true));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean inHand) {
|
||||
if(ItemNBTHelper.getBoolean(stack, "isActive", true)) {
|
||||
double posX = entity.posX;
|
||||
double posY = entity.posY;
|
||||
double posZ = entity.posZ;
|
||||
final AxisAlignedBB asis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1).expand(8, 8, 8);
|
||||
final List<EntityFallingBlock> listEntity = (List<EntityFallingBlock>)world.getEntitiesWithinAABB((Class)EntityFallingBlock.class, asis);
|
||||
for(EntityFallingBlock fallBlock : listEntity) {
|
||||
int x = (int) (fallBlock.posX >= 0 ? fallBlock.posX : fallBlock.posX - 1);
|
||||
int y = (int) fallBlock.posY;
|
||||
int z = (int) (fallBlock.posZ >= 0 ? fallBlock.posZ : fallBlock.posZ - 1);
|
||||
Block block = fallBlock.func_145805_f();
|
||||
fallBlock.setInvisible(true);
|
||||
if(!world.isRemote) {
|
||||
setBlock(world, x, y, z, block, fallBlock.field_145814_a);
|
||||
setBlock(world, x, y - 1, z, BlockListAB.blockAntigravitation, 0);
|
||||
}
|
||||
fallBlock.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
if(world.getBlock(x, y, z).getMaterial() == Material.air && y < 256) {
|
||||
world.setBlock(x, y, z, block, meta, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user