Skip to content

Commit

Permalink
Add support for isSideInvisible. Close #248
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Sep 24, 2021
1 parent 7bcdfd0 commit 3e6160a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.blamejared.contenttweaker.api.functions;

import com.blamejared.contenttweaker.blocks.types.advanced.CoTBlockAdvanced;
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.impl.util.MCDirection;
import com.blamejared.crafttweaker_annotations.annotations.Document;
import net.minecraft.block.BlockState;
import org.openzen.zencode.java.ZenCodeType;

@FunctionalInterface
@ZenRegister
@ZenCodeType.Name("mods.contenttweaker.functions.IBlockIsSideInvisible")
@Document("mods/contenttweaker/API/functions/IBlockIsSideInvisible")
public interface IBlockIsSideInvisible extends ICotFunction {

@ZenCodeType.Field
IBlockIsSideInvisible GLASS_LIKE = (thisBlock, state, adjacentBlockState, side) -> adjacentBlockState.isIn(thisBlock);

@ZenCodeType.Method
boolean apply(CoTBlockAdvanced thisBlock, BlockState state, BlockState adjacentBlockState, MCDirection side);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import com.blamejared.contenttweaker.api.functions.*;
import com.blamejared.contenttweaker.blocks.types.basic.CoTBlockBasic;
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.impl.util.MCDirection;
import com.blamejared.crafttweaker_annotations.annotations.Document;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -45,6 +47,7 @@ public CoTBlockAdvanced(Properties properties, Item.Properties itemProperties, R
private IBlockReplaced blockReplaced;
private IBlockActivated blockActivated;
private IBlockColorSupplier blockColorSupplier = IBlockColorSupplier.DEFAULT;
private IBlockIsSideInvisible blockIsSideInvisible = (thisBlock, state, adjacentBlockState, side) -> false;

/**
* Sets what will happen when the block is added.
Expand Down Expand Up @@ -116,6 +119,12 @@ public CoTBlockAdvanced setBlockColorSupplier(IBlockColorSupplier func) {
ActionSetFunctionClient.applyNewAction("blockColorSupplier", this, func, IBlockColorSupplier.DEFAULT, (block, fun) -> block.blockColorSupplier = fun);
return this;
}

@ZenCodeType.Method
public CoTBlockAdvanced setIsSideInvisible(IBlockIsSideInvisible func) {
ActionSetFunctionClient.applyNewAction("isSideInvisible", this, func, (thisBlock, state, adjacentBlockState, side) -> false, (block, fun) -> block.blockIsSideInvisible = fun);
return this;
}

@Override
@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -166,7 +175,12 @@ public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}


@Override
public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) {
return blockIsSideInvisible.apply(this,state, adjacentBlockState, MCDirection.get(side));
}

public int getColor(BlockState state, IBlockDisplayReader world, BlockPos pos, int tintIndex) {
return blockColorSupplier.apply(state, world, pos, tintIndex);
}
Expand Down

0 comments on commit 3e6160a

Please sign in to comment.