Skip to content

Commit

Permalink
Fancy tweaks to flux capacitor
Browse files Browse the repository at this point in the history
  • Loading branch information
northernlimit committed Dec 15, 2024
1 parent e00873d commit 80d1d92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.block.WireOrientation;
Expand Down Expand Up @@ -52,6 +54,23 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, Block
return validateTicker(type, CubliminalBlockEntities.FLUX_CAPACITOR_BLOCK_ENTITY, FluxCapacitorBlockEntity::tick);
}

@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
if (state.get(POWERED)) {
Direction direction = Direction.random(random);
if (direction != Direction.UP) {
BlockPos blockPos = pos.offset(direction);
BlockState blockState = world.getBlockState(blockPos);
if (!state.isOpaque() || !blockState.isSideSolidFullSquare(world, blockPos, direction.getOpposite())) {
double d = direction.getOffsetX() == 0 ? random.nextDouble() : 0.5 + (double) direction.getOffsetX() * 0.6;
double e = direction.getOffsetY() == 0 ? random.nextDouble() : 0.5 + (double) direction.getOffsetY() * 0.6;
double f = direction.getOffsetZ() == 0 ? random.nextDouble() : 0.5 + (double) direction.getOffsetZ() * 0.6;
world.addParticle(ParticleTypes.LAVA, (double) pos.getX() + d, (double) pos.getY() + e, (double) pos.getZ() + f, 0.0, 0.0, 0.0);
}
}
}
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(POWERED, FACING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private static Block register(String id, Function<AbstractBlock.Settings, Block>
public static final Block FLUX_CAPACITOR = register("flux_capacitor", FluxCapacitorBlock::new,
AbstractBlock.Settings.copy(Blocks.OBSIDIAN)
.mapColor(MapColor.GRAY)
.luminance(isPowered(10)));
.luminance(isPowered(15)));

public static final Block GABBRO = register("gabbro", Block::new,
AbstractBlock.Settings.copy(Blocks.STONE)
Expand Down

0 comments on commit 80d1d92

Please sign in to comment.