Skip to content

Commit

Permalink
Fix transparency bug with glass stairs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Dec 12, 2023
1 parent 72f0e79 commit c6fdadf
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 12 deletions.
27 changes: 24 additions & 3 deletions src/main/java/net/wurstclient/glass/GlassStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,29 @@ private boolean isInvisibleToGlassStairs(BlockState state,
}

// other stairs rear
if(facingFrom == direction.getOpposite())
if(facingFrom == direction.getOpposite()
&& shapeFrom != StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

// other curved stairs fully covered side
if(facingFrom == direction.rotateYClockwise()
&& shapeFrom == StairShape.INNER_RIGHT)
return true;
if(facingFrom == direction.rotateYCounterclockwise()
&& shapeFrom == StairShape.INNER_LEFT)
return true;

// rear
if(direction == facing && half == halfFrom
&& shape != StairShape.STRAIGHT)
if(direction == facing && half == halfFrom)
{
if(facingFrom == facing.rotateYCounterclockwise()
&& shape == StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

if(facingFrom == facing.rotateYClockwise()
&& shape == StairShape.OUTER_RIGHT
&& shapeFrom != StairShape.OUTER_LEFT)
return true;
}
Expand Down Expand Up @@ -269,6 +280,11 @@ private boolean isInvisibleToGlassStairs(BlockState state,
if(facingFrom == facing && shapeFrom != StairShape.OUTER_LEFT)
return true;

if(facingFrom == facing.rotateYClockwise()
&& shapeFrom == StairShape.OUTER_LEFT
&& shape != StairShape.INNER_LEFT)
return true;

if(facingFrom == facing.getOpposite()
&& shape == StairShape.OUTER_RIGHT)
return true;
Expand All @@ -284,6 +300,11 @@ private boolean isInvisibleToGlassStairs(BlockState state,
if(facingFrom == facing && shapeFrom != StairShape.OUTER_RIGHT)
return true;

if(facingFrom == facing.rotateYCounterclockwise()
&& shapeFrom == StairShape.OUTER_RIGHT
&& shape != StairShape.INNER_RIGHT)
return true;

if(facingFrom == facing.getOpposite()
&& shape == StairShape.OUTER_LEFT)
return true;
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/net/wurstclient/glass/StainedGlassStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,29 @@ private boolean isInvisibleToGlassStairs(BlockState state,
}

// other stairs rear
if(facingFrom == direction.getOpposite())
if(facingFrom == direction.getOpposite()
&& shapeFrom != StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

// other curved stairs fully covered side
if(facingFrom == direction.rotateYClockwise()
&& shapeFrom == StairShape.INNER_RIGHT)
return true;
if(facingFrom == direction.rotateYCounterclockwise()
&& shapeFrom == StairShape.INNER_LEFT)
return true;

// rear
if(direction == facing && half == halfFrom
&& shape != StairShape.STRAIGHT)
if(direction == facing && half == halfFrom)
{
if(facingFrom == facing.rotateYCounterclockwise()
&& shape == StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

if(facingFrom == facing.rotateYClockwise()
&& shape == StairShape.OUTER_RIGHT
&& shapeFrom != StairShape.OUTER_LEFT)
return true;
}
Expand Down Expand Up @@ -273,6 +284,11 @@ private boolean isInvisibleToGlassStairs(BlockState state,
if(facingFrom == facing && shapeFrom != StairShape.OUTER_LEFT)
return true;

if(facingFrom == facing.rotateYClockwise()
&& shapeFrom == StairShape.OUTER_LEFT
&& shape != StairShape.INNER_LEFT)
return true;

if(facingFrom == facing.getOpposite()
&& shape == StairShape.OUTER_RIGHT)
return true;
Expand All @@ -288,6 +304,11 @@ private boolean isInvisibleToGlassStairs(BlockState state,
if(facingFrom == facing && shapeFrom != StairShape.OUTER_RIGHT)
return true;

if(facingFrom == facing.rotateYCounterclockwise()
&& shapeFrom == StairShape.OUTER_RIGHT
&& shape != StairShape.INNER_RIGHT)
return true;

if(facingFrom == facing.getOpposite()
&& shape == StairShape.OUTER_LEFT)
return true;
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/net/wurstclient/glass/TintedGlassStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,29 @@ private boolean isInvisibleToGlassStairs(BlockState state,
}

// other stairs rear
if(facingFrom == direction.getOpposite())
if(facingFrom == direction.getOpposite()
&& shapeFrom != StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

// other curved stairs fully covered side
if(facingFrom == direction.rotateYClockwise()
&& shapeFrom == StairShape.INNER_RIGHT)
return true;
if(facingFrom == direction.rotateYCounterclockwise()
&& shapeFrom == StairShape.INNER_LEFT)
return true;

// rear
if(direction == facing && half == halfFrom
&& shape != StairShape.STRAIGHT)
if(direction == facing && half == halfFrom)
{
if(facingFrom == facing.rotateYCounterclockwise()
&& shape == StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

if(facingFrom == facing.rotateYClockwise()
&& shape == StairShape.OUTER_RIGHT
&& shapeFrom != StairShape.OUTER_LEFT)
return true;
}
Expand Down Expand Up @@ -269,6 +280,11 @@ private boolean isInvisibleToGlassStairs(BlockState state,
if(facingFrom == facing && shapeFrom != StairShape.OUTER_LEFT)
return true;

if(facingFrom == facing.rotateYClockwise()
&& shapeFrom == StairShape.OUTER_LEFT
&& shape != StairShape.INNER_LEFT)
return true;

if(facingFrom == facing.getOpposite()
&& shape == StairShape.OUTER_RIGHT)
return true;
Expand All @@ -284,6 +300,11 @@ private boolean isInvisibleToGlassStairs(BlockState state,
if(facingFrom == facing && shapeFrom != StairShape.OUTER_RIGHT)
return true;

if(facingFrom == facing.rotateYCounterclockwise()
&& shapeFrom == StairShape.OUTER_RIGHT
&& shape != StairShape.INNER_RIGHT)
return true;

if(facingFrom == facing.getOpposite()
&& shape == StairShape.OUTER_LEFT)
return true;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/net/wurstclient/glass/mixin/GlassBlockMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.block.StairsBlock;
import net.minecraft.block.enums.BlockHalf;
import net.minecraft.block.enums.SlabType;
import net.minecraft.block.enums.StairShape;
import net.minecraft.util.math.Direction;
import net.wurstclient.glass.MoGlass;
import net.wurstclient.glass.MoGlassBlocks;
Expand Down Expand Up @@ -67,6 +68,7 @@ private boolean isInvisibleToGlassStairs(BlockState state,
{
BlockHalf halfFrom = stateFrom.get(StairsBlock.HALF);
Direction facingFrom = stateFrom.get(StairsBlock.FACING);
StairShape shapeFrom = stateFrom.get(StairsBlock.SHAPE);

// up
if(direction == Direction.UP)
Expand All @@ -79,7 +81,17 @@ private boolean isInvisibleToGlassStairs(BlockState state,
return true;

// other stairs rear
if(facingFrom == direction.getOpposite())
if(facingFrom == direction.getOpposite()
&& shapeFrom != StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

// other curved stairs fully covered side
if(facingFrom == direction.rotateYClockwise()
&& shapeFrom == StairShape.INNER_RIGHT)
return true;
if(facingFrom == direction.rotateYCounterclockwise()
&& shapeFrom == StairShape.INNER_LEFT)
return true;

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.block.StairsBlock;
import net.minecraft.block.enums.BlockHalf;
import net.minecraft.block.enums.SlabType;
import net.minecraft.block.enums.StairShape;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.Direction;
import net.wurstclient.glass.MoGlass;
Expand Down Expand Up @@ -82,6 +83,7 @@ private boolean isInvisibleToGlassStairs(BlockState state,
{
BlockHalf halfFrom = stateFrom.get(StairsBlock.HALF);
Direction facingFrom = stateFrom.get(StairsBlock.FACING);
StairShape shapeFrom = stateFrom.get(StairsBlock.SHAPE);

// up
if(direction == Direction.UP)
Expand All @@ -94,7 +96,17 @@ private boolean isInvisibleToGlassStairs(BlockState state,
return true;

// other stairs rear
if(facingFrom == direction.getOpposite())
if(facingFrom == direction.getOpposite()
&& shapeFrom != StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

// other curved stairs fully covered side
if(facingFrom == direction.rotateYClockwise()
&& shapeFrom == StairShape.INNER_RIGHT)
return true;
if(facingFrom == direction.rotateYCounterclockwise()
&& shapeFrom == StairShape.INNER_LEFT)
return true;

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.block.TintedGlassBlock;
import net.minecraft.block.enums.BlockHalf;
import net.minecraft.block.enums.SlabType;
import net.minecraft.block.enums.StairShape;
import net.minecraft.util.math.Direction;
import net.wurstclient.glass.MoGlass;
import net.wurstclient.glass.MoGlassBlocks;
Expand Down Expand Up @@ -67,6 +68,7 @@ private boolean isInvisibleToGlassStairs(BlockState state,
{
BlockHalf halfFrom = stateFrom.get(StairsBlock.HALF);
Direction facingFrom = stateFrom.get(StairsBlock.FACING);
StairShape shapeFrom = stateFrom.get(StairsBlock.SHAPE);

// up
if(direction == Direction.UP)
Expand All @@ -79,7 +81,17 @@ private boolean isInvisibleToGlassStairs(BlockState state,
return true;

// other stairs rear
if(facingFrom == direction.getOpposite())
if(facingFrom == direction.getOpposite()
&& shapeFrom != StairShape.OUTER_LEFT
&& shapeFrom != StairShape.OUTER_RIGHT)
return true;

// other curved stairs fully covered side
if(facingFrom == direction.rotateYClockwise()
&& shapeFrom == StairShape.INNER_RIGHT)
return true;
if(facingFrom == direction.rotateYCounterclockwise()
&& shapeFrom == StairShape.INNER_LEFT)
return true;

return false;
Expand Down

0 comments on commit c6fdadf

Please sign in to comment.