EndStoneSmelter block
This commit is contained in:
parent
c9326931d3
commit
e482247b40
17 changed files with 200 additions and 3 deletions
28
src/main/java/ru/betterend/blocks/BaseBlockWithEntity.java
Normal file
28
src/main/java/ru/betterend/blocks/BaseBlockWithEntity.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
public class BaseBlockWithEntity extends BlockWithEntity {
|
||||
|
||||
public BaseBlockWithEntity(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
}
|
104
src/main/java/ru/betterend/blocks/EndStoneSmelter.java
Normal file
104
src/main/java/ru/betterend/blocks/EndStoneSmelter.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalFacingBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
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.util.ActionResult;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
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.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
|
||||
public static final BooleanProperty LIT = Properties.LIT;
|
||||
|
||||
public EndStoneSmelter() {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.GRAY)
|
||||
.hardness(4F)
|
||||
.resistance(100F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.STONE));
|
||||
this.setDefaultState(this.stateManager.getDefaultState()
|
||||
.with(FACING, Direction.NORTH)
|
||||
.with(LIT, false));
|
||||
}
|
||||
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (world.isClient) {
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
this.openScreen(world, pos, player);
|
||||
return ActionResult.CONSUME;
|
||||
}
|
||||
}
|
||||
|
||||
private void openScreen(World world, BlockPos pos, PlayerEntity player) {}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, LIT);
|
||||
}
|
||||
}
|
|
@ -9,11 +9,11 @@ import ru.betterend.registry.BlockRegistry;
|
|||
public class CraftingRecipes {
|
||||
public static void register() {
|
||||
if (blockExists(BlockRegistry.ENDER_BLOCK)) {
|
||||
RecipeBuilder.make("be_ender_pearl_to_block", BlockRegistry.ENDER_BLOCK)
|
||||
RecipeBuilder.make("ender_pearl_to_block", BlockRegistry.ENDER_BLOCK)
|
||||
.setShape(new String[] { "OO", "OO" })
|
||||
.addMaterial('O', Items.ENDER_PEARL)
|
||||
.build();
|
||||
RecipeBuilder.make("be_ender_block_to_pearl", Items.ENDER_PEARL)
|
||||
RecipeBuilder.make("ender_block_to_pearl", Items.ENDER_PEARL)
|
||||
.addMaterial('#', BlockRegistry.ENDER_BLOCK)
|
||||
.setOutputCount(4)
|
||||
.setList("#")
|
||||
|
|
|
@ -11,6 +11,7 @@ import ru.betterend.blocks.AeterniumBlock;
|
|||
import ru.betterend.blocks.BlockEndstoneDust;
|
||||
import ru.betterend.blocks.BlockOre;
|
||||
import ru.betterend.blocks.BlockTerrain;
|
||||
import ru.betterend.blocks.EndStoneSmelter;
|
||||
import ru.betterend.blocks.EnderBlock;
|
||||
import ru.betterend.blocks.TerminiteBlock;
|
||||
import ru.betterend.tab.CreativeTab;
|
||||
|
@ -29,6 +30,9 @@ public class BlockRegistry {
|
|||
public static final Block AETERNIUM_BLOCK = registerBlock("aeternium_block", new AeterniumBlock());
|
||||
public static final Block ENDER_BLOCK = registerBlock("ender_block", new EnderBlock());
|
||||
|
||||
// BlockEntities //
|
||||
public static final Block END_STONE_SMELTER = registerBlock("end_stone_smelter", new EndStoneSmelter());
|
||||
|
||||
public static void register() {}
|
||||
|
||||
private static Block registerBlock(String name, Block block) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue