mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-21 15:03:30 +01:00
Tiny Torch
This commit is contained in:
parent
c960149ca5
commit
8236527fb7
11 changed files with 255 additions and 244 deletions
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2024-03-03T00:40:33.018052 Block States: actuallyadditions
|
||||
// 1.20.1 2024-03-03T20:34:33.9679563 Block States: actuallyadditions
|
||||
23a6aa86c3f14e6a61fc8b17b65063f1995c8592 assets/actuallyadditions/blockstates/atomic_reconstructor.json
|
||||
88f479927d1abdf16e24a0950ccffa86b5af8b3f assets/actuallyadditions/blockstates/battery_box.json
|
||||
5c96fc287e63f5bdd31864bdab698ce34817fd9d assets/actuallyadditions/blockstates/black_quartz_block.json
|
||||
|
@ -113,7 +113,7 @@ b3d5e4a006bd2a2126ed81803a4cd7dc976542ae assets/actuallyadditions/blockstates/sh
|
|||
c34fa31f1f9888dac79b210d8e78e818c6ce7d8c assets/actuallyadditions/blockstates/smooth_black_quartz_slab.json
|
||||
c2f07f07d6dc0c8134e92e81f41eef9f9c2a1f18 assets/actuallyadditions/blockstates/smooth_black_quartz_stair.json
|
||||
c04bbda2945960887da98121afe3b170abe3006f assets/actuallyadditions/blockstates/smooth_black_quartz_wall.json
|
||||
c355c87874ca6b88b8bda48903cc1989808352da assets/actuallyadditions/blockstates/tiny_torch.json
|
||||
c38128c6f6b0e4cc38f74e923736a8536d0b2456 assets/actuallyadditions/blockstates/tiny_torch.json
|
||||
93868ba257844c7b666ce600799fcc0c89ca8dd9 assets/actuallyadditions/blockstates/vertical_digger.json
|
||||
08797aa1d132142e78947b38bb1ce0e9e6260450 assets/actuallyadditions/blockstates/void_crystal_block.json
|
||||
6072c1955309c670d75f3bdf9076ca7fafe7b5fd assets/actuallyadditions/blockstates/void_crystal_cluster.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2024-03-03T00:40:33.0195512 Item Models: actuallyadditions
|
||||
// 1.20.1 2024-03-03T20:47:45.1476512 Item Models: actuallyadditions
|
||||
1966de13838437bc6035f3649976a44797cf5144 assets/actuallyadditions/models/item/advanced_coil.json
|
||||
24594fc68e66011dc2d7b79b92c94b387e710318 assets/actuallyadditions/models/item/advanced_leaf_blower.json
|
||||
ba2d814e269cdef72e1045f200b3c20ed6961517 assets/actuallyadditions/models/item/atomic_reconstructor.json
|
||||
|
@ -211,7 +211,7 @@ f4f238229a72372ad2d6fd862a5f2b7789196f01 assets/actuallyadditions/models/item/st
|
|||
0f91c0cf92a346bccd1142ac7b6ab37bee7822e5 assets/actuallyadditions/models/item/teleport_staff.json
|
||||
86863a1c74a9bebd1ea7524e0ad3435f4e83cafb assets/actuallyadditions/models/item/tiny_charcoal.json
|
||||
3b23a8a33dbe5fd8f965a8d76dbd181e7a52ca78 assets/actuallyadditions/models/item/tiny_coal.json
|
||||
7d7f92fd44743414cc193cec9880c05530c597e0 assets/actuallyadditions/models/item/tiny_torch.json
|
||||
cf9fefdbd60278e5c0eb3858789c1305037f517d assets/actuallyadditions/models/item/tiny_torch.json
|
||||
37c33ee537ada74f1ba2bfe2b53ae42677be1dc9 assets/actuallyadditions/models/item/travelers_sack.json
|
||||
3ac4b97ae2690d645087d6872d39d7f35070b947 assets/actuallyadditions/models/item/triple_battery.json
|
||||
a2d656d1974443483eb69de4d8a738a6d02ea32a assets/actuallyadditions/models/item/vertical_digger.json
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"facing=east": {
|
||||
"model": "actuallyadditions:block/tiny_torch_wall"
|
||||
},
|
||||
"facing=north": {
|
||||
"model": "actuallyadditions:block/tiny_torch_wall",
|
||||
"y": 270
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "actuallyadditions:block/tiny_torch_wall",
|
||||
"y": 90
|
||||
},
|
||||
"facing=up": {
|
||||
"model": "actuallyadditions:block/tiny_torch"
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "actuallyadditions:block/tiny_torch_wall",
|
||||
"y": 180
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
{
|
||||
"parent": "actuallyadditions:block/tiny_torch"
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "actuallyadditions:block/tiny_torch"
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@ package de.ellpeck.actuallyadditions.data;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockTinyTorch;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -58,7 +60,7 @@ public class BlockStateGenerator extends BlockStateProvider {
|
|||
standardBlock(ActuallyBlocks.BATTERY_BOX);
|
||||
standardBlock(ActuallyBlocks.ITEM_INTERFACE_HOPPING);
|
||||
standardBlock(ActuallyBlocks.EMPOWERER);
|
||||
standardBlock(ActuallyBlocks.TINY_TORCH);
|
||||
tinyTorchBlock(ActuallyBlocks.TINY_TORCH);
|
||||
standardBlock(ActuallyBlocks.SHOCK_SUPPRESSOR);
|
||||
standardBlock(ActuallyBlocks.DISPLAY_STAND);
|
||||
standardBlock(ActuallyBlocks.PLAYER_INTERFACE);
|
||||
|
@ -236,8 +238,8 @@ public class BlockStateGenerator extends BlockStateProvider {
|
|||
|
||||
private void fullyDirectionalBlock(Supplier<Block> block) {
|
||||
ResourceLocation name = ForgeRegistries.BLOCKS.getKey(block.get());
|
||||
ModelFile model = new ModelFile.UncheckedModelFile(modLoc("block/" + name.toString().split(":")[1]));
|
||||
ModelFile verModel = new ModelFile.UncheckedModelFile(modLoc("block/" + name.toString().split(":")[1] + "_ver"));
|
||||
ModelFile model = new ModelFile.UncheckedModelFile(modLoc("block/" + name.getPath()));
|
||||
ModelFile verModel = new ModelFile.UncheckedModelFile(modLoc("block/" + name.getPath() + "_ver"));
|
||||
|
||||
assert name != null;
|
||||
directionalBlock(block.get(), model);
|
||||
|
@ -245,9 +247,29 @@ public class BlockStateGenerator extends BlockStateProvider {
|
|||
|
||||
private void horizontallyDirectionalBlock(Supplier<Block> block) {
|
||||
ResourceLocation name = ForgeRegistries.BLOCKS.getKey(block.get());
|
||||
ModelFile model = new ModelFile.UncheckedModelFile(modLoc("block/" + name.toString().split(":")[1]));
|
||||
ModelFile model = new ModelFile.UncheckedModelFile(modLoc("block/" + name.getPath()));
|
||||
|
||||
assert name != null;
|
||||
horizontalBlock(block.get(), model);
|
||||
}
|
||||
|
||||
private void tinyTorchBlock(Supplier<Block> block) {
|
||||
assert block.get() instanceof BlockTinyTorch;
|
||||
ResourceLocation name = ForgeRegistries.BLOCKS.getKey(block.get());
|
||||
ModelFile model = new ModelFile.UncheckedModelFile(modLoc("block/" + name.getPath()));
|
||||
ModelFile wallModel = new ModelFile.UncheckedModelFile(modLoc("block/" + name.getPath() + "_wall"));
|
||||
|
||||
assert name != null;
|
||||
getVariantBuilder(block.get())
|
||||
.partialState().with(BlockTinyTorch.FACING, Direction.UP)
|
||||
.modelForState().modelFile(model).addModel()
|
||||
.partialState().with(BlockTinyTorch.FACING, Direction.EAST)
|
||||
.modelForState().modelFile(wallModel).addModel()
|
||||
.partialState().with(BlockTinyTorch.FACING, Direction.NORTH)
|
||||
.modelForState().modelFile(wallModel).rotationY(270).addModel()
|
||||
.partialState().with(BlockTinyTorch.FACING, Direction.SOUTH)
|
||||
.modelForState().modelFile(wallModel).rotationY(90).addModel()
|
||||
.partialState().with(BlockTinyTorch.FACING, Direction.WEST)
|
||||
.modelForState().modelFile(wallModel).rotationY(180).addModel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ public class ItemModelGenerator extends ItemModelProvider {
|
|||
ActuallyBlocks.CANOLA.get(),
|
||||
ActuallyBlocks.RICE.get(),
|
||||
ActuallyBlocks.FLAX.get(),
|
||||
ActuallyBlocks.COFFEE.get()
|
||||
ActuallyBlocks.COFFEE.get(),
|
||||
ActuallyBlocks.TINY_TORCH.get()
|
||||
);
|
||||
|
||||
// Blocks
|
||||
|
@ -69,6 +70,9 @@ public class ItemModelGenerator extends ItemModelProvider {
|
|||
.texture("layer0", modLoc("item/" + wormpath))
|
||||
.override().predicate(new ResourceLocation(ActuallyAdditions.MODID, "snail"), 1F)
|
||||
.model(getBuilder("snail").parent(getExistingFile(mcLoc("item/handheld"))).texture("layer0", "item/snail")).end();*/
|
||||
|
||||
String torchPath = ForgeRegistries.ITEMS.getKey(ActuallyBlocks.TINY_TORCH.getItem()).getPath();
|
||||
singleTexture(torchPath, mcLoc("item/generated"), "layer0", modLoc("block/" + torchPath));
|
||||
}
|
||||
|
||||
private void generateBucket(FluidAA fluidSupplier) {
|
||||
|
|
|
@ -11,245 +11,132 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BlockTinyTorch extends BlockBase {
|
||||
|
||||
//Thanks to xdjackiexd for these.
|
||||
//Man, I hate numbers.
|
||||
private static final AABB STANDING_AABB = new AABB(0.4375D, 0.0D, 0.4375D, 0.5625D, 0.3125D, 0.5625D);
|
||||
private static final AABB TORCH_NORTH_AABB = new AABB(0.4375D, 0.25D, 0.8125D, 0.5625D, 0.5625D, 1.0D);
|
||||
private static final AABB TORCH_SOUTH_AABB = new AABB(0.4375D, 0.25D, 0.0D, 0.5625D, 0.5625D, 0.1875D);
|
||||
private static final AABB TORCH_WEST_AABB = new AABB(0.8125D, 0.25D, 0.4375D, 1.0D, 0.5625D, 0.5625D);
|
||||
private static final AABB TORCH_EAST_AABB = new AABB(0.0D, 0.25D, 0.4375D, 0.1875D, 0.5625D, 0.5625D);
|
||||
public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.UP);
|
||||
|
||||
public BlockTinyTorch() {
|
||||
super(Properties.of().pushReaction(PushReaction.DESTROY).sound(SoundType.WOOD).strength(0.0F, 0.8F));
|
||||
// TorchBlock
|
||||
// this.setDefaultState(this.blockState.getBaseState().withProperty(BlockTorch.FACING, Direction.UP));
|
||||
// this.setTickRandomly(true);
|
||||
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.UP));
|
||||
}
|
||||
|
||||
// TODO: [port] add back
|
||||
//
|
||||
// @Override
|
||||
// public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
// switch (state.getValue(BlockTorch.FACING)) {
|
||||
// case EAST:
|
||||
// return TORCH_EAST_AABB;
|
||||
// case WEST:
|
||||
// return TORCH_WEST_AABB;
|
||||
// case SOUTH:
|
||||
// return TORCH_SOUTH_AABB;
|
||||
// case NORTH:
|
||||
// return TORCH_NORTH_AABB;
|
||||
// default:
|
||||
// return STANDING_AABB;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public AxisAlignedBB getCollisionBoundingBox(BlockState blockState, IBlockAccess worldIn, BlockPos pos) {
|
||||
// return NULL_AABB;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isOpaqueCube(BlockState state) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isFullCube(BlockState state) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isNormalCube(BlockState state) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockFaceShape getBlockFaceShape(IBlockAccess world, BlockState state, BlockPos pos, Direction facing) {
|
||||
// return BlockFaceShape.UNDEFINED;
|
||||
// }
|
||||
//
|
||||
// private boolean canPlaceOn(World worldIn, BlockPos pos) {
|
||||
// BlockState state = worldIn.getBlockState(pos);
|
||||
// return state.isSideSolid(worldIn, pos, Direction.UP) || state.getBlock().canPlaceTorchOnTop(state, worldIn, pos);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
|
||||
// for (Direction enumfacing : BlockTorch.FACING.getAllowedValues()) {
|
||||
// if (this.canPlaceAt(worldIn, pos, enumfacing)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// private boolean canPlaceAt(World worldIn, BlockPos pos, Direction facing) {
|
||||
// BlockPos blockpos = pos.offset(facing.getOpposite());
|
||||
// boolean flag = facing.getAxis().isHorizontal();
|
||||
// return flag && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(Direction.UP) && this.canPlaceOn(worldIn, blockpos);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockState getStateForPlacement(World worldIn, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
// if (this.canPlaceAt(worldIn, pos, facing)) {
|
||||
// return this.getDefaultState().withProperty(BlockTorch.FACING, facing);
|
||||
// } else {
|
||||
// for (Direction enumfacing : Direction.Plane.HORIZONTAL) {
|
||||
// if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)) {
|
||||
// return this.getDefaultState().withProperty(BlockTorch.FACING, enumfacing);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return this.getDefaultState();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBlockAdded(World worldIn, BlockPos pos, BlockState state) {
|
||||
// this.checkForDrop(worldIn, pos, state);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) {
|
||||
// this.onNeighborChangeInternal(worldIn, pos, state);
|
||||
// }
|
||||
//
|
||||
// protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, BlockState state) {
|
||||
// if (!this.checkForDrop(worldIn, pos, state)) {
|
||||
// return true;
|
||||
// } else {
|
||||
// Direction enumfacing = state.getValue(BlockTorch.FACING);
|
||||
// Direction.Axis axis = enumfacing.getAxis();
|
||||
// Direction enumfacing1 = enumfacing.getOpposite();
|
||||
// boolean flag = false;
|
||||
//
|
||||
// if (axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)) {
|
||||
// flag = true;
|
||||
// } else if (axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))) {
|
||||
// flag = true;
|
||||
// }
|
||||
//
|
||||
// if (flag) {
|
||||
// this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||
// worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected boolean checkForDrop(World worldIn, BlockPos pos, BlockState state) {
|
||||
// if (state.getBlock() == this && this.canPlaceAt(worldIn, pos, state.getValue(BlockTorch.FACING))) {
|
||||
// return true;
|
||||
// } else {
|
||||
// if (worldIn.getBlockState(pos).getBlock() == this) {
|
||||
// this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||
// worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public void randomDisplayTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
||||
// if (rand.nextBoolean()) {
|
||||
// Direction enumfacing = stateIn.getValue(BlockTorch.FACING);
|
||||
// double d0 = pos.getX() + 0.5D;
|
||||
// double d1 = pos.getY() + 0.4D;
|
||||
// double d2 = pos.getZ() + 0.5D;
|
||||
//
|
||||
// if (enumfacing.getAxis().isHorizontal()) {
|
||||
// Direction enumfacing1 = enumfacing.getOpposite();
|
||||
// worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + 0.35D * enumfacing1.getXOffset(), d1 + 0.22D, d2 + 0.35D * enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D);
|
||||
// worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + 0.35D * enumfacing1.getXOffset(), d1 + 0.22D, d2 + 0.35D * enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D);
|
||||
// } else {
|
||||
// worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
// worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockState getStateFromMeta(int meta) {
|
||||
// BlockState iblockstate = this.getDefaultState();
|
||||
//
|
||||
// switch (meta) {
|
||||
// case 1:
|
||||
// iblockstate = iblockstate.withProperty(BlockTorch.FACING, Direction.EAST);
|
||||
// break;
|
||||
// case 2:
|
||||
// iblockstate = iblockstate.withProperty(BlockTorch.FACING, Direction.WEST);
|
||||
// break;
|
||||
// case 3:
|
||||
// iblockstate = iblockstate.withProperty(BlockTorch.FACING, Direction.SOUTH);
|
||||
// break;
|
||||
// case 4:
|
||||
// iblockstate = iblockstate.withProperty(BlockTorch.FACING, Direction.NORTH);
|
||||
// break;
|
||||
// case 5:
|
||||
// default:
|
||||
// iblockstate = iblockstate.withProperty(BlockTorch.FACING, Direction.UP);
|
||||
// }
|
||||
//
|
||||
// return iblockstate;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockRenderLayer getRenderLayer() {
|
||||
// return BlockRenderLayer.CUTOUT;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getMetaFromState(BlockState state) {
|
||||
// int i = 0;
|
||||
//
|
||||
// switch (state.getValue(BlockTorch.FACING)) {
|
||||
// case EAST:
|
||||
// i = i | 1;
|
||||
// break;
|
||||
// case WEST:
|
||||
// i = i | 2;
|
||||
// break;
|
||||
// case SOUTH:
|
||||
// i = i | 3;
|
||||
// break;
|
||||
// case NORTH:
|
||||
// i = i | 4;
|
||||
// break;
|
||||
// case DOWN:
|
||||
// case UP:
|
||||
// default:
|
||||
// i = i | 5;
|
||||
// }
|
||||
//
|
||||
// return i;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockState withRotation(BlockState state, Rotation rot) {
|
||||
// return state.withProperty(BlockTorch.FACING, rot.rotate(state.getValue(BlockTorch.FACING)));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockState withMirror(BlockState state, Mirror mirrorIn) {
|
||||
// return state.withRotation(mirrorIn.toRotation(state.getValue(BlockTorch.FACING)));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected BlockStateContainer createBlockState() {
|
||||
// return new BlockStateContainer(this, BlockTorch.FACING);
|
||||
// }
|
||||
@Override
|
||||
public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
switch (state.getValue(FACING)) {
|
||||
case EAST:
|
||||
return VoxelShapes.TinyTorchShapes.TORCH_EAST_AABB;
|
||||
case WEST:
|
||||
return VoxelShapes.TinyTorchShapes.TORCH_WEST_AABB;
|
||||
case SOUTH:
|
||||
return VoxelShapes.TinyTorchShapes.TORCH_SOUTH_AABB;
|
||||
case NORTH:
|
||||
return VoxelShapes.TinyTorchShapes.TORCH_NORTH_AABB;
|
||||
default:
|
||||
return VoxelShapes.TinyTorchShapes.STANDING_AABB;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState,
|
||||
LevelAccessor levelAccessor, BlockPos pos, BlockPos neighborPos) {
|
||||
return !this.canSurvive(state, levelAccessor, pos)
|
||||
? Blocks.AIR.defaultBlockState()
|
||||
: super.updateShape(state, direction, neighborState, levelAccessor, pos, neighborPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader levelReader, BlockPos pos) {
|
||||
Direction direction = state.getValue(FACING);
|
||||
if (direction == Direction.UP) {
|
||||
return canSupportCenter(levelReader, pos.below(), Direction.UP);
|
||||
} else {
|
||||
BlockPos blockpos = pos.relative(direction.getOpposite());
|
||||
BlockState blockstate = levelReader.getBlockState(blockpos);
|
||||
return blockstate.isFaceSturdy(levelReader, blockpos, direction);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
LevelReader levelreader = context.getLevel();
|
||||
BlockState state = this.defaultBlockState();
|
||||
Direction facing = context.getClickedFace();
|
||||
BlockPos pos = context.getClickedPos();
|
||||
if (this.canSurvive(state, levelreader, pos)) {
|
||||
return state.setValue(BlockTinyTorch.FACING, facing);
|
||||
} else {
|
||||
Direction[] adirection = context.getNearestLookingDirections();
|
||||
for(Direction direction : adirection) {
|
||||
if (direction.getAxis().isHorizontal()) {
|
||||
Direction direction1 = direction.getOpposite();
|
||||
state = state.setValue(FACING, direction1);
|
||||
if (state.canSurvive(levelreader, pos)) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, Mirror mirror) {
|
||||
return state.rotate(mirror.getRotation(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource randomSource) {
|
||||
if (randomSource.nextBoolean()) {
|
||||
Direction direction = state.getValue(FACING);
|
||||
double d0 = pos.getX() + 0.5D;
|
||||
double d1 = pos.getY() + 0.4D;
|
||||
double d2 = pos.getZ() + 0.5D;
|
||||
|
||||
if (direction.getAxis().isHorizontal()) {
|
||||
Direction opposite = direction.getOpposite();
|
||||
level.addParticle(ParticleTypes.SMOKE, d0 + 0.35D * opposite.getStepX(), d1 + 0.22D, d2 + 0.35D * opposite.getStepZ(), 0.0D, 0.0D, 0.0D);
|
||||
level.addParticle(ParticleTypes.FLAME, d0 + 0.35D * opposite.getStepX(), d1 + 0.22D, d2 + 0.35D * opposite.getStepZ(), 0.0D, 0.0D, 0.0D);
|
||||
} else {
|
||||
level.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
level.addParticle(ParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateBuilder) {
|
||||
stateBuilder.add(FACING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.BooleanOp;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
@ -145,6 +146,14 @@ public class VoxelShapes {
|
|||
static final VoxelShape SHAPE_W = Stream.of(Block.box(15, 1, 1, 16, 15, 15), Block.box(11, 3, 3, 15, 13, 13), Block.box(6, 7, 7, 12, 9, 9)).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
|
||||
}
|
||||
|
||||
static final class TinyTorchShapes {
|
||||
static final VoxelShape STANDING_AABB = Block.box(7, 0, 7, 9, 5, 9);
|
||||
static final VoxelShape TORCH_NORTH_AABB = Block.box(7, 4, 13, 9, 9, 16);
|
||||
static final VoxelShape TORCH_SOUTH_AABB = Block.box(7, 4, 0, 9, 9, 3);
|
||||
static final VoxelShape TORCH_WEST_AABB = Block.box(13, 4, 7, 16, 9, 9);
|
||||
static final VoxelShape TORCH_EAST_AABB = Block.box(0, 4, 7, 3, 9, 9);
|
||||
}
|
||||
|
||||
public static class ShapeBuilder {
|
||||
Stream.Builder<VoxelShape> shapes = Stream.builder();
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@
|
|||
"block.actuallyadditions.booklet_stand": "Wall-Mount Manual (wip)",
|
||||
"block.actuallyadditions.display_stand": "Display Stand",
|
||||
"block.actuallyadditions.shock_suppressor": "Shock Absorber (wip)",
|
||||
"block.actuallyadditions.tiny_torch": "Tiny Torch (wip)",
|
||||
"block.actuallyadditions.tiny_torch": "Tiny Torch",
|
||||
"block.actuallyadditions.empowerer": "Empowerer",
|
||||
"block.actuallyadditions.distributor_item": "Item Distributor (wip)",
|
||||
"block.actuallyadditions.bio_reactor": "Bio Reactor (wip)",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"particle": "actuallyadditions:block/tiny_torch",
|
||||
"torch": "actuallyadditions:block/tiny_torch"
|
||||
},
|
||||
"render_type": "minecraft:cutout",
|
||||
"elements": [
|
||||
{ "from": [ 7, 0, 7 ],
|
||||
"to": [ 9, 5, 9 ],
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" },
|
||||
"up": { "uv": [ 7, 11, 9, 13 ], "texture": "#torch" }
|
||||
}
|
||||
},
|
||||
{ "from": [ 7, 0, 0 ],
|
||||
"to": [ 9, 16, 16 ],
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
|
||||
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
|
||||
}
|
||||
},
|
||||
{ "from": [ 0, 0, 7 ],
|
||||
"to": [ 16, 16, 9 ],
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
|
||||
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"particle": "actuallyadditions:block/tiny_torch",
|
||||
"torch": "actuallyadditions:block/tiny_torch"
|
||||
},
|
||||
"render_type": "minecraft:cutout",
|
||||
"elements": [
|
||||
{ "from": [ -1, 3.5, 7 ],
|
||||
"to": [ 1, 8.5, 9 ],
|
||||
"rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 },
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" },
|
||||
"up": { "uv": [ 7, 11, 9, 13 ], "texture": "#torch" }
|
||||
}
|
||||
},
|
||||
{ "from": [ -1, 3.5, 0 ],
|
||||
"to": [ 1, 19.5, 16 ],
|
||||
"rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 },
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
|
||||
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
|
||||
}
|
||||
},
|
||||
{ "from": [ -8, 3.5, 7 ],
|
||||
"to": [ 8, 19.5, 9 ],
|
||||
"rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 },
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
|
||||
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue