src/main/java/com/Mrbysco/cactusmod/items/CactusCartItem.java
public ItemStack execute(IBlockSource source, ItemStack stack) {
            Direction direction = source.getBlockState().getValue(DispenserBlock.FACING);
            World world = source.getLevel();
            double d0 = source.x() + (double)direction.getStepX() * 1.125D;
            double d1 = Math.floor(source.y()) + (double)direction.getStepY();
            double d2 = source.z() + (double)direction.getStepZ() * 1.125D;
            BlockPos blockpos = source.getPos().relative(direction);
            BlockState blockstate = world.getBlockState(blockpos);
            RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock)blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH;
            double d3;
            if (blockstate.is(BlockTags.RAILS)) {
                if (railshape.isAscending()) {
                    d3 = 0.6D;
                } else {
                    d3 = 0.1D;
                }
            } else {
                if (!blockstate.isAir() || !world.getBlockState(blockpos.below()).is(BlockTags.RAILS)) {
                    return this.behaviourDefaultDispenseItem.dispense(source, stack);
                }

                BlockState blockstate1 = world.getBlockState(blockpos.below());
                RailShape railshape1 = blockstate1.getBlock() instanceof AbstractRailBlock ? blockstate1.getValue(((AbstractRailBlock)blockstate1.getBlock()).getShapeProperty()) : RailShape.NORTH_SOUTH;
                if (direction != Direction.DOWN && railshape1.isAscending()) {
                    d3 = -0.4D;
                } else {
                    d3 = -0.9D;
                }
            }

            CactiCartEntity cactusCart = new CactiCartEntity(world, d0, d1 + d3, d2);
            if (stack.hasCustomHoverName()) {
                cactusCart.setCustomName(stack.getHoverName());
            }

            world.addFreshEntity(cactusCart);
            stack.shrink(1);
            return stack;
        }
/**
         * Dispense the specified stack, play the dispense sound and spawn particles.
         */
Dispense the specified stack, play the dispense sound and spawn particles.
Dispense the specified stack play the dispense sound and spawn particles .
public ItemStack execute(IBlockSource source, ItemStack stack) {
            Direction direction = source.getBlockState().getValue(DispenserBlock.FACING);
            World world = source.getLevel();
            double d0 = source.x() + (double)direction.getStepX() * 1.125D;
            double d1 = Math.floor(source.y()) + (double)direction.getStepY();
            double d2 = source.z() + (double)direction.getStepZ() * 1.125D;
            BlockPos blockpos = source.getPos().relative(direction);
            BlockState blockstate = world.getBlockState(blockpos);
            RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock)blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH;
            double d3;
            if (blockstate.is(BlockTags.RAILS)) {
                if (railshape.isAscending()) {
                    d3 = 0.6D;
                } else {
                    d3 = 0.1D;
                }
            } else {
                if (!blockstate.isAir() || !world.getBlockState(blockpos.below()).is(BlockTags.RAILS)) {
                    return this.behaviourDefaultDispenseItem.dispense(source, stack);
                }
                BlockState blockstate1 = world.getBlockState(blockpos.below());
                RailShape railshape1 = blockstate1.getBlock() instanceof AbstractRailBlock ? blockstate1.getValue(((AbstractRailBlock)blockstate1.getBlock()).getShapeProperty()) : RailShape.NORTH_SOUTH;
                if (direction != Direction.DOWN && railshape1.isAscending()) {
                    d3 = -0.4D;
                } else {
                    d3 = -0.9D;
                }
            }
            CactiCartEntity cactusCart = new CactiCartEntity(world, d0, d1 + d3, d2);
            if (stack.hasCustomHoverName()) {
                cactusCart.setCustomName(stack.getHoverName());
            }
            world.addFreshEntity(cactusCart);
            stack.shrink(1);
            return stack;
        }
public ItemStack execute ( IBlockSource source , ItemStack stack ) { Direction direction = source . getBlockState ( ) . getValue ( DispenserBlock . FACING ) ; World world = source . getLevel ( ) ; double d0 = source . x ( ) + ( double ) direction . getStepX ( ) * 1.125D ; double d1 = Math . floor ( source . y ( ) ) + ( double ) direction . getStepY ( ) ; double d2 = source . z ( ) + ( double ) direction . getStepZ ( ) * 1.125D ; BlockPos blockpos = source . getPos ( ) . relative ( direction ) ; BlockState blockstate = world . getBlockState ( blockpos ) ; RailShape railshape = blockstate . getBlock ( ) instanceof AbstractRailBlock ? ( ( AbstractRailBlock ) blockstate . getBlock ( ) ) . getRailDirection ( blockstate , world , blockpos , null ) : RailShape . NORTH_SOUTH ; double d3 ; if ( blockstate . is ( BlockTags . RAILS ) ) { if ( railshape . isAscending ( ) ) { d3 = 0.6D ; } else { d3 = 0.1D ; } } else { if ( ! blockstate . isAir ( ) || ! world . getBlockState ( blockpos . below ( ) ) . is ( BlockTags . RAILS ) ) { return this . behaviourDefaultDispenseItem . dispense ( source , stack ) ; } BlockState blockstate1 = world . getBlockState ( blockpos . below ( ) ) ; RailShape railshape1 = blockstate1 . getBlock ( ) instanceof AbstractRailBlock ? blockstate1 . getValue ( ( ( AbstractRailBlock ) blockstate1 . getBlock ( ) ) . getShapeProperty ( ) ) : RailShape . NORTH_SOUTH ; if ( direction != Direction . DOWN && railshape1 . isAscending ( ) ) { d3 = - 0.4D ; } else { d3 = - 0.9D ; } } CactiCartEntity cactusCart = new CactiCartEntity ( world , d0 , d1 + d3 , d2 ) ; if ( stack . hasCustomHoverName ( ) ) { cactusCart . setCustomName ( stack . getHoverName ( ) ) ; } world . addFreshEntity ( cactusCart ) ; stack . shrink ( 1 ) ; return stack ; }
Dispense the specified stack, play the dispense sound and spawn particles.
Dispense the specified stack play the dispense sound and spawn particles .