Skip to content

Commit

Permalink
extended mob spawn detection to spawn inside transparent blocks
Browse files Browse the repository at this point in the history
With Minecraft spawning it is possible to spawn on top of blocks with
solid top surface and 2 blocks clear space above. Up to now the clear
space was tested only with air, but also other transparent blocks allow
mobs to spawn inside (e.g. button, flower or thin snow).
Now both cases are handled correctly.
  • Loading branch information
EtlamGit committed Feb 10, 2014
1 parent fa6507d commit db9fc95
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 33 deletions.
7 changes: 7 additions & 0 deletions blockidentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ BlockInfo::BlockInfo()
, liquid(false)
, rendernormal(true)
, providepower(false)
, spawninside(false)
{}

bool BlockInfo::isOpaque()
Expand Down Expand Up @@ -218,16 +219,21 @@ void BlockIdentifier::parseDefinition(JSONObject *b, BlockInfo *parent, int pack
block->rendernormal=false; // for most cases except the following
if (b->has("rendercube"))
block->rendernormal=b->at("rendercube")->asBool();
block->spawninside=false; // for most cases except the following
if (b->has("spawninside"))
block->spawninside=b->at("spawninside")->asBool();
}
else if (parent!=NULL)
{
block->transparent=parent->transparent;
block->rendernormal=parent->rendernormal;
block->spawninside=parent->spawninside;
}
else
{
block->transparent=false;
block->rendernormal=true;
block->spawninside=false;
}

