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 "ThinFenceTile.h"
3#include "net.minecraft.world.level.h"
4#include "net.minecraft.world.h"
5
6ThinFenceTile::ThinFenceTile(int id, const wstring &tex, const wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material,isSolidRender())
7{
8 iconSide = NULL;
9 edgeTexture = edgeTex;
10 this->dropsResources = dropsResources;
11 this->texture = tex;
12}
13
14int ThinFenceTile::getResource(int data, Random *random, int playerBonusLevel)
15{
16 if (!dropsResources)
17 {
18 return 0;
19 }
20 return Tile::getResource(data, random, playerBonusLevel);
21}
22
23bool ThinFenceTile::isSolidRender(bool isServerLevel)
24{
25 return false;
26}
27
28bool ThinFenceTile::isCubeShaped()
29{
30 return false;
31}
32
33int ThinFenceTile::getRenderShape()
34{
35 return material == Material::glass ? Tile::SHAPE_THIN_PANE : Tile::SHAPE_IRON_FENCE;
36}
37
38bool ThinFenceTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
39{
40 int id = level->getTile(x, y, z);
41 if (id == this->id) return false;
42 return Tile::shouldRenderFace(level, x, y, z, face);
43}
44
45void ThinFenceTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
46{
47 bool n = attachsTo(level->getTile(x, y, z - 1));
48 bool s = attachsTo(level->getTile(x, y, z + 1));
49 bool w = attachsTo(level->getTile(x - 1, y, z));
50 bool e = attachsTo(level->getTile(x + 1, y, z));
51
52 if ((w && e) || (!w && !e && !n && !s))
53 {
54 setShape(0, 0, 7.0f / 16.0f, 1, 1, 9.0f / 16.0f);
55 Tile::addAABBs(level, x, y, z, box, boxes, source);
56 }
57 else if (w && !e)
58 {
59 setShape(0, 0, 7.0f / 16.0f, .5f, 1, 9.0f / 16.0f);
60 Tile::addAABBs(level, x, y, z, box, boxes, source);
61 }
62 else if (!w && e)
63 {
64 setShape(.5f, 0, 7.0f / 16.0f, 1, 1, 9.0f / 16.0f);
65 Tile::addAABBs(level, x, y, z, box, boxes, source);
66 }
67 if ((n && s) || (!w && !e && !n && !s))
68 {
69 setShape(7.0f / 16.0f, 0, 0, 9.0f / 16.0f, 1, 1);
70 Tile::addAABBs(level, x, y, z, box, boxes, source);
71 }
72 else if (n && !s)
73 {
74 setShape(7.0f / 16.0f, 0, 0, 9.0f / 16.0f, 1, .5f);
75 Tile::addAABBs(level, x, y, z, box, boxes, source);
76 }
77 else if (!n && s)
78 {
79 setShape(7.0f / 16.0f, 0, .5f, 9.0f / 16.0f, 1, 1);
80 Tile::addAABBs(level, x, y, z, box, boxes, source);
81 }
82}
83
84void ThinFenceTile::updateDefaultShape()
85{
86 setShape(0, 0, 0, 1, 1, 1);
87}
88
89void ThinFenceTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
90{
91 float minX = 7.0f / 16.0f;
92 float maxX = 9.0f / 16.0f;
93 float minZ = 7.0f / 16.0f;
94 float maxZ = 9.0f / 16.0f;
95
96 bool n = attachsTo(level->getTile(x, y, z - 1));
97 bool s = attachsTo(level->getTile(x, y, z + 1));
98 bool w = attachsTo(level->getTile(x - 1, y, z));
99 bool e = attachsTo(level->getTile(x + 1, y, z));
100
101 if ((w && e) || (!w && !e && !n && !s))
102 {
103 minX = 0;
104 maxX = 1;
105 }
106 else if (w && !e)
107 {
108 minX = 0;
109 }
110 else if (!w && e)
111 {
112 maxX = 1;
113 }
114 if ((n && s) || (!w && !e && !n && !s))
115 {
116 minZ = 0;
117 maxZ = 1;
118 }
119 else if (n && !s)
120 {
121 minZ = 0;
122 }
123 else if (!n && s)
124 {
125 maxZ = 1;
126 }
127 setShape(minX, 0, minZ, maxX, 1, maxZ);
128}
129
130Icon *ThinFenceTile::getEdgeTexture()
131{
132 return iconSide;
133}
134
135bool ThinFenceTile::attachsTo(int tile)
136{
137 return Tile::solid[tile] || tile == id || tile == Tile::glass_Id || tile == Tile::stained_glass_Id || tile == Tile::stained_glass_pane_Id;
138}
139
140bool ThinFenceTile::isSilkTouchable()
141{
142 return true;
143}
144
145shared_ptr<ItemInstance> ThinFenceTile::getSilkTouchItemInstance(int data)
146{
147 return shared_ptr<ItemInstance>(new ItemInstance(id, 1, data));
148}
149
150void ThinFenceTile::registerIcons(IconRegister *iconRegister)
151{
152 icon = iconRegister->registerIcon(texture);
153 iconSide = iconRegister->registerIcon(edgeTexture);
154}