Skip to content

Commit

Permalink
移除打火石的合成返还,修复耐久度合并的bug,调整透明建材代码
Browse files Browse the repository at this point in the history
  • Loading branch information
YipKei committed Jul 27, 2024
1 parent ab32938 commit 6a607a3
Show file tree
Hide file tree
Showing 18 changed files with 302 additions and 227 deletions.
5 changes: 1 addition & 4 deletions src/main/java/com/yipkei/vanilladdition/VanillaAddition.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import net.fabricmc.api.ModInitializer;

import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.impl.blockrenderlayer.BlockRenderLayerMapImpl;
import net.minecraft.client.render.RenderLayer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -41,7 +39,6 @@ public void onInitialize() {

FuelRegistry.INSTANCE.add(ModBlocks.COMPRESS_WOOL, 800);

BlockRenderLayerMapImpl blockRenderLayerMap = new BlockRenderLayerMapImpl();
blockRenderLayerMap.putBlocks(RenderLayer.getTranslucent(), ModBlocks.ICE_SLAB, ModBlocks.ICE_STAIRS, ModBlocks.ICE_WALL);

}
}
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);
}
}
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 src/main/java/com/yipkei/vanilladdition/block/IceSlab.java

This file was deleted.

46 changes: 0 additions & 46 deletions src/main/java/com/yipkei/vanilladdition/block/IceStairs.java

This file was deleted.

39 changes: 0 additions & 39 deletions src/main/java/com/yipkei/vanilladdition/block/IceWall.java

This file was deleted.

71 changes: 71 additions & 0 deletions src/main/java/com/yipkei/vanilladdition/block/TranslucentSlab.java
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);
}
}
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 src/main/java/com/yipkei/vanilladdition/block/TranslucentWall.java
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);
}

}
Loading

0 comments on commit 6a607a3

Please sign in to comment.