Furnaces prototypes
This commit is contained in:
parent
364382b29b
commit
5475e514dc
9 changed files with 161 additions and 3 deletions
65
src/main/java/ru/betterend/blocks/basis/EndFurnaceBlock.java
Normal file
65
src/main/java/ru/betterend/blocks/basis/EndFurnaceBlock.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.FurnaceBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned {
|
||||
public EndFurnaceBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new EFurnaceBlockEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openScreen(World world, BlockPos pos, PlayerEntity player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EFurnaceBlockEntity) {
|
||||
player.openHandledScreen((NamedScreenHandlerFactory) blockEntity);
|
||||
player.incrementStat(Stats.INTERACT_WITH_FURNACE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String add = block.contains("_on") ? "_on" : "";
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%top%", blockId.getPath() + "_top");
|
||||
map.put("%front%", blockId.getPath() + "_front" + add);
|
||||
map.put("%side%", blockId.getPath() + "_side");
|
||||
map.put("%bottom%", blockId.getPath() + "_bottom");
|
||||
return Patterns.createJson(Patterns.BLOCK_FURNACE, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterns.STATE_FURNACE;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import net.minecraft.tag.BlockTags;
|
|||
import net.minecraft.tag.ItemTags;
|
||||
import ru.betterend.blocks.EndPedestal;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.blocks.basis.EndFurnaceBlock;
|
||||
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||
import ru.betterend.blocks.basis.EndSlabBlock;
|
||||
import ru.betterend.blocks.basis.EndStairsBlock;
|
||||
|
@ -40,6 +41,7 @@ public class StoneMaterial {
|
|||
public final Block brick_stairs;
|
||||
public final Block brick_slab;
|
||||
public final Block brick_wall;
|
||||
public final Block furnace;
|
||||
|
||||
public StoneMaterial(String name, MaterialColor color) {
|
||||
FabricBlockSettings material = FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color);
|
||||
|
@ -60,6 +62,7 @@ public class StoneMaterial {
|
|||
brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new EndStairsBlock(bricks));
|
||||
brick_slab = EndBlocks.registerBlock(name + "_bricks_slab", new EndSlabBlock(bricks));
|
||||
brick_wall = EndBlocks.registerBlock(name + "_bricks_wall", new EndWallBlock(bricks));
|
||||
furnace = EndBlocks.registerBlock(name + "_furnace", new EndFurnaceBlock(bricks));
|
||||
|
||||
// Recipes //
|
||||
GridRecipe.make(name + "_bricks", bricks).setOutputCount(4).setShape("##", "##").addMaterial('#', stone).setGroup("end_bricks").build();
|
||||
|
@ -78,6 +81,7 @@ public class StoneMaterial {
|
|||
GridRecipe.make(name + "_button", button).setList("#").addMaterial('#', stone).setGroup("end_stone_buttons").build();
|
||||
GridRecipe.make(name + "_pressure_plate", pressure_plate).setShape("##").addMaterial('#', stone).setGroup("end_stone_plates").build();
|
||||
GridRecipe.make(name + "_lantern", lantern).setShape("S", "#", "S").addMaterial('#', EndItems.CRYSTAL_SHARDS).addMaterial('S', slab, brick_slab).setGroup("end_stone_lanterns").build();
|
||||
GridRecipe.make(name + "_furnace", furnace).setShape("###", "# #", "###").addMaterial('#', stone).setGroup("end_stone_furnaces").build();
|
||||
|
||||
CraftingRecipes.registerPedestal(name + "_pedestal", pedestal, slab, pillar);
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.screen.FurnaceScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
|
||||
public EFurnaceBlockEntity() {
|
||||
super(EndBlockEntities.FURNACE, RecipeType.SMELTING);
|
||||
}
|
||||
|
||||
protected Text getContainerName() {
|
||||
return new TranslatableText("container.furnace");
|
||||
}
|
||||
|
||||
protected ScreenHandler createScreenHandler(int syncId, PlayerInventory playerInventory) {
|
||||
return new FurnaceScreenHandler(syncId, playerInventory, this, this.propertyDelegate);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue