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 "TheEndPortal.h"
3#include "TheEndPortalTileEntity.h"
4#include "net.minecraft.world.level.h"
5#include "net.minecraft.world.level.dimension.h"
6#include "net.minecraft.world.level.storage.h"
7#include "net.minecraft.world.entity.h"
8#include "net.minecraft.world.entity.player.h"
9#include "net.minecraft.world.h"
10
11DWORD TheEndPortal::tlsIdx = TlsAlloc();
12
13// 4J - allowAnywhere is a static in java, implementing as TLS here to make thread safe
14bool TheEndPortal::allowAnywhere()
15{
16 return (TlsGetValue(tlsIdx) != NULL);
17}
18
19void TheEndPortal::allowAnywhere(bool set)
20{
21 TlsSetValue(tlsIdx,(LPVOID)(set?1:0));
22}
23
24TheEndPortal::TheEndPortal(int id, Material *material) : BaseEntityTile(id, material, isSolidRender())
25{
26 this->setLightEmission(1.0f);
27}
28
29shared_ptr<TileEntity> TheEndPortal::newTileEntity(Level *level)
30{
31 return shared_ptr<TileEntity>(new TheEndPortalTileEntity());
32}
33
34void TheEndPortal::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
35{
36 float r = 1 / 16.0f;
37 setShape(0, 0, 0, 1, r, 1);
38}
39
40bool TheEndPortal::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
41{
42 if (face != 0) return false;
43 return BaseEntityTile::shouldRenderFace(level, x, y, z, face);
44}
45
46void TheEndPortal::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
47{
48}
49
50bool TheEndPortal::isSolidRender(bool isServerLevel)
51{
52 return false;
53}
54
55bool TheEndPortal::isCubeShaped()
56{
57 return false;
58}
59
60int TheEndPortal::getResourceCount(Random *random)
61{
62 return 0;
63}
64
65void TheEndPortal::entityInside(Level *level, int x, int y, int z, shared_ptr<Entity> entity)
66{
67 if (entity->GetType() == eTYPE_EXPERIENCEORB ) return; // 4J added
68
69 if (entity->riding == NULL && entity->rider.lock() == NULL)
70 {
71 if (!level->isClientSide)
72 {
73 if ( entity->instanceof(eTYPE_PLAYER) )
74 {
75 // 4J Stu - Update the level data position so that the stronghold portal can be shown on the maps
76 int x,z;
77 x = z = 0;
78 if(level->dimension == 0 && !level->getLevelData()->getHasStrongholdEndPortal() && app.GetTerrainFeaturePosition( eTerrainFeature_StrongholdEndPortal, &x, &z) )
79 {
80 level->getLevelData()->setXStrongholdEndPortal(x);
81 level->getLevelData()->setZStrongholdEndPortal(z);
82 level->getLevelData()->setHasStrongholdEndPortal();
83 }
84 }
85 entity->changeDimension(1);
86 }
87 }
88}
89
90void TheEndPortal::animateTick(Level *level, int xt, int yt, int zt, Random *random)
91{
92 double x = xt + random->nextFloat();
93 double y = yt + 0.8f;
94 double z = zt + random->nextFloat();
95 double xa = 0;
96 double ya = 0;
97 double za = 0;
98
99 level->addParticle(eParticleType_endportal, x, y, z, xa, ya, za);
100}
101
102int TheEndPortal::getRenderShape()
103{
104 return SHAPE_INVISIBLE;
105}
106
107void TheEndPortal::onPlace(Level *level, int x, int y, int z)
108{
109 if (allowAnywhere()) return;
110
111 if (level->dimension->id != 0)
112 {
113 level->removeTile(x, y, z);
114 return;
115 }
116}
117
118int TheEndPortal::cloneTileId(Level *level, int x, int y, int z)
119{
120 return 0;
121}
122
123void TheEndPortal::registerIcons(IconRegister *iconRegister)
124{
125 // don't register null, because of particles
126 icon = iconRegister->registerIcon(L"portal");
127}