-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathBlockCampfire.java
More file actions
118 lines (96 loc) · 3.64 KB
/
Copy pathBlockCampfire.java
File metadata and controls
118 lines (96 loc) · 3.64 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package noppes.npcs.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileCampfire;
import noppes.npcs.config.ConfigClient;
import org.lwjgl.opengl.GL11;
import java.util.Random;
public class BlockCampfire extends BlockLightable {
public BlockCampfire(boolean lit) {
super(Blocks.cobblestone, lit);
setBlockBounds(0, 0, 0, 1, 0.5f, 1);
if (lit)
setLightLevel(0.9375F);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCampfire();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null)
return false;
if ((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this) {
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2);
if (item.getItem() == Items.flint)
NoppesUtilServer.consumeItemStack(1, player);
else
item.damageItem(1, player);
return true;
}
if (item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this) {
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}
return false;
}
@Override
public int maxRotation() {
return 8;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName());
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta) {
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1)
return;
if (random.nextInt(36) == 0) {
world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f, false);
}
TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z);
float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f;
double d0 = (double) ((float) x + xOffset);
double d1 = (double) ((float) y + yOffset);
double d2 = (double) ((float) z + zOffset);
GL11.glPushMatrix();
if (ConfigClient.LegacyCampfire) {
CustomNpcs.proxy.spawnParticle("largesmoke", d0, d1, d2, 0.0D, 0.0D, 0.0D, 2);
CustomNpcs.proxy.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D, 4);
} else {
tile.updateEntity();
}
GL11.glPopMatrix();
}
@Override
public Block unlitBlock() {
return CustomItems.campfire_unlit;
}
@Override
public Block litBlock() {
return CustomItems.campfire;
}
}