-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
302 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
src/main/java/com/yipkei/vanilladdition/VanillaAdditionClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package com.yipkei.vanilladdition; | ||
|
||
import com.yipkei.vanilladdition.init.ModBlocks; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.fabric.impl.blockrenderlayer.BlockRenderLayerMapImpl; | ||
import net.minecraft.client.render.RenderLayer; | ||
|
||
public class VanillaAdditionClient implements ClientModInitializer { | ||
@Override | ||
public void onInitializeClient() { | ||
|
||
BlockRenderLayerMapImpl blockRenderLayerMap = new BlockRenderLayerMapImpl(); | ||
blockRenderLayerMap.putBlocks(RenderLayer.getTranslucent(), ModBlocks.ICE_SLAB, ModBlocks.ICE_STAIRS, ModBlocks.ICE_WALL); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../vanilladdition/block/TranslucentIce.java → ...ition/block/AbstractTranslucentBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.yipkei.vanilladdition.block; | ||
|
||
public interface TranslucentIce { | ||
public interface AbstractTranslucentBlock { | ||
} |
73 changes: 0 additions & 73 deletions
73
src/main/java/com/yipkei/vanilladdition/block/IceSlab.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
src/main/java/com/yipkei/vanilladdition/block/IceStairs.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
src/main/java/com/yipkei/vanilladdition/block/IceWall.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/main/java/com/yipkei/vanilladdition/block/TranslucentSlab.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.yipkei.vanilladdition.block; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.block.enums.BlockHalf; | ||
import net.minecraft.block.enums.SlabType; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.math.Direction; | ||
|
||
import static com.yipkei.vanilladdition.helper.BlockStateHelper.hasCompleteSlabSurface; | ||
import static com.yipkei.vanilladdition.helper.BlockStateHelper.hasCompleteStairSurface; | ||
|
||
public class TranslucentSlab extends SlabBlock implements AbstractTranslucentBlock{ | ||
public TranslucentSlab(AbstractBlock.Settings settings) { | ||
super(settings); | ||
} | ||
|
||
private Block blockSeries; | ||
|
||
public Block setBlockSeriesAtSetting(Block block){ | ||
this.setBlockSeries(block); | ||
return this; | ||
} | ||
|
||
public void setBlockSeries(Block block){ | ||
this.blockSeries = block; | ||
} | ||
|
||
public Block getBlockSeries(){ | ||
return blockSeries; | ||
} | ||
|
||
@Override | ||
protected boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) { | ||
if (!(stateFrom.getBlock() instanceof AbstractTranslucentBlock)) { | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentBlock) { | ||
if (this.getBlockSeries() != stateFrom.getBlock()){ | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
return switch (state.get(Properties.SLAB_TYPE)) { | ||
case DOUBLE -> true; | ||
case TOP -> direction != Direction.DOWN || super.isSideInvisible(state, stateFrom, direction); | ||
case BOTTOM -> direction != Direction.UP || super.isSideInvisible(state, stateFrom, direction); | ||
}; | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentSlab) { | ||
if (this.getBlockSeries() != ((TranslucentSlab)(stateFrom.getBlock())).getBlockSeries()) | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
return switch (state.get(Properties.SLAB_TYPE)){ | ||
case DOUBLE -> (hasCompleteSlabSurface(stateFrom,direction.getOpposite())) || super.isSideInvisible(state, stateFrom, direction); | ||
case TOP -> ((direction == Direction.UP && stateFrom.get(Properties.SLAB_TYPE) != SlabType.TOP) || ((direction.getAxis() != Direction.Axis.Y) && stateFrom.get(Properties.SLAB_TYPE) != SlabType.BOTTOM)) || super.isSideInvisible(state, stateFrom, direction); | ||
case BOTTOM -> ((direction == Direction.DOWN && stateFrom.get(Properties.SLAB_TYPE) != SlabType.BOTTOM)||((direction.getAxis() != Direction.Axis.Y) && stateFrom.get(Properties.SLAB_TYPE) != SlabType.TOP)) || super.isSideInvisible(state, stateFrom, direction); | ||
}; | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentStairs){ | ||
if (this.getBlockSeries() != ((TranslucentStairs)(stateFrom.getBlock())).getBlockSeries()) | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
return switch (state.get(Properties.SLAB_TYPE)){ | ||
case DOUBLE -> (hasCompleteStairSurface(stateFrom,direction.getOpposite())) || super.isSideInvisible(state, stateFrom, direction); | ||
case TOP -> ((direction == Direction.UP && stateFrom.get(Properties.BLOCK_HALF) == BlockHalf.BOTTOM) || ((direction.getAxis() != Direction.Axis.Y) && stateFrom.get(Properties.BLOCK_HALF) == BlockHalf.TOP)) || super.isSideInvisible(state, stateFrom, direction); | ||
case BOTTOM -> ((direction == Direction.DOWN && stateFrom.get(Properties.BLOCK_HALF) == BlockHalf.TOP) || ((direction.getAxis() != Direction.Axis.Y) && stateFrom.get(Properties.BLOCK_HALF) == BlockHalf.BOTTOM)) || super.isSideInvisible(state, stateFrom, direction); | ||
}; | ||
} | ||
|
||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/yipkei/vanilladdition/block/TranslucentStairs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.yipkei.vanilladdition.block; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.math.Direction; | ||
|
||
import static com.yipkei.vanilladdition.helper.BlockStateHelper.*; | ||
|
||
public class TranslucentStairs extends StairsBlock implements AbstractTranslucentBlock { | ||
public TranslucentStairs(BlockState baseBlockState, Settings settings) { | ||
super(baseBlockState, settings); | ||
} | ||
|
||
private Block blockSeries; | ||
|
||
public Block setBlockSeriesAtSetting(Block block){ | ||
this.setBlockSeries(block); | ||
return this; | ||
} | ||
|
||
public void setBlockSeries(Block block){ | ||
this.blockSeries = block; | ||
} | ||
|
||
public Block getBlockSeries(){ | ||
return blockSeries; | ||
} | ||
|
||
@Override | ||
protected boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) { | ||
|
||
if (!(stateFrom.getBlock() instanceof AbstractTranslucentBlock)) | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentBlock) { | ||
return (this.getBlockSeries() == stateFrom.getBlock()) || super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
|
||
if (this.getBlockSeries() == stateFrom.getBlock()) return true; | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentStairs) { | ||
if (this.getBlockSeries() != ((TranslucentStairs)(stateFrom.getBlock())).getBlockSeries()) | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
if (hasCompleteStairSurface(stateFrom, direction.getOpposite())) return true; | ||
Direction facing = state.get(Properties.HORIZONTAL_FACING); | ||
if (state.get(Properties.BLOCK_HALF) == stateFrom.get(Properties.BLOCK_HALF)) { | ||
if (direction.getAxis() == facing.getAxis()) { | ||
if (facing == stateFrom.get(Properties.HORIZONTAL_FACING)) | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
return true; | ||
} | ||
if (direction.getAxis() == Direction.Axis.Y){ | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentSlab && this.getBlockSeries() == ((TranslucentSlab)(stateFrom.getBlock())).getBlockSeries() && hasCompleteSlabSurface(stateFrom, direction.getOpposite())) | ||
return true; | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
src/main/java/com/yipkei/vanilladdition/block/TranslucentWall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.yipkei.vanilladdition.block; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.util.math.Direction; | ||
|
||
import static com.yipkei.vanilladdition.helper.BlockStateHelper.*; | ||
|
||
public class TranslucentWall extends WallBlock implements AbstractTranslucentBlock { | ||
public TranslucentWall(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
private Block blockSeries; | ||
|
||
public Block setBlockSeriesAtSetting(Block block){ | ||
this.setBlockSeries(block); | ||
return this; | ||
} | ||
|
||
public void setBlockSeries(Block block){ | ||
this.blockSeries = block; | ||
} | ||
|
||
public Block getBlockSeries(){ | ||
return blockSeries; | ||
} | ||
|
||
@Override | ||
protected boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) { | ||
if (!(stateFrom.getBlock() instanceof AbstractTranslucentBlock)){ | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentBlock || stateFrom.getBlock() instanceof TranslucentWall) { | ||
return (this.getBlockSeries() == stateFrom.getBlock()) || super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentStairs) { | ||
return (this.getBlockSeries() == ((TranslucentStairs)(stateFrom.getBlock())).getBlockSeries() && hasCompleteStairSurface(stateFrom,direction.getOpposite())) || super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
|
||
if (stateFrom.getBlock() instanceof TranslucentSlab){ | ||
return (this.getBlockSeries() == ((TranslucentSlab)(stateFrom.getBlock())).getBlockSeries() && hasCompleteSlabSurface(stateFrom,direction.getOpposite())) || super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
return super.isSideInvisible(state, stateFrom, direction); | ||
} | ||
|
||
} |
Oops, something went wrong.