Spend less on candles
This commit is contained in:
parent
a793bad0ed
commit
3d77770a8b
@ -3,6 +3,7 @@ package io.github.cottonmc.templates;
|
||||
import io.github.cottonmc.templates.api.TemplateInteractionUtil;
|
||||
import io.github.cottonmc.templates.block.TemplateBlock;
|
||||
import io.github.cottonmc.templates.block.TemplateButtonBlock;
|
||||
import io.github.cottonmc.templates.block.TemplateCandleBlock;
|
||||
import io.github.cottonmc.templates.block.TemplateCarpetBlock;
|
||||
import io.github.cottonmc.templates.block.TemplateFenceBlock;
|
||||
import io.github.cottonmc.templates.block.TemplateFenceGateBlock;
|
||||
@ -16,16 +17,16 @@ import io.github.cottonmc.templates.block.TemplateWallBlock;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -46,21 +47,25 @@ public class Templates implements ModInitializer {
|
||||
return b;
|
||||
}
|
||||
|
||||
public static final Block BUTTON = reg("button", new TemplateButtonBlock(TemplateInteractionUtil.makeSettings().pistonBehavior(PistonBehavior.DESTROY)));
|
||||
//candle? (lol)
|
||||
public static final Block CARPET = reg("carpet", new TemplateCarpetBlock(TemplateInteractionUtil.makeSettings().sounds(BlockSoundGroup.WOOL).pistonBehavior(PistonBehavior.DESTROY)));
|
||||
private static AbstractBlock.Settings cp(Block base) {
|
||||
return TemplateInteractionUtil.configureSettings(AbstractBlock.Settings.copy(base));
|
||||
}
|
||||
|
||||
public static final Block BUTTON = reg("button", new TemplateButtonBlock(cp(Blocks.OAK_BUTTON)));
|
||||
public static final Block CANDLE = reg("candle", new TemplateCandleBlock(TemplateCandleBlock.configureSettings(cp(Blocks.CANDLE))));
|
||||
public static final Block CARPET = reg("carpet", new TemplateCarpetBlock(cp(Blocks.WHITE_CARPET)));
|
||||
public static final Block CUBE = reg("cube", new TemplateBlock(TemplateInteractionUtil.makeSettings()));
|
||||
//door? (hard cause its a multiblock)
|
||||
public static final Block FENCE = reg("fence", new TemplateFenceBlock(TemplateInteractionUtil.makeSettings()));
|
||||
public static final Block FENCE_GATE = reg("fence_gate", new TemplateFenceGateBlock(TemplateInteractionUtil.makeSettings()));
|
||||
public static final Block LEVER = reg("lever", new TemplateLeverBlock(TemplateInteractionUtil.makeSettings().pistonBehavior(PistonBehavior.DESTROY)));
|
||||
public static final Block FENCE = reg("fence", new TemplateFenceBlock(cp(Blocks.OAK_FENCE)));
|
||||
public static final Block FENCE_GATE = reg("fence_gate", new TemplateFenceGateBlock(cp(Blocks.OAK_FENCE_GATE)));
|
||||
public static final Block LEVER = reg("lever", new TemplateLeverBlock(cp(Blocks.LEVER)));
|
||||
//pane
|
||||
public static final Block POST = reg("post", new TemplatePostBlock(TemplateInteractionUtil.makeSettings()));
|
||||
public static final Block PRESSURE_PLATE = reg("pressure_plate", new TemplatePressurePlateBlock(TemplateInteractionUtil.makeSettings().noCollision().pistonBehavior(PistonBehavior.DESTROY)));
|
||||
public static final Block SLAB = reg("slab", new TemplateSlabBlock(TemplateInteractionUtil.makeSettings()));
|
||||
public static final Block POST = reg("post", new TemplatePostBlock(cp(Blocks.OAK_FENCE)));
|
||||
public static final Block PRESSURE_PLATE = reg("pressure_plate", new TemplatePressurePlateBlock(cp(Blocks.OAK_PRESSURE_PLATE)));
|
||||
public static final Block SLAB = reg("slab", new TemplateSlabBlock(cp(Blocks.OAK_SLAB)));
|
||||
//stair
|
||||
//trapdoor
|
||||
public static final Block WALL = reg("wall", new TemplateWallBlock(TemplateInteractionUtil.makeSettings()));
|
||||
public static final Block WALL = reg("wall", new TemplateWallBlock(cp(Blocks.COBBLESTONE_WALL)));
|
||||
|
||||
public static final Block SLOPE = reg("slope", new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings()));
|
||||
//30 degree slope (shallow/deep)
|
||||
|
@ -61,6 +61,10 @@ public class TemplatesClient implements ClientModInitializer {
|
||||
//vanilla style models (using "auto" method)
|
||||
provider.addTemplateModel(Templates.id("button_special"), new UnbakedAutoRetexturedModel(new Identifier("block/button")));
|
||||
provider.addTemplateModel(Templates.id("button_pressed_special"), new UnbakedAutoRetexturedModel(new Identifier("block/button_pressed")));
|
||||
provider.addTemplateModel(Templates.id("one_candle_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_candle")));
|
||||
provider.addTemplateModel(Templates.id("two_candles_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_two_candles")));
|
||||
provider.addTemplateModel(Templates.id("three_candles_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_three_candles")));
|
||||
provider.addTemplateModel(Templates.id("four_candles_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_four_candles")));
|
||||
provider.addTemplateModel(Templates.id("carpet_special"), new UnbakedAutoRetexturedModel(new Identifier("block/carpet")));
|
||||
provider.addTemplateModel(Templates.id("cube_special"), new UnbakedAutoRetexturedModel(new Identifier("block/cube")));
|
||||
provider.addTemplateModel(Templates.id("fence_post_special"), new UnbakedAutoRetexturedModel(new Identifier("block/fence_post")));
|
||||
@ -92,6 +96,7 @@ public class TemplatesClient implements ClientModInitializer {
|
||||
|
||||
//item model assignments (in lieu of models/item/___.json)
|
||||
provider.assignItemModel(Templates.id("button_inventory_special"), Templates.BUTTON);
|
||||
provider.assignItemModel(Templates.id("one_candle_special"), Templates.CANDLE); //TODO vanilla uses its own item model
|
||||
provider.assignItemModel(Templates.id("carpet_special"), Templates.CARPET);
|
||||
provider.assignItemModel(Templates.id("cube_special"), Templates.CUBE);
|
||||
provider.assignItemModel(Templates.id("fence_inventory_special"), Templates.FENCE);
|
||||
|
@ -0,0 +1,85 @@
|
||||
package io.github.cottonmc.templates.block;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import io.github.cottonmc.templates.Templates;
|
||||
import io.github.cottonmc.templates.api.TemplateInteractionUtil;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.CandleBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
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.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TemplateCandleBlock extends CandleBlock implements BlockEntityProvider {
|
||||
public TemplateCandleBlock(Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(TemplateInteractionUtil.setDefaultStates(getDefaultState()));
|
||||
}
|
||||
|
||||
public static AbstractBlock.Settings configureSettings(AbstractBlock.Settings in) {
|
||||
return in.luminance(state -> Math.max(TemplateInteractionUtil.luminance(state), CandleBlock.STATE_TO_LUMINANCE.applyAsInt(state)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return Templates.TEMPLATE_BLOCK_ENTITY.instantiate(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(TemplateInteractionUtil.appendProperties(builder));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
|
||||
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
TemplateInteractionUtil.onStateReplaced(state, world, pos, newState, moved);
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
TemplateInteractionUtil.onPlaced(world, pos, state, placer, stack);
|
||||
super.onPlaced(world, pos, state, placer, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
|
||||
return MoreObjects.firstNonNull(TemplateInteractionUtil.getCollisionShape(state, view, pos, ctx), super.getCollisionShape(state, view, pos, ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsRedstonePower(BlockState state) {
|
||||
return TemplateInteractionUtil.emitsRedstonePower(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
|
||||
return TemplateInteractionUtil.getWeakRedstonePower(state, view, pos, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
|
||||
return TemplateInteractionUtil.getStrongRedstonePower(state, view, pos, dir);
|
||||
}
|
||||
}
|
16
src/main/resources/assets/templates/blockstates/candle.json
Normal file
16
src/main/resources/assets/templates/blockstates/candle.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"variants": {
|
||||
"candles=1": {
|
||||
"model": "templates:one_candle_special"
|
||||
},
|
||||
"candles=2": {
|
||||
"model": "templates:two_candles_special"
|
||||
},
|
||||
"candles=3": {
|
||||
"model": "templates:three_candles_special"
|
||||
},
|
||||
"candles=4": {
|
||||
"model": "templates:four_candles_special"
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
"itemGroup.templates.tab": "Templates",
|
||||
|
||||
"block.templates.button": "Button Template",
|
||||
"block.templates.candle": "Candle Template",
|
||||
"block.templates.carpet": "Carpet Template",
|
||||
"block.templates.cube": "Cube Template",
|
||||
"block.templates.fence": "Fence Template",
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"templates:candle"
|
||||
]
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"templates:button",
|
||||
"templates:candle",
|
||||
"templates:carpet",
|
||||
"templates:cube",
|
||||
"templates:fence",
|
||||
|
@ -0,0 +1,63 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"bonus_rolls": 0.0,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"add": false,
|
||||
"conditions": [
|
||||
{
|
||||
"block": "templates:candle",
|
||||
"condition": "minecraft:block_state_property",
|
||||
"properties": {
|
||||
"candles": "2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"count": 2.0,
|
||||
"function": "minecraft:set_count"
|
||||
},
|
||||
{
|
||||
"add": false,
|
||||
"conditions": [
|
||||
{
|
||||
"block": "templates:candle",
|
||||
"condition": "minecraft:block_state_property",
|
||||
"properties": {
|
||||
"candles": "3"
|
||||
}
|
||||
}
|
||||
],
|
||||
"count": 3.0,
|
||||
"function": "minecraft:set_count"
|
||||
},
|
||||
{
|
||||
"add": false,
|
||||
"conditions": [
|
||||
{
|
||||
"block": "templates:candle",
|
||||
"condition": "minecraft:block_state_property",
|
||||
"properties": {
|
||||
"candles": "4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"count": 4.0,
|
||||
"function": "minecraft:set_count"
|
||||
},
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "templates:candle"
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
}
|
||||
],
|
||||
"random_sequence": "minecraft:blocks/candle"
|
||||
}
|
24
src/main/resources/data/templates/recipes/candle.json
Normal file
24
src/main/resources/data/templates/recipes/candle.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"~",
|
||||
"I",
|
||||
"C"
|
||||
],
|
||||
"key": {
|
||||
"I": {
|
||||
"item": "minecraft:bamboo"
|
||||
},
|
||||
"~": {
|
||||
"item": "minecraft:string"
|
||||
},
|
||||
"C": {
|
||||
"item": "#minecraft:candles"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "templates:candle",
|
||||
"count": 1
|
||||
},
|
||||
"group": "templates"
|
||||
}
|
Loading…
Reference in New Issue
Block a user