Resin basin finished (Recipe, functionality, textures, models)
This commit is contained in:
parent
1c07084416
commit
856f66eeb0
28 changed files with 959 additions and 273 deletions
|
@ -0,0 +1,98 @@
|
|||
package techreborn.blocks.machine.tier1;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldView;
|
||||
import reborncore.api.blockentity.IMachineGuiHandler;
|
||||
import reborncore.common.BaseBlockEntityProvider;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import techreborn.blocks.GenericMachineBlock;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ResinBasinBlock extends BaseBlockEntityProvider {
|
||||
|
||||
public static DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||
public static BooleanProperty POURING = BooleanProperty.of("pouring");
|
||||
public static BooleanProperty FULL = BooleanProperty.of("full");
|
||||
Supplier<BlockEntity> blockEntityClass;
|
||||
|
||||
public ResinBasinBlock(Supplier<BlockEntity> blockEntityClass) {
|
||||
super(Block.Settings.of(Material.WOOD).strength(2F, 2F));
|
||||
this.blockEntityClass = blockEntityClass;
|
||||
|
||||
this.setDefaultState(
|
||||
this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(POURING, false).with(FULL, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return VoxelShapes.cuboid(0, 0, 0,1,15/16f,1);
|
||||
}
|
||||
|
||||
public void setFacing(Direction facing, World world, BlockPos pos) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing));
|
||||
}
|
||||
|
||||
// Block
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
FACING = DirectionProperty.of("facing", Direction.Type.HORIZONTAL);
|
||||
POURING = BooleanProperty.of("pouring");
|
||||
FULL = BooleanProperty.of("full");
|
||||
builder.add(FACING, POURING, FULL);
|
||||
}
|
||||
|
||||
public Direction getFacing(BlockState state) {
|
||||
return state.get(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
super.onPlaced(worldIn, pos, state, placer, stack);
|
||||
|
||||
if(worldIn.isClient) return;
|
||||
|
||||
Direction facing = placer.getHorizontalFacing().getOpposite();
|
||||
setFacing(facing, worldIn, pos);
|
||||
|
||||
// Drop item if not next to log and yell at user
|
||||
if(worldIn.getBlockState(pos.offset(facing.getOpposite())).getBlock() != TRContent.RUBBER_LOG){
|
||||
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(this.asBlock()));
|
||||
worldIn.spawnEntity(itemEntity);
|
||||
placer.sendSystemMessage(new LiteralText(new TranslatableText(this.getTranslationKey()).getString() + new TranslatableText("techreborn.tooltip.invalid_basin_placement").getString()),null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView worldIn) {
|
||||
if (blockEntityClass == null) {
|
||||
return null;
|
||||
}
|
||||
return blockEntityClass.get();
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package techreborn.blocks.machine.tier1;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import reborncore.api.blockentity.IMachineGuiHandler;
|
||||
import techreborn.blocks.GenericMachineBlock;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TapperBlock extends GenericMachineBlock {
|
||||
public TapperBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
|
||||
super(gui, blockEntityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return VoxelShapes.cuboid(2/16f, 0, 2/16f,14/16f,8/16f,14/16f);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue