Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PoweredFurnaceEntity extends AbstractFurnaceBlockEntity {
- protected PoweredFurnaceEntity() {
- super(MachineMod.POWERED_FURNACE_ENTITY, RecipeType.SMELTING);
- }
- @Override
- protected Text getContainerName() {
- return new TranslatableText("machines.powered_furnace_entity", new Object[0]);
- }
- @Override
- protected Container createContainer(int i, PlayerInventory playerInventory) {
- return new FurnaceContainer(i, playerInventory, this, this.propertyDelegate);
- }
- @Override
- public void tick() {
- List<BlockPos> positions = Arrays.asList(pos.up(), pos.down(), pos.north(), pos.south(), pos.east(), pos.west());
- Predicate<BlockPos> isLitEngine = pos -> world.getBlockState(pos).getBlock() instanceof Engine
- && world.getBlockState(pos).get(Engine.LIT);
- if (positions.stream().anyMatch(isLitEngine)) {
- world.setBlockState(getPos(), world.getBlockState(pos).with(AbstractFurnaceBlock.LIT, true));
- super.tick();
- } else {
- world.setBlockState(getPos(), world.getBlockState(pos).with(AbstractFurnaceBlock.LIT, false));
- }
- }
- @Override
- protected int getCookTime() {
- return (int) (0.7 * super.getCookTime());
- }
- }
- public class PoweredFurnace extends AbstractFurnaceBlock {
- protected PoweredFurnace(Settings settings) {
- super(settings);
- }
- @Override
- protected void openContainer(World world, BlockPos pos, PlayerEntity player) {
- BlockEntity blockEntity = world.getBlockEntity(pos);
- if (blockEntity instanceof PoweredFurnaceEntity) {
- player.openContainer((NameableContainerProvider) blockEntity);
- player.incrementStat(Stats.INTERACT_WITH_FURNACE);
- }
- }
- @Override
- public BlockEntity createBlockEntity(BlockView view) {
- return new PoweredFurnaceEntity();
- }
- @Environment(EnvType.CLIENT)
- @Override
- public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
- if (state.get(LIT)) {
- double d = (double)pos.getX() + 0.5D;
- double e = pos.getY();
- double f = (double)pos.getZ() + 0.5D;
- if (random.nextDouble() < 0.1D) {
- world.playSound(d, e, f, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
- }
- Direction direction = state.get(FACING);
- Direction.Axis axis = direction.getAxis();
- double g = 0.52D;
- double h = random.nextDouble() * 0.6D - 0.3D;
- double i = axis == Direction.Axis.X ? (double)direction.getOffsetX() * 0.52D : h;
- double j = random.nextDouble() * 6.0D / 16.0D;
- double k = axis == Direction.Axis.Z ? (double)direction.getOffsetZ() * 0.52D : h;
- world.addParticle(ParticleTypes.SMOKE, d + i, e + j, f + k, 0.0D, 0.0D, 0.0D);
- world.addParticle(ParticleTypes.FLAME, d + i, e + j, f + k, 0.0D, 0.0D, 0.0D);
- }
- }
- @Override
- public int getLuminance(BlockState state) {
- return state.get(LIT) ? 15 : super.getLuminance(state);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement