Skip to content

Commit

Permalink
Fixing Pane, wall, and fence bounding box innaccuries and 1.17+ error…
Browse files Browse the repository at this point in the history
…s [v1.11.2.1]
  • Loading branch information
funkemunky committed Jan 8, 2022
1 parent 58cc0e9 commit 01c3eea
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 31 deletions.
4 changes: 2 additions & 2 deletions AtlasParent/Atlas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<parent>
<groupId>cc.funkemunky.utils</groupId>
<version>1.11.2</version>
<version>1.11.2.1</version>
<artifactId>atlas-parent</artifactId>
<relativePath>../pom.xml</relativePath>
</parent>
Expand Down Expand Up @@ -416,7 +416,7 @@
<dependency>
<groupId>org.github.spigot</groupId>
<artifactId>1.11.2</artifactId>
<version>1.11.2</version>
<version>1.11.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion;
import cc.funkemunky.api.utils.BlockUtils;
import cc.funkemunky.api.utils.Materials;
import cc.funkemunky.api.utils.XMaterial;
import cc.funkemunky.api.utils.world.CollisionBox;
import cc.funkemunky.api.utils.world.types.CollisionFactory;
import cc.funkemunky.api.utils.world.types.ComplexCollisionBox;
Expand Down Expand Up @@ -37,18 +38,20 @@ public CollisionBox fetch(ProtocolVersion version, Block b) {
}

static boolean isBlacklisted(Material m) {
switch(m.ordinal()) {
case 138:
case 280:
case 86:
case 103:
case 166:
XMaterial material = XMaterial.matchXMaterial(m);
switch(material) {
case BEACON:
case STICK:
case SNOW_BLOCK:
case MELON:
case BARRIER:
return true;
default:
return Materials.checkFlag(m, Materials.STAIRS)
return !Materials.checkFlag(m, Materials.SOLID)
|| Materials.checkFlag(m, Materials.STAIRS)
|| Materials.checkFlag(m, Materials.WALL)
|| m.name().contains("DAYLIGHT")
|| Materials.checkFlag(m, Materials.FENCE);
|| Materials.checkFlag(m, Materials.FENCE)
|| m.name().contains("DAYLIGHT");
}
}

Expand All @@ -58,13 +61,14 @@ private static boolean fenceConnects(ProtocolVersion v,Block fenceBlock, BlockFa

if(!targetBlock.isPresent()) return false;
BlockState sFence = fenceBlock.getState();
BlockState sTarget = targetBlock.get().getState();
Material target = sTarget.getType();
Material target = targetBlock.get().getType();
Material fence = sFence.getType();

if (!isFence(target)&&isBlacklisted(target))
return false;

BlockState sTarget = targetBlock.get().getState();

if(Materials.checkFlag(target, Materials.STAIRS)) {
if (v.isBelow(ProtocolVersion.V1_12)) return false;
Stairs stairs = (Stairs) sTarget.getData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cc.funkemunky.api.utils.world.blocks;

import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion;
import cc.funkemunky.api.utils.Materials;
import cc.funkemunky.api.utils.XMaterial;
import cc.funkemunky.api.utils.world.CollisionBox;
import cc.funkemunky.api.utils.world.types.CollisionFactory;
import cc.funkemunky.api.utils.world.types.ComplexCollisionBox;
Expand Down Expand Up @@ -43,24 +45,25 @@ public CollisionBox fetch(ProtocolVersion version, Block b) {

private static boolean fenceConnects(ProtocolVersion v, Block fenceBlock, BlockFace direction) {
Block targetBlock = fenceBlock.getRelative(direction,1);
BlockState sFence = fenceBlock.getState();
BlockState sTarget = targetBlock.getState();
Material target = sTarget.getType();
Material fence = sFence.getType();
Material target = targetBlock.getType();

if (!isPane(target)&&DynamicFence.isBlacklisted(target))
return false;

if(target.name().contains("STAIRS")) {
BlockState sTarget = targetBlock.getState();

if(Materials.checkFlag(target, Materials.STAIRS)) {
if (v.isBelow(ProtocolVersion.V1_12)) return false;
Stairs stairs = (Stairs) sTarget.getData();
return stairs.getFacing() == direction;
} else return isPane(target) || (target.isSolid() && !target.isTransparent());
}

private static boolean isPane(Material m) {
int id = m.getId();
return id == 101 || id == 102 || id == 160;
final XMaterial mat = XMaterial.matchXMaterial(m);

return mat == XMaterial.IRON_BARS || mat.name().contains("PANE")
|| mat.name().contains("THIN");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion;
import cc.funkemunky.api.utils.BlockUtils;
import cc.funkemunky.api.utils.Materials;
import cc.funkemunky.api.utils.XMaterial;
import cc.funkemunky.api.utils.world.CollisionBox;
import cc.funkemunky.api.utils.world.types.CollisionFactory;
import cc.funkemunky.api.utils.world.types.SimpleCollisionBox;
Expand Down Expand Up @@ -65,12 +66,13 @@ private static boolean wallConnects(ProtocolVersion v, Block fenceBlock, BlockFa
Optional<Block> targetBlock = BlockUtils.getRelativeAsync(fenceBlock, direction, 1);

if(!targetBlock.isPresent()) return false;
BlockState sTarget = targetBlock.get().getState();
Material target = sTarget.getType();
Material target = targetBlock.get().getType();

if (!isWall(target)&&DynamicFence.isBlacklisted(target))
return false;

BlockState sTarget = targetBlock.get().getState();

if(Materials.checkFlag(target, Materials.STAIRS)) {
if (v.isBelow(ProtocolVersion.V1_12)) return false;
Stairs stairs = (Stairs) sTarget.getData();
Expand All @@ -79,7 +81,7 @@ private static boolean wallConnects(ProtocolVersion v, Block fenceBlock, BlockFa
}

private static boolean isWall(Material m) {
return m.name().contains("WALL");
return Materials.checkFlag(m, Materials.WALL);
}

}
2 changes: 1 addition & 1 deletion AtlasParent/AtlasBukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>atlas-parent</artifactId>
<groupId>cc.funkemunky.utils</groupId>
<version>1.11.2</version>
<version>1.11.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion AtlasParent/AtlasBungee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>atlas-parent</artifactId>
<groupId>cc.funkemunky.utils</groupId>
<version>1.11.2</version>
<version>1.11.2.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
6 changes: 3 additions & 3 deletions AtlasParent/AtlasExample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<parent>
<artifactId>atlas-parent</artifactId>
<groupId>cc.funkemunky.utils</groupId>
<version>1.11.2</version>
<version>1.11.2.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>cc.funkemunky.example</groupId>
<artifactId>AtlasExample</artifactId>
<version>1.11.2</version>
<version>1.11.2.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -87,7 +87,7 @@
<dependency>
<groupId>cc.funkemunky.utils</groupId>
<artifactId>Atlas</artifactId>
<version>1.11.2</version>
<version>1.11.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion AtlasParent/AtlasVelocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>atlas-parent</artifactId>
<groupId>cc.funkemunky.utils</groupId>
<version>1.11.2</version>
<version>1.11.2.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion AtlasParent/Atlas_Compat_1_18/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>atlas-parent</artifactId>
<groupId>cc.funkemunky.utils</groupId>
<version>1.11.2</version>
<version>1.11.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion AtlasParent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>cc.funkemunky.utils</groupId>
<artifactId>atlas-parent</artifactId>
<packaging>pom</packaging>
<version>1.11.2</version>
<version>1.11.2.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 01c3eea

Please sign in to comment.