if (b->has("liquid"))
Expand Down Expand Up @@ -302,6 +308,7 @@ void BlockIdentifier::parseDefinition(JSONObject *b, BlockInfo *parent, int pack
block->mask=b->at("mask")->asNumber();
else
block->mask=0xff;

if (b->has("variants"))
{
JSONArray *variants=dynamic_cast<JSONArray *>(b->at("variants"));
Expand Down
1 change: 1 addition & 0 deletions blockidentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class BlockInfo
bool liquid;
bool rendernormal;
bool providepower;
bool spawninside;
quint32 colors[16];
};

Expand Down
36 changes: 26 additions & 10 deletions definitions/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ to the Minecraft source code. The Minecraft Wiki is not correct in all cases.
In the Minecraft source code some major flags are defined for all blocks:
isOpaque renderAsNormalBlock isLiquid and canProvidePower

Additionally mobs can spawn inside/through some transparent blocks which is
checked with hit box collision. As this is not possible to check in Minutor
a special flag "spawninside" has to be set for that blocks.


isLiquid:
is obvious and true for still and flowing water and lava

Expand All @@ -25,19 +30,30 @@ isOpaque and renderAsNormalBlock
"transparent": true,
"rendercube": true

all other transparent blocks have to be flagged only with
all other transparent blocks have to be tagged only with
"transparent": true

List of tranparent blocks:
Anvil, PressurePlate(s), Beacon, Bed, Ice, BrewingStand, Button(s), Cactus,
Cake, Carpet(s), Cauldron, Chest(s), Cocoa, DaylightDetector, Door(s), DragonEgg,
EnchantmentTable, EnderChest, EndPortal, EndPortalFrame, Farmland, Fence,
FenceGate, Fire, Flower(s), FlowerPot, Fluid = Water/Lava, Glass, HalfSlab(s),
Hopper, Ladder, Leave(s), Lever, MobSpawner, Pane(s), PistonBase, PistonExtension,
PistonMoving, Portal, Rail(s), Repeater, Comperator, RedstoneWire, Reed, Sign,
Skull, Snow, Stair(s), Torch, TrapDoor, TripWire, TripWireSource, Vine, Wall, Web

All this information is gathered from the 1.6.4 source code.
As at the moment no deobfuscated 1.7.x code is available.
Cake, Carpet(s), Cauldron, Chest(s), Cocoa, DaylightDetector, Door(s),
DragonEgg, EnchantmentTable, EnderChest, EndPortal, EndPortalFrame, Farmland,
Fence, FenceGate, Fire, Flower(s), FlowerPot, Fluid = Water/Lava, Glass,
HalfSlab(s), Hopper, Ladder, Leave(s), Lever, MobSpawner, Pane(s), PistonBase,
PistonExtension, PistonMoving, Portal, Rail(s), Repeater, Comperator,
RedstoneWire, Reed, Sign, Skull, Snow, Stair(s), Torch, TrapDoor, TripWire,
TripWireSource, Vine, Wall, Web


List of blocks that mobs can spawn inside:
PressurePlate(s), Button(s), Cocoa, (single block) Flower(s), Ladder, Lever,
Rail(s), Reed, Sign, Snow, Vine
to be flagged with
"spawninside": true


All this information is gathered directly from the 1.6.4 source code or special
test setup per block in 1.8 snapshots. As at the moment deobfuscated 1.7.x or
1.8.x code is not available.


[EtlamGit]
51 changes: 43 additions & 8 deletions definitions/vanilla_ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
{
"id": 0,
"name": "Air",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 1,
Expand Down Expand Up @@ -98,6 +99,7 @@
"color": "1f6519",
"mask": 7,
"transparent": true,
"spawninside": true,
"variants": [
{
"data": 1,
Expand Down Expand Up @@ -294,13 +296,15 @@
"id": 27,
"name": "Powered Rail",
"color": "ab0301",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 28,
"name": "Detector Rail",
"color": "7d7171",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
Expand All @@ -320,6 +324,7 @@
"name": "Dead Shrub",
"color": "946428",
"transparent": true,
"spawninside": true,
"variants": [
{
"data": 1,
Expand All @@ -339,6 +344,7 @@
"name": "Dead Bush",
"color": "946428",
"transparent": true,
"spawninside": true,
"alpha": 0.3
},
{
Expand Down Expand Up @@ -439,13 +445,15 @@
"name": "Dandelion",
"color": "f1f902",
"transparent": true,
"spawninside": true,
"alpha": 0.3
},
{
"id": 38,
"name": "Poppy",
"color": "ba050b",
"transparent": true,
"spawninside": true,
"alpha": 0.3,
"variants": [
{
Expand Down Expand Up @@ -495,13 +503,15 @@
"name": "Brown Mushroom",
"color": "916d55",
"transparent": true,
"spawninside": true,
"alpha": 0.3
},
{
"id": 40,
"name": "Red Mushroom",
"color": "e21212",
"transparent": true,
"spawninside": true,
"alpha": 0.3
},
{
Expand Down Expand Up @@ -727,7 +737,8 @@
"id": 63,
"name": "Sign Post",
"color": "9f844d",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 64,
Expand All @@ -739,13 +750,15 @@
"id": 65,
"name": "Ladder",
"color": "8e733c",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 66,
"name": "Rail",
"color": "a4a4a4",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 67,
Expand All @@ -757,20 +770,23 @@
"id": 68,
"name": "Wall Sign",
"color": "b4905a",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 69,
"name": "Lever",
"color": "735e39",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
"id": 70,
"name": "Stone Pressure Plate",
"color": "8f8f8f",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
Expand All @@ -784,6 +800,7 @@
"name": "Wooden Pressure Plate",
"color": "bc9862",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
Expand Down Expand Up @@ -815,12 +832,14 @@
"name": "Stone Button",
"color": "a8a8a8",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
"id": 78,
"name": "Snow",
"color": "eeffff",
"spawninside": true,
"transparent": true
},
{
Expand Down Expand Up @@ -851,6 +870,7 @@
"id": 83,
"name": "Sugar Cane",
"color": "aadb74",
"spawninside": true,
"transparent": true
},
{
Expand Down Expand Up @@ -1162,7 +1182,8 @@
"id": 106,
"name": "Vines",
"color": "6cc44a",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 107,
Expand Down Expand Up @@ -1353,6 +1374,8 @@
"id": 127,
"name": "Immature Cocoa Pod",
"color": "929943",
"transparent": true,
"spawninside": true,
"mask": 12,
"variants": [
{
Expand Down Expand Up @@ -1384,6 +1407,7 @@
"name": "Tripwire Hook",
"color": "6e6e6e",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
Expand Down Expand Up @@ -1525,6 +1549,7 @@
"name": "Wooden Button",
"color": "b4905a",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
Expand All @@ -1551,13 +1576,15 @@
"name": "Weighted Pressure Plate (Light)",
"color": "fdfb4f",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
"id": 148,
"name": "Weighted Pressure Plate (Heavy)",
"color": "e6e6e6",
"transparent": true,
"spawninside": true,
"canProvidePower": true
},
{
Expand Down Expand Up @@ -1636,7 +1663,8 @@
"id": 157,
"name": "Activator Rail",
"color": "ab0301",
"transparent": true
"transparent": true,
"spawninside": true
},
{
"id": 158,
Expand Down Expand Up @@ -1854,6 +1882,12 @@
"name": "Slime Block",
"color": "608756"
},
{
"id": 166,
"name": "Barrier",
"color": "00000000",
"alpha": 0.0
},
{
"id": 170,
"name": "Hay Bale",
Expand Down Expand Up @@ -1961,6 +1995,7 @@
"id": 175,
"name": "Sunflower",
"transparent": true,
"spawninside": true,
"variants": [
{
"data": 1,
Expand Down
Loading

0 comments on commit db9fc95

Please sign in to comment.