aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/FenceTile.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/FenceTile.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/FenceTile.cpp')
-rw-r--r--Minecraft.World/FenceTile.cpp146
1 files changed, 86 insertions, 60 deletions
diff --git a/Minecraft.World/FenceTile.cpp b/Minecraft.World/FenceTile.cpp
index 0d1f9bc4..39f4aac1 100644
--- a/Minecraft.World/FenceTile.cpp
+++ b/Minecraft.World/FenceTile.cpp
@@ -1,6 +1,6 @@
#include "stdafx.h"
+#include "net.minecraft.world.item.h"
#include "net.minecraft.world.level.h"
-#include "net.minecraft.world.phys.h"
#include "net.minecraft.world.h"
#include "FenceTile.h"
@@ -9,73 +9,89 @@ FenceTile::FenceTile(int id, const wstring &texture, Material *material) : Tile(
this->texture = texture;
}
-AABB *FenceTile::getAABB(Level *level, int x, int y, int z)
+void FenceTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
{
- bool n = connectsTo(level, x, y, z - 1);
- bool s = connectsTo(level, x, y, z + 1);
- bool w = connectsTo(level, x - 1, y, z);
- bool e = connectsTo(level, x + 1, y, z);
+ bool n = connectsTo(level, x, y, z - 1);
+ bool s = connectsTo(level, x, y, z + 1);
+ bool w = connectsTo(level, x - 1, y, z);
+ bool e = connectsTo(level, x + 1, y, z);
- float west = 6.0f / 16.0f;
- float east = 10.0f / 16.0f;
- float north = 6.0f / 16.0f;
- float south = 10.0f / 16.0f;
+ float west = 6.0f / 16.0f;
+ float east = 10.0f / 16.0f;
+ float north = 6.0f / 16.0f;
+ float south = 10.0f / 16.0f;
- if (n)
+ if (n)
{
- north = 0;
- }
- if (s)
+ north = 0;
+ }
+ if (s)
{
- south = 1;
- }
- if (w)
+ south = 1;
+ }
+ if (n || s)
{
- west = 0;
- }
- if (e)
+ setShape(west, 0, north, east, 1.5f, south);
+ Tile::addAABBs(level, x, y, z, box, boxes, source);
+ }
+ north = 6.0f / 16.0f;
+ south = 10.0f / 16.0f;
+ if (w)
{
- east = 1;
- }
+ west = 0;
+ }
+ if (e)
+ {
+ east = 1;
+ }
+ if (w || e || (!n && !s))
+ {
+ setShape(west, 0, north, east, 1.5f, south);
+ Tile::addAABBs(level, x, y, z, box, boxes, source);
+ }
+
+ if (n)
+ {
+ north = 0;
+ }
+ if (s)
+ {
+ south = 1;
+ }
- return AABB::newTemp(x + west, y, z + north, x + east, y + 1.5f, z + south);
+ setShape(west, 0, north, east, 1.0f, south);
}
void FenceTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{
- bool n = connectsTo(level, x, y, z - 1);
- bool s = connectsTo(level, x, y, z + 1);
- bool w = connectsTo(level, x - 1, y, z);
- bool e = connectsTo(level, x + 1, y, z);
+ bool n = connectsTo(level, x, y, z - 1);
+ bool s = connectsTo(level, x, y, z + 1);
+ bool w = connectsTo(level, x - 1, y, z);
+ bool e = connectsTo(level, x + 1, y, z);
- float west = 6.0f / 16.0f;
- float east = 10.0f / 16.0f;
- float north = 6.0f / 16.0f;
- float south = 10.0f / 16.0f;
+ float west = 6.0f / 16.0f;
+ float east = 10.0f / 16.0f;
+ float north = 6.0f / 16.0f;
+ float south = 10.0f / 16.0f;
- if (n)
+ if (n)
{
- north = 0;
- }
- if (s)
+ north = 0;
+ }
+ if (s)
{
- south = 1;
- }
- if (w)
+ south = 1;
+ }
+ if (w)
{
- west = 0;
- }
- if (e)
+ west = 0;
+ }
+ if (e)
{
- east = 1;
- }
+ east = 1;
+ }
- setShape(west, 0, north, east, 1.0f, south);
-}
-
-bool FenceTile::blocksLight()
-{
- return false;
+ setShape(west, 0, north, east, 1.0f, south);
}
bool FenceTile::isSolidRender(bool isServerLevel)
@@ -100,20 +116,20 @@ int FenceTile::getRenderShape()
bool FenceTile::connectsTo(LevelSource *level, int x, int y, int z)
{
- int tile = level->getTile(x, y, z);
- if (tile == id || tile == Tile::fenceGate_Id)
+ int tile = level->getTile(x, y, z);
+ if (tile == id || tile == Tile::fenceGate_Id)
{
- return true;
- }
- Tile *tileInstance = Tile::tiles[tile];
- if (tileInstance != NULL)
+ return true;
+ }
+ Tile *tileInstance = Tile::tiles[tile];
+ if (tileInstance != NULL)
{
- if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
+ if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
{
- return tileInstance->material != Material::vegetable;
- }
- }
- return false;
+ return tileInstance->material != Material::vegetable;
+ }
+ }
+ return false;
}
bool FenceTile::isFence(int tile)
@@ -129,4 +145,14 @@ void FenceTile::registerIcons(IconRegister *iconRegister)
bool FenceTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{
return true;
+}
+
+bool FenceTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
+{
+ if (level->isClientSide) return true;
+ if (LeashItem::bindPlayerMobs(player, level, x, y, z))
+ {
+ return true;
+ }
+ return false;
} \ No newline at end of file