the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.item.h"
3#include "net.minecraft.world.level.h"
4#include "net.minecraft.world.h"
5#include "FenceTile.h"
6
7FenceTile::FenceTile(int id, const wstring &texture, Material *material) : Tile( id, material, isSolidRender())
8{
9 this->texture = texture;
10}
11
12void FenceTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
13{
14 bool n = connectsTo(level, x, y, z - 1);
15 bool s = connectsTo(level, x, y, z + 1);
16 bool w = connectsTo(level, x - 1, y, z);
17 bool e = connectsTo(level, x + 1, y, z);
18
19 float west = 6.0f / 16.0f;
20 float east = 10.0f / 16.0f;
21 float north = 6.0f / 16.0f;
22 float south = 10.0f / 16.0f;
23
24 if (n)
25 {
26 north = 0;
27 }
28 if (s)
29 {
30 south = 1;
31 }
32 if (n || s)
33 {
34 setShape(west, 0, north, east, 1.5f, south);
35 Tile::addAABBs(level, x, y, z, box, boxes, source);
36 }
37 north = 6.0f / 16.0f;
38 south = 10.0f / 16.0f;
39 if (w)
40 {
41 west = 0;
42 }
43 if (e)
44 {
45 east = 1;
46 }
47 if (w || e || (!n && !s))
48 {
49 setShape(west, 0, north, east, 1.5f, south);
50 Tile::addAABBs(level, x, y, z, box, boxes, source);
51 }
52
53 if (n)
54 {
55 north = 0;
56 }
57 if (s)
58 {
59 south = 1;
60 }
61
62 setShape(west, 0, north, east, 1.0f, south);
63}
64
65void FenceTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
66{
67 bool n = connectsTo(level, x, y, z - 1);
68 bool s = connectsTo(level, x, y, z + 1);
69 bool w = connectsTo(level, x - 1, y, z);
70 bool e = connectsTo(level, x + 1, y, z);
71
72 float west = 6.0f / 16.0f;
73 float east = 10.0f / 16.0f;
74 float north = 6.0f / 16.0f;
75 float south = 10.0f / 16.0f;
76
77 if (n)
78 {
79 north = 0;
80 }
81 if (s)
82 {
83 south = 1;
84 }
85 if (w)
86 {
87 west = 0;
88 }
89 if (e)
90 {
91 east = 1;
92 }
93
94 setShape(west, 0, north, east, 1.0f, south);
95}
96
97bool FenceTile::isSolidRender(bool isServerLevel)
98{
99 return false;
100}
101
102bool FenceTile::isCubeShaped()
103{
104 return false;
105}
106
107bool FenceTile::isPathfindable(LevelSource *level, int x, int y, int z)
108{
109 return false;
110}
111
112int FenceTile::getRenderShape()
113{
114 return Tile::SHAPE_FENCE;
115}
116
117bool FenceTile::connectsTo(LevelSource *level, int x, int y, int z)
118{
119 int tile = level->getTile(x, y, z);
120 if (tile == id || tile == Tile::fenceGate_Id)
121 {
122 return true;
123 }
124 Tile *tileInstance = Tile::tiles[tile];
125 if (tileInstance != NULL)
126 {
127 if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
128 {
129 return tileInstance->material != Material::vegetable;
130 }
131 }
132 return false;
133}
134
135bool FenceTile::isFence(int tile)
136{
137 return tile == Tile::fence_Id || tile == Tile::netherFence_Id;
138}
139
140void FenceTile::registerIcons(IconRegister *iconRegister)
141{
142 icon = iconRegister->registerIcon(texture);
143}
144
145bool FenceTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
146{
147 return true;
148}
149
150bool FenceTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
151{
152 if (level->isClientSide) return true;
153 if (LeashItem::bindPlayerMobs(player, level, x, y, z))
154 {
155 return true;
156 }
157 return false;
158}