-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathBlockBorder.java
More file actions
98 lines (83 loc) · 2.98 KB
/
Copy pathBlockBorder.java
File metadata and controls
98 lines (83 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package noppes.npcs.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.constants.EnumGuiType;
public class BlockBorder extends BlockContainer {
public int renderId = -1;
public BlockBorder() {
super(Material.rock);
setBlockUnbreakable();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if (side == 1) {
return this.blockIcon;
}
return Blocks.iron_block.getIcon(side, meta);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand) {
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Border, player);
return true;
}
return false;
}
@Override
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileBorder tile = (TileBorder) par1World.getTileEntity(x, y, z);
TileBorder adjacent = getTile(par1World, x - 1, y, z);
if (adjacent == null)
adjacent = getTile(par1World, x, y, z - 1);
if (adjacent == null)
adjacent = getTile(par1World, x, y, z + 1);
if (adjacent == null)
adjacent = getTile(par1World, x + 1, y, z);
if (adjacent != null) {
NBTTagCompound compound = new NBTTagCompound();
adjacent.writeExtraNBT(compound);
tile.readExtraNBT(compound);
}
tile.rotation = l;
}
private TileBorder getTile(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileBorder)
return (TileBorder) tile;
return null;
}
@Override
public int getRenderType() {
return renderId;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBorder();
}
